إنّ إبقاء البطاقات محدّثة هو وسيلة مهمة للتفاعل مع العملاء وتقديم تجربة إيجابية.
هناك مرجعان يمكن تعديلهما: FlightClass
وFlightObject
.
أفضل الممارسات
تحتوي القائمة التالية على معلومات مفيدة يجب مراعاتها عند تحديث فئات وكائنات بطاقة الصعود إلى الطائرة:
- عندما تريد تعديل فئة أو عنصر بالكامل، يمكنك إرسال طلب
update
. عندما تريد تعديل عدد صغير من الحقول في فئة أو عنصر، أرسِل طلبpatch
. - عند تقديم طلب "
update
"، يتم تعديل العنصر أو الفئة بالكامل. وهذا يعني أنّه سيتم محو أي حقول غير مضمّنة في الطلب. قبل إرسال طلبupdate
، ننصحك بإرسال طلبGET
للتأكد من أنك تعمل على أحدث إصدار ومن تضمين جميع الحقول المطلوبة في طلبك. - عند تقديم طلب "
patch
"، يتم تحديث الحقول المصحّحة فقط. قبل إرسال طلبpatch
، يمكنك بشكل اختياري إرسال طلبGET
لمقارنة التغييرات التي أجريتها بأحدث نسخة. - عند إرسال طلبات
patch
لتعديل الصفائف، يتم استبدال الصفيف الأصلي بالمصفوفة المضمّنة في نص الطلب. لا يمكنك تعديل العناصر في صفيف بشكل فردي. - في بعض الحالات، قد لا تعرف وقت حدوث التغييرات أو وقت بدء التحديثات. ننصحك بجدولة طلبات
update
أوpatch
بشكل دوري لكل الفئات والكائنات.
تعديل فئة البطاقات
استخدام Google Wallet Business Console
يمكن تعديل فئات البطاقات (وليس العناصر) مباشرةً في 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}
لمزيد من المعلومات، يُرجى الاطّلاع على مرجع واجهة برمجة التطبيقات.
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
لبدء عملية الدمج في Node، يمكنك الرجوع إلى نماذج التعليمات البرمجية الكاملة على 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}`; }
تعديل عنصر بطاقات
ويؤثر تعديل 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}
لمزيد من المعلومات، يُرجى الاطّلاع على مرجع واجهة برمجة التطبيقات.
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
لبدء عملية الدمج في Node، يمكنك الرجوع إلى نماذج التعليمات البرمجية الكاملة على 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"
بيانات من رحلات جوية من Google
أو المعلومات المقدَّمة في بطاقة "محفظة Google". ويعتمد المصدر الذي يتمّ استخدامه على ما يلي:
-
في حال عدم تقديم السمة
class.localEstimatedOrActualDepartureDateTime
، سيتم استخدام "رحلات جوية من Google". وفي هذه الحالة، يتم تجاهل أيclass.flightStatus
تضبطه.على سبيل المثال، في حال تأخّر رحلة جوية، تظهر للمستخدمين بطاقة ضمن علامة التبويب "الصفحة الرئيسية" في تطبيق "محفظة Google" تعرض وقت المغادرة الجديد. وتظهر بطاقة تأخير مشابهة للمستخدمين أيضًا ضمن علامة التبويب "البطاقات".
- إذا قدّمت
class.localEstimatedOrActualDepartureDateTime
وليسclass.flightStatus
، يتم استخدام الوقت المقدَّم لتحديد ما إذا كانت الرحلة الجوية متأخرة أم لا. بعد ذلك، يتم عرض حالة الرحلة الجوية على البطاقة للمستخدمين استنادًا إلى المنطق التالي:- إذا كانت قيمة السمة
class.localEstimatedOrActualDepartureDateTime
أكبر منclass.localScheduledDepartureDateTime
، اعرض للمستخدمين بطاقة تتضمّن الرحلة الجوية على أنّها متأخرة. - إذا كانت قيمة السمة
class.localEstimatedOrActualDepartureDateTime
لا تتجاوزclass.localScheduledDepartureDateTime
، يمكنك عرض البطاقة للمستخدمين مع معلومات الرحلة الجوية ولكن بدون أي رسالة حالة.
- إذا كانت قيمة السمة
إذا كنت لا تريد استخدام "رحلات جوية من Google" كمصدر للمعلومات حول الرحلات الجوية، احرص على
تقديم flightStatus
وlocalScheduledDepartureDateTime
و
localEstimatedOrActualDepartureDateTime
من FlightClass
. يتم استخدام بياناتك فقط
على البطاقة. إذا كنت تستخدم رمز شركة النقل ICAO بدلاً من رمز الاتحاد الدولي للنقل الجوي في FlightClass
، لن يتم استخدام "رحلات جوية من Google" كمصدر لمعلومات الرحلات الجوية.
عند تغيير حقول معيَّنة، يتلقّى المستخدم إشعارات فورية بشأن التغييرات. لمزيد من التفاصيل، يمكنك الاطّلاع على تلقّي إشعارات بتحديثات الرحلات الجوية.