पास को अपडेट रखना, ग्राहकों से जुड़ने और उन्हें बेहतर अनुभव देने का एक अहम तरीका है.
दो संसाधन अपडेट किए जा सकते हैं: 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
में बदलाव करने पर, उन सभी उपयोगकर्ताओं पर असर पड़ेगा जिनके लिए इस क्लास का इस्तेमाल करने वाले बोर्डिंग पास हैं. उदाहरण के लिए, अपने बोर्डिंग पास का लोगो अपडेट करने के लिए, आपको Google Wallet API को update
या patch
अनुरोध सबमिट करना होगा. इसके लिए, इन एंडपॉइंट में से किसी एक पर जाएं. 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
नोड में इंटिग्रेशन शुरू करने के लिए, 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
नोड में इंटिग्रेशन शुरू करने के लिए, 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.localEstimatedOrActualDepartureDateTime
नहीं दिया गया है, तो Google Flights का इस्तेमाल किया जाता है. इस मामले में, आपके सेट किए गए किसी भीclass.flightStatus
को अनदेखा कर दिया जाता है.उदाहरण के लिए, अगर कोई फ़्लाइट देरी से चल रही है, तो उपयोगकर्ताओं को Google Wallet ऐप्लिकेशन के "होम" टैब में एक कार्ड दिखता है. इस कार्ड में, रवाना होने का नया समय दिखता है. देरी वाला एक कार्ड, उपयोगकर्ताओं को "पास" टैब में भी दिखता है.
- अगर आपने
class.localEstimatedOrActualDepartureDateTime
की जानकारी दी है, लेकिनclass.flightStatus
नहीं, तो दिए गए समय का इस्तेमाल यह पता लगाने के लिए किया जाता है कि फ़्लाइट में देरी हुई है या नहीं. इसके बाद, कार्ड पर फ़्लाइट की स्थिति, नीचे दिए गए लॉजिक के आधार पर उपयोगकर्ताओं को दिखाई जाती है:- अगर
class.localEstimatedOrActualDepartureDateTime
की कीमतclass.localScheduledDepartureDateTime
से ज़्यादा है, तो उपयोगकर्ताओं को वह कार्ड दिखाएं जिसकी फ़्लाइट में देरी हुई है. - अगर
class.localEstimatedOrActualDepartureDateTime
की कीमतclass.localScheduledDepartureDateTime
से बड़ी नहीं है, तो उपयोगकर्ताओं को फ़्लाइट की जानकारी के साथ वह कार्ड दिखाएं जिसमें स्थिति का कोई मैसेज न हो.
- अगर
अगर आपको फ़्लाइट की जानकारी के लिए Google Flights का इस्तेमाल नहीं करना है, तो FlightClass
के flightStatus
, localScheduledDepartureDateTime
, और localEstimatedOrActualDepartureDateTime
देना न भूलें. कार्ड पर सिर्फ़ आपका डेटा
इस्तेमाल किया जाता है. इसके अलावा, अगर FlightClass
में आईएटीए कोड के बजाय, ICAO कैरियर कोड का इस्तेमाल किया जाता है, तो Google Flights का इस्तेमाल फ़्लाइट की जानकारी के सोर्स के तौर पर नहीं किया जाता है.
कुछ फ़ील्ड बदलने पर, उपयोगकर्ता को बदलावों के बारे में पुश नोटिफ़िकेशन मिलते हैं. ज़्यादा जानकारी के लिए, फ़्लाइट के अपडेट की सूचनाएं पाना देखें.