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

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ Organization

Returns a new instance of Organization.



22243
22244
22245
22246
22247
22248
22249
22250
22251
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22243

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

#environmentObject (readonly)

Returns the value of attribute environment.



22241
22242
22243
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22241

def environment
  @environment
end

#idObject (readonly)

Returns the value of attribute id.



22241
22242
22243
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22241

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



22241
22242
22243
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22241

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



22241
22242
22243
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22241

def parent
  @parent
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



22257
22258
22259
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22257

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

#subtype_to_hashObject



22261
22262
22263
22264
22265
22266
22267
22268
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22261

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

#to_jsonObject



22253
22254
22255
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22253

def to_json
  JSON.dump(to_hash)
end