Class: Io::Flow::V0::Models::OrganizationSession

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

Instance Attribute Summary collapse

Attributes inherited from Session

#discriminator

Instance Method Summary collapse

Methods inherited from Session

#to_hash

Constructor Details

#initialize(incoming = {}) ⇒ OrganizationSession

Returns a new instance of OrganizationSession.



17616
17617
17618
17619
17620
17621
17622
17623
17624
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17616

def initialize(incoming={})
  super(:discriminator => Session::Types::ORGANIZATION_SESSION)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :organization, :attributes], 'OrganizationSession')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @organization = HttpClient::Preconditions.assert_class('organization', opts.delete(:organization), String)
  @attributes = HttpClient::Preconditions.assert_class('attributes', opts.delete(:attributes), Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h }
  @local = (x = opts.delete(:local); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::LocalSession) ? x : ::Io::Flow::V0::Models::LocalSession.new(x)))
end

Instance Attribute Details

#attributes ⇒ Object (readonly)

Returns the value of attribute attributes.



17614
17615
17616
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17614

def attributes
  @attributes
end

#id ⇒ Object (readonly)

Returns the value of attribute id.



17614
17615
17616
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17614

def id
  @id
end

#local ⇒ Object (readonly)

Returns the value of attribute local.



17614
17615
17616
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17614

def local
  @local
end

#organization ⇒ Object (readonly)

Returns the value of attribute organization.



17614
17615
17616
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17614

def organization
  @organization
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



17630
17631
17632
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17630

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

#subtype_to_hash ⇒ Object



17634
17635
17636
17637
17638
17639
17640
17641
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17634

def subtype_to_hash
  {
    :id => id,
    :organization => organization,
    :attributes => attributes,
    :local => local.nil? ? nil : local.to_hash
  }
end

#to_json ⇒ Object



17626
17627
17628
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17626

def to_json
  JSON.dump(to_hash)
end