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

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

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Card

Returns a new instance of Card.



10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10245

def initialize(incoming={})
  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)
  @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::Address) ? x : ::Io::Flow::V0::Models::Address.new(x)))
end

Instance Attribute Details

#address ⇒ Object (readonly)

Returns the value of attribute address.



10243
10244
10245
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10243

def address
  @address
end

#expiration ⇒ Object (readonly)

Returns the value of attribute expiration.



10243
10244
10245
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10243

def expiration
  @expiration
end

#id ⇒ Object (readonly)

Returns the value of attribute id.



10243
10244
10245
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10243

def id
  @id
end

#iin ⇒ Object (readonly)

Returns the value of attribute iin.



10243
10244
10245
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10243

def iin
  @iin
end

#last4 ⇒ Object (readonly)

Returns the value of attribute last4.



10243
10244
10245
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10243

def last4
  @last4
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



10243
10244
10245
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10243

def name
  @name
end

#token ⇒ Object (readonly)

Returns the value of attribute token.



10243
10244
10245
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10243

def token
  @token
end

#type ⇒ Object (readonly)

Returns the value of attribute type.



10243
10244
10245
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10243

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



10262
10263
10264
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10262

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

#to_hash ⇒ Object



10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10266

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

#to_json ⇒ Object



10258
10259
10260
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10258

def to_json
  JSON.dump(to_hash)
end