Class: Io::Flow::V0::Models::MembershipForm

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

Overview

Top level resource to create a membership.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ MembershipForm

Returns a new instance of MembershipForm.



17280
17281
17282
17283
17284
17285
17286
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17280

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:organization, :user], 'MembershipForm')
  @organization = HttpClient::Preconditions.assert_class('organization', opts.delete(:organization), String)
  @user = HttpClient::Preconditions.assert_class('user', opts.delete(:user), String)
  @role = (x = (x = opts.delete(:role); x.nil? ? "member" : x); x.is_a?(::Io::Flow::V0::Models::Role) ? x : ::Io::Flow::V0::Models::Role.apply(x))
end

Instance Attribute Details

#organizationObject (readonly)

Returns the value of attribute organization.



17278
17279
17280
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17278

def organization
  @organization
end

#roleObject (readonly)

Returns the value of attribute role.



17278
17279
17280
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17278

def role
  @role
end

#userObject (readonly)

Returns the value of attribute user.



17278
17279
17280
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17278

def user
  @user
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



17292
17293
17294
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17292

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

#to_hashObject



17296
17297
17298
17299
17300
17301
17302
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17296

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

#to_jsonObject



17288
17289
17290
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17288

def to_json
  JSON.dump(to_hash)
end