Class: Io::Flow::V0::Models::RedirectAuthorizationForm

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

Overview

Executes a redirect-based payment based on the provided payment method.

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 = {}) ⇒ RedirectAuthorizationForm

Returns a new instance of RedirectAuthorizationForm.



58181
58182
58183
58184
58185
58186
58187
58188
58189
58190
58191
58192
58193
58194
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58181

def initialize(incoming={})
  super(:discriminator => AuthorizationForm::Types::REDIRECT_AUTHORIZATION_FORM)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:method, :order_number, :amount, :currency, :redirect_urls], 'RedirectAuthorizationForm')
  @method = HttpClient::Preconditions.assert_class('method', opts.delete(:method), String)
  @issuer = (x = opts.delete(:issuer); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::IssuerReference) ? x : ::Io::Flow::V0::Models::IssuerReference.new(x)))
  @order_number = HttpClient::Preconditions.assert_class('order_number', opts.delete(:order_number), 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)
  @redirect_urls = (x = opts.delete(:redirect_urls); x.is_a?(::Io::Flow::V0::Models::PostPaymentRedirectUrls) ? x : ::Io::Flow::V0::Models::PostPaymentRedirectUrls.new(x))
  @key = (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, 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 })
  @ip = (x = opts.delete(:ip); x.nil? ? nil : HttpClient::Preconditions.assert_class('ip', x, String))
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



58179
58180
58181
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58179

def amount
  @amount
end

#attributesObject (readonly)

Returns the value of attribute attributes.



58179
58180
58181
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58179

def attributes
  @attributes
end

#currencyObject (readonly)

Returns the value of attribute currency.



58179
58180
58181
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58179

def currency
  @currency
end

#ipObject (readonly)

Returns the value of attribute ip.



58179
58180
58181
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58179

def ip
  @ip
end

#issuerObject (readonly)

Returns the value of attribute issuer.



58179
58180
58181
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58179

def issuer
  @issuer
end

#keyObject (readonly)

Returns the value of attribute key.



58179
58180
58181
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58179

def key
  @key
end

#methodObject (readonly)

Returns the value of attribute method.



58179
58180
58181
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58179

def method
  @method
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



58179
58180
58181
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58179

def order_number
  @order_number
end

#redirect_urlsObject (readonly)

Returns the value of attribute redirect_urls.



58179
58180
58181
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58179

def redirect_urls
  @redirect_urls
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



58200
58201
58202
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58200

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

#subtype_to_hashObject



58204
58205
58206
58207
58208
58209
58210
58211
58212
58213
58214
58215
58216
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58204

def subtype_to_hash
  {
    :method => method,
    :issuer => issuer.nil? ? nil : issuer.to_hash,
    :order_number => order_number,
    :amount => amount.to_f.to_s,
    :currency => currency,
    :redirect_urls => redirect_urls.to_hash,
    :key => key,
    :attributes => attributes.nil? ? nil : attributes,
    :ip => ip
  }
end

#to_jsonObject



58196
58197
58198
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58196

def to_json
  JSON.dump(to_hash)
end