Class: VaucharAPI::CustomerDeal

Inherits:
Base
  • Object
show all
Defined in:
lib/vauchar_api/resources/customer_deal.rb

Overview

Examples

Read
deals = VaucharAPI::CustomerDeal.find(:all, params: {customer_id: "cust-15507323535c6e4c416c697"})

Redemptions
deals[1].redemptions
deals[1].voucher.voucher_code # => "DA2C2J65JFVNY"

Validate
deals[1].validate

Instance Method Summary collapse

Methods inherited from Base

#accepts_attributes, #encode, init_prefix, init_prefix_explicit, password, user

Instance Method Details

#customer_idObject



18
19
20
# File 'lib/vauchar_api/resources/customer_deal.rb', line 18

def customer_id
  @prefix_options[:customer_id]
end

#idObject



22
23
24
# File 'lib/vauchar_api/resources/customer_deal.rb', line 22

def id
  self.data.id
end

#redemptionsObject



26
27
28
29
30
31
32
# File 'lib/vauchar_api/resources/customer_deal.rb', line 26

def redemptions
  keep_prefix_options do
    resource = post(:redemptions, {}, only_id)
    data = self.class.format.decode(resource.body)
    load({voucher: data}, false, true)
  end
end

#validateObject



34
35
36
37
38
39
# File 'lib/vauchar_api/resources/customer_deal.rb', line 34

def validate
  keep_prefix_options do
    resource = get(:validate, {})
    load({data: resource}, false, true)
  end
end