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.



19318
19319
19320
19321
19322
19323
19324
19325
19326
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19318

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) }
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



19316
19317
19318
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19316

def id
  @id
end

#imagesObject (readonly)

Returns the value of attribute images.



19316
19317
19318
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19316

def images
  @images
end

#nameObject (readonly)

Returns the value of attribute name.



19316
19317
19318
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19316

def name
  @name
end

#regionsObject (readonly)

Returns the value of attribute regions.



19316
19317
19318
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19316

def regions
  @regions
end

#typeObject (readonly)

Returns the value of attribute type.



19316
19317
19318
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19316

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



19332
19333
19334
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19332

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

#to_hashObject



19336
19337
19338
19339
19340
19341
19342
19343
19344
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19336

def to_hash
  {
    :id => id,
    :type => type.value,
    :name => name,
    :images => images.to_hash,
    :regions => regions
  }
end

#to_jsonObject



19328
19329
19330
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19328

def to_json
  JSON.dump(to_hash)
end