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) ⇒ Object
Accepts the invitation w/ the specified token and the authenticated user.
Constructor Details
#initialize(client) ⇒ Invitations
Returns a new instance of Invitations.
6521 6522 6523 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6521 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(id) ⇒ Object
6595 6596 6597 6598 6599 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6595 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.
6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6526 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.
6585 6586 6587 6588 6589 6590 6591 6592 6593 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6585 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.
6550 6551 6552 6553 6554 6555 6556 6557 6558 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6550 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
6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6571 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.
6543 6544 6545 6546 6547 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6543 def post(invitation_form) (x = invitation_form; x.is_a?(::Io::Flow::V0::Models::InvitationForm) ? x : ::Io::Flow::V0::Models::InvitationForm.new(x)) r = @client.request("/invitations").with_json(invitation_form.to_json).post ::Io::Flow::V0::Models::Invitation.new(r) end |
#put_tokens_by_token(token) ⇒ Object
Accepts the invitation w/ the specified token and the authenticated user. 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 or if the user’s email addresses do not match the email on the invite.
6565 6566 6567 6568 6569 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6565 def put_tokens_by_token(token) HttpClient::Preconditions.assert_class('token', token, String) r = @client.request("/invitations/tokens/#{CGI.escape(token)}").put ::Io::Flow::V0::Models::Membership.new(r) end |