การอัปเดตบัตรอยู่เสมอเป็นวิธีสำคัญในการมีส่วนร่วมกับลูกค้าและ สร้างประสบการณ์ที่ดี
มีแหล่งข้อมูล 2 อย่างที่อัปเดตได้ ได้แก่ FlightClass และ
FlightObject
แนวทางปฏิบัติแนะนำ
รายการต่อไปนี้มีข้อมูลที่เป็นประโยชน์ซึ่งควรพิจารณาเมื่ออัปเดต คลาสและวัตถุต่างๆ ของบอร์ดดิ้งพาส:
- เมื่อต้องการอัปเดตทั้งคลาสหรือออบเจ็กต์ ให้ส่งคำขอ
updateเมื่อต้องการอัปเดตช่องจำนวนน้อยในชั้นเรียนหรือออบเจ็กต์ ให้ส่ง คำขอpatch - เมื่อคุณส่งคำขอ
updateระบบจะอัปเดตออบเจ็กต์หรือคลาสทั้งหมด ซึ่งหมายความว่าระบบจะล้างช่องที่ไม่ได้อยู่ในคำขอ ก่อนที่จะส่งคำขอupdateเราขอแนะนำให้คุณส่งคำขอGETไปยัง ต้องแน่ใจว่าคุณกำลังใช้เวอร์ชันล่าสุดและ ไว้ในคำขอของคุณด้วย - เมื่อส่งคำขอ
patchเฉพาะฟิลด์ที่แพตช์แล้ว อัปเดตแล้ว ก่อนที่จะส่งคำขอpatchโปรดพิจารณาเลือกส่งคำขอ คำขอGETเพื่อเปรียบเทียบการเปลี่ยนแปลงของคุณกับเวอร์ชันล่าสุด - เมื่อส่งคำขออัปเดตอาร์เรย์
patchอาร์เรย์เดิมจะเป็น แทนที่ด้วย URL ที่อยู่ในเนื้อหาคำขอ คุณไม่สามารถแก้ไข ในอาร์เรย์แยกกัน - ในบางกรณี คุณอาจไม่ทราบว่ามีการเปลี่ยนแปลงหรือทริกเกอร์เมื่อใด
อัปเดต ลองตั้งเวลาคำขอ
updateหรือpatchเป็นระยะๆ สำหรับ คลาสและออบเจ็กต์ทั้งหมด
อัปเดตคลาสบัตร
ใช้คอนโซลธุรกิจของ Google Wallet
คลาส Pass (ไม่ใช่ออบเจ็กต์) จะแก้ไขได้โดยตรงใน Google Pay และ Wallet Console
- ไปที่คอนโซล
- เลือก Google Wallet API
- เลือกชั้นเรียนที่ต้องการแก้ไข
- เลือกแก้ไข
- อัปเดตพร็อพเพอร์ตี้ของชั้นเรียน
- เลือกบันทึก
เมื่อคุณบันทึกการเปลี่ยนแปลง ชั้นเรียนจะได้รับการอัปเดตโดยอัตโนมัติสำหรับ ผู้ถือเที่ยวบิน
ใช้ Google Wallet API
การอัปเดต FlightClass จะมีผลกับผู้ใช้ทุกคนที่ได้รับการจัดสรร
บอร์ดดิ้งพาสที่ใช้ชั้นนี้ เช่น หากต้องการอัปเดตโลโก้สำหรับ
บอร์ดดิ้งพาสของคุณ คุณจะต้องส่งคำขอ update หรือ patch ไปยัง
Google Wallet API ที่ปลายทางแห่งใดแห่งหนึ่งต่อไปนี้ resourceId
จะเป็นรหัสคลาส (ISSUER_ID.CLASS_SUFFIX)
# Update
PUT https://walletobjects.googleapis.com/walletobjects/v1/flightclass/{resourceId}
# Patch
PATCH https://walletobjects.googleapis.com/walletobjects/v1/flightclass/{resourceId}
สำหรับข้อมูลเพิ่มเติม โปรดดู เอกสารอ้างอิง API
Java
หากต้องการเริ่มการผสานรวมของคุณใน Java โปรดดู ตัวอย่างโค้ดใน GitHub
/** * Update a class. * * <p><strong>Warning:</strong> This replaces all existing class attributes! * * @param issuerId The issuer ID being used for this request. * @param classSuffix Developer-defined unique ID for this pass class. * @return The pass class ID: "{issuerId}.{classSuffix}" */ public String updateClass(String issuerId, String classSuffix) throws IOException { FlightClass updatedClass; // Check if the class exists try { updatedClass = service.flightclass().get(String.format("%s.%s", issuerId, classSuffix)).execute(); } catch (GoogleJsonResponseException ex) { if (ex.getStatusCode() == 404) { // Class does not exist System.out.printf("Class %s.%s not found!%n", issuerId, classSuffix); return String.format("%s.%s", issuerId, classSuffix); } else { // Something else went wrong... ex.printStackTrace(); return String.format("%s.%s", issuerId, classSuffix); } } // Class exists // Update the class by adding a homepage updatedClass.setHomepageUri( new Uri() .setUri("https://developers.google.com/wallet") .setDescription("Homepage description")); // Note: reviewStatus must be 'UNDER_REVIEW' or 'DRAFT' for updates updatedClass.setReviewStatus("UNDER_REVIEW"); FlightClass response = service .flightclass() .update(String.format("%s.%s", issuerId, classSuffix), updatedClass) .execute(); System.out.println("Class update response"); System.out.println(response.toPrettyString()); return response.getId(); }
PHP
หากต้องการเริ่มการผสานรวมใน PHP โปรดดู ตัวอย่างโค้ดใน GitHub
/** * Update a class. * * **Warning:** This replaces all existing class attributes! * * @param string $issuerId The issuer ID being used for this request. * @param string $classSuffix Developer-defined unique ID for this pass class. * * @return string The pass class ID: "{$issuerId}.{$classSuffix}" */ public function updateClass(string $issuerId, string $classSuffix) { // Check if the class exists try { $updatedClass = $this->service->flightclass->get("{$issuerId}.{$classSuffix}"); } catch (Google\Service\Exception $ex) { if (!empty($ex->getErrors()) && $ex->getErrors()[0]['reason'] == 'classNotFound') { // Class does not exist print("Class {$issuerId}.{$classSuffix} not found!"); return "{$issuerId}.{$classSuffix}"; } else { // Something else went wrong... print_r($ex); return "{$issuerId}.{$classSuffix}"; } } // Update the class by adding a homepage $updatedClass->setHomepageUri(new Uri([ 'uri' => 'https://developers.google.com/wallet', 'description' => 'Homepage description' ])); // Note: reviewStatus must be 'UNDER_REVIEW' or 'DRAFT' for updates $updatedClass->setReviewStatus('UNDER_REVIEW'); $response = $this->service->flightclass->update("{$issuerId}.{$classSuffix}", $updatedClass); print "Class update response\n"; print_r($response); return $response->id; }
Python
หากต้องการเริ่มการผสานรวมใน Python โปรดดู ตัวอย่างโค้ดใน GitHub
def update_class(self, issuer_id: str, class_suffix: str) -> str: """Update a class. **Warning:** This replaces all existing class attributes! Args: issuer_id (str): The issuer ID being used for this request. class_suffix (str): Developer-defined unique ID for this pass class. Returns: The pass class ID: f"{issuer_id}.{class_suffix}" """ # Check if the class exists try: response = self.client.flightclass().get(resourceId=f'{issuer_id}.{class_suffix}').execute() except HttpError as e: if e.status_code == 404: print(f'Class {issuer_id}.{class_suffix} not found!') return f'{issuer_id}.{class_suffix}' else: # Something else went wrong... print(e.error_details) return f'{issuer_id}.{class_suffix}' # Class exists updated_class = response # Update the class by adding a homepage updated_class['homepageUri'] = { 'uri': 'https://developers.google.com/wallet', 'description': 'Homepage description' } # Note: reviewStatus must be 'UNDER_REVIEW' or 'DRAFT' for updates updated_class['reviewStatus'] = 'UNDER_REVIEW' response = self.client.flightclass().update( resourceId=f'{issuer_id}.{class_suffix}', body=updated_class).execute() print('Class update response') print(response) return f'{issuer_id}.{class_suffix}'
C#
หากต้องการเริ่มการผสานรวมใน C# โปรดดู ตัวอย่างโค้ดใน GitHub
/// <summary> /// Update a class. /// <para /> /// <strong>Warning:</strong> This replaces all existing class attributes! /// </summary> /// <param name="issuerId">The issuer ID being used for this request.</param> /// <param name="classSuffix">Developer-defined unique ID for this pass class.</param> /// <returns>The pass class ID: "{issuerId}.{classSuffix}"</returns> public string UpdateClass(string issuerId, string classSuffix) { // Check if the class exists Stream responseStream = service.Flightclass .Get($"{issuerId}.{classSuffix}") .ExecuteAsStream(); StreamReader responseReader = new StreamReader(responseStream); JObject jsonResponse = JObject.Parse(responseReader.ReadToEnd()); if (jsonResponse.ContainsKey("error")) { if (jsonResponse["error"].Value<int>("code") == 404) { // Class does not exist Console.WriteLine($"Class {issuerId}.{classSuffix} not found!"); return $"{issuerId}.{classSuffix}"; } else { // Something else went wrong... Console.WriteLine(jsonResponse.ToString()); return $"{issuerId}.{classSuffix}"; } } // Class exists FlightClass updatedClass = JsonConvert.DeserializeObject<FlightClass>(jsonResponse.ToString()); // Update the class by adding a homepage updatedClass.HomepageUri = new Google.Apis.Walletobjects.v1.Data.Uri { UriValue = "https://developers.google.com/wallet", Description = "Homepage description" }; // Note: reviewStatus must be 'UNDER_REVIEW' or 'DRAFT' for updates updatedClass.ReviewStatus = "UNDER_REVIEW"; responseStream = service.Flightclass .Update(updatedClass, $"{issuerId}.{classSuffix}") .ExecuteAsStream(); responseReader = new StreamReader(responseStream); jsonResponse = JObject.Parse(responseReader.ReadToEnd()); Console.WriteLine("Class update response"); Console.WriteLine(jsonResponse.ToString()); return $"{issuerId}.{classSuffix}"; }
Node.js
หากต้องการเริ่มการผสานรวมในโหนด โปรดดู ตัวอย่างโค้ดใน GitHub
/** * Update a class. * * **Warning:** This replaces all existing class attributes! * * @param {string} issuerId The issuer ID being used for this request. * @param {string} classSuffix Developer-defined unique ID for this pass class. * * @returns {string} The pass class ID: `${issuerId}.${classSuffix}` */ async updateClass(issuerId, classSuffix) { let response; // Check if the class exists try { response = await this.client.flightclass.get({ resourceId: `${issuerId}.${classSuffix}` }); } catch (err) { if (err.response && err.response.status === 404) { console.log(`Class ${issuerId}.${classSuffix} not found!`); return `${issuerId}.${classSuffix}`; } else { // Something else went wrong... console.log(err); return `${issuerId}.${classSuffix}`; } } // Class exists let updatedClass = response.data; // Update the class by adding a homepage updatedClass['homepageUri'] = { 'uri': 'https://developers.google.com/wallet', 'description': 'Homepage description' }; // Note: reviewStatus must be 'UNDER_REVIEW' or 'DRAFT' for updates updatedClass['reviewStatus'] = 'UNDER_REVIEW'; response = await this.client.flightclass.update({ resourceId: `${issuerId}.${classSuffix}`, requestBody: updatedClass }); console.log('Class update response'); console.log(response); return `${issuerId}.${classSuffix}`; }
อัปเดตออบเจ็กต์ Passes
การอัปเดต FlightObject แต่ละรายการจะมีผลเฉพาะกับผู้ใช้ที่ถูก
ออบเจ็กต์ที่เฉพาะเจาะจงนั้น คุณควรอัปเดตผลิตภัณฑ์แต่ละรายการเป็นประจำ
บอร์ดดิ้งพาสเพื่อให้สอดคล้องกับการเปลี่ยนแปลงที่ส่งผลต่อลูกค้าและรักษา
อย่างมีส่วนร่วม ค่า resourceId จะเป็นรหัสออบเจ็กต์
(ISSUER_ID.OBJECT_SUFFIX)
# Update
PUT https://walletobjects.googleapis.com/walletobjects/v1/flightobject/{resourceId}
# Patch
PATCH https://walletobjects.googleapis.com/walletobjects/v1/flightobject/{resourceId}
สำหรับข้อมูลเพิ่มเติม โปรดดู เอกสารอ้างอิง API
Java
หากต้องการเริ่มการผสานรวมของคุณใน Java โปรดดู ตัวอย่างโค้ดใน GitHub
/** * Update an object. * * <p><strong>Warning:</strong> This replaces all existing object attributes! * * @param issuerId The issuer ID being used for this request. * @param objectSuffix Developer-defined unique ID for this pass object. * @return The pass object ID: "{issuerId}.{objectSuffix}" */ public String updateObject(String issuerId, String objectSuffix) throws IOException { FlightObject updatedObject; // Check if the object exists try { updatedObject = service.flightobject().get(String.format("%s.%s", issuerId, objectSuffix)).execute(); } catch (GoogleJsonResponseException ex) { if (ex.getStatusCode() == 404) { // Object does not exist System.out.printf("Object %s.%s not found!%n", issuerId, objectSuffix); return String.format("%s.%s", issuerId, objectSuffix); } else { // Something else went wrong... ex.printStackTrace(); return String.format("%s.%s", issuerId, objectSuffix); } } // Object exists // Update the object by adding a link Uri newLink = new Uri() .setUri("https://developers.google.com/wallet") .setDescription("New link description"); if (updatedObject.getLinksModuleData() == null) { // LinksModuleData was not set on the original object updatedObject.setLinksModuleData(new LinksModuleData().setUris(List.of(newLink))); } else { updatedObject.getLinksModuleData().getUris().add(newLink); } FlightObject response = service .flightobject() .update(String.format("%s.%s", issuerId, objectSuffix), updatedObject) .execute(); System.out.println("Object update response"); System.out.println(response.toPrettyString()); return response.getId(); }
PHP
หากต้องการเริ่มการผสานรวมใน PHP โปรดดู ตัวอย่างโค้ดใน GitHub
/** * Update an object. * * **Warning:** This replaces all existing object attributes! * * @param string $issuerId The issuer ID being used for this request. * @param string $objectSuffix Developer-defined unique ID for this pass object. * * @return string The pass object ID: "{$issuerId}.{$objectSuffix}" */ public function updateObject(string $issuerId, string $objectSuffix) { // Check if the object exists try { $updatedObject = $this->service->flightobject->get("{$issuerId}.{$objectSuffix}"); } catch (Google\Service\Exception $ex) { if (!empty($ex->getErrors()) && $ex->getErrors()[0]['reason'] == 'resourceNotFound') { print("Object {$issuerId}.{$objectSuffix} not found!"); return "{$issuerId}.{$objectSuffix}"; } else { // Something else went wrong... print_r($ex); return "{$issuerId}.{$objectSuffix}"; } } // Update the object by adding a link $newLink = new Uri([ 'uri' => 'https://developers.google.com/wallet', 'description' => 'New link description' ]); $linksModuleData = $updatedObject->getLinksModuleData(); if (is_null($linksModuleData)) { // LinksModuleData was not set on the original object $linksModuleData = new LinksModuleData([ 'uris' => [] ]); } $uris = $linksModuleData->getUris(); array_push( $uris, $newLink ); $linksModuleData->setUris($uris); $updatedObject->setLinksModuleData($linksModuleData); $response = $this->service->flightobject->update("{$issuerId}.{$objectSuffix}", $updatedObject); print "Object update response\n"; print_r($response); return $response->id; }
Python
หากต้องการเริ่มการผสานรวมใน Python โปรดดู ตัวอย่างโค้ดใน GitHub
def update_object(self, issuer_id: str, object_suffix: str) -> str: """Update an object. **Warning:** This replaces all existing object attributes! Args: issuer_id (str): The issuer ID being used for this request. object_suffix (str): Developer-defined unique ID for the pass object. Returns: The pass object ID: f"{issuer_id}.{object_suffix}" """ # Check if the object exists try: response = self.client.flightobject().get(resourceId=f'{issuer_id}.{object_suffix}').execute() except HttpError as e: if e.status_code == 404: print(f'Object {issuer_id}.{object_suffix} not found!') return f'{issuer_id}.{object_suffix}' else: # Something else went wrong... print(e.error_details) return f'{issuer_id}.{object_suffix}' # Object exists updated_object = response # Update the object by adding a link new_link = { 'uri': 'https://developers.google.com/wallet', 'description': 'New link description' } if not updated_object.get('linksModuleData'): updated_object['linksModuleData'] = {'uris': []} updated_object['linksModuleData']['uris'].append(new_link) response = self.client.flightobject().update( resourceId=f'{issuer_id}.{object_suffix}', body=updated_object).execute() print('Object update response') print(response) return f'{issuer_id}.{object_suffix}'
C#
หากต้องการเริ่มการผสานรวมใน C# โปรดดู ตัวอย่างโค้ดใน GitHub
/// <summary> /// Update an object. /// <para /> /// <strong>Warning:</strong> This replaces all existing class attributes! /// </summary> /// <param name="issuerId">The issuer ID being used for this request.</param> /// <param name="objectSuffix">Developer-defined unique ID for this pass object.</param> /// <returns>The pass object ID: "{issuerId}.{objectSuffix}"</returns> public string UpdateObject(string issuerId, string objectSuffix) { // Check if the object exists Stream responseStream = service.Flightobject .Get($"{issuerId}.{objectSuffix}") .ExecuteAsStream(); StreamReader responseReader = new StreamReader(responseStream); JObject jsonResponse = JObject.Parse(responseReader.ReadToEnd()); if (jsonResponse.ContainsKey("error")) { if (jsonResponse["error"].Value<int>("code") == 404) { // Object does not exist Console.WriteLine($"Object {issuerId}.{objectSuffix} not found!"); return $"{issuerId}.{objectSuffix}"; } else { // Something else went wrong... Console.WriteLine(jsonResponse.ToString()); return $"{issuerId}.{objectSuffix}"; } } // Object exists FlightObject updatedObject = JsonConvert.DeserializeObject<FlightObject>(jsonResponse.ToString()); // Update the object by adding a link Google.Apis.Walletobjects.v1.Data.Uri newLink = new Google.Apis.Walletobjects.v1.Data.Uri { UriValue = "https://developers.google.com/wallet", Description = "New link description" }; if (updatedObject.LinksModuleData == null) { // LinksModuleData was not set on the original object updatedObject.LinksModuleData = new LinksModuleData { Uris = new List<Google.Apis.Walletobjects.v1.Data.Uri>() }; } updatedObject.LinksModuleData.Uris.Add(newLink); responseStream = service.Flightobject .Update(updatedObject, $"{issuerId}.{objectSuffix}") .ExecuteAsStream(); responseReader = new StreamReader(responseStream); jsonResponse = JObject.Parse(responseReader.ReadToEnd()); Console.WriteLine("Object update response"); Console.WriteLine(jsonResponse.ToString()); return $"{issuerId}.{objectSuffix}"; }
Node.js
หากต้องการเริ่มการผสานรวมในโหนด โปรดดู ตัวอย่างโค้ดใน GitHub
/** * Update an object. * * **Warning:** This replaces all existing object attributes! * * @param {string} issuerId The issuer ID being used for this request. * @param {string} objectSuffix Developer-defined unique ID for the pass object. * * @returns {string} The pass object ID: `${issuerId}.${objectSuffix}` */ async updateObject(issuerId, objectSuffix) { let response; // Check if the object exists try { response = await this.client.flightobject.get({ resourceId: `${issuerId}.${objectSuffix}` }); } catch (err) { if (err.response && err.response.status === 404) { console.log(`Object ${issuerId}.${objectSuffix} not found!`); return `${issuerId}.${objectSuffix}`; } else { // Something else went wrong... console.log(err); return `${issuerId}.${objectSuffix}`; } } // Object exists let updatedObject = response.data; // Update the object by adding a link let newLink = { 'uri': 'https://developers.google.com/wallet', 'description': 'New link description' } if (updatedObject['linksModuleData'] === undefined) { updatedObject['linksModuleData'] = { 'uris': [newLink] }; } else { updatedObject['linksModuleData']['uris'].push(newLink); } response = await this.client.flightobject.update({ resourceId: `${issuerId}.${objectSuffix}`, requestBody: updatedObject }); console.log('Object update response'); console.log(response); return `${issuerId}.${objectSuffix}`; }
แหล่งข้อมูลสำหรับการอัปเดตเที่ยวบิน
หากเวลาที่ระบุโดย class.localScheduledDepartureDateTime คือในช่วง 24 ชั่วโมงที่ผ่านมา
หรือในอีก 48 ชั่วโมงข้างหน้า การ์ดสถานะเที่ยวบินจะปรากฏต่อผู้ใช้ ในกรณีนี้ Google Wallet
แสดงข้อมูลจาก Google Flights ได้
หรือข้อมูลที่ให้ไว้ในบัตร Google Wallet แหล่งที่มาที่ใช้จะขึ้นอยู่กับ
ดังต่อไปนี้:
-
หากไม่ได้ระบุ
class.localEstimatedOrActualDepartureDateTimeGoogle ใช้เที่ยวบิน ในกรณีนี้ ระบบจะไม่สนใจclass.flightStatusที่คุณตั้งค่าไว้เช่น หากเที่ยวบินล่าช้า ผู้ใช้จะเห็นการ์ดใต้ "หน้าแรก" ของ Google Wallet แอปที่แสดงเวลาออกเดินทางใหม่ การ์ดความล่าช้าที่คล้ายกันจะแสดงให้กับผู้ใช้ภายใต้ "บัตร"
- หากคุณระบุ
class.localEstimatedOrActualDepartureDateTimeแต่ไม่ได้ระบุclass.flightStatusระบบจะใช้เวลาที่ระบุเพื่อพิจารณาว่าเที่ยวบินล่าช้าหรือไม่ จากนั้นสถานะเที่ยวบินในการ์ดจะแสดงต่อผู้ใช้ตามตรรกะต่อไปนี้- หาก
class.localEstimatedOrActualDepartureDateTimeมากกว่าclass.localScheduledDepartureDateTimeแสดงการ์ดที่มีเที่ยวบินต่อผู้ใช้ ล่าช้า - หาก
class.localEstimatedOrActualDepartureDateTimeไม่เกินclass.localScheduledDepartureDateTimeแสดงการ์ดที่มีเที่ยวบินให้ผู้ใช้เห็น แต่ไม่มีข้อความสถานะใดๆ
- หาก
หากคุณไม่ต้องการใช้ Google Flights เป็นแหล่งข้อมูลเกี่ยวกับเที่ยวบิน โปรด
ระบุ flightStatus, localScheduledDepartureDateTime และ
localEstimatedOrActualDepartureDateTime ของ FlightClass เฉพาะข้อมูลของคุณ
ใช้บนบัตร หรือหากคุณใช้รหัสผู้ให้บริการ ICAO แทนรหัส IATA ใน
FlightClass เราไม่ได้ใช้ Google Flights เป็นแหล่งข้อมูลเที่ยวบิน
เมื่อมีการเปลี่ยนแปลงบางช่อง ผู้ใช้จะได้รับข้อความ Push เกี่ยวกับการเปลี่ยนแปลงดังกล่าว สำหรับข้อมูลเพิ่มเติม โปรดดูรายละเอียดที่หัวข้อรับการแจ้งเตือนอัปเดตเที่ยวบิน