Class: Io::Flow::V0::Models::AuthorizationCopyForm

Inherits:
AuthorizationForm show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Creates a new authorization based on the underlying information in an existing authorization. A common use case here is to create a new auth when the existing one has expired.

Instance Attribute Summary collapse

Attributes inherited from AuthorizationForm

#discriminator

Instance Method Summary collapse

Methods inherited from AuthorizationForm

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ AuthorizationCopyForm

Returns a new instance of AuthorizationCopyForm.



23321
23322
23323
23324
23325
23326
23327
23328
23329
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23321

def initialize(incoming={})
  super(:discriminator => AuthorizationForm::Types::AUTHORIZATION_COPY_FORM)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:source_authorization_key, :amount, :currency], 'AuthorizationCopyForm')
  @source_authorization_key = HttpClient::Preconditions.assert_class('source_authorization_key', opts.delete(:source_authorization_key), String)
  @amount = HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(opts.delete(:amount)), BigDecimal)
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h })
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



23319
23320
23321
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23319

def amount
  @amount
end

#attributesObject (readonly)

Returns the value of attribute attributes.



23319
23320
23321
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23319

def attributes
  @attributes
end

#currencyObject (readonly)

Returns the value of attribute currency.



23319
23320
23321
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23319

def currency
  @currency
end

#source_authorization_keyObject (readonly)

Returns the value of attribute source_authorization_key.



23319
23320
23321
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23319

def source_authorization_key
  @source_authorization_key
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



23335
23336
23337
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23335

def copy(incoming={})
  AuthorizationCopyForm.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#subtype_to_hashObject



23339
23340
23341
23342
23343
23344
23345
23346
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23339

def subtype_to_hash
  {
    :source_authorization_key => source_authorization_key,
    :amount => amount.to_f.to_s,
    :currency => currency,
    :attributes => attributes.nil? ? nil : attributes
  }
end

#to_jsonObject



23331
23332
23333
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23331

def to_json
  JSON.dump(to_hash)
end