Class: Voucherify::Service::PromotionTiers

Inherits:
Object
  • Object
show all
Defined in:
lib/voucherify/service/promotions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#clientObject (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/#{URI.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/#{URI.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/#{URI.encode(promotion_id)}/tiers")
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/#{URI.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/#{URI.encode(promotions_tier['id'] || promotions_tier[:id])}", promotions_tier.to_json)
end