Class: Io::Flow::V0::Models::PaymentMethod

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ PaymentMethod

Returns a new instance of PaymentMethod.



44013
44014
44015
44016
44017
44018
44019
44020
44021
44022
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44013

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

#capabilitiesObject (readonly)

Returns the value of attribute capabilities.



44011
44012
44013
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44011

def capabilities
  @capabilities
end

#idObject (readonly)

Returns the value of attribute id.



44011
44012
44013
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44011

def id
  @id
end

#imagesObject (readonly)

Returns the value of attribute images.



44011
44012
44013
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44011

def images
  @images
end

#nameObject (readonly)

Returns the value of attribute name.



44011
44012
44013
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44011

def name
  @name
end

#regionsObject (readonly)

Returns the value of attribute regions.



44011
44012
44013
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44011

def regions
  @regions
end

#typeObject (readonly)

Returns the value of attribute type.



44011
44012
44013
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44011

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



44028
44029
44030
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44028

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

#to_hashObject



44032
44033
44034
44035
44036
44037
44038
44039
44040
44041
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44032

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_jsonObject



44024
44025
44026
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44024

def to_json
  JSON.dump(to_hash)
end