Class: Dropwallet::Core::User
- Defined in:
- lib/dropwallet/core/user.rb
Class Method Summary collapse
-
.login(username, password) ⇒ Object
Login Function, returns User object on success, nil on failure.
Instance Method Summary collapse
Methods inherited from Model
all, baseServiceUrl, count, create, debug?, delete, #delete, field, find, #initialize, #isNew?, pages, #read_attribute, #read_attribute_for_validation, #save, serviceUrl, #to_json, #to_s, #update, #write_attribute
Constructor Details
This class inherits a constructor from Dropwallet::Core::Model
Class Method Details
.login(username, password) ⇒ Object
Login Function, returns User object on success, nil on failure
30 31 32 33 34 35 36 |
# File 'lib/dropwallet/core/user.rb', line 30 def self.login(username, password) login = JSON.parse(RestClient.post baseServiceUrl + '/session/login', "username=#{username}&password=#{password}", {:accept => :json}) if login['status'] == 'SUCCESS' return Dropwallet::Core::User.find(login['userId']) end return nil end |
Instance Method Details
#order(orderId) ⇒ Object
20 21 22 23 |
# File 'lib/dropwallet/core/user.rb', line 20 def order(orderId) = {:path => "#{Dropwallet::Core::Model.baseServiceUrl}/users/#{id}/orders"} return Dropwallet::Core::Order.find(orderId, ) end |
#orders(page = 1) ⇒ Object
15 16 17 18 |
# File 'lib/dropwallet/core/user.rb', line 15 def orders(page = 1) = {:path => "#{Dropwallet::Core::Model.baseServiceUrl}/users/#{id}/orders.json"} return Dropwallet::Core::Order.all(page, ) end |
#ordersPages ⇒ Object
25 26 27 28 |
# File 'lib/dropwallet/core/user.rb', line 25 def ordersPages = {:path => "#{Dropwallet::Core::Model.baseServiceUrl}/users/#{id}/orders.json"} return Dropwallet::Core::Order.pages() end |