Class: Io::Flow::V0::Models::OrganizationToken

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

Overview

All of the metadata associated with a given token.

Instance Attribute Summary collapse

Attributes inherited from Token

#discriminator

Instance Method Summary collapse

Methods inherited from Token

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ OrganizationToken



21263
21264
21265
21266
21267
21268
21269
21270
21271
21272
21273
21274
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21263

def initialize(incoming={})
  super(:discriminator => Token::Types::ORGANIZATION_TOKEN)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :organization, :user, :environment, :partial, :created_at], 'OrganizationToken')
  @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))
  @user = (x = opts.delete(:user); x.is_a?(::Io::Flow::V0::Models::UserReference) ? x : ::Io::Flow::V0::Models::UserReference.new(x))
  @environment = (x = opts.delete(:environment); x.is_a?(::Io::Flow::V0::Models::Environment) ? x : ::Io::Flow::V0::Models::Environment.apply(x))
  @partial = HttpClient::Preconditions.assert_class('partial', opts.delete(:partial), String)
  @created_at = HttpClient::Preconditions.assert_class('created_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:created_at)), DateTime)
  @description = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String))
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



21261
21262
21263
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21261

def created_at
  @created_at
end

#descriptionObject (readonly)

Returns the value of attribute description.



21261
21262
21263
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21261

def description
  @description
end

#environmentObject (readonly)

Returns the value of attribute environment.



21261
21262
21263
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21261

def environment
  @environment
end

#idObject (readonly)

Returns the value of attribute id.



21261
21262
21263
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21261

def id
  @id
end

#organizationObject (readonly)

Returns the value of attribute organization.



21261
21262
21263
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21261

def organization
  @organization
end

#partialObject (readonly)

Returns the value of attribute partial.



21261
21262
21263
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21261

def partial
  @partial
end

#userObject (readonly)

Returns the value of attribute user.



21261
21262
21263
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21261

def user
  @user
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



21280
21281
21282
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21280

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

#subtype_to_hashObject



21284
21285
21286
21287
21288
21289
21290
21291
21292
21293
21294
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21284

def subtype_to_hash
  {
    :id => id,
    :organization => organization.to_hash,
    :user => user.to_hash,
    :environment => environment.value,
    :partial => partial,
    :created_at => created_at,
    :description => description
  }
end

#to_jsonObject



21276
21277
21278
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21276

def to_json
  JSON.dump(to_hash)
end