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.



28139
28140
28141
28142
28143
28144
28145
28146
28147
28148
28149
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28139

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :organization, :email, :name, :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.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Role) ? x : ::Io::Flow::V0::Models::Role.apply(x)))
  @roles = (x = opts.delete(:roles); x.nil? ? nil : HttpClient::Preconditions.assert_class('roles', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::FlowRole) ? x : ::Io::Flow::V0::Models::FlowRole.from_json(x)) })
  @expiration = HttpClient::Preconditions.assert_class('expiration', HttpClient::Helper.to_date_time_iso8601(opts.delete(:expiration)), DateTime)
end

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



28137
28138
28139
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28137

def email
  @email
end

#expirationObject (readonly)

Returns the value of attribute expiration.



28137
28138
28139
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28137

def expiration
  @expiration
end

#idObject (readonly)

Returns the value of attribute id.



28137
28138
28139
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28137

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



28137
28138
28139
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28137

def name
  @name
end

#organizationObject (readonly)

Returns the value of attribute organization.



28137
28138
28139
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28137

def organization
  @organization
end

#roleObject (readonly)

Returns the value of attribute role.



28137
28138
28139
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28137

def role
  @role
end

#rolesObject (readonly)

Returns the value of attribute roles.



28137
28138
28139
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28137

def roles
  @roles
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



28155
28156
28157
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28155

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

#to_hashObject



28159
28160
28161
28162
28163
28164
28165
28166
28167
28168
28169
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28159

def to_hash
  {
    :id => id,
    :organization => organization.to_hash,
    :email => email,
    :name => name.to_hash,
    :role => role.nil? ? nil : role.value,
    :roles => roles.nil? ? nil : roles.map { |o| o.to_hash },
    :expiration => expiration
  }
end

#to_jsonObject



28151
28152
28153
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28151

def to_json
  JSON.dump(to_hash)
end