Class: Kiik::Wallet::User
- Inherits:
-
Object
- Object
- Kiik::Wallet::User
- Defined in:
- lib/kiik/wallet/user.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #create(options = {}, &block) ⇒ Object
- #create_creditcard(options = {}, &block) ⇒ Object
-
#initialize(client) ⇒ User
constructor
A new instance of User.
- #login(options = {}, &block) ⇒ Object
- #regenerate_token(options = {}, &block) ⇒ Object
- #set_password(options = {}, &block) ⇒ Object
- #update(options = {}, &block) ⇒ Object
Constructor Details
#initialize(client) ⇒ User
Returns a new instance of User.
7 8 9 10 11 |
# File 'lib/kiik/wallet/user.rb', line 7 def initialize(client) @client = client @base_uri = '/users' @card = Kiik::Wallet::Creditcard.new(client) end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
5 6 7 |
# File 'lib/kiik/wallet/user.rb', line 5 def token @token end |
Instance Method Details
#create(options = {}, &block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/kiik/wallet/user.rb', line 13 def create(={},&block) params = { :user => { :email => [:email], :password => [:password], :external_id => [:id] } } @client.request(:post,@base_uri,request_params(params),&block) end |
#create_creditcard(options = {}, &block) ⇒ Object
72 73 74 |
# File 'lib/kiik/wallet/user.rb', line 72 def create_creditcard(={},&block) @card.create(,&block) end |
#login(options = {}, &block) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/kiik/wallet/user.rb', line 46 def login(={},&block) params = { :auth => { :external_id => [:id], :password => [:password] } } @client.request(:post, '/auth/login', params ) do |response| @token = response["token"] block.call(response) end end |
#regenerate_token(options = {}, &block) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/kiik/wallet/user.rb', line 59 def regenerate_token(={},&block) params = { :auth => { :external_id => [:id], :password => [:password] } } @client.request(:post, '/auth/regenerate_token', params ) do |response| @token = response["token"] block.call(response) end end |
#set_password(options = {}, &block) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/kiik/wallet/user.rb', line 35 def set_password(={},&block) params = { :user => { :email => [:email], :password => [:password], :new_password => [:new_password] } } @client.request(:put,"#{@base_uri}/#{[:id]}",request_params(params),&block) end |
#update(options = {}, &block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/kiik/wallet/user.rb', line 24 def update(={},&block) params = { :user => { :email => [:email], :password => [:password], :new_password => [:new_password] } } @client.request(:put,"#{@base_uri}/#{[:id]}",request_params(params),&block) end |