Class: Io::Flow::V0::Models::Invitation

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

Overview

An invitation via email to a user to join this organization. The user will then walk through a user login/registration process and will immediately become a member of the organization.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Invitation

Returns a new instance of Invitation.



14458
14459
14460
14461
14462
14463
14464
14465
14466
14467
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14458

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :organization, :email, :name, :role, :expiration], 'Invitation')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @organization = (x = opts.delete(:organization); x.is_a?(::Io::Flow::V0::Models::ExpandableOrganization) ? x : ::Io::Flow::V0::Models::ExpandableOrganization.from_json(x))
  @email = HttpClient::Preconditions.assert_class('email', opts.delete(:email), String)
  @name = (x = opts.delete(:name); x.is_a?(::Io::Flow::V0::Models::Name) ? x : ::Io::Flow::V0::Models::Name.new(x))
  @role = (x = opts.delete(:role); x.is_a?(::Io::Flow::V0::Models::Role) ? x : ::Io::Flow::V0::Models::Role.apply(x))
  @expiration = HttpClient::Preconditions.assert_class('expiration', HttpClient::Helper.to_date_time_iso8601(opts.delete(:expiration)), DateTime)
end

Instance Attribute Details

#email ⇒ Object (readonly)

Returns the value of attribute email.



14456
14457
14458
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14456

def email
  @email
end

#expiration ⇒ Object (readonly)

Returns the value of attribute expiration.



14456
14457
14458
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14456

def expiration
  @expiration
end

#id ⇒ Object (readonly)

Returns the value of attribute id.



14456
14457
14458
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14456

def id
  @id
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



14456
14457
14458
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14456

def name
  @name
end

#organization ⇒ Object (readonly)

Returns the value of attribute organization.



14456
14457
14458
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14456

def organization
  @organization
end

#role ⇒ Object (readonly)

Returns the value of attribute role.



14456
14457
14458
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14456

def role
  @role
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



14473
14474
14475
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14473

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

#to_hash ⇒ Object



14477
14478
14479
14480
14481
14482
14483
14484
14485
14486
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14477

def to_hash
  {
    :id => id,
    :organization => organization.to_hash,
    :email => email,
    :name => name.to_hash,
    :role => role.value,
    :expiration => expiration
  }
end

#to_json ⇒ Object



14469
14470
14471
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14469

def to_json
  JSON.dump(to_hash)
end