Skip to content

Commit

Permalink
Merge pull request #56 from voucherifyio/feature/customerGetList
Browse files Browse the repository at this point in the history
FEATURE - Customers getList method
  • Loading branch information
mandraszyk authored Feb 11, 2018
2 parents 1cf99f3 + ebf6125 commit 181c067
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ Methods are provided within `$client->customers->*` namespace.
- [Get Customer](#get-customer)
- [Update Customer](#update-customer)
- [Delete Customer](#delete-customer)
- [List Customers](#list-customers)

Check [customer object](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-customer-object).

Expand All @@ -330,6 +331,11 @@ $client->customers->update($customer_update);
```php
$client->customers->delete($customer_id);
```
#### [List Customers]
```php
$client->customers->getList();
$client->customers->getList($params);
```

---

Expand Down Expand Up @@ -654,6 +660,7 @@ class Voucher extends CI_Controller {
Bug reports and pull requests are welcome through [GitHub Issues](https://github.com/rspective/voucherify-php-sdk/issues).

### Changelog
- **2018-02-11** - `1.7.4` - Customers getList method
- **2018-01-14** - `1.7.3` - Promotions API
- **2017-07-24** - `1.7.2` - Fix get publications missing params
- **2017-07-23** - `1.7.1` - Api Client conneciton options
Expand Down Expand Up @@ -727,6 +734,7 @@ Bug reports and pull requests are welcome through [GitHub Issues](https://github
[Get Customer]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#read-customer
[Update Customer]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-customer
[Delete Customer]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-customer
[List Customers]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-customers

[Create Order]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-order
[Get Order]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-order
Expand Down
17 changes: 17 additions & 0 deletions src/Customers.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,23 @@ public function get($customerId)
return $this->client->get("/customers/" . rawurlencode($customerId), null);
}

/**
* @param array|stdClass $filter
*
* Get a filtered list of vouchers. The filter can include following properties:
* - limit - number (default 100)
* - page - number (default 1)
* - email - string
* - city - string
* - name - string
*
* @throws \Voucherify\ClientException
*/
public function getList($filter = null)
{
return $this->client->get("/customers/", $filter);
}

/**
* @param array|stdClass $customer Object with customer fields for update
*
Expand Down
14 changes: 14 additions & 0 deletions test/CustomersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ public function testGet()
CurlMock::done();
}

public function testGetList()
{
CurlMock::register("https://api.voucherify.io/v1", self::$headers)
->get("/customers/")
->query([ "limit" => 3 ])
->reply(200, [ "status" => "ok" ]);

$result = self::$client->customers->getList([ "limit" => 3 ]);

$this->assertEquals($result, (object)[ "status" => "ok" ]);

CurlMock::done();
}

public function testUpdateByObject()
{
CurlMock::register("https://api.voucherify.io/v1", self::$headers)
Expand Down

0 comments on commit 181c067

Please sign in to comment.