Skip to content

Commit

Permalink
add: get & search coupon in promotion api
Browse files Browse the repository at this point in the history
  • Loading branch information
nVuln committed Aug 5, 2024
1 parent d68a6a7 commit f647b8c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Resources/Promotion.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,17 @@ public function deactivateActivity($activity_id)
{
return $this->call('POST', 'activities/'.$activity_id.'/deactivate');
}

public function searchCoupons($query = [], $body = [])
{
return $this->call('POST', 'coupons/search', [
RequestOptions::QUERY => $query,
RequestOptions::JSON => $body,
]);
}

public function getCoupon($coupon_id)
{
return $this->call('GET', 'coupons/'.$coupon_id);
}
}
13 changes: 13 additions & 0 deletions tests/Resources/PromotionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,17 @@ public function testRemoveActivityProduct()
$this->caller->removeActivityProduct($activity_id);
$this->assertPreviousRequest('DELETE', 'promotion/'.TestResource::TEST_API_VERSION.'/activities/'.$activity_id.'/products');
}

public function testSearchCoupons()
{
$this->caller->searchCoupons();
$this->assertPreviousRequest('POST', 'promotion/'.TestResource::TEST_API_VERSION.'/coupons/search');
}

public function testGetCoupon()
{
$coupon_id = 1009;
$this->caller->getCoupon($coupon_id);
$this->assertPreviousRequest('GET', 'promotion/'.TestResource::TEST_API_VERSION.'/coupons/'.$coupon_id);
}
}

0 comments on commit f647b8c

Please sign in to comment.