From ee16c102126cf476c5b3128bb23e75f029124e85 Mon Sep 17 00:00:00 2001 From: David Albrecht Date: Thu, 14 Apr 2016 21:41:08 +0200 Subject: [PATCH] implements getPurchases API call --- resources/service.php | 5 +++++ tests/OpenBazaar/ClientTest.php | 7 +++++++ tests/fixtures/get_purchases | 24 ++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 tests/fixtures/get_purchases diff --git a/resources/service.php b/resources/service.php index e5ca68f..0ddfc93 100644 --- a/resources/service.php +++ b/resources/service.php @@ -120,6 +120,11 @@ 'uri' => 'api/v1/get_sales', 'responseModel' => 'GetResponse', ], + 'getPurchases' => [ + 'httpMethod' => 'GET', + 'uri' => 'api/v1/get_purchases', + 'responseModel' => 'GetResponse', + ], ], 'models' => [ 'GetResponse' => [ diff --git a/tests/OpenBazaar/ClientTest.php b/tests/OpenBazaar/ClientTest.php index b05c679..b49514d 100644 --- a/tests/OpenBazaar/ClientTest.php +++ b/tests/OpenBazaar/ClientTest.php @@ -91,6 +91,13 @@ public function testGetSales() $response = $client->getSales(); $this->assertSame($response[0]['order_id'], "549c844c08048166ed4ac9d44d9bf8916c7ce9cb"); } + public function testGetPurchases() + { + $history = new History(); + $client = $this->createClient('get_purchases', $history); + $response = $client->getPurchases(); + $this->assertSame($response[0]['order_id'], "8bd10ebab092d0fbf2cec1f2d0ad84dfa0f4f8df"); + } public function testLoginFail() { $history = new History(); diff --git a/tests/fixtures/get_purchases b/tests/fixtures/get_purchases new file mode 100644 index 0000000..bf84ed1 --- /dev/null +++ b/tests/fixtures/get_purchases @@ -0,0 +1,24 @@ +HTTP/1.1 200 OK +Reproxy-Status: yes +Access-Control-Allow-Origin: * +Cache-Control: public, must-revalidate +Content-Type: application/json +Server: lighttpd +Content-Length: 5103 +Date: Mon, 28 Jul 2014 18:40:39 GMT +X-Varnish: 1913846781 1913780733 +Age: 259 +Via: 1.1 varnish +Connection: close + +[{ + "status": 0, + "contract_type": "digital good", + "vendor": "@themes", + "description": "A beach theme", + "title": "Beach Theme", + "order_id": "8bd10ebab092d0fbf2cec1f2d0ad84dfa0f4f8df", + "timestamp": 1449283905.809595, + "btc_total": 0.005, + "thumbnail_hash": "4cde0fba7feb2f979975e2d4e772198c77807c0b" +}] \ No newline at end of file