Class: Io::Flow::V0::Models::CustomerToken

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

Overview

Represents a mapping between a customer number and a token

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ CustomerToken

Returns a new instance of CustomerToken.



35511
35512
35513
35514
35515
35516
35517
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35511

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :customer, :token], 'CustomerToken')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @customer = (x = opts.delete(:customer); x.is_a?(::Io::Flow::V0::Models::CustomerReference) ? x : ::Io::Flow::V0::Models::CustomerReference.new(x))
  @token = HttpClient::Preconditions.assert_class('token', opts.delete(:token), String)
end

Instance Attribute Details

#customerObject (readonly)

Returns the value of attribute customer.



35509
35510
35511
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35509

def customer
  @customer
end

#idObject (readonly)

Returns the value of attribute id.



35509
35510
35511
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35509

def id
  @id
end

#tokenObject (readonly)

Returns the value of attribute token.



35509
35510
35511
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35509

def token
  @token
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



35523
35524
35525
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35523

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

#to_hashObject



35527
35528
35529
35530
35531
35532
35533
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35527

def to_hash
  {
    :id => id,
    :customer => customer.to_hash,
    :token => token
  }
end

#to_jsonObject



35519
35520
35521
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35519

def to_json
  JSON.dump(to_hash)
end