diff --git a/Tests/Recurly/Coupon_Test.php b/Tests/Recurly/Coupon_Test.php index 0266a946..9a1d41b3 100644 --- a/Tests/Recurly/Coupon_Test.php +++ b/Tests/Recurly/Coupon_Test.php @@ -34,6 +34,16 @@ public function testRedeemCoupon() { $this->assertInstanceOf('Recurly_CouponRedemption', $redemption); } + public function testGetCouponRedemptions() { + $this->client->addResponse('GET', 'https://api.recurly.com/v2/coupons/special/redemptions', 'coupons/show-redemptions-200.xml'); + + $coupon = Recurly_Coupon::get('special', $this->client); + $redemptions = $coupon->redemptions->get(); + + $this->assertInstanceOf('Recurly_CouponRedemptionList', $redemptions); + $this->assertEquals(2, $redemptions->count()); + } + public function testRedeemCouponExpired() { $this->client->addResponse('GET', '/coupons/expired', 'coupons/show-200-expired.xml'); diff --git a/Tests/fixtures/coupons/show-redemptions-200.xml b/Tests/fixtures/coupons/show-redemptions-200.xml new file mode 100644 index 00000000..52dcc2ec --- /dev/null +++ b/Tests/fixtures/coupons/show-redemptions-200.xml @@ -0,0 +1,25 @@ +HTTP/1.1 200 OK +Content-Type: application/xml; charset=utf-8 +Location: https://api.recurly.com/v2/coupons/special/redemptions + + + + + + + false + 0 + USD + active + 2014-01-06T19:06:35Z + + + + + false + 1238 + USD + active + 2014-01-14T13:27:53Z + + diff --git a/lib/recurly.php b/lib/recurly.php index 7462db0c..040c344e 100644 --- a/lib/recurly.php +++ b/lib/recurly.php @@ -30,6 +30,7 @@ require_once(dirname(__FILE__) . '/recurly/plan.php'); require_once(dirname(__FILE__) . '/recurly/plan_list.php'); require_once(dirname(__FILE__) . '/recurly/redemption.php'); +require_once(dirname(__FILE__) . '/recurly/redemption_list.php'); require_once(dirname(__FILE__) . '/recurly/subscription.php'); require_once(dirname(__FILE__) . '/recurly/subscription_list.php'); require_once(dirname(__FILE__) . '/recurly/subscription_addon.php'); diff --git a/lib/recurly/base.php b/lib/recurly/base.php index 7c42ed24..7bc1d13a 100644 --- a/lib/recurly/base.php +++ b/lib/recurly/base.php @@ -169,6 +169,7 @@ private function addLink($name, $href, $method){ 'plan_codes' => 'array', 'pending_subscription' => 'Recurly_Subscription', 'redemption' => 'Recurly_CouponRedemption', + 'redemptions' => 'Recurly_CouponRedemptionList', 'setup_fee_in_cents' => 'Recurly_CurrencyList', 'subscription' => 'Recurly_Subscription', 'subscriptions' => 'Recurly_SubscriptionList', diff --git a/lib/recurly/client.php b/lib/recurly/client.php index cee5e6a8..85663751 100644 --- a/lib/recurly/client.php +++ b/lib/recurly/client.php @@ -49,6 +49,7 @@ class Recurly_Client const PATH_BILLING_INFO = '/billing_info'; const PATH_COUPON = '/coupon'; const PATH_COUPON_REDEMPTION = '/redemption'; + const PATH_COUPON_REDEMPTIONS = '/redemptions'; const PATH_COUPONS = '/coupons'; const PATH_INVOICES = '/invoices'; const PATH_NOTES = '/notes'; diff --git a/lib/recurly/redemption_list.php b/lib/recurly/redemption_list.php new file mode 100644 index 00000000..db7171ec --- /dev/null +++ b/lib/recurly/redemption_list.php @@ -0,0 +1,15 @@ +_loadFrom(Recurly_Client::PATH_COUPON_REDEMPTIONS, $params); + return $list; + } + + protected function getNodeName() { + return 'redemptions'; + } +}