Class: Io::Flow::V0::Models::PaymentMethod
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::PaymentMethod
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Represents a single payment method - e.g VISA or Paypal - and any associated metadata required for processing
Instance Attribute Summary collapse
-
#capabilities ⇒ Object
readonly
Returns the value of attribute capabilities.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#images ⇒ Object
readonly
Returns the value of attribute images.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#regions ⇒ Object
readonly
Returns the value of attribute regions.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ PaymentMethod
constructor
A new instance of PaymentMethod.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ PaymentMethod
Returns a new instance of PaymentMethod.
42553 42554 42555 42556 42557 42558 42559 42560 42561 42562 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42553 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :type, :name, :images, :regions], 'PaymentMethod') @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String) @type = (x = opts.delete(:type); x.is_a?(::Io::Flow::V0::Models::PaymentMethodType) ? x : ::Io::Flow::V0::Models::PaymentMethodType.apply(x)) @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String) @images = (x = opts.delete(:images); x.is_a?(::Io::Flow::V0::Models::PaymentMethodImages) ? x : ::Io::Flow::V0::Models::PaymentMethodImages.new(x)) @regions = HttpClient::Preconditions.assert_class('regions', opts.delete(:regions), Array).map { |v| HttpClient::Preconditions.assert_class('regions', v, String) } @capabilities = (x = opts.delete(:capabilities); x.nil? ? nil : HttpClient::Preconditions.assert_class('capabilities', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::PaymentMethodCapability) ? x : ::Io::Flow::V0::Models::PaymentMethodCapability.apply(x)) }) end |
Instance Attribute Details
#capabilities ⇒ Object (readonly)
Returns the value of attribute capabilities.
42551 42552 42553 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42551 def capabilities @capabilities end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
42551 42552 42553 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42551 def id @id end |
#images ⇒ Object (readonly)
Returns the value of attribute images.
42551 42552 42553 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42551 def images @images end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
42551 42552 42553 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42551 def name @name end |
#regions ⇒ Object (readonly)
Returns the value of attribute regions.
42551 42552 42553 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42551 def regions @regions end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
42551 42552 42553 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42551 def type @type end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
42568 42569 42570 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42568 def copy(incoming={}) PaymentMethod.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
42572 42573 42574 42575 42576 42577 42578 42579 42580 42581 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42572 def to_hash { :id => id, :type => type.value, :name => name, :images => images.to_hash, :regions => regions, :capabilities => capabilities.nil? ? nil : capabilities.map { |o| o.value } } end |
#to_json ⇒ Object
42564 42565 42566 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42564 def to_json JSON.dump(to_hash) end |