Class: Kiik::Wallet::User

Inherits:
Object
  • Object
show all
Defined in:
lib/kiik/wallet/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#tokenObject (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(options={},&block)
	params = { 
		:user => { 
			:email => options[:email], 
			:password => options[:password], 
			:external_id => options[: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(options={},&block)
	@card.create(options,&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 (options={},&block)
	params = { 
		:auth => { 
			:external_id => options[:id], 
			:password => options[: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(options={},&block)
	params = { 
		:auth => { 
			:external_id => options[:id], 
			:password => options[: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(options={},&block)
	params = { 
		:user => { 
			:email => options[:email], 
			:password => options[:password], 
			:new_password => options[:new_password] 
		}
	}
	@client.request(:put,"#{@base_uri}/#{options[: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(options={},&block)
	params = { 
		:user => { 
			:email => options[:email], 
			:password => options[:password], 
			:new_password => options[:new_password] 
		}
	}
	@client.request(:put,"#{@base_uri}/#{options[:id]}",request_params(params),&block)
end