Module: Simplewoo::Client::User
- Included in:
- Simplewoo::Client
- Defined in:
- lib/simplewoo/client/user.rb
Instance Method Summary collapse
-
#create_user(email, password, password_confirmation, birthday, first_name, last_name, options = {}) ⇒ Hashie::Mash
Create a user on the core api.
-
#me ⇒ Object
Returns the currently authenticated user.
-
#update_user(options = {}) ⇒ Hashie::Mash
(also: #reset_password)
Update a user on the core api.
Instance Method Details
#create_user(email, password, password_confirmation, birthday, first_name, last_name, options = {}) ⇒ Hashie::Mash
Create a user on the core api
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/simplewoo/client/user.rb', line 27 def create_user(email, password, password_confirmation, birthday, first_name, last_name, = {}) .merge!({ :email => email, :password => password, :password_confirmation => password_confirmation, :birthday => birthday, :first_name => first_name, :last_name => last_name }) result = post("/users", { :user => }) # TODO we should really make this core method return an api_token as well and use that instead authenticate({:email => email, :password => password }) result end |
#me ⇒ Object
Note:
This method requires an authenticated user via email + password or api_token
Returns the currently authenticated user
77 78 79 80 81 82 83 |
# File 'lib/simplewoo/client/user.rb', line 77 def me if authenticated? get("/users/me") else raise "No authorized user." end end |
#update_user(options = {}) ⇒ Hashie::Mash Also known as: reset_password
Note:
This method requires an authenticated user via email + password or api_token
Update a user on the core api
62 63 64 65 66 67 68 |
# File 'lib/simplewoo/client/user.rb', line 62 def update_user( = {}) if authenticated? put("/users/me", { :user => }) else raise "No authorized user." end end |