Class: Tinder::Client
- Inherits:
-
Object
- Object
- Tinder::Client
- Defined in:
- lib/tinder/client.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #auth(fb_token) ⇒ Object
- #change_filter(age_filter_min: 18, age_filter_max: 30, gender: 0, gender_filter: 1, distance_filter: 50) ⇒ Object
- #change_location(lat, lon) ⇒ Object
-
#initialize(fb_token = nil) ⇒ Client
constructor
A new instance of Client.
- #profile ⇒ Object
- #recs ⇒ Object
- #user(id) ⇒ Object
Constructor Details
#initialize(fb_token = nil) ⇒ Client
Returns a new instance of Client.
5 6 7 |
# File 'lib/tinder/client.rb', line 5 def initialize(fb_token = nil) @token = fb_token ? auth(fb_token)['token'] : nil end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
3 4 5 |
# File 'lib/tinder/client.rb', line 3 def token @token end |
Instance Method Details
#auth(fb_token) ⇒ Object
9 10 11 12 |
# File 'lib/tinder/client.rb', line 9 def auth(fb_token) res = Util.post('/auth', {facebook_token: fb_token}) JSON.parse(res.body) end |
#change_filter(age_filter_min: 18, age_filter_max: 30, gender: 0, gender_filter: 1, distance_filter: 50) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/tinder/client.rb', line 29 def change_filter(age_filter_min: 18, age_filter_max: 30, gender: 0, gender_filter: 1, distance_filter: 50) if gender.is_a?(String) gender = gender == 'man' ? 0 : 1 end if gender_filter.is_a?(String) gender_filter = gender_filter == 'man' ? 0 : 1 end payload = { age_filter_min: age_filter_min, age_filter_max: age_filter_max, gender: gender, gender_filter: gender_filter, distance_filter: distance_filter } res = Util.post('/profile', payload, {'X-Auth-Token': token}) JSON.parse(res.body) end |
#change_location(lat, lon) ⇒ Object
50 51 52 53 |
# File 'lib/tinder/client.rb', line 50 def change_location(lat, lon) res = Util.post('/user/ping', {lat: lat, lon: lon}, {'X-Auth-Token': token}) JSON.parse(res.body) end |
#profile ⇒ Object
24 25 26 27 |
# File 'lib/tinder/client.rb', line 24 def profile res = Util.get('/profile', {}, {'X-Auth-Token': token}) JSON.parse(res.body) end |