-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsample_client.php
More file actions
51 lines (38 loc) · 2.56 KB
/
sample_client.php
File metadata and controls
51 lines (38 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
include('retention_science_api.php');
$api_user = "testing";
$api_pass = "testing";
$testmode = true;
$client = new RetentionScienceApi($api_user, $api_pass, $testmode);
// GET the last user record id
echo "Last user record id: ";
echo $client->get_last_user_record_id() . "\n";
// GET if user exists with this record_id
echo "Does this user 123 exist?";
echo $client->user_exists('123') . "\n";
// POST a new or existing user
$user_record_id = 12300;
$user_array = array('email' => 'johndoe@gmail.com', 'full_name' => "John Doe", 'address1' => "123 Main St", 'city' => "San Diego", 'state' => 'CA', 'zip' => 91311, 'country' => "US", 'phone' => '8882221111', 'birth_year' => '1920', 'gender' => 'm', 'ip_address' => "127.6.6.6", 'number_logons' => 2, 'account_created_on' => date("Y-m-d"), 'last_logon_at' => date("D M j G:i:s T Y"));
$client->update_user($user_record_id, $user_array);
// POST a new / existing category
$category_record_id1 = "sports";
$category_record_id2 = "exercise";
$category_array1 = array('name' => "Sporting Goods", 'description' => 'Sporting goods and accessories', 'parent_record_id' => null);
$client->update_category($category_record_id1, $category_array1);
$category_array2 = array('name' => "Exercise", 'description' => 'Exercise toys and equipment', 'parent_record_id' => $category_record_id1);
$client->update_category($category_record_id2, $category_array2);
// POST a new or existing item
$item_record_id = 20;
$item_name = "Pogo Stick";
$item_price = "29.99";
$item_array = array("name" => $item_name, "manufacturer" => "Nike", "model" => "PG101", "quantity" => 100, "price" => $item_price, "active" => true, "image_list" => array("http://myhost.com/pogo1.jpg", "http://myhost.com/pogo2.jpg"), "categories" => array($category_record_id1,$category_record_id2));
$client->update_item($item_record_id, $item_array);
// GET the last order record id
echo "Last order record id: ";
echo $client->get_last_order_record_id() . "\n";
// POST a new or existing order with order_item
$order_record_id = 5000;
$order_item_array = array('item_record_id' => $item_record_id, 'name' => $item_name, 'quantity' => 1, 'price' => $item_price, 'final_price' => $item_price, 'categories' => array($category_record_id1, $category_record_id2));
$order_array = array('user_record_id' => $user_record_id, 'total_price' => "19.99", 'discount_amount' => "", 'shipping_amount' => "10.00", 'tax_amount' => "0.00", 'ordered_at' => date("D M j G:i:s T Y"), 'payment_method' => 'Credit Card', 'order_items' => array($order_item_array));
$client->update_order($order_record_id, $order_array);
?>