Class: Io::Flow::V0::Clients::Invitations
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Invitations
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_id(id) ⇒ Object
-
#get(incoming = {}) ⇒ Object
Search invitations.
-
#get_by_id(id, incoming = {}) ⇒ Object
Returns information about a specific invitation.
-
#get_tokens_by_token(token, incoming = {}) ⇒ Object
Lookup an invitation by its token.
- #get_versions(incoming = {}) ⇒ Object
-
#initialize(client) ⇒ Invitations
constructor
A new instance of Invitations.
-
#post(invitation_form) ⇒ Object
Create a new invitation.
-
#put_tokens_by_token(token, invitation_accepts_form) ⇒ Object
Accepts the invitation w/ the specified token, creating a membership record for this user within this organization.
Constructor Details
#initialize(client) ⇒ Invitations
Returns a new instance of Invitations.
3374 3375 3376 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3374 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(id) ⇒ Object
3413 3414 3415 3416 3417 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3413 def delete_by_id(id) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/invitations/#{CGI.escape(id)}").delete nil end |
#get(incoming = {}) ⇒ Object
Search invitations. Always paginated.
3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3379 def get(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :id => (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, Array).map { |v| HttpClient::Preconditions.assert_class('id', v, String) }), :organization => (x = opts.delete(:organization); x.nil? ? nil : HttpClient::Preconditions.assert_class('organization', x, String)), :email => (x = opts.delete(:email); x.nil? ? nil : HttpClient::Preconditions.assert_class('email', x, String)), :token => (x = opts.delete(:token); x.nil? ? nil : HttpClient::Preconditions.assert_class('token', x, String)), :limit => HttpClient::Preconditions.assert_class('limit', (x = opts.delete(:limit); x.nil? ? 25 : x), Integer), :offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer), :sort => HttpClient::Preconditions.assert_class('sort', (x = opts.delete(:sort); x.nil? ? "-created_at" : x), String), :expand => (x = opts.delete(:expand); x.nil? ? nil : HttpClient::Preconditions.assert_class('expand', x, Array).map { |v| HttpClient::Preconditions.assert_class('expand', v, String) }) }.delete_if { |k, v| v.nil? } r = @client.request("/invitations").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Invitation.new(x) } end |
#get_by_id(id, incoming = {}) ⇒ Object
Returns information about a specific invitation.
3403 3404 3405 3406 3407 3408 3409 3410 3411 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3403 def get_by_id(id, incoming={}) HttpClient::Preconditions.assert_class('id', id, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :expand => (x = opts.delete(:expand); x.nil? ? nil : HttpClient::Preconditions.assert_class('expand', x, Array).map { |v| HttpClient::Preconditions.assert_class('expand', v, String) }) }.delete_if { |k, v| v.nil? } r = @client.request("/invitations/#{CGI.escape(id)}").with_query(query).get ::Io::Flow::V0::Models::Invitation.new(r) end |
#get_tokens_by_token(token, incoming = {}) ⇒ Object
Lookup an invitation by its token.
3420 3421 3422 3423 3424 3425 3426 3427 3428 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3420 def get_tokens_by_token(token, incoming={}) HttpClient::Preconditions.assert_class('token', token, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :expand => (x = opts.delete(:expand); x.nil? ? nil : HttpClient::Preconditions.assert_class('expand', x, Array).map { |v| HttpClient::Preconditions.assert_class('expand', v, String) }) }.delete_if { |k, v| v.nil? } r = @client.request("/invitations/tokens/#{CGI.escape(token)}").with_query(query).get ::Io::Flow::V0::Models::Invitation.new(r) end |
#get_versions(incoming = {}) ⇒ Object
3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3441 def get_versions(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :id => (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, Array).map { |v| HttpClient::Preconditions.assert_class('id', v, String) }), :invitation => (x = opts.delete(:invitation); x.nil? ? nil : HttpClient::Preconditions.assert_class('invitation', x, Array).map { |v| HttpClient::Preconditions.assert_class('invitation', v, String) }), :limit => HttpClient::Preconditions.assert_class('limit', (x = opts.delete(:limit); x.nil? ? 25 : x), Integer), :offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer), :sort => HttpClient::Preconditions.assert_class('sort', (x = opts.delete(:sort); x.nil? ? "journal_timestamp" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/invitations/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::InvitationVersion.new(x) } end |
#post(invitation_form) ⇒ Object
Create a new invitation.
3396 3397 3398 3399 3400 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3396 def post(invitation_form) HttpClient::Preconditions.assert_class('invitation_form', invitation_form, ::Io::Flow::V0::Models::InvitationForm) r = @client.request("/invitations").with_json(invitation_form.to_json).post ::Io::Flow::V0::Models::Invitation.new(r) end |
#put_tokens_by_token(token, invitation_accepts_form) ⇒ Object
Accepts the invitation w/ the specified token, creating a membership record for this user within this organization. Invitations are one time use only - you will get a validation error if the invitation has previously been accepted.
3434 3435 3436 3437 3438 3439 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3434 def put_tokens_by_token(token, invitation_accepts_form) HttpClient::Preconditions.assert_class('token', token, String) HttpClient::Preconditions.assert_class('invitation_accepts_form', invitation_accepts_form, ::Io::Flow::V0::Models::InvitationAcceptsForm) r = @client.request("/invitations/tokens/#{CGI.escape(token)}").with_json(invitation_accepts_form.to_json).put ::Io::Flow::V0::Models::Membership.new(r) end |