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.



16159
16160
16161
16162
16163
16164
16165
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16159

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

#organization ⇒ Object (readonly)

Returns the value of attribute organization.



16157
16158
16159
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16157

def organization
  @organization
end

#role ⇒ Object (readonly)

Returns the value of attribute role.



16157
16158
16159
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16157

def role
  @role
end

#user ⇒ Object (readonly)

Returns the value of attribute user.



16157
16158
16159
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16157

def user
  @user
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



16171
16172
16173
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16171

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

#to_hash ⇒ Object



16175
16176
16177
16178
16179
16180
16181
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16175

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

#to_json ⇒ Object



16167
16168
16169
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16167

def to_json
  JSON.dump(to_hash)
end