-
Notifications
You must be signed in to change notification settings - Fork 4
Creating, Listing and Editing Store Cards
pedro ivo edited this page Jul 11, 2016
·
5 revisions
<?php
require 'vendor/autoload.php';
use Passworks\Client;
// Instantiate the Passworks client
$api = new Passworks\Client('your api username', 'your api key');
// upload a asset (background image)
$api->createAsset('background', '/local-path-to-a-image/image.png');
// create a store card / loyalty campaign
$store_campaign_args = array(
'name' => "My Store card / Lotalty campaign",
'icon_id' => '51838f55-8d40-4554-be22-03ae685a0a32',
'background_color' => '#ffffff',
'text_color' => '#000000',
'label_color' => '#00000'
);
$store_campaign = $api->createStoreCardCampaign($store_campaign_args);
print_r($store_campaign);
// list all store card campaigns
print_r($api->getStoreCardCampaigns()->toArray());
// add a pass (store card) to the store card campaign
$store_card_args = array(
'back_fields' => array(
array(
'value' => 'Marques de Pombal, Portugal',
'key' => 'address',
'label' => 'Addess'
)
)
);
$store_card = $api->createStoreCard($store_campaign->id, $store_card_args);
print_r($store_card);
// get a specific store card pass
print_r($api->getStoreCard($store_campaign->id, $store_card->id));
// update the store card pass
$store_update_params = array(
'back_fields' => array(
array(
'value' => 'Av. da Liberdade, 230',
'key' => 'address',
'label' => 'Addess'
)
)
);
$extra = array('push' => false);
$updated_store_card = $api->updateStoreCard($store_campaign->id, $store_card->id, $store_update_params, $extra);
print_r($updated_store_card);
// There are two reports available, a daily and a totalisation report
// for more information, check the API documentation:
// https://github.com/passworks/passworks-api/blob/master/v2/sections/reports.md
//
// Daily usage:
// $report_params = array("start_date" => '2010-10-10', "end_date" => '2016-06-30');
// $daily_report = $api->getStoreCardDailyReport($campaign_id, $report_params);
// Totalisation
$total_report = $api->getStoreCardTotalReport($coupon_campaign->id);
$report_data = get_object_vars($total_report->report);
print_r($report_data);
// Array
// (
// [apple] => stdClass Object
// (
// [installs_count] => 0
// [uninstalls_count] => 0
// )
// [android] => stdClass Object
// (
// [installs_count] => 2
// [uninstalls_count] => 0
// )
// [installs_count] => 2
// [uninstalls_count] => 0
// [redeems_count] => 0
// [fetches_count] => 0
// [downloads_count] => 1
// [views_count] => 0
// [creates_count] => 3
// [expires_count] => 0
// [pushes_count] => 0
// [updates_count] => 0
// [webhooks_count] => 0
// [api_calls_count] => 0
// [distribution_updates_count] => 0
// [active_count] => 2
// [removed_count] => 0
// )
?>