Class: Io::Flow::V0::Models::VirtualCard

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

Overview

Virtual card details

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ VirtualCard

Returns a new instance of VirtualCard.



34171
34172
34173
34174
34175
34176
34177
34178
34179
34180
34181
34182
34183
34184
34185
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34171

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :key, :limit, :type, :expiration, :iin, :last4, :name], 'VirtualCard')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
  @number = (x = opts.delete(:number); x.nil? ? nil : HttpClient::Preconditions.assert_class('number', x, String))
  @cvv = (x = opts.delete(:cvv); x.nil? ? nil : HttpClient::Preconditions.assert_class('cvv', x, String))
  @limit = (x = opts.delete(:limit); x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x))
  @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)
  @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h })
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



34169
34170
34171
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34169

def attributes
  @attributes
end

#cvvObject (readonly)

Returns the value of attribute cvv.



34169
34170
34171
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34169

def cvv
  @cvv
end

#expirationObject (readonly)

Returns the value of attribute expiration.



34169
34170
34171
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34169

def expiration
  @expiration
end

#idObject (readonly)

Returns the value of attribute id.



34169
34170
34171
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34169

def id
  @id
end

#iinObject (readonly)

Returns the value of attribute iin.



34169
34170
34171
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34169

def iin
  @iin
end

#keyObject (readonly)

Returns the value of attribute key.



34169
34170
34171
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34169

def key
  @key
end

#last4Object (readonly)

Returns the value of attribute last4.



34169
34170
34171
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34169

def last4
  @last4
end

#limitObject (readonly)

Returns the value of attribute limit.



34169
34170
34171
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34169

def limit
  @limit
end

#nameObject (readonly)

Returns the value of attribute name.



34169
34170
34171
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34169

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



34169
34170
34171
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34169

def number
  @number
end

#typeObject (readonly)

Returns the value of attribute type.



34169
34170
34171
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34169

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



34191
34192
34193
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34191

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

#to_hashObject



34195
34196
34197
34198
34199
34200
34201
34202
34203
34204
34205
34206
34207
34208
34209
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34195

def to_hash
  {
    :id => id,
    :key => key,
    :number => number,
    :cvv => cvv,
    :limit => limit.to_hash,
    :type => type.value,
    :expiration => expiration.to_hash,
    :iin => iin,
    :last4 => last4,
    :name => name,
    :attributes => attributes.nil? ? nil : attributes
  }
end

#to_jsonObject



34187
34188
34189
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34187

def to_json
  JSON.dump(to_hash)
end