Created
November 3, 2023 00:32
-
-
Save muno92/678cde39ae74877ba3c888c1ec903797 to your computer and use it in GitHub Desktop.
Google Wallet Event Pass Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 何かのカンファレンス用のチケットを発行する想定 | |
// イベントパスクラスの作成 | |
$eventClass = new Google_Service_Walletobjects_EventTicketClass([ | |
'id' => '(カンファレンス && イベント種別 (本編、懇親会など) )ごとに一意な値', | |
'issuerName' => 'カンファレンス名', | |
// ACCEPTEDは指定できない。登録後にACCEPTEDに変更される。 | |
// https://developers.google.com/wallet/reference/rest/v1/ReviewStatus | |
'reviewStatus' => 'UNDER_REVIEW', | |
'eventName' => new Google_Service_Walletobjects_LocalizedString([ | |
'defaultValue' => new Google_Service_Walletobjects_TranslatedString([ | |
'language' => 'ja-JP', | |
'value' => '{カンファレンス名} {イベント種別}', | |
]), | |
]), | |
'heroImage' => new Google_Service_Walletobjects_Image([ | |
'sourceUri' => new Google_Service_Walletobjects_ImageUri([ | |
'uri' => 'カンファレンスバナーのURL' | |
]), | |
]), | |
'classTemplateInfo' => new Google_Service_Walletobjects_ClassTemplateInfo([ | |
// https://developers.google.com/wallet/tickets/events/resources/template?hl=ja#web_2 | |
'cardTemplateOverride' => new Google_Service_Walletobjects_CardTemplateOverride([ | |
'cardRowTemplateInfos' => [ | |
new Google_Service_Walletobjects_CardRowTemplateInfo([ | |
'twoItems' => new Google_Service_Walletobjects_CardRowTwoItems([ | |
'startItem' => new Google_Service_Walletobjects_TemplateItem([ | |
// // パスオブジェクトの1つ目のtextModulesDataを参照 | |
'firstValue' => new Google_Service_Walletobjects_FieldSelector([ | |
'fields' => [ | |
new Google_Service_Walletobjects_FieldReference([ | |
// https://codelabs.developers.google.com/add-to-wallet-web#3 | |
// のチュートリアルではnameとキー指定できそうだが、インデックス指定じゃないと取れなかった | |
'fieldPath' => 'object.textModulesData[0]', | |
]), | |
], | |
]), | |
]), | |
'endItem' => new Google_Service_Walletobjects_TemplateItem([ | |
// パスオブジェクトのticketNumberを参照 | |
'firstValue' => new Google_Service_Walletobjects_FieldSelector([ | |
'fields' => [ | |
new Google_Service_Walletobjects_FieldReference([ | |
'fieldPath' => 'object.ticketNumber', | |
]), | |
], | |
]), | |
]), | |
]), | |
]), | |
], | |
]), | |
]), | |
'hexBackgroundColor' => 'チケット上部の背景色', | |
'logo' => new Google_Service_Walletobjects_Image([ | |
'sourceUri' => new Google_Service_Walletobjects_ImageUri([ | |
'uri' => 'カンファレンスロゴのURL', | |
]), | |
]), | |
]); | |
// イベントパスオブジェクトの作成 | |
$eventObject = new Google_Service_Walletobjects_EventTicketObject([ | |
'id' => '各参加者のチケット毎に一意な値', | |
'classId' => 'eventClassのクラスID', | |
'state' => 'ACTIVE', | |
'barcode' => new Google_Service_Walletobjects_Barcode([ | |
'type' => 'QR_CODE', | |
'value' => '受付用QRに埋め込む文字列', | |
]), | |
'ticketNumber' => $attendee->ticket_no, | |
'textModulesData' => [ | |
new Google_Service_Walletobjects_TextModuleData([ | |
'header' => '参加者名', | |
'body' => '各参加者の名前', | |
'id' => 'name', | |
]), | |
], | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment