Class: Io::Flow::V0::Models::Membership
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Membership
- 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
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#organization ⇒ Object
readonly
Returns the value of attribute organization.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Membership
constructor
A new instance of Membership.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Membership
Returns a new instance of Membership.
36053 36054 36055 36056 36057 36058 36059 36060 36061 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36053 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :organization, :user, :roles], '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.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Role) ? x : ::Io::Flow::V0::Models::Role.apply(x))) @roles = HttpClient::Preconditions.assert_class('roles', opts.delete(:roles), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::FlowRole) ? x : ::Io::Flow::V0::Models::FlowRole.from_json(x)) } end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
36051 36052 36053 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36051 def id @id end |
#organization ⇒ Object (readonly)
Returns the value of attribute organization.
36051 36052 36053 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36051 def organization @organization end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
36051 36052 36053 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36051 def role @role end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
36051 36052 36053 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36051 def roles @roles end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
36051 36052 36053 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36051 def user @user end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
36067 36068 36069 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36067 def copy(incoming={}) Membership.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
36071 36072 36073 36074 36075 36076 36077 36078 36079 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36071 def to_hash { :id => id, :organization => organization.to_hash, :user => user.to_hash, :role => role.nil? ? nil : role.value, :roles => roles.map { |o| o.to_hash } } end |
#to_json ⇒ Object
36063 36064 36065 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36063 def to_json JSON.dump(to_hash) end |