Esempio n. 1
0
 /**
  * Create an example Offer Class
  *
  * @param String $issuerId Wallet Object merchant account id.
  * @param String $classId Wallet Class that this wallet object references.
  * @return Object $wobClass Offerclass resource.
  */
 public static function generateOfferClass($issuerId, $classId)
 {
     // Used to select which templates to use for rendering in this section.
     $renderSpecs = array(array('templateFamily' => '1.offer_list', 'viewName' => 'g_list'), array('templateFamily' => '1.offer_expanded', 'viewName' => 'g_expanded'));
     // A list of locations at which the Wallet Class can be used.
     $locations = array(array('kind' => 'walletobjects#latLongPoint', 'latitude' => 37.424015499999996, 'longitude' => -122.09259560000001), array('kind' => 'walletobjects#latLongPoint', 'latitude' => 37.424354, 'longitude' => -122.09508869999999), array('kind' => 'walletobjects#latLongPoint', 'latitude' => 37.7901435, 'longitude' => -122.39026709999997), array('kind' => 'walletobjects#latLongPoint', 'latitude' => 40.7406578, 'longitude' => -74.00208940000002));
     // Source uri of title image.
     $uriTitleImageInstance = new Google_Service_Walletobjects_Uri();
     $imageTitleImageInstance = new Google_Service_Walletobjects_Image();
     $uriTitleImageInstance->setUri('http://farm4.staticflickr.com/3723/11177041115_6e6a3b6f49_o.jpg');
     $imageTitleImageInstance->setSourceUri($uriTitleImageInstance);
     // Define text module data.
     $textModulesData = array(array('header' => 'Details', 'body' => '20% off one cup of coffee at all Baconrista Coffee locations. ' . 'Only one can be used per visit.'), array('header' => 'About Baconrista', 'body' => 'Since 2013, Baconrista Coffee has been committed to making high ' . 'quality bacon coffee. Visit us in our stores or online at www.baconrista.com'));
     // Define links module data.
     $linksModuleData = new Google_Service_Walletobjects_LinksModuleData();
     $uris = array(array('uri' => 'http://maps.google.com/?q=google', 'kind' => 'walletobjecs#uri', 'description' => 'Nearby Locations'), array('uri' => 'tel:6505555555', 'kind' => 'walletobjecs#uri', 'description' => 'Call Customer Service'));
     $linksModuleData->setUris($uris);
     $uriModuleImageInstance = new Google_Service_Walletobjects_Uri();
     $uriModuleImageInstance->setUri('http://farm8.staticflickr.com/7401/11177116434_d8e600bba6_o.jpg');
     $uriModuleImageInstance->setDescription('Coffee beans');
     $imageModuleImageInstance = new Google_Service_Walletobjects_Image();
     $imageModuleImageInstance->setSourceUri($uriModuleImageInstance);
     $imagesModuleData = new Google_Service_Walletobjects_ImageModuleData();
     $imagesModuleData->setMainImage($imageModuleImageInstance);
     $imagesModuleDataArr = array($imagesModuleData);
     // Create wallet class.
     $wobClass = new Google_Service_Walletobjects_OfferClass();
     $wobClass->setId($issuerId . '.' . $classId);
     $wobClass->setIssuerName('Baconrista Coffee');
     $wobClass->setTitle('20% off on one bacon fat latte');
     $wobClass->setProvider('Baconrista Deals');
     $wobClass->setTitleImage($imageTitleImageInstance);
     $wobClass->setRenderSpecs($renderSpecs);
     $wobClass->setLinksModuleData($linksModuleData);
     $wobClass->setTextModulesData($textModulesData);
     $wobClass->setImageModulesData($imagesModuleDataArr);
     $wobClass->setRedemptionChannel('both');
     $wobClass->setReviewStatus('underReview');
     $wobClass->setLocations($locations);
     $wobClass->setAllowMultipleUsersPerObject(true);
     return $wobClass;
 }
 /**
  * Generates a GiftCard Object
  *
  * @param String $issuerId Wallet Object merchant account id.
  * @param String $classId Wallet Class that this wallet object references.
  * @param String $objectId Unique identifier for a wallet object.
  * @return Object $wobObject Loyaltyobject resource.
  */
 public static function generateGiftCardObject($issuerId, $classId, $objectId)
 {
     // Define barcode type and value.
     $barcode = new Google_Service_Walletobjects_Barcode();
     $barcode->setAlternateText('12345');
     $barcode->setLabel('User Id');
     $barcode->setType('qrCode');
     $barcode->setValue('28343E3');
     // Define text module data.
     $textModulesData = array(array('header' => 'Earn double points', 'body' => 'Jane, don\'t forget to use your Baconrista Rewards when ' . 'paying with this gift card to earn additional points'));
     // Define links module data.
     $linksModuleData = new Google_Service_Walletobjects_LinksModuleData();
     $uris = array(array('uri' => 'http://www.baconrista.com/mybalance?id=1234567890', 'kind' => 'walletobjecs#uri', 'description' => 'My Baconrista Gift Card Purchases'));
     $linksModuleData->setUris($uris);
     $balance = new Google_Service_Walletobjects_Money();
     $balance->setKind('walletobjects#money');
     $balance->setMicros(20000000);
     $balance->setCurrencyCode('USD');
     $balanceUpdateTime = new Google_Service_Walletobjects_DateTime();
     date_default_timezone_set('UTC');
     $balanceUpdateTime->setDate(date("Y-m-d\\TH:i:s.u\\Z"));
     // Create wallet object.
     $wobObject = new Google_Service_Walletobjects_GiftCardObject();
     $wobObject->setClassId($issuerId . "." . $classId);
     $wobObject->setId($issuerId . "." . $objectId);
     $wobObject->setState('active');
     $wobObject->setVersion(1);
     $wobObject->setBarcode($barcode);
     $wobObject->setLinksModuleData($linksModuleData);
     $wobObject->setTextModulesData($textModulesData);
     $wobObject->setBalance($balance);
     $wobObject->setBalanceUpdateTime($balanceUpdateTime);
     $wobObject->setCardNumber('123jkl4889');
     $wobObject->setEventNumber('123456');
     $wobObject->setPin('1111');
     return $wobObject;
 }
 /**
  * Generates a Loyalty Object
  *
  * @param String $issuerId Wallet Object merchant account id.
  * @param String $classId Wallet Class that this wallet object references.
  * @param String $objectId Unique identifier for a wallet object.
  * @return Object $wobObject Loyaltyobject resource.
  */
 public static function generateLoyaltyObject($issuerId, $classId, $objectId)
 {
     // Define barcode type and value.
     $barcode = new Google_Service_Walletobjects_Barcode();
     $barcode->setAlternateText('12345');
     $barcode->setLabel('User Id');
     $barcode->setType('qrCode');
     $barcode->setValue('28343E3');
     // Define text module data.
     $textModulesData = array(array('header' => 'Janes Baconrista Rewards', 'body' => 'Save more at your local Mountain View store Jane. ' . 'You get 1 bacon fat latte for every 5 coffees purchased. ' . 'Also just for you, 10% off all pastries in the Mountain View store.'));
     // Define links module data.
     $linksModuleData = new Google_Service_Walletobjects_LinksModuleData();
     $uris = array(array('uri' => 'http://www.baconrista.com/myaccount?id=1234567890', 'kind' => 'walletobjecs#uri', 'description' => 'My Baconrista Account'));
     $linksModuleData->setUris($uris);
     // Define label values.
     $labelValueRows = array(array('hexFontColor' => '#F8EDC1', 'hexBackgroundColor' => '#922635', 'columns' => array(array('label' => 'Next Reward in', 'value' => '2 coffees'), array('label' => 'Member Since', 'value' => '01/15/2013'))), array('hexFontColor' => '#F8EDC1', 'hexBackgroundColor' => '#922635', 'columns' => array(array('label' => 'Local Store', 'value' => 'Mountain View'))));
     // Define info module data.
     $infoModuleData = new Google_Service_Walletobjects_InfoModuleData();
     $infoModuleData->setHexBackgroundColor('#442905');
     $infoModuleData->setHexFontColor('#F8EDC1');
     $infoModuleData->setShowLastUpdateTime(true);
     $infoModuleData->setLabelValueRows($labelValueRows);
     // Messages to be displayed.
     $messages = array(array('actionUri' => array('kind' => 'walletobjects#uri', 'uri' => 'http://baconrista.com'), 'header' => 'Jane, welcome to Banconrista Rewards!', 'body' => 'Thanks for joining our program. Show this message to ' . 'our barista for your first free coffee on us!', 'image' => array('kind' => 'walletobjects#image', 'sourceUri' => array('kind' => 'walletobjects#uri', 'uri' => 'http://farm4.staticflickr.com/3723/' . '11177041115_6e6a3b6f49_o.jpg')), 'kind' => 'walletobjects#walletObjectMessage'));
     // Reward points a user has.
     $points = new Google_Service_Walletobjects_LoyaltyPoints();
     $balance = new Google_Service_Walletobjects_LoyaltyPointsBalance();
     $balance->setString('500');
     $points->setBalance($balance);
     $points->setLabel('Points');
     $points->setPointsType('points');
     // Create wallet object.
     $wobObject = new Google_Service_Walletobjects_LoyaltyObject();
     $wobObject->setClassId($issuerId . "." . $classId);
     $wobObject->setId($issuerId . "." . $objectId);
     $wobObject->setState('active');
     $wobObject->setVersion(1);
     $wobObject->setBarcode($barcode);
     $wobObject->setInfoModuleData($infoModuleData);
     $wobObject->setLinksModuleData($linksModuleData);
     $wobObject->setTextModulesData($textModulesData);
     $wobObject->setAccountName('Jane Doe');
     $wobObject->setAccountId('1234567890');
     $wobObject->setLoyaltyPoints($points);
     $wobObject->setMessages($messages);
     return $wobObject;
 }