If you're reading this then you've probably come to the realisation that setting up Google Wallet Offers is not a simple task, especially when compared to setting up Apple's Passbook Coupons.
I'm on the last leg of this project now and one of the final tasks is to roll expiry dates into the Google Offers I've created.
There's a handy snippet of code found at https://developers.google.com/wallet/objects/offers/tutorial which suggests it should be no big deal...
$validTimeInterval = new Google_TimeInterval(); $startDateTime = new Google_DateTime(); $startDateTime->setDate('2013-06-12T23:20:50.52Z'); $validTimeInterval->setStart($startDateTime); $endDateTime = new Google_DateTime(); $endDateTime->setDate('2013-12-12T23:20:50.52Z'); $validTimeInterval->setEnd($endDateTime);
and then during the Offer creation:
$offerObject->setValidTimeInterval($validTimeInterval);
Unfortunately there's a little wrinkle there - the Google_TimeInterval and Google_DateTime classes were not included in any of the API libraries I couldn't find, and I couldn't find anything useful about where to get them.
Solution:
What you should be looking for is Google_Service_Walletobjects_TimeInterval and Google_Service_Walletobjects_DateTime so your code will be like this:
$validTimeInterval = new Google_Service_Walletobjects_TimeInterval(); $startDateTime = new Google_Service_Walletobjects_DateTime(); $startDateTime->setDate('2013-06-12T23:20:50.52Z'); $validTimeInterval->setStart($startDateTime); $endDateTime = new Google_Service_Walletobjects_DateTime(); $endDateTime->setDate('2013-12-12T23:20:50.52Z'); $validTimeInterval->setEnd($endDateTime);