Class: Io::Flow::V0::Models::Card

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

Overview

Card represents the metadata about a secure, tokenized card. The card ‘token’ is a unique, cryptographically secure token by which this card can be identified in the future. The card token itself will either be a permanent card token (denoted by a prefix of F96) or a one time nonce (denoted by a prefix of F17). Nonces represent cards that were encrypted from public channels (like the user’s browser via JavaScript) and can be used once only. If you have a nonce you can exchange it for a permanent card token via the operation POST /:organization/cards/nonces

Instance Attribute Summary collapse

Attributes inherited from ExpandableCard

#discriminator

Instance Method Summary collapse

Methods inherited from ExpandableCard

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ Card

Returns a new instance of Card.



33060
33061
33062
33063
33064
33065
33066
33067
33068
33069
33070
33071
33072
33073
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33060

def initialize(incoming={})
  super(:discriminator => ExpandableCard::Types::CARD)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :token, :type, :expiration, :iin, :last4, :name], 'Card')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @token = HttpClient::Preconditions.assert_class('token', opts.delete(:token), String)
  @type = (x = opts.delete(:type); x.is_a?(::Io::Flow::V0::Models::CardType) ? x : ::Io::Flow::V0::Models::CardType.apply(x))
  @expiration = (x = opts.delete(:expiration); x.is_a?(::Io::Flow::V0::Models::Expiration) ? x : ::Io::Flow::V0::Models::Expiration.new(x))
  @iin = HttpClient::Preconditions.assert_class('iin', opts.delete(:iin), String)
  @issuer = (x = opts.delete(:issuer); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::IssuerSummary) ? x : ::Io::Flow::V0::Models::IssuerSummary.new(x)))
  @last4 = HttpClient::Preconditions.assert_class('last4', opts.delete(:last4), String)
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
  @address = (x = opts.delete(:address); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::BillingAddress) ? x : ::Io::Flow::V0::Models::BillingAddress.new(x)))
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



33058
33059
33060
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33058

def address
  @address
end

#expirationObject (readonly)

Returns the value of attribute expiration.



33058
33059
33060
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33058

def expiration
  @expiration
end

#idObject (readonly)

Returns the value of attribute id.



33058
33059
33060
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33058

def id
  @id
end

#iinObject (readonly)

Returns the value of attribute iin.



33058
33059
33060
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33058

def iin
  @iin
end

#issuerObject (readonly)

Returns the value of attribute issuer.



33058
33059
33060
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33058

def issuer
  @issuer
end

#last4Object (readonly)

Returns the value of attribute last4.



33058
33059
33060
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33058

def last4
  @last4
end

#nameObject (readonly)

Returns the value of attribute name.



33058
33059
33060
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33058

def name
  @name
end

#tokenObject (readonly)

Returns the value of attribute token.



33058
33059
33060
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33058

def token
  @token
end

#typeObject (readonly)

Returns the value of attribute type.



33058
33059
33060
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33058

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



33079
33080
33081
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33079

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

#subtype_to_hashObject



33083
33084
33085
33086
33087
33088
33089
33090
33091
33092
33093
33094
33095
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33083

def subtype_to_hash
  {
    :id => id,
    :token => token,
    :type => type.value,
    :expiration => expiration.to_hash,
    :iin => iin,
    :issuer => issuer.nil? ? nil : issuer.to_hash,
    :last4 => last4,
    :name => name,
    :address => address.nil? ? nil : address.to_hash
  }
end

#to_jsonObject



33075
33076
33077
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33075

def to_json
  JSON.dump(to_hash)
end