Class: Io::Flow::V0::Models::CardPaymentSource

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

Overview

Represents a saved credit card payment method.

Instance Attribute Summary collapse

Attributes inherited from PaymentSource

#discriminator

Instance Method Summary collapse

Methods inherited from PaymentSource

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ CardPaymentSource

Returns a new instance of CardPaymentSource.



22287
22288
22289
22290
22291
22292
22293
22294
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22287

def initialize(incoming={})
  super(:discriminator => PaymentSource::Types::CARD_PAYMENT_SOURCE)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :summary], 'CardPaymentSource')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @actions = (x = opts.delete(:actions); x.nil? ? nil : HttpClient::Preconditions.assert_class('actions', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::PaymentSourceConfirmationAction) ? x : ::Io::Flow::V0::Models::PaymentSourceConfirmationAction.new(x)) })
  @summary = (x = opts.delete(:summary); x.is_a?(::Io::Flow::V0::Models::CardPaymentSourceSummary) ? x : ::Io::Flow::V0::Models::CardPaymentSourceSummary.new(x))
end

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



22285
22286
22287
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22285

def actions
  @actions
end

#idObject (readonly)

Returns the value of attribute id.



22285
22286
22287
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22285

def id
  @id
end

#summaryObject (readonly)

Returns the value of attribute summary.



22285
22286
22287
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22285

def summary
  @summary
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



22300
22301
22302
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22300

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

#subtype_to_hashObject



22304
22305
22306
22307
22308
22309
22310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22304

def subtype_to_hash
  {
    :id => id,
    :actions => actions.nil? ? nil : actions.map { |o| o.to_hash },
    :summary => summary.to_hash
  }
end

#to_jsonObject



22296
22297
22298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22296

def to_json
  JSON.dump(to_hash)
end