Class: Io::Flow::V0::Models::Organization

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

Overview

Represents a single organization in the system, and what environment it is currently operating in.

Instance Attribute Summary collapse

Attributes inherited from ExpandableOrganization

#discriminator

Instance Method Summary collapse

Methods inherited from ExpandableOrganization

#to_hash

Constructor Details

#initialize(incoming = {}) ⇒ Organization

Returns a new instance of Organization.



17310
17311
17312
17313
17314
17315
17316
17317
17318
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17310

def initialize(incoming={})
  super(:discriminator => ExpandableOrganization::Types::ORGANIZATION)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :name, :environment], 'Organization')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
  @environment = (x = opts.delete(:environment); x.is_a?(::Io::Flow::V0::Models::Environment) ? x : ::Io::Flow::V0::Models::Environment.apply(x))
  @parent = (x = opts.delete(:parent); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrganizationReference) ? x : ::Io::Flow::V0::Models::OrganizationReference.new(x)))
end

Instance Attribute Details

#environment ⇒ Object (readonly)

Returns the value of attribute environment.



17308
17309
17310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17308

def environment
  @environment
end

#id ⇒ Object (readonly)

Returns the value of attribute id.



17308
17309
17310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17308

def id
  @id
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



17308
17309
17310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17308

def name
  @name
end

#parent ⇒ Object (readonly)

Returns the value of attribute parent.



17308
17309
17310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17308

def parent
  @parent
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



17324
17325
17326
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17324

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

#subtype_to_hash ⇒ Object



17328
17329
17330
17331
17332
17333
17334
17335
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17328

def subtype_to_hash
  {
    :id => id,
    :name => name,
    :environment => environment.value,
    :parent => parent.nil? ? nil : parent.to_hash
  }
end

#to_json ⇒ Object



17320
17321
17322
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17320

def to_json
  JSON.dump(to_hash)
end