Class: Tinder::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/tinder/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#tokenObject (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

#profileObject



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

#recsObject



14
15
16
17
# File 'lib/tinder/client.rb', line 14

def recs
  res = Util.get('/user/recs', {}, {'X-Auth-Token': token})
  JSON.parse(res.body)['results']
end

#user(id) ⇒ Object



19
20
21
22
# File 'lib/tinder/client.rb', line 19

def user(id)
  res = Util.get('/user/' + id, {}, {'X-Auth-Token': token})
  JSON.parse(res.body)['results']
end