Class: Voucherify::Service::PromotionTiers
- Inherits:
-
Object
- Object
- Voucherify::Service::PromotionTiers
- Defined in:
- lib/voucherify/service/promotions.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #create(promotion_id, promotion_tier) ⇒ Object
- #delete(promotions_tier_id) ⇒ Object
-
#initialize(client) ⇒ PromotionTiers
constructor
A new instance of PromotionTiers.
- #list(promotion_id) ⇒ Object
- #list_tiers(query = {}) ⇒ Object
- #redeem(promotions_tier_id, redemption_context) ⇒ Object
- #update(promotions_tier) ⇒ Object
Constructor Details
#initialize(client) ⇒ PromotionTiers
Returns a new instance of PromotionTiers.
28 29 30 |
# File 'lib/voucherify/service/promotions.rb', line 28 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
26 27 28 |
# File 'lib/voucherify/service/promotions.rb', line 26 def client @client end |
Instance Method Details
#create(promotion_id, promotion_tier) ⇒ Object
36 37 38 |
# File 'lib/voucherify/service/promotions.rb', line 36 def create(promotion_id, promotion_tier) @client.post("/promotions/#{ERB::Util.url_encode(promotion_id)}/tiers", promotion_tier.to_json) end |
#delete(promotions_tier_id) ⇒ Object
48 49 50 51 |
# File 'lib/voucherify/service/promotions.rb', line 48 def delete(promotions_tier_id) @client.delete("/promotions/tiers/#{ERB::Util.url_encode(promotions_tier_id)}") nil end |
#list(promotion_id) ⇒ Object
32 33 34 |
# File 'lib/voucherify/service/promotions.rb', line 32 def list(promotion_id) @client.get("/promotions/#{ERB::Util.url_encode(promotion_id)}/tiers") end |
#list_tiers(query = {}) ⇒ Object
53 54 55 |
# File 'lib/voucherify/service/promotions.rb', line 53 def list_tiers(query = {}) @client.get("/promotions/tiers", query) end |
#redeem(promotions_tier_id, redemption_context) ⇒ Object
40 41 42 |
# File 'lib/voucherify/service/promotions.rb', line 40 def redeem(promotions_tier_id, redemption_context) @client.post("/promotions/tiers/#{ERB::Util.url_encode(promotions_tier_id)}/redemption", redemption_context.to_json) end |
#update(promotions_tier) ⇒ Object
44 45 46 |
# File 'lib/voucherify/service/promotions.rb', line 44 def update(promotions_tier) @client.put("/promotions/tiers/#{ERB::Util.url_encode(promotions_tier['id'] || promotions_tier[:id])}", promotions_tier.to_json) end |