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

Inherits:
Object
  • Object
show all
Defined in:
lib/io_flow_reference_v0.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.



480
481
482
483
484
485
486
487
488
# File 'lib/io_flow_reference_v0.rb', line 480

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::Reference::V0::Models::PaymentMethodType) ? x : ::Io::Flow::Reference::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::Reference::V0::Models::PaymentMethodImages) ? x : ::Io::Flow::Reference::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.



478
479
480
# File 'lib/io_flow_reference_v0.rb', line 478

def id
  @id
end

#imagesObject (readonly)

Returns the value of attribute images.



478
479
480
# File 'lib/io_flow_reference_v0.rb', line 478

def images
  @images
end

#nameObject (readonly)

Returns the value of attribute name.



478
479
480
# File 'lib/io_flow_reference_v0.rb', line 478

def name
  @name
end

#regionsObject (readonly)

Returns the value of attribute regions.



478
479
480
# File 'lib/io_flow_reference_v0.rb', line 478

def regions
  @regions
end

#typeObject (readonly)

Returns the value of attribute type.



478
479
480
# File 'lib/io_flow_reference_v0.rb', line 478

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



494
495
496
# File 'lib/io_flow_reference_v0.rb', line 494

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

#to_hashObject



498
499
500
501
502
503
504
505
506
# File 'lib/io_flow_reference_v0.rb', line 498

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

#to_jsonObject



490
491
492
# File 'lib/io_flow_reference_v0.rb', line 490

def to_json
  JSON.dump(to_hash)
end