diff --git a/README.md b/README.md index 683f148..bca04da 100644 --- a/README.md +++ b/README.md @@ -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). @@ -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 @@ -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 @@ -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 diff --git a/src/PromotionTiers.php b/src/PromotionTiers.php index 4b3bcea..f662fcd 100644 --- a/src/PromotionTiers.php +++ b/src/PromotionTiers.php @@ -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 diff --git a/test/PromotionsTest.php b/test/PromotionsTest.php index f003339..ad332d3 100644 --- a/test/PromotionsTest.php +++ b/test/PromotionsTest.php @@ -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"); @@ -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)