Class: Io::Flow::V0::Models::Membership

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

Overview

Represents the users that are part of this organization. Primary purpose is to manage which users have access to the organization’s data and to provide a simple user interface to assign roles and permissions to each member of the organization

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Membership

Returns a new instance of Membership.



20751
20752
20753
20754
20755
20756
20757
20758
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20751

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :organization, :user, :role], 'Membership')
  @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))
  @user = (x = opts.delete(:user); x.is_a?(::Io::Flow::V0::Models::ExpandableUser) ? x : ::Io::Flow::V0::Models::ExpandableUser.from_json(x))
  @role = (x = opts.delete(:role); x.is_a?(::Io::Flow::V0::Models::Role) ? x : ::Io::Flow::V0::Models::Role.apply(x))
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



20749
20750
20751
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20749

def id
  @id
end

#organizationObject (readonly)

Returns the value of attribute organization.



20749
20750
20751
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20749

def organization
  @organization
end

#roleObject (readonly)

Returns the value of attribute role.



20749
20750
20751
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20749

def role
  @role
end

#userObject (readonly)

Returns the value of attribute user.



20749
20750
20751
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20749

def user
  @user
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



20764
20765
20766
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20764

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

#to_hashObject



20768
20769
20770
20771
20772
20773
20774
20775
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20768

def to_hash
  {
    :id => id,
    :organization => organization.to_hash,
    :user => user.to_hash,
    :role => role.value
  }
end

#to_jsonObject



20760
20761
20762
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20760

def to_json
  JSON.dump(to_hash)
end