लॉयल्टी टेंप्लेट

लॉयल्टी पास, टेंप्लेट रेंडरिंग के साथ काम करता है. अगर कोई टेंप्लेट तय नहीं किया गया है, तो डिफ़ॉल्ट टेंप्लेट इस्तेमाल किया जाता है.

टेंप्लेट की परिभाषा

पास के टेंप्लेट की जानकारी क्लास के लेवल पर की जाती है. इसकी मदद से, कक्षा से जुड़े किसी भी ऑब्जेक्ट को दिखाया जाता है. टेंप्लेट से पता चलता है कि पास के अलग-अलग सेक्शन में कौनसे फ़ील्ड दिखाने हैं.

टेंप्लेट को नीचे दिए गए सेक्शन में बांटा गया है:

Android

टेंप्लेट की खास जानकारी

वेब

टेंप्लेट की खास जानकारी

कार्ड शीर्षक

Android

कार्ड के शीर्षक वाले एलिमेंट
  1. class.programLogo
  2. class.localizedIssuerName
    या class.issuerName
  3. class.localizedProgramName
    या class.programName
  4. class.hexBackgroundColor

वेब

कार्ड के शीर्षक वाले एलिमेंट
  1. class.programLogo
  2. class.localizedIssuerName
    या class.issuerName
  3. class.localizedProgramName
    या class.programName
  4. class.hexBackgroundColor

कार्ड के शीर्षक वाले सेक्शन में लोगो, जारी करने वाले का नाम, और कार्यक्रम का शीर्षक दिखता है. उन्हें भरने के लिए, फ़ील्ड के रेफ़रंस न तो इस्तेमाल किए जाते हैं और न ही उनकी जगह बदली जा सकती है.

कार्ड का टेंप्लेट

Android

टेंप्लेट की खास जानकारी

वेब

टेंप्लेट की खास जानकारी

कार्ड टेंप्लेट के सेक्शन का इस्तेमाल, ज़्यादा पंक्तियां दिखाने के लिए किया जाता है. इन पंक्तियों में, टेक्स्ट पर आधारित स्ट्रक्चर्ड डेटा फ़ील्ड या टेक्स्ट मॉड्यूल फ़ील्ड हो सकते हैं.

आप पंक्तियों की वह संख्या बता सकते हैं जिससे class.classTemplateInfo.cardTemplateOverride.cardRowTemplateInfos[] सूची में मौजूद ऑब्जेक्ट की संख्या पता चलती है. सूची में कम से कम एक एलिमेंट होना ज़रूरी है. इसलिए, हमने ज़्यादा से ज़्यादा दो एलिमेंट का इस्तेमाल करने का सुझाव दिया है. हर एलिमेंट, इनमें से किसी एक तरह का होना चाहिए:

  • oneItem, एक आइटम स्वीकार करता है:
    • item
  • twoItems इन दो आइटम को स्वीकार करता है:
    • startItem
    • endItem
  • threeItems इन तीन आइटम को स्वीकार करता है:
    • startItem
    • middleItem
    • endItem

हर आइटम को सिंगल फ़ील्ड सिलेक्टर (.firstValue), दो फ़ील्ड सिलेक्टर (.firstValue और .secondValue या पहले से तय आइटम (.predefinedItem) के तौर पर बताया जा सकता है. चुने गए फ़ील्ड की वैल्यू और उनसे जुड़े लेबल, दोनों दिखाए जाते हैं. जब दो फ़ील्ड सिलेक्टर तय किए जाते हैं, तो चुने गए फ़ील्ड की वैल्यू "/" सेपरेटर के साथ दिखती हैं. चुने गए फ़ील्ड के लेबल पर भी यही बात लागू होती है. पहले से तय आइटम का इस्तेमाल, ज़्यादा कॉम्प्लेक्स रेंडरिंग को तय करने के लिए किया जाता है.

कोड के इस नमूने में दो पंक्तियों की जानकारी देने के लिए, कार्ड टेंप्लेट के कार्ड लाइन सेक्शन को बदलने का तरीका बताया गया है. हर पंक्ति में तीन आइटम होते हैं, जिनमें हर आइटम, छह क्लास लेवल के textModuleData कस्टम फ़ील्ड और उनके हेडर को लेबल के तौर पर दिखाता है:

Python

 {
   ... //Rest of class
   "textModulesData": [
        {
            "header": "Label 1",
            "body": "Some info 1",
            "id": "myfield1"
        },
        {
            "header": "Label 2",
            "body": "Some info 2",
            "id": "myfield2"
        },
        {
            "header": "Label 3",
            "body": "Some info 3",
            "id": "myfield3"
        },
        {
            "header": "Label 4",
            "body": "Some info 4",
            "id": "myfield4"
        },
        {
            "header": "Label 5",
            "body": "Some info 5",
            "id": "myfield5"
        },
        {
            "header": "Label 6",
            "body": "Some info 6",
            "id": "myfield6"
        }
    ],
   "classTemplateInfo": {
        "cardTemplateOverride": {
            "cardRowTemplateInfos": [{
                "threeItems": {
                    "startItem": {
                        "firstValue": {
                            "fields": [{
                                "fieldPath": "class.textModulesData['myfield1']"
                            }]
                        }
                    },
                    "middleItem": {
                        "firstValue": {
                            "fields": [{
                                "fieldPath": "class.textModulesData['myfield2']"
                            }]
                        }
                    },
                    "endItem": {
                        "firstValue": {
                            "fields": [{
                                "fieldPath": "class.textModulesData['myfield3']"
                            }]
                        }
                    },
                }
            },{
                "threeItems": {
                    "startItem": {
                        "firstValue": {
                            "fields": [{
                                "fieldPath": "class.textModulesData['myfield4']"
                            }]
                        }
                    },
                    "middleItem": {
                        "firstValue": {
                            "fields": [{
                                "fieldPath": "class.textModulesData['myfield5']"
                            }]
                        }
                    },
                    "endItem": {
                        "firstValue": {
                            "fields": [{
                                "fieldPath": "class.textModulesData['myfield6']"
                            }]
                        }
                    },
                }
            }]
        }
    }
}
    

Java

// Rest of class
  .setTextModulesData((new ArrayList<TextModuleData>() {
    {
      add((new TextModuleData()).setHeader("Label 1")
        .setBody("Some info 1")
        .setId("myfield1"));
      add((new TextModuleData()).setHeader("Label 2")
        .setBody("Some info 1")
        .setId("myfield2"));
      add((new TextModuleData()).setHeader("Label 3")
        .setBody("Some info 3")
        .setId("myfield3"));
      add((new TextModuleData()).setHeader("Label 4")
        .setBody("Some info 4")
        .setId("myfield4"));
      add((new TextModuleData()).setHeader("Label 5")
        .setBody("Some info 5")
        .setId("myfield5"));
      add((new TextModuleData()).setHeader("Label 6")
        .setBody("Some info 5")
        .setId("myfield6"));
    }
  }))
  .setClassTemplateInfo((new ClassTemplateInfo())
    .setCardTemplateOverride((new CardTemplateOverride())
      .setCardRowTemplateInfos(new ArrayList<CardRowTemplateInfo>() {
        {
          add((new CardRowTemplateInfo()).setThreeItems((new CardRowThreeItems())
            .setStartItem((new TemplateItem()).setFirstValue((new FieldSelector()).setFields(new ArrayList<FieldReference>(){
              {
                add((new FieldReference()).setFieldPath("class.textModulesData['myfield1']"));
              }
            })))
            .setMiddleItem((new TemplateItem()).setFirstValue((new FieldSelector()).setFields(new ArrayList<FieldReference>(){
              {
                add((new FieldReference()).setFieldPath("class.textModulesData['myfield2']"));
              }
            })))
            .setEndItem((new TemplateItem()).setFirstValue((new FieldSelector()).setFields(new ArrayList<FieldReference>(){
              {
                add((new FieldReference()).setFieldPath("class.textModulesData['myfield3']"));
              }
            })))
          ));
          add((new CardRowTemplateInfo()).setThreeItems((new CardRowThreeItems())
            .setStartItem((new TemplateItem()).setFirstValue((new FieldSelector()).setFields(new ArrayList<FieldReference>(){
              {
                add((new FieldReference()).setFieldPath("class.textModulesData['myfield4']"));
              }
            })))
            .setMiddleItem((new TemplateItem()).setFirstValue((new FieldSelector()).setFields(new ArrayList<FieldReference>(){
              {
                add((new FieldReference()).setFieldPath("class.textModulesData['myfield5']"));
              }
            })))
            .setEndItem((new TemplateItem()).setFirstValue((new FieldSelector()).setFields(new ArrayList<FieldReference>(){
              {
                add((new FieldReference()).setFieldPath("class.textModulesData['myfield6']"));
              }
            })))
          ));
          }
  })))
    

129

// Rest of class
    $textModulesData1 = new Google_Service_Walletobjects_TextModuleData();
    $textModulesData1->setBody("Some info 1");
    $textModulesData1->setHeader("Label 1");
    $textModulesData1->setId("myfield1");

    $textModulesData2 = new Google_Service_Walletobjects_TextModuleData();
    $textModulesData2->setBody("Some info 2");
    $textModulesData2->setHeader("Label 2");
    $textModulesData2->setId("myfield2");

    $textModulesData3 = new Google_Service_Walletobjects_TextModuleData();
    $textModulesData3->setBody("Some info 3");
    $textModulesData3->setHeader("Label 3");
    $textModulesData3->setId("myfield3");

    $textModulesData4 = new Google_Service_Walletobjects_TextModuleData();
    $textModulesData4->setBody("Some info 4");
    $textModulesData4->setHeader("Label 4");
    $textModulesData4->setId("myfield4");

    $textModulesData5 = new Google_Service_Walletobjects_TextModuleData();
    $textModulesData5->setBody("Some info 5");
    $textModulesData5->setHeader("Label 5");
    $textModulesData5->setId("myfield5");

    $textModulesData6 = new Google_Service_Walletobjects_TextModuleData();
    $textModulesData6->setBody("Some info 6");
    $textModulesData6->setHeader("Label 6");
    $textModulesData6->setId("myfield6");

    $textModulesDatas = array($textModulesData1, $textModulesData2, $textModulesData3,
                  $textModulesData4, $textModulesData5, $textModulesData6);

    $startItemField = new Google_Service_Walletobjects_FieldReference();
    $startItemField->setFieldPath("class.textModulesData['myfield1']");

    $startItemFirstValue = new Google_Service_Walletobjects_FieldSelector();
    $startItemFirstValue->setFields(array($startItemField));

    $startItem = new Google_Service_Walletobjects_TemplateItem();
    $startItem->setFirstValue($startItemFirstValue);

    $middleItemField = new Google_Service_Walletobjects_FieldReference();
    $middleItemField->setFieldPath("class.textModulesData['myfield2']");

    $middleItemFirstValue = new Google_Service_Walletobjects_FieldSelector();
    $middleItemFirstValue->setFields(array($middleItemField));

    $middleItem = new Google_Service_Walletobjects_TemplateItem();
    $middleItem->setFirstValue($middleItemFirstValue);

    $endItemField = new Google_Service_Walletobjects_FieldReference();
    $endItemField->setFieldPath("class.textModulesData['myfield3']");

    $endItemFirstValue = new Google_Service_Walletobjects_FieldSelector();
    $endItemFirstValue->setFields(array($endItemField));

    $endItem = new Google_Service_Walletobjects_TemplateItem();
    $endItem->setFirstValue($endItemFirstValue);

    $cardRowTemplate = new Google_Service_Walletobjects_CardRowThreeItems();
    $cardRowTemplate->setStartItem($startItem);
    $cardRowTemplate->setMiddleItem($middleItem);
    $cardRowTemplate->setEndItem($endItem);

    $cardRowTemplateInfo1 = new Google_Service_Walletobjects_CardRowTemplateInfo();
    $cardRowTemplateInfo1->setThreeItems($cardRowTemplate);

    $startItemField2 = new Google_Service_Walletobjects_FieldReference();
    $startItemField2->setFieldPath("class.textModulesData['myfield4']");

    $startItemFirstValue2 = new Google_Service_Walletobjects_FieldSelector();
    $startItemFirstValue2->setFields(array($startItemField2));

    $startItem2 = new Google_Service_Walletobjects_TemplateItem();
    $startItem2->setFirstValue($startItemFirstValue2);

    $middleItemField2 = new Google_Service_Walletobjects_FieldReference();
    $middleItemField2->setFieldPath("class.textModulesData['myfield5']");

    $middleItemFirstValue2 = new Google_Service_Walletobjects_FieldSelector();
    $middleItemFirstValue2->setFields(array($middleItemField2));

    $middleItem2 = new Google_Service_Walletobjects_TemplateItem();
    $middleItem2->setFirstValue($middleItemFirstValue2);

    $endItemField2 = new Google_Service_Walletobjects_FieldReference();
    $endItemField2->setFieldPath("class.textModulesData['myfield6']");

    $endItemFirstValue2 = new Google_Service_Walletobjects_FieldSelector();
    $endItemFirstValue2->setFields(array($endItemField2));

    $endItem2 = new Google_Service_Walletobjects_TemplateItem();
    $endItem2->setFirstValue($endItemFirstValue2);

    $cardRowTemplate2 = new Google_Service_Walletobjects_CardRowThreeItems();
    $cardRowTemplate2->setStartItem($startItem2);
    $cardRowTemplate2->setMiddleItem($middleItem2);
    $cardRowTemplate2->setEndItem($endItem2);

    $cardRowTemplateInfo2 = new Google_Service_Walletobjects_CardRowTemplateInfo();
    $cardRowTemplateInfo2->setThreeItems($cardRowTemplate2);

    $cardTemplateOverride = new Google_Service_Walletobjects_CardTemplateOverride();
    $cardTemplateOverride->setCardRowTemplateInfos(array($cardRowTemplateInfo1,
                  $cardRowTemplateInfo2));

    $classTemplateInfo = new Google_Service_Walletobjects_ClassTemplateInfo();
    $classTemplateInfo->setCardTemplateOverride($cardTemplateOverride);

    $payload->setTextModulesData($textModulesDatas);
    $payload->setClassTemplateInfo($classTemplateInfo);
    

कोड, कोड टेंप्लेट वाले इस सेक्शन के फ़ॉर्मैट के साथ पास बनाता है:

लेबल के बदलाव का उदाहरण.

अगर कोई आइटम खाली है, तो उसे नहीं दिखाया जाता. ज़्यादा जानकारी के लिए, फ़ील्ड रेफ़रंस देखें. पंक्ति में मौजूद सभी आइटम खाली होने पर, लाइन नहीं दिखती है. अगर पंक्ति के सभी आइटम खाली हैं, लेकिन सभी आइटम खाली हैं, तो जो आइटम खाली नहीं होते उन्हें फिर से व्यवस्थित किया जाता है. साथ ही, कम आइटम वाली पंक्ति के तौर पर दिखाया जाता है.

कार्ड के टेंप्लेट को न बदलने पर, लाइन की डिफ़ॉल्ट संख्या, आइटम की डिफ़ॉल्ट संख्या, और डिफ़ॉल्ट फ़ील्ड के रेफ़रंस का इस्तेमाल किया जाता है. ज़्यादा जानकारी के लिए, डिफ़ॉल्ट टेंप्लेट देखें.

हीरो इमेज के बारे में बताने के बाद, अगर cardRowTemplateInfos सूची में कई पंक्तियां हैं या पंक्ति के ऊपर सिर्फ़ एक पंक्ति है, तो यह पहली पंक्ति के बाद दिख सकती है.

कार्ड का बारकोड

Android

कार्ड के बारकोड वाले एलिमेंट
  1. class.classTemplateInfo
      .cardBarcodeSectionDetails
      .firstTopDetail
  2. class.classTemplateInfo
      .cardBarcodeSectionDetails
      .secondTopDetail
  3. object.barcode.type और object.barcode.value
    या object.accountId
  4. object.barcode.alternateText
    या object.accountId
    या object.barcode.value
  5. class.classTemplateInfo
      .cardBarcodeSectionDetails
      .firstBottomDetail
  6. object.heroImage
    या class.heroImage

वेब

कार्ड के बारकोड वाले एलिमेंट
  1. class.classTemplateInfo
      .cardBarcodeSectionDetails
      .firstTopDetail
  2. class.classTemplateInfo
      .cardBarcodeSectionDetails
      .secondTopDetail
  3. object.barcode.type और object.barcode.value
    या object.accountId
  4. object.barcode.alternateText
    या object.accountId
    या object.barcode.value
  5. class.classTemplateInfo
      .cardBarcodeSectionDetails
      .firstBottomDetail

कार्ड बारकोड सेक्शन का इस्तेमाल, बारकोड के ऊपर और नीचे अतिरिक्त टेक्स्ट या इमेज दिखाने के लिए किया जाता है. इस सेक्शन के किसी भी फ़ील्ड की ज़रूरत नहीं है.

तीन फ़ील्ड सिलेक्टर होते हैं जिनका इस्तेमाल ऊपर और साथ-साथ बारकोड के नीचे दिए गए दो फ़ील्ड को तय करने के लिए किया जा सकता है. इन्हें बिना किसी लेबल के दिखाया जाता है. ये टेक्स्ट-आधारित स्ट्रक्चर्ड डेटा फ़ील्ड, टेक्स्ट मॉड्यूल फ़ील्ड या इमेज मॉड्यूल फ़ील्ड हो सकते हैं. अगर इमेज का इस्तेमाल किया जा रहा है, तो ब्रैंड के दिशा-निर्देशों का पालन करें.

बारकोड, टाइप और वैल्यू से तय होता है. इस्तेमाल किए जा सकने वाले बारकोड के टाइप की सूची के लिए, रेफ़रंस देखें. इसके अलावा, टेक्स्ट को बारकोड के ठीक नीचे दिखाया जा सकता है. इस टेक्स्ट की मदद से, बारकोड को स्कैन करके इस्तेमाल करना आसान बनाया जा सकता है.

कोड का यह नमूना दिखाता है कि बारकोड के ऊपर इमेज दिखाने के लिए, पास के बारकोड सेक्शन को कैसे बदला जा सकता है:

Python

#... rest of class
    "imageModulesData": [
        {
            "mainImage": {
                "sourceUri": {
                    "uri":  "http://farm4.staticflickr.com/3738/12440799783_3dc3c20606_b.jpg",
                    "description": "Coffee"
                }
            },
            "Id": "myimage"
        }
    ],
    "classTemplateInfo": {
        "cardBarcodeSectionDetails": {
            "firstTopDetail": {
                "fieldSelector": {
                    "fields": [
                        {
                        "fieldPath": "class.imageModulesData['myimage'].mainImage"
                        }
                    ]
                }
            }
        }
    }
}
    

Java

//... rest of class
  .setImageModulesData((new ArrayList<ImageModuleData>() {
    {
      add((new ImageModuleData())
        .setId("myimage")
        .setMainImage((new Image()).setSourceUri((new ImageUri()).setDescription("Coffee beans")
          .setUri("http://farm4.staticflickr.com/3738/12440799783_3dc3c20606_b.jpg"))));
        }
      }))
      .setClassTemplateInfo((new ClassTemplateInfo())
        .setCardBarcodeSectionDetails((new CardBarcodeSectionDetails())
          .setFirstTopDetail((new BarcodeSectionDetail())
            .setFieldSelector((new FieldSelector())
              .setFields((new ArrayList<FieldReference>(){
                {
                  add((new FieldReference()).setFieldPath("class.imageModulesData['myimage'].mainImage"));
                }
            })))))
      }
    

129

//... rest of class
    $imageUri = new Google_Service_Walletobjects_ImageUri();
    $imageUri->setUri("https://farm8.staticflickr.com/7340/11177041185_a61a7f2139_o.jpg");
    $imageUri->setDescription("Baconrista flights image");
    $image = new Google_Service_Walletobjects_Image();
    $image->setSourceUri($imageUri);
    $imageModulesData = new Google_Service_Walletobjects_ImageModuleData();
    $imageModulesData->setMainImage($image);
            $imageModulesData->setId("myimage");

    $cardBarcodeFieldReference = new Google_Service_Walletobjects_FieldReference();
    $cardBarcodeFieldReference->setFieldPath("class.imageModulesData['myimage'].mainImage");

    $cardBarcodeFieldSelector = new Google_Service_Walletobjects_FieldSelector();
    $cardBarcodeFieldSelector->setFields(array($cardBarcodeFieldReference));

    $cardBarcodeDetail = new Google_Service_Walletobjects_BarcodeSectionDetail();
    $cardBarcodeDetail->setFieldSelector($cardBarcodeFieldSelector);

    $cardBarcodeSectionDetails = new Google_Service_Walletobjects_CardBarcodeSectionDetails();
    $cardBarcodeSectionDetails->setFirstTopDetail($cardBarcodeDetail);

    $classTemplateInfo = new Google_Service_Walletobjects_ClassTemplateInfo();
    $classTemplateInfo->setCardBarcodeSectionDetails($cardBarcodeSectionDetails);

    $payload->setClassTemplateInfo($classTemplateInfo);
            $payload->setImageModuleData($imageModulesData);
    

कोड, यहां दिए गए बारकोड सेक्शन फ़ॉर्मैट का इस्तेमाल करके पास बनाता है:

कार्ड के बारकोड में बदलाव करने का उदाहरण.

अगर बारकोड सेक्शन को बदला नहीं जाता है, तो डिफ़ॉल्ट बारकोड फ़ील्ड का इस्तेमाल किया जाता है. ज़्यादा जानकारी के लिए, डिफ़ॉल्ट टेंप्लेट देखें.

ज़्यादा जानकारी वाला टेंप्लेट

Android

ब्यौरे वाले टेंप्लेट के सेक्शन
  • class.classTemplateInfo.detailsTemplateOverride
      .detailsItemInfos[0].item
  • class.classTemplateInfo.detailsTemplateOverride
      .detailsItemInfos[1].item
  • class.classTemplateInfo.detailsTemplateOverride
      .detailsItemInfos[2].item
  • class.classTemplateInfo.detailsTemplateOverride
      .detailsItemInfos[3].item
  • ...

वेब

ब्यौरे वाले टेंप्लेट के सेक्शन
  • class.classTemplateInfo.detailsTemplateOverride
      .detailsItemInfos[0].item
  • class.classTemplateInfo.detailsTemplateOverride
      .detailsItemInfos[1].item
  • class.classTemplateInfo.detailsTemplateOverride
      .detailsItemInfos[2].item
  • class.classTemplateInfo.detailsTemplateOverride
      .detailsItemInfos[3].item
  • ...

जानकारी वाले टेंप्लेट सेक्शन में, आइटम की सूची दी गई है class.classTemplateInfo.detailsTemplateOverride.detailsItemInfos[]. आइटम में किसी भी तरह का स्ट्रक्चर्ड डेटा फ़ील्ड, टेक्स्ट मॉड्यूल फ़ील्ड, लिंक मॉड्यूल फ़ील्ड, इमेज मॉड्यूल फ़ील्ड या मैसेज शामिल हो सकते हैं.

हर आइटम को सिंगल फ़ील्ड सिलेक्टर (.firstValue), दो फ़ील्ड सिलेक्टर (.firstValue और .secondValue) या पहले से तय आइटम (.predefinedItem) के तौर पर बताया जा सकता है. चुने गए फ़ील्ड की वैल्यू और उनसे जुड़े लेबल, दोनों दिखाए जाते हैं. जब दो फ़ील्ड सिलेक्टर तय किए जाते हैं, तो चुने गए फ़ील्ड की वैल्यू, "/" सेपरेटर के साथ दिखाई जाती हैं. चुने गए फ़ील्ड के लेबल पर भी लागू होता है. पहले से तय आइटम का इस्तेमाल, ज़्यादा कॉम्प्लेक्स रेंडरिंग को तय करने के लिए किया जाता है. इमेज मॉड्यूल फ़ील्ड को बिना किसी लेबल के पूरी चौड़ाई में रेंडर किया जाता है.

यह कोड सैंपल, पास के linksModuleData सेक्शन को लेबल के साथ दिखाने के लिए, पास की ज़्यादा जानकारी वाले सेक्शन को बदलने का तरीका बताता है:

Python

//... rest of class
   "linksModuleData": {
        "uris": [
            {
                "uri": "http://maps.google.com/",
                "description": "Nearby Locations",
                "id":"mylink"
            }
        ]
    },
   "classTemplateInfo": {
        "detailsTemplateOverride": {
            "detailsItemInfos": [
                {
                    "item":{
                        "firstValue": {
                            "fields": [{
                                "fieldPath": "class.linksModuleData.uris['mylink']"
                            }]
                        }
                    }
                }
            ]
        }
     }
//... rest of class
    

Java

 //... rest of class
  .setLinksModuleData((new ArrayList<LinksModuleData>() {
    {
      add((new LinksModuleData()).setDescription("Nearby Locations")
        .setUri("http://maps.google.com/")
        .setId("mylink"));
      }))
      .setClassTemplateInfo((new ClassTemplateInfo())
        .setDetailsTemplateOverride((new DetailsTemplateOverride())
          .setDetailsItemInfos(new ArrayList<DetailsItemInfo>(){
            {
              add((new DetailsItemInfo())
                .setItem((new TemplateItem()).setFirstValue((new FieldSelector()).setFields(new ArrayList<FieldReference>(){
                  {
                    add((new FieldReference()).setFieldPath("class.linksModuleData.uris['mylink']"));
                  }
                }))));
              }
            }))
//... rest of class
    

129



    //... rest of class building
    $locationUri = new Google_Service_Walletobjects_Uri();
    $locationUri->setUri("http://maps.google.com/");
    $locationUri->setDescription("Nearby Locations");
    $locationUri->setId("mylink");

    $linksModuleData = new Google_Service_Walletobjects_LinksModuleData();
    $linksModuleData->setUris(array($locationUri));

    $detailItemFieldReference = new Google_Service_Walletobjects_FieldReference();
    $detailItemFieldReference->setFieldPath("class.linksModuleData.uris['mylink']");
    $detailItemFieldSelector = new Google_Service_Walletobjects_FieldSelector();
    $detailItemFieldSelector->setFields(array($detailItemFieldReference));

    $detailItem = new Google_Service_Walletobjects_TemplateItem();
    $detailItem->setFirstValue($detailItemFieldSelector);

    $detailsItemInfo = new Google_Service_Walletobjects_DetailsItemInfo();
    $detailsItemInfo->setItem($detailItem);

    $cardDetailsTemplateOverride = new Google_Service_Walletobjects_DetailsTemplateOverride();
    $cardDetailsTemplateOverride->setDetailsItemInfos(array($detailsItemInfo));

    $classTemplateInfo = new Google_Service_Walletobjects_ClassTemplateInfo();
    $classTemplateInfo->setDetailsTemplateOverride($cardDetailsTemplateOverride);

    $payload->setClassTemplateInfo($classTemplateInfo);
    $payload->setLinksModuleData($linksModuleData);
    //... rest of class
    

कोड, ज़्यादा जानकारी वाले सेक्शन के इस फ़ॉर्मैट के लिए पास बनाता है:

डिटेल में बदलाव करने का उदाहरण.

अगर कोई आइटम खाली है, तो उसे नहीं दिखाया जाता. ज़्यादा जानकारी के लिए, फ़ील्ड रेफ़रंस देखें.

ज़्यादा जानकारी वाले टेंप्लेट को न बदलने पर, डिफ़ॉल्ट क्रम में रेफ़रंस फ़ील्ड की डिफ़ॉल्ट सूची दिखेगी. ज़्यादा जानकारी के लिए, डिफ़ॉल्ट टेंप्लेट देखें.

सूची का टेंप्लेट

टेंप्लेट के एलिमेंट की सूची बनाना
  1. class.classTemplateInfo.listTemplateOverride
      .firstRowOption.fieldOption.fields[]
  2. class.classTemplateInfo.listTemplateOverride
      .secondRowOption.fields[]
  3. class.programLogo
  4. class.hexBackgroundColor

लिस्ट टेंप्लेट सेक्शन का इस्तेमाल, यह चुनने के लिए किया जाता है कि Google Wallet ऐप्लिकेशन के "पास" व्यू में कौनसा फ़ील्ड दिखाना है. पास को सूची में लोगो, बैकग्राउंड के रंग, और तीन पंक्तियों से दिखाया जाता है.

यह कोड सैंपल दिखाता है कि सूची टेंप्लेट की पहली पंक्ति में एक पास का ऑब्जेक्ट एक्सपायर होने की तारीख वाला फ़ील्ड दिखाने के लिए, पास के लिस्ट टेंप्लेट को कैसे बदला जा सकता है:

Python


#... rest of class definition
   "classTemplateInfo": {
        "listTemplateOverride":{
            "firstRowOption": {
                "fieldOption":{
                    "fields": [{
                        "fieldPath": "object.validTimeInterval.end"
                    }]
                }
            }
        }
   }
}
    

Java

//... rest of class
  .setClassTemplateInfo((new ClassTemplateInfo())
    .setListTemplateOverride((new ListTemplateOverride())
      .setFirstRowOption((new FirstRowOption())
        .setFieldOption((new FieldSelector()).setFields(new ArrayList<FieldReference>(){
          {
            add((new FieldReference()).setFieldPath("object.validTimeInterval.end"));
          }
        }))))
//... rest of class
    

129

    //... rest of class
    $fieldReference = new Google_Service_Walletobjects_FieldReference();
    $fieldReference->setFieldPath("object.validTimeInterval.end");

    $fieldOption = new Google_Service_Walletobjects_FieldSelector();
    $fieldOption->setFields(array($fieldReference));

    $firstRowOption = new Google_Service_Walletobjects_FirstRowOption();
    $firstRowOption->setFieldOption($fieldOption);

    $listTemplateOverride = new Google_Service_Walletobjects_ListTemplateOverride();
    $listTemplateOverride->setFirstRowOption($firstRowOption);

    $classTemplateInfo = new Google_Service_Walletobjects_ClassTemplateInfo();
    $classTemplateInfo->setListTemplateOverride($listTemplateOverride);

    $payload->setClassTemplateInfo($classTemplateInfo);
    //... rest of class
    

कोड, इस सूची टेंप्लेट के साथ एक पास बनाता है:

बदले गए सूची
                                                                           का उदाहरण.

तीन पंक्तियों को एक फ़ील्ड सिलेक्टर से तय किया जा सकता है. फ़ील्ड बिना किसी लेबल के दिखाए जाते हैं.

लेबल

स्ट्रक्चर्ड डेटा के सभी फ़ील्ड में Google से मिला लेबल होता है. इनमें से हर लेबल का अनुवाद, उन सभी भाषाओं में करने की ज़िम्मेदारी Google की है जिनका इस्तेमाल किया जा सकता है.

इनमें से किसी लेबल को अपनी पसंद के मुताबिक बनाया जा सकता है. इसके लिए, class.custom<name_of_the_field>Label फ़ील्ड में से किसी एक का इस्तेमाल करें. किसी लेबल को पसंद के मुताबिक बनाने पर, उस लेबल के लिए अनुवाद उन सभी भाषाओं में देने की ज़िम्मेदारी आपकी होती है जिनमें आपको काम करना है.

फ़ील्ड के बारे में जानकारी

फ़ील्ड के रेफ़रंस, टेंप्लेट के अलग-अलग हिस्सों में फ़ॉर्म class.classTemplateInfo.*.fields[] में इस्तेमाल किए जाते हैं. फ़ील्ड के रेफ़रंस में, स्ट्रक्चर्ड डेटा फ़ील्ड, टेक्स्ट मॉड्यूल फ़ील्ड, लिंक मॉड्यूल फ़ील्ड, इमेज मॉड्यूल फ़ील्ड या मैसेज के पाथ की सूची शामिल होती है.

हर फ़ील्ड रेफ़रंस में, सभी तरह के पाथ की अनुमति नहीं है. उदाहरण के लिए, कुछ फ़ील्ड के रेफ़रंस सिर्फ़ टेक्स्ट वाले स्ट्रक्चर्ड डेटा फ़ील्ड या टेक्स्ट मॉड्यूल फ़ील्ड के पाथ की अनुमति देते हैं. टेक्स्ट पर आधारित स्ट्रक्चर्ड फ़ील्ड, टाइप स्ट्रिंग, स्थानीय भाषा वाली स्ट्रिंग, तारीख या पैसे के स्ट्रक्चर्ड डेटा फ़ील्ड होते हैं.

इस सूची का इस्तेमाल, फ़ॉलबैक लॉजिक लागू करने के लिए किया जा सकता है. इसका मतलब है कि अगर सूची का पहला पाथ खाली फ़ील्ड में बदल जाता है, तो अगले पाथ का मूल्यांकन किया जाता है. फ़ॉलबैक लॉजिक, मुख्य रूप से टेक्स्ट पर आधारित स्ट्रक्चर्ड डेटा फ़ील्ड या टेक्स्ट मॉड्यूल फ़ील्ड को टारगेट करता है. एक ही सूची में, अलग-अलग तरह के फ़ील्ड को शामिल न करें. फ़ॉलबैक लॉजिक का इस्तेमाल सावधानी से और सिर्फ़ कुछ खास स्थितियों में करें, जब आपको उन फ़ील्ड के एक जैसे पैटर्न की उम्मीद हो जो कुछ ऑब्जेक्ट में मौजूद हैं, लेकिन दूसरों के लिए नहीं. ज़्यादातर मामलों में, इस्तेमाल के अलग-अलग मामलों के लिए अलग-अलग कक्षाएं बनाना आसान होता है.

फ़ील्ड के रेफ़रंस की सूची के सभी पाथ में खाली फ़ील्ड मौजूद होने पर, फ़ील्ड के रेफ़रंस का इस्तेमाल करने वाला आइटम नहीं दिखाया जाता है. अगर आपको फ़ील्ड रेफ़रंस के तौर पर इस्तेमाल होने वाले आइटम को हमेशा मौजूद रखना है, तो पक्का करें कि कम से कम एक पाथ खाली न हो. हमारा सुझाव है कि आप किसी खास वर्ण, जैसे कि '-' को शून्य वैल्यू दिखाने के लिए सेट करें, भले ही कुछ फ़ील्ड स्ट्रिंग के लिए सिर्फ़ स्पेस का इस्तेमाल करते हों.

किसी सूची में शामिल फ़ील्ड का संदर्भ देने के लिए, आप सूची के फ़ील्ड के इंडेक्स का इस्तेमाल कर सकते हैं. ज़्यादातर मामलों में, आप रेफ़रंस आईडी का इस्तेमाल कर सकते हैं. सूची में जिन आइटम की जानकारी होती है उन्हें आईडी से रेफ़रंस किया जा सकता है. इनमें .id फ़ील्ड होता है. हमारा सुझाव है कि आप सूची में फ़ील्ड के इंडेक्स पर रेफ़रंस आईडी का इस्तेमाल करें.

यहां एक सूची में मौजूद फ़ील्ड का रेफ़रंस देने का उदाहरण दिया गया है.

  • object.imageModulesData[0].id = my-first-id
  • object.imageModulesData[1].id = my-second-id
  • class.detailsTemplateOverride.detailsItemInfos[0].item.firstValue.fields[0].fieldPath = object.imageModulesData[‘my-second-id’]
  • class.detailsTemplateOverride.detailsItemInfos[1].item.firstValue.fields[0].fieldPath = object.imageModulesData[0]

इस मामले में, पास के ज़्यादा जानकारी वाले सेक्शन में पहला आइटम, ऑब्जेक्ट में बताया गया दूसरा इमेज है. पास के सेक्शन में मौजूद दूसरा आइटम, ऑब्जेक्ट में बताया गया पहला इमेज होता है.

डिफ़ॉल्ट टेंप्लेट

Android

डिफ़ॉल्ट टेंप्लेट एलिमेंट
  1. class.programLogo
  2. class.localizedIssuerName
    या class.issuerName
  3. class.localizedProgramName
    या class.programName
  4. अंक
    या object.loyaltyPoints.localizedLabel
    या object.loyaltyPoints.label
  5. object.loyaltyPoints.balance
  6. इनाम
    या object.secondaryLoyaltyPoints.localizedLabel
    या object.secondaryLoyaltyPoints.label
  7. object.secondaryLoyaltyPoints.balance
  8. object.barcode.type और object.barcode.value
    या object.accountId
  9. object.barcode.alternateText
    या object.accountId
    या object.barcode.value
  10. object.heroImage
    या class.heroImage
  11. class.hexBackgroundColor
  12. सदस्य का नाम
    या class.localizedAccountNameLabel
    या class.accountNameLabel
  13. object.accountName
  14. सदस्य आईडी
    या class.localizedAccountIdLabel
    या class.accountIdLabel
  15. object.accountId
  16. इनामों का टियर
    या class.localizedRewardsTierLabel
    या class.rewardsTierLabel
  17. class.localizedRewardsTier
    या class.rewardsTier
  18. सेकंडरी इनाम का टियर
    या class.localizedSecondaryRewardsTierLabel
    या class.secondaryRewardsTierLabel
  19. class.localizedSecondaryRewardsTier
    या class.secondaryRewardsTier
  20. class.imageModulesData[0].mainImage
  21. object.imageModulesData[0].mainImage
  22. class.messages[].header
  23. class.messages[].body
  24. object.messages[].header
  25. object.messages[].body
  26. class.textModulesData[0..9].header
  27. class.textModulesData[0..9].body
  28. object.textModulesData[0..9].header
  29. object.textModulesData[0..9].body
  30. class.linksModuleData.uris[].description
  31. object.linksModuleData.uris[].description
  32. class.homepageUri

वेब

डिफ़ॉल्ट टेंप्लेट एलिमेंट
  1. class.programLogo
  2. class.localizedIssuerName
    या class.issuerName
  3. class.localizedProgramName
    या class.programName
  4. अंक
    या object.loyaltyPoints.localizedLabel
    या object.loyaltyPoints.label
  5. object.loyaltyPoints.balance
  6. इनाम
    या object.secondaryLoyaltyPoints.localizedLabel
    या object.secondaryLoyaltyPoints.label
  7. object.secondaryLoyaltyPoints.balance
  8. object.barcode.type और object.barcode.value
    या object.accountId
  9. object.barcode.alternateText
    या object.accountId
    या object.barcode.value
  10. object.heroImage
    या class.heroImage
  11. class.hexBackgroundColor
  12. सदस्य का नाम
    या class.localizedAccountNameLabel
    या class.accountNameLabel
  13. object.accountName
  14. सदस्य आईडी
    या class.localizedAccountIdLabel
    या class.accountIdLabel
  15. object.accountId
  16. इनामों का टियर
    या class.localizedRewardsTierLabel
    या class.rewardsTierLabel
  17. class.localizedRewardsTier
    या class.rewardsTier
  18. सेकंडरी इनाम का टियर
    या class.localizedSecondaryRewardsTierLabel
    या class.secondaryRewardsTierLabel
  19. class.localizedSecondaryRewardsTier
    या class.secondaryRewardsTier
  20. class.imageModulesData[0].mainImage
  21. object.imageModulesData[0].mainImage
  22. class.messages[].header
  23. class.messages[].body
  24. object.messages[].header
  25. object.messages[].body
  26. class.textModulesData[0..9].header
  27. class.textModulesData[0..9].body
  28. object.textModulesData[0..9].header
  29. object.textModulesData[0..9].body
  30. class.linksModuleData.uris[].description
  31. object.linksModuleData.uris[].description
  32. class.homepageUri

इमेज मॉड्यूल फ़ील्ड के लिए, हम क्लास से एक और सिर्फ़ एक इमेज मॉड्यूल फ़ील्ड दिखाते हैं. साथ ही, ऑब्जेक्ट से सिर्फ़ एक इमेज मॉड्यूल फ़ील्ड दिखाते हैं. अगर आपको किसी भी लेवल पर एक से ज़्यादा इमेज मॉड्यूल फ़ील्ड इस्तेमाल करने हैं, तो डिफ़ॉल्ट टेंप्लेट को बदलें.

टेक्स्ट मॉड्यूल फ़ील्ड के लिए, हम क्लास से सिर्फ़ 20 टेक्स्ट मॉड्यूल फ़ील्ड और ऑब्जेक्ट से 20 टेक्स्ट मॉड्यूल फ़ील्ड दिखाते हैं. फ़ील्ड उसी क्रम में दिखाए जाते हैं जिस क्रम में वे श्रेणी में तय किए जाते हैं. अगर आपको किसी भी लेवल पर 20 से ज़्यादा टेक्स्ट मॉड्यूल फ़ील्ड की ज़रूरत है, तो डिफ़ॉल्ट टेंप्लेट को बदलें.

मैसेज के लिए, हम क्लास से सिर्फ़ 20 मैसेज और ऑब्जेक्ट से 20 मैसेज दिखाते हैं. हम मैसेज के क्रम की गारंटी नहीं देते. अगर आपको किसी भी लेवल पर 20 से ज़्यादा मैसेज चाहिए या किसी ऑर्डर के लिए गारंटी चाहिए, तो डिफ़ॉल्ट टेंप्लेट को बदलें.

लिंक मॉड्यूल फ़ील्ड के लिए, आप जो भी यूआरआई दे सकते हैं उनकी संख्या की कोई सीमा नहीं है. यूआरआई को हर लेवल (क्लास या ऑब्जेक्ट के लिए) इस क्रम में बांटा जाता है:

  1. मैप निर्देशांक
  2. टेलीफ़ोन नंबर
  3. ईमेल पते
  4. वेब पेज

हर ग्रुप के लिए, यूआरआई को उसी क्रम में दिखाया जाता है जिस क्रम में वे ऐरे में तय किए जाते हैं. अगर आपको किसी दूसरे ऑर्डर की ज़रूरत है, तो डिफ़ॉल्ट टेंप्लेट को बदलें.

डिफ़ॉल्ट सूची टेंप्लेट के एलिमेंट
  1. class.localizedIssuerName
    या class.issuerName
  2. class.localizedProgramName
    या class.programName
  3. class.programLogo
  4. class.hexBackgroundColor