Class: Dropwallet::Core::User

Inherits:
Model
  • Object
show all
Defined in:
lib/dropwallet/core/user.rb

Class Method Summary collapse

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.(username, password)
   = JSON.parse(RestClient.post baseServiceUrl + '/session/login', "username=#{username}&password=#{password}", {:accept => :json})
  if ['status'] == 'SUCCESS'
    return Dropwallet::Core::User.find(['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)
  options = {:path => "#{Dropwallet::Core::Model.baseServiceUrl}/users/#{id}/orders"}
  return Dropwallet::Core::Order.find(orderId, options)
end

#orders(page = 1) ⇒ Object



15
16
17
18
# File 'lib/dropwallet/core/user.rb', line 15

def orders(page = 1)
  options = {:path => "#{Dropwallet::Core::Model.baseServiceUrl}/users/#{id}/orders.json"}
  return Dropwallet::Core::Order.all(page, options)
end

#ordersPagesObject



25
26
27
28
# File 'lib/dropwallet/core/user.rb', line 25

def ordersPages
  options = {:path => "#{Dropwallet::Core::Model.baseServiceUrl}/users/#{id}/orders.json"}
  return Dropwallet::Core::Order.pages(options)
end