Class: Io::Flow::V0::Clients::Users
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Users
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#delete_passwords_by_id(id) ⇒ Object
Deletes a password for the given user.
-
#get(incoming = {}) ⇒ Object
Search users.
-
#get_by_id(id) ⇒ Object
Returns information about a specific user.
-
#get_versions(incoming = {}) ⇒ Object
Provides visibility into recent changes of each object, including deletion.
-
#initialize(client) ⇒ Users
constructor
A new instance of Users.
-
#patch_passwords_by_id(id, password_change_form) ⇒ Object
Update the password for a user.
-
#post(user_form) ⇒ Object
Create a new user.
-
#post_authenticate(authentication_form) ⇒ Object
Authenticates a user by email / password.
-
#put_by_id(id, user_put_form) ⇒ Object
Update a user.
Constructor Details
#initialize(client) ⇒ Users
Returns a new instance of Users.
3470 3471 3472 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3470 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_passwords_by_id(id) ⇒ Object
Deletes a password for the given user.
3519 3520 3521 3522 3523 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3519 def delete_passwords_by_id(id) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/users/#{CGI.escape(id)}/passwords").delete nil end |
#get(incoming = {}) ⇒ Object
Search users. Always paginated.
3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3475 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) }), :email => (x = opts.delete(:email); x.nil? ? nil : HttpClient::Preconditions.assert_class('email', 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) }.delete_if { |k, v| v.nil? } r = @client.request("/users").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::User.new(x) } end |
#get_by_id(id) ⇒ Object
Returns information about a specific user.
3496 3497 3498 3499 3500 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3496 def get_by_id(id) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/users/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::User.new(r) end |
#get_versions(incoming = {}) ⇒ Object
Provides visibility into recent changes of each object, including deletion
3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3533 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) }), :user_id => (x = opts.delete(:user_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('user_id', x, Array).map { |v| HttpClient::Preconditions.assert_class('user_id', 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("/users/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::UserVersion.new(x) } end |
#patch_passwords_by_id(id, password_change_form) ⇒ Object
Update the password for a user.
3511 3512 3513 3514 3515 3516 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3511 def patch_passwords_by_id(id, password_change_form) HttpClient::Preconditions.assert_class('id', id, String) HttpClient::Preconditions.assert_class('password_change_form', password_change_form, ::Io::Flow::V0::Models::PasswordChangeForm) r = @client.request("/users/#{CGI.escape(id)}/passwords").with_json(password_change_form.to_json).patch nil end |
#post(user_form) ⇒ Object
Create a new user.
3489 3490 3491 3492 3493 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3489 def post(user_form) HttpClient::Preconditions.assert_class('user_form', user_form, ::Io::Flow::V0::Models::UserForm) r = @client.request("/users").with_json(user_form.to_json).post ::Io::Flow::V0::Models::User.new(r) end |
#post_authenticate(authentication_form) ⇒ Object
Authenticates a user by email / password.
3526 3527 3528 3529 3530 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3526 def post_authenticate(authentication_form) HttpClient::Preconditions.assert_class('authentication_form', authentication_form, ::Io::Flow::V0::Models::AuthenticationForm) r = @client.request("/users/authenticate").with_json(authentication_form.to_json).post ::Io::Flow::V0::Models::User.new(r) end |
#put_by_id(id, user_put_form) ⇒ Object
Update a user.
3503 3504 3505 3506 3507 3508 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3503 def put_by_id(id, user_put_form) HttpClient::Preconditions.assert_class('id', id, String) HttpClient::Preconditions.assert_class('user_put_form', user_put_form, ::Io::Flow::V0::Models::UserPutForm) r = @client.request("/users/#{CGI.escape(id)}").with_json(user_put_form.to_json).put ::Io::Flow::V0::Models::User.new(r) end |