Class: Io::Flow::V0::Models::CheckoutToken

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

Overview

Represents a secure token that can be used to redirect to Checkout UI

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ CheckoutToken

Returns a new instance of CheckoutToken.



21361
21362
21363
21364
21365
21366
21367
21368
21369
21370
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21361

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :organization, :order, :session, :urls, :expires_at], 'CheckoutToken')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @organization = (x = opts.delete(:organization); x.is_a?(::Io::Flow::V0::Models::OrganizationReference) ? x : ::Io::Flow::V0::Models::OrganizationReference.new(x))
  @order = (x = opts.delete(:order); x.is_a?(::Io::Flow::V0::Models::OrderNumberReference) ? x : ::Io::Flow::V0::Models::OrderNumberReference.new(x))
  @session = (x = opts.delete(:session); x.is_a?(::Io::Flow::V0::Models::SessionReference) ? x : ::Io::Flow::V0::Models::SessionReference.new(x))
  @urls = (x = opts.delete(:urls); x.is_a?(::Io::Flow::V0::Models::CheckoutUrls) ? x : ::Io::Flow::V0::Models::CheckoutUrls.new(x))
  @expires_at = HttpClient::Preconditions.assert_class('expires_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:expires_at)), DateTime)
end

Instance Attribute Details

#expires_atObject (readonly)

Returns the value of attribute expires_at.



21359
21360
21361
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21359

def expires_at
  @expires_at
end

#idObject (readonly)

Returns the value of attribute id.



21359
21360
21361
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21359

def id
  @id
end

#orderObject (readonly)

Returns the value of attribute order.



21359
21360
21361
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21359

def order
  @order
end

#organizationObject (readonly)

Returns the value of attribute organization.



21359
21360
21361
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21359

def organization
  @organization
end

#sessionObject (readonly)

Returns the value of attribute session.



21359
21360
21361
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21359

def session
  @session
end

#urlsObject (readonly)

Returns the value of attribute urls.



21359
21360
21361
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21359

def urls
  @urls
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



21376
21377
21378
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21376

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

#to_hashObject



21380
21381
21382
21383
21384
21385
21386
21387
21388
21389
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21380

def to_hash
  {
    :id => id,
    :organization => organization.to_hash,
    :order => order.to_hash,
    :session => session.to_hash,
    :urls => urls.to_hash,
    :expires_at => expires_at
  }
end

#to_jsonObject



21372
21373
21374
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21372

def to_json
  JSON.dump(to_hash)
end