Skip to content

Commit

Permalink
Merge pull request #57 from voucherifyio/feature/getAvailablePromotio…
Browse files Browse the repository at this point in the history
…nTiers

FEATURE - Get available promotion tiers method
  • Loading branch information
mandraszyk authored Feb 13, 2018
2 parents 181c067 + 32e25cd commit 6f981eb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ Methods are provided within `$client->promotions->*` namespace.
- [Redeem Promotion's Tier](#redeem-promotions-tier)
- [Update Promotion's Tier](#update-promotions-tier)
- [Delete Promotion's Tier](#delete-promotions-tier)
- [List Available Promotion Tiers](#list-available-promotion-tiers)

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

Expand Down Expand Up @@ -532,6 +533,11 @@ $client->promotions->tiers->update($promotionTierId);
$client->promotions->tiers->delete($promotionTierId);
```

#### [List Available Promotion Tiers]
```php
$client->promotions->tiers->getAvailable();
```

---

### Migration from 0.x
Expand Down Expand Up @@ -660,6 +666,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-12** - `1.7.5` - Promotions Tiers getAvailable method
- **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
Expand Down Expand Up @@ -769,3 +776,4 @@ Bug reports and pull requests are welcome through [GitHub Issues](https://github
[Redeem Promotion's Tier]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#redeem-promotion
[Update Promotion's Tier]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-promotion
[Delete Promotion's Tier]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-promotion
[List Available Promotion Tiers]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#introduction-1
13 changes: 13 additions & 0 deletions src/PromotionTiers.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ public function getList($promotionId)
return $this->client->get("/promotions/" . rawurlencode($promotionId) . "/tiers", null);
}

/**
* List available promotion tiers.
*
* @throws \Voucherify\ClientException
*/
public function getAvailable()
{
$params = [ "is_available" => true ];
return $this->client->get("/promotions/tiers", $params);
}



/**
* @param string $promotionTierId
* @param array|stdClass $params
Expand Down
18 changes: 15 additions & 3 deletions test/PromotionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ public function testTiersCreate()
public function testTiersGetList()
{
CurlMock::register("https://api.voucherify.io/v1", self::$headers)
->get("/promotions/test_promotion/tiers", [
"name" => "test promotion tier name"
])
->get("/promotions/test_promotion/tiers")
->reply(200, [ "status" => "ok" ]);

$result = self::$client->promotions->tiers->getList("test_promotion");
Expand All @@ -111,6 +109,20 @@ public function testTiersGetList()
CurlMock::done();
}

public function testTiersGetAvailable()
{
CurlMock::register("https://api.voucherify.io/v1", self::$headers)
->get("/promotions/tiers")
->query([ "is_available" => true ])
->reply(200, [ "status" => "ok" ]);

$result = self::$client->promotions->tiers->getAvailable();

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

CurlMock::done();
}

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

0 comments on commit 6f981eb

Please sign in to comment.