Class: AGCOD::CreateGiftCard

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/aws_agcod/create_gift_card.rb

Constant Summary collapse

CURRENCIES =
%w(USD EUR JPY CNY CAD)

Instance Method Summary collapse

Constructor Details

#initialize(httpable, request_id, amount, currency = 'USD') ⇒ CreateGiftCard

Returns a new instance of CreateGiftCard.



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/aws_agcod/create_gift_card.rb', line 13

def initialize(httpable, request_id, amount, currency = 'USD')
  unless CURRENCIES.include?(currency.to_s)
    raise CreateGiftCardError, "Currency #{currency} not supported, available types are #{CURRENCIES.join(", ")}"
  end

  @response = Request.new(httpable, 'CreateGiftCard',
    'creationRequestId' => request_id,
    'value' => {
      'currencyCode' => currency,
      'amount' => amount
    }
  ).response
end

Instance Method Details

#claim_codeObject



27
28
29
# File 'lib/aws_agcod/create_gift_card.rb', line 27

def claim_code
  @response.payload['gcClaimCode']
end

#expiration_dateObject



31
32
33
# File 'lib/aws_agcod/create_gift_card.rb', line 31

def expiration_date
  @expiration_date ||= Time.parse @response.payload['gcExpirationDate']
end

#gc_idObject



35
36
37
# File 'lib/aws_agcod/create_gift_card.rb', line 35

def gc_id
  @response.payload['gcId']
end

#request_idObject



39
40
41
# File 'lib/aws_agcod/create_gift_card.rb', line 39

def request_id
  @response.payload['creationRequestId']
end