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.



26885
26886
26887
26888
26889
26890
26891
26892
26893
26894
26895
26896
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26885

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :organization, :checkout, :order, :urls, :expires_at, :session], '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))
  @checkout = (x = opts.delete(:checkout); x.is_a?(::Io::Flow::V0::Models::CheckoutReference) ? x : ::Io::Flow::V0::Models::CheckoutReference.new(x))
  @order = (x = opts.delete(:order); x.is_a?(::Io::Flow::V0::Models::OrderNumberReference) ? x : ::Io::Flow::V0::Models::OrderNumberReference.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)
  @session = (x = opts.delete(:session); x.is_a?(::Io::Flow::V0::Models::SessionReference) ? x : ::Io::Flow::V0::Models::SessionReference.new(x))
  @customer = (x = opts.delete(:customer); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::CustomerReference) ? x : ::Io::Flow::V0::Models::CustomerReference.new(x)))
end

Instance Attribute Details

#checkoutObject (readonly)

Returns the value of attribute checkout.



26883
26884
26885
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26883

def checkout
  @checkout
end

#customerObject (readonly)

Returns the value of attribute customer.



26883
26884
26885
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26883

def customer
  @customer
end

#expires_atObject (readonly)

Returns the value of attribute expires_at.



26883
26884
26885
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26883

def expires_at
  @expires_at
end

#idObject (readonly)

Returns the value of attribute id.



26883
26884
26885
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26883

def id
  @id
end

#orderObject (readonly)

Returns the value of attribute order.



26883
26884
26885
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26883

def order
  @order
end

#organizationObject (readonly)

Returns the value of attribute organization.



26883
26884
26885
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26883

def organization
  @organization
end

#sessionObject (readonly)

Returns the value of attribute session.



26883
26884
26885
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26883

def session
  @session
end

#urlsObject (readonly)

Returns the value of attribute urls.



26883
26884
26885
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26883

def urls
  @urls
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



26902
26903
26904
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26902

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

#to_hashObject



26906
26907
26908
26909
26910
26911
26912
26913
26914
26915
26916
26917
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26906

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

#to_jsonObject



26898
26899
26900
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26898

def to_json
  JSON.dump(to_hash)
end