tinderbot 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84853898e9d2cc0998d3d44d659bb9e767b51c09
4
- data.tar.gz: ef39b53b0ac78c8c090f0f4020f0b70548ac7341
3
+ metadata.gz: 98fa0c94eb84588a78f917644c41c5a53cb46bed
4
+ data.tar.gz: 6a9a980b9d191d4b85fa7921d80aaa16264fdbd6
5
5
  SHA512:
6
- metadata.gz: 8d829e7abf8623650226008e7e23c710ebb61a87d8b4619f651845f0a4faa210d916fde9cdce7b1ba57c6c274c82d5f3ec27f69aa15d5b48bb9e987279684c38
7
- data.tar.gz: 73e10a13e17d9124dd91136e2b2ddda63d5a22e4a1f74c276fadec7fd68d94af1fcec39ce073b69974a6b52ec510571ac976489f49ef6c723c4e830133fc473e
6
+ metadata.gz: 40d41f4d09f375b8fe4b12d918f00971ebc793219c5dde22453c9d499b05db8d02b5981c33f8703a1e301b59b763bef35ddaf08f62fcf7ea1a1862ee1db21831
7
+ data.tar.gz: a99d62a37a6abd5cdd02b8a45889b440467441727b2ccecfcf4573646dbe6f74668a8075f9d1cdfa54b6893534c0536b8b8c697917fb92267863abd4e17071ae
data/README.md CHANGED
@@ -52,22 +52,35 @@ tinder_client.sign_in tinder_authentication_token
52
52
 
53
53
  ### Interacting with the Tinder API
54
54
  ```ruby
55
- tinder_client.me
56
- tinder_client.user(user_id)
57
- tinder_client.updates
58
- tinder_client.recommended_users
59
- tinder_client.like(user_id)
60
- tinder_client.like_all(user_ids)
61
- tinder_client.dislike(user_id)
62
- tinder_client.dislike_all(user_ids)
55
+ user = tinder_client.me #=> returns an instance of Tinderbot::Tinder::Models::User
56
+ user.original_tinder_json #=> {...} original json from tinder's API
57
+ user.id #=> 1234
58
+ user.name #=> 'Bob'
59
+ user.bio #=> 'I am awesome'
60
+ user.birth_date #=> #<Date: 2014-05-01>
61
+ user.gender #=> :male (or :female)
62
+ user.photo_urls #=> ['http://photo_1_url.jpg', 'http://photo_2_url.jpg']
63
+
64
+ user = tinder_client.user(user_id) #=> returns an instance of Tinderbot::Tinder::Models::User
65
+
66
+ users = tinder_client.recommended_users #=> returns an array of Tinderbot::Tinder::Models::User instances
67
+
68
+ tinder_client.updates #=> {...} original json from tinder's API
69
+
63
70
  tinder_client.send_message(user_id, message)
71
+
72
+ # you can provide a user instance or a user id to like or dislike users
73
+ tinder_client.like(user)
74
+ tinder_client.like(user.id)
75
+ tinder_client.dislike(user)
76
+ tinder_client.dislike(user.id)
64
77
  ```
65
78
 
66
79
  ### Using the bot
67
80
  Tinderbot provides a simple bot which automatically likes all recommended people. It stops when there is no more recommended people.
68
81
  ```ruby
69
82
  tinder_bot = Tinderbot::Tinder::Bot.new tinder_client
70
- tinder_bot.like_recommended_people
83
+ tinder_bot.like_recommended_users
71
84
  ```
72
85
 
73
86
  ### Using the command line tool
@@ -8,37 +8,37 @@ module Tinderbot
8
8
  desc 'me', 'Get your profile data'
9
9
  def me
10
10
  tinder_client = sign_in
11
- puts tinder_client.me
11
+ puts tinder_client.me.to_yaml
12
12
  end
13
13
 
14
14
  desc 'user USER_ID', 'Get user profile data'
15
15
  def user(user_id)
16
16
  tinder_client = sign_in
17
- puts tinder_client.user user_id
17
+ puts tinder_client.user(user_id).to_yaml
18
18
  end
19
19
 
20
20
  desc 'updates', 'Get updates'
21
21
  def updates
22
22
  tinder_client = sign_in
23
- puts tinder_client.updates
23
+ puts tinder_client.updates.to_yaml
24
24
  end
25
25
 
26
26
  desc 'recommended', 'Get recommended users'
27
27
  def recommended
28
28
  tinder_client = sign_in
29
- puts tinder_client.recommended_users
29
+ puts tinder_client.recommended_users.to_yaml
30
30
  end
31
31
 
32
32
  desc 'like USER_ID', 'Like user'
33
33
  def like(user_id)
34
34
  tinder_client = sign_in
35
- puts tinder_client.like user_id
35
+ tinder_client.like user_id
36
36
  end
37
37
 
38
38
  desc 'dislike USER_ID', 'Dislike user'
39
39
  def dislike(user_id)
40
40
  tinder_client = sign_in
41
- puts tinder_client.dislike user_id
41
+ tinder_client.dislike user_id
42
42
  end
43
43
 
44
44
  desc 'send USER_ID MESSAGE', 'Send message to user'
@@ -53,7 +53,7 @@ module Tinderbot
53
53
 
54
54
  puts 'Starting likes...'
55
55
  tinder_bot = Tinderbot::Tinder::Bot.new tinder_client
56
- tinder_bot.like_recommended_people
56
+ tinder_bot.like_recommended_users
57
57
  end
58
58
 
59
59
  private
@@ -7,12 +7,11 @@ module Tinderbot
7
7
  @client = client
8
8
  end
9
9
 
10
- def like_recommended_people
11
- recommended_people = @client.recommended_users
12
- while recommended_people
13
- recommended_people_ids = recommended_people.map {|r| r['_id']}
14
- @client.like_all recommended_people_ids
15
- recommended_people = @client.recommended_users
10
+ def like_recommended_users
11
+ recommended_users = @client.recommended_users
12
+ while recommended_users
13
+ recommended_users.each { |user| @client.like user }
14
+ recommended_users = @client.recommended_users
16
15
  end
17
16
  end
18
17
  end
@@ -21,11 +21,11 @@ module Tinderbot
21
21
  end
22
22
 
23
23
  def me
24
- JSON.parse(@connection.get('profile').body)
24
+ Tinderbot::Tinder::Models::User.build_from_tinder_json JSON.parse(@connection.get('profile').body)
25
25
  end
26
26
 
27
27
  def user(user_id)
28
- JSON.parse(@connection.get("user/#{user_id}").body)
28
+ Tinderbot::Tinder::Models::User.build_from_tinder_json JSON.parse(@connection.get("user/#{user_id}").body)['results']
29
29
  end
30
30
 
31
31
  def updates
@@ -33,33 +33,44 @@ module Tinderbot
33
33
  end
34
34
 
35
35
  def recommended_users
36
- JSON.parse(@connection.post('user/recs').body)['results']
36
+ JSON.parse(@connection.post('user/recs').body)['results'].map { |r| Tinderbot::Tinder::Models::User.build_from_tinder_json r }
37
37
  end
38
38
 
39
- def like(user_id)
40
- @connection.get "like/#{user_id}"
41
- puts "Liked #{user_id}" if @logs_enabled
42
- end
43
-
44
- def like_all(user_ids)
45
- user_ids.each { |user_id| like user_id }
46
- end
47
-
48
- def dislike(user_id)
49
- @connection.get "pass/#{user_id}"
50
- puts "Disliked #{user_id}" if @logs_enabled
39
+ def like(user_or_user_id)
40
+ if user_or_user_id.is_a? Tinderbot::Tinder::Models::User
41
+ like_from_user_id(user_or_user_id.id)
42
+ puts "Liked #{user_or_user_id.id} (#{user_or_user_id.name})" if @logs_enabled
43
+ else
44
+ like_from_user_id(user_or_user_id)
45
+ puts "Liked #{user_or_user_id}" if @logs_enabled
46
+ end
51
47
  end
52
48
 
53
- def dislike_all(user_ids)
54
- user_ids.each { |user_id| dislike user_id }
49
+ def dislike(user_or_user_id)
50
+ if user_or_user_id.is_a? Tinderbot::Tinder::Models::User
51
+ dislike_from_user_id(user_or_user_id.id)
52
+ puts "Disliked #{user_or_user_id.id} (#{user_or_user_id.name})" if @logs_enabled
53
+ else
54
+ dislike_from_user_id(user_or_user_id)
55
+ puts "Disliked #{user_or_user_id}" if @logs_enabled
56
+ end
55
57
  end
56
58
 
57
59
  def send_message(user_id, message)
58
60
  @connection.post("user/matches/#{user_id}", {message: message})
61
+ puts "Sent message to #{user_id}" if @logs_enabled
59
62
  end
60
63
 
61
64
  protected
62
65
 
66
+ def like_from_user_id(user_id)
67
+ @connection.get "like/#{user_id}"
68
+ end
69
+
70
+ def dislike_from_user_id(user_id)
71
+ @connection.get "pass/#{user_id}"
72
+ end
73
+
63
74
  def build_connection
64
75
  @connection = Faraday.new(url: TINDER_API_URL) do |faraday|
65
76
  faraday.request :json
@@ -0,0 +1,21 @@
1
+ module Tinderbot
2
+ module Tinder
3
+ module Models
4
+ class User
5
+ attr_accessor :original_tinder_json, :id, :name, :bio, :birth_date, :gender, :photo_urls
6
+
7
+ def self.build_from_tinder_json(tinder_json)
8
+ user = self.new
9
+ user.original_tinder_json = tinder_json
10
+ user.id = tinder_json['_id']
11
+ user.name = tinder_json['name']
12
+ user.bio = tinder_json['bio']
13
+ user.birth_date = Date.parse tinder_json['birth_date']
14
+ user.gender = tinder_json['gender'] == 0 ? :male : :female
15
+ user.photo_urls = tinder_json['photos'].map { |t| t['url'] }
16
+ user
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module Tinderbot
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
@@ -0,0 +1,95 @@
1
+ {
2
+ "_id": "user_id",
3
+ "age_filter_max": 1000,
4
+ "age_filter_min": 19,
5
+ "bio": "user bio",
6
+ "birth_date": "1989-02-13T00:00:00.000Z",
7
+ "create_date": "2013-11-21T22:29:01.958Z",
8
+ "facebook_id": "user_facebook_id",
9
+ "gender": 0,
10
+ "gender_filter": 1,
11
+ "location": {
12
+ "id": "location_id",
13
+ "name": "Paris, France"
14
+ },
15
+ "name": "Name",
16
+ "ping_time": "2014-08-25T18:01:50.032Z",
17
+ "pos": {
18
+ "at": 123,
19
+ "lon": 1.123,
20
+ "lat": 1.123
21
+ },
22
+ "photos": [
23
+ {
24
+ "url": "http://images.gotinder.com/user_id/image_1_id.jpg",
25
+ "processedFiles": [
26
+ {
27
+ "url": "http://images.gotinder.com/user_id/640x640_image_1_id.jpg",
28
+ "height": 640,
29
+ "width": 640
30
+ },
31
+ {
32
+ "url": "http://images.gotinder.com/user_id/320x320_image_1_id.jpg",
33
+ "height": 320,
34
+ "width": 320
35
+ },
36
+ {
37
+ "url": "http://images.gotinder.com/user_id/172x172_image_1_id.jpg",
38
+ "height": 172,
39
+ "width": 172
40
+ },
41
+ {
42
+ "url": "http://images.gotinder.com/user_id/84x84_image_1_id.jpg",
43
+ "height": 84,
44
+ "width": 84
45
+ }
46
+ ],
47
+ "fbId": "image_2_facebook_id",
48
+ "extension": "jpg",
49
+ "fileName": "image_1_id.jpg",
50
+ "main": true,
51
+ "ydistance_percent": 1,
52
+ "yoffset_percent": 0,
53
+ "xoffset_percent": 0.1235275,
54
+ "id": "image_1_id",
55
+ "xdistance_percent": 0.7529297
56
+ },
57
+ {
58
+ "url": "http://images.gotinder.com/user_id/image_2_id.jpg",
59
+ "processedFiles": [
60
+ {
61
+ "url": "http://images.gotinder.com/user_id/640x640_image_2_id.jpg",
62
+ "height": 640,
63
+ "width": 640
64
+ },
65
+ {
66
+ "url": "http://images.gotinder.com/user_id/320x320_image_2_id.jpg",
67
+ "height": 320,
68
+ "width": 320
69
+ },
70
+ {
71
+ "url": "http://images.gotinder.com/user_id/172x172_image_2_id.jpg",
72
+ "height": 172,
73
+ "width": 172
74
+ },
75
+ {
76
+ "url": "http://images.gotinder.com/user_id/84x84_image_2_id.jpg",
77
+ "height": 84,
78
+ "width": 84
79
+ }
80
+ ],
81
+ "fbId": "image_2_facebook_id",
82
+ "extension": "jpg",
83
+ "fileName": "image_2_id.jpg",
84
+ "main": false,
85
+ "ydistance_percent": 0.8473684,
86
+ "yoffset_percent": 0.005296052,
87
+ "xoffset_percent": 0,
88
+ "id": "image_2_id",
89
+ "xdistance_percent": 1
90
+ }
91
+ ],
92
+ "interested_in": [1],
93
+ "distance_filter": 13,
94
+ "discoverable": true
95
+ }
@@ -2,11 +2,165 @@
2
2
  "results": [
3
3
  {
4
4
  "_id": "user_1_id",
5
- "name": "user_1"
5
+ "bio": "user bio",
6
+ "birth_date": "1989-02-06T00:00:00.000Z",
7
+ "gender": 0,
8
+ "name": "User 1",
9
+ "ping_time": "2014-08-25T18:01:50.032Z",
10
+ "photos": [
11
+ {
12
+ "url": "http://images.gotinder.com/user_1_id/image_1_id.jpg",
13
+ "processedFiles": [
14
+ {
15
+ "url": "http://images.gotinder.com/user_1_id/640x640_image_1_id.jpg",
16
+ "height": 640,
17
+ "width": 640
18
+ },
19
+ {
20
+ "url": "http://images.gotinder.com/user_1_id/320x320_image_1_id.jpg",
21
+ "height": 320,
22
+ "width": 320
23
+ },
24
+ {
25
+ "url": "http://images.gotinder.com/user_1_id/172x172_image_1_id.jpg",
26
+ "height": 172,
27
+ "width": 172
28
+ },
29
+ {
30
+ "url": "http://images.gotinder.com/user_1_id/84x84_image_1_id.jpg",
31
+ "height": 84,
32
+ "width": 84
33
+ }
34
+ ],
35
+ "extension": "jpg",
36
+ "fileName": "image_1_id.jpg",
37
+ "main": true,
38
+ "ydistance_percent": 1,
39
+ "yoffset_percent": 0,
40
+ "xoffset_percent": 0.1235275,
41
+ "id": "image_1_id",
42
+ "xdistance_percent": 0.7529297
43
+ },
44
+ {
45
+ "url": "http://images.gotinder.com/user_1_id/image_2_id.jpg",
46
+ "processedFiles": [
47
+ {
48
+ "url": "http://images.gotinder.com/user_1_id/640x640_image_2_id.jpg",
49
+ "height": 640,
50
+ "width": 640
51
+ },
52
+ {
53
+ "url": "http://images.gotinder.com/user_1_id/320x320_image_2_id.jpg",
54
+ "height": 320,
55
+ "width": 320
56
+ },
57
+ {
58
+ "url": "http://images.gotinder.com/user_1_id/172x172_image_2_id.jpg",
59
+ "height": 172,
60
+ "width": 172
61
+ },
62
+ {
63
+ "url": "http://images.gotinder.com/user_1_id/84x84_image_2_id.jpg",
64
+ "height": 84,
65
+ "width": 84
66
+ }
67
+ ],
68
+ "extension": "jpg",
69
+ "fileName": "image_2_id.jpg",
70
+ "main": false,
71
+ "ydistance_percent": 0.8473684,
72
+ "yoffset_percent": 0.005296052,
73
+ "xoffset_percent": 0,
74
+ "id": "image_2_id",
75
+ "xdistance_percent": 1
76
+ }
77
+ ],
78
+ "birth_date_info": "fuzzy birthdate active, not displaying real birth_date",
79
+ "common_friends": ["common_friend_1_facebook_id", "common_friend_2_facebook_id"],
80
+ "common_like_count": 130,
81
+ "common_friend_count": 309,
82
+ "distance_mi": 1
6
83
  },
7
84
  {
8
85
  "_id": "user_2_id",
9
- "name": "user_2"
86
+ "bio": "user bio",
87
+ "birth_date": "1989-02-06T00:00:00.000Z",
88
+ "gender": 0,
89
+ "name": "User 2",
90
+ "ping_time": "2014-08-25T18:01:50.032Z",
91
+ "photos": [
92
+ {
93
+ "url": "http://images.gotinder.com/user_2_id/image_1_id.jpg",
94
+ "processedFiles": [
95
+ {
96
+ "url": "http://images.gotinder.com/user_2_id/640x640_image_1_id.jpg",
97
+ "height": 640,
98
+ "width": 640
99
+ },
100
+ {
101
+ "url": "http://images.gotinder.com/user_2_id/320x320_image_1_id.jpg",
102
+ "height": 320,
103
+ "width": 320
104
+ },
105
+ {
106
+ "url": "http://images.gotinder.com/user_2_id/172x172_image_1_id.jpg",
107
+ "height": 172,
108
+ "width": 172
109
+ },
110
+ {
111
+ "url": "http://images.gotinder.com/user_2_id/84x84_image_1_id.jpg",
112
+ "height": 84,
113
+ "width": 84
114
+ }
115
+ ],
116
+ "extension": "jpg",
117
+ "fileName": "image_1_id.jpg",
118
+ "main": true,
119
+ "ydistance_percent": 1,
120
+ "yoffset_percent": 0,
121
+ "xoffset_percent": 0.1235275,
122
+ "id": "image_1_id",
123
+ "xdistance_percent": 0.7529297
124
+ },
125
+ {
126
+ "url": "http://images.gotinder.com/user_2_id/image_2_id.jpg",
127
+ "processedFiles": [
128
+ {
129
+ "url": "http://images.gotinder.com/user_2_id/640x640_image_2_id.jpg",
130
+ "height": 640,
131
+ "width": 640
132
+ },
133
+ {
134
+ "url": "http://images.gotinder.com/user_2_id/320x320_image_2_id.jpg",
135
+ "height": 320,
136
+ "width": 320
137
+ },
138
+ {
139
+ "url": "http://images.gotinder.com/user_2_id/172x172_image_2_id.jpg",
140
+ "height": 172,
141
+ "width": 172
142
+ },
143
+ {
144
+ "url": "http://images.gotinder.com/user_2_id/84x84_image_2_id.jpg",
145
+ "height": 84,
146
+ "width": 84
147
+ }
148
+ ],
149
+ "extension": "jpg",
150
+ "fileName": "image_2_id.jpg",
151
+ "main": false,
152
+ "ydistance_percent": 0.8473684,
153
+ "yoffset_percent": 0.005296052,
154
+ "xoffset_percent": 0,
155
+ "id": "image_2_id",
156
+ "xdistance_percent": 1
157
+ }
158
+ ],
159
+ "birth_date_info": "fuzzy birthdate active, not displaying real birth_date",
160
+ "common_friends": ["common_friend_1_facebook_id", "common_friend_2_facebook_id"],
161
+ "common_like_count": 130,
162
+ "common_friend_count": 309,
163
+ "distance_mi": 1
10
164
  }
11
165
  ]
12
166
  }
@@ -1,3 +1,84 @@
1
1
  {
2
- "_id": "user_id"
2
+ "status": 200,
3
+ "results": {
4
+ "_id": "user_id",
5
+ "bio": "user bio",
6
+ "birth_date": "1989-02-06T00:00:00.000Z",
7
+ "gender": 0,
8
+ "name": "Name",
9
+ "ping_time": "2014-08-25T18:01:50.032Z",
10
+ "photos": [
11
+ {
12
+ "url": "http://images.gotinder.com/user_id/image_1_id.jpg",
13
+ "processedFiles": [
14
+ {
15
+ "url": "http://images.gotinder.com/user_id/640x640_image_1_id.jpg",
16
+ "height": 640,
17
+ "width": 640
18
+ },
19
+ {
20
+ "url": "http://images.gotinder.com/user_id/320x320_image_1_id.jpg",
21
+ "height": 320,
22
+ "width": 320
23
+ },
24
+ {
25
+ "url": "http://images.gotinder.com/user_id/172x172_image_1_id.jpg",
26
+ "height": 172,
27
+ "width": 172
28
+ },
29
+ {
30
+ "url": "http://images.gotinder.com/user_id/84x84_image_1_id.jpg",
31
+ "height": 84,
32
+ "width": 84
33
+ }
34
+ ],
35
+ "extension": "jpg",
36
+ "fileName": "image_1_id.jpg",
37
+ "main": true,
38
+ "ydistance_percent": 1,
39
+ "yoffset_percent": 0,
40
+ "xoffset_percent": 0.1235275,
41
+ "id": "image_1_id",
42
+ "xdistance_percent": 0.7529297
43
+ },
44
+ {
45
+ "url": "http://images.gotinder.com/user_id/image_2_id.jpg",
46
+ "processedFiles": [
47
+ {
48
+ "url": "http://images.gotinder.com/user_id/640x640_image_2_id.jpg",
49
+ "height": 640,
50
+ "width": 640
51
+ },
52
+ {
53
+ "url": "http://images.gotinder.com/user_id/320x320_image_2_id.jpg",
54
+ "height": 320,
55
+ "width": 320
56
+ },
57
+ {
58
+ "url": "http://images.gotinder.com/user_id/172x172_image_2_id.jpg",
59
+ "height": 172,
60
+ "width": 172
61
+ },
62
+ {
63
+ "url": "http://images.gotinder.com/user_id/84x84_image_2_id.jpg",
64
+ "height": 84,
65
+ "width": 84
66
+ }
67
+ ],
68
+ "extension": "jpg",
69
+ "fileName": "image_2_id.jpg",
70
+ "main": false,
71
+ "ydistance_percent": 0.8473684,
72
+ "yoffset_percent": 0.005296052,
73
+ "xoffset_percent": 0,
74
+ "id": "image_2_id",
75
+ "xdistance_percent": 1
76
+ }
77
+ ],
78
+ "birth_date_info": "fuzzy birthdate active, not displaying real birth_date",
79
+ "common_friends": ["common_friend_1_facebook_id", "common_friend_2_facebook_id"],
80
+ "common_like_count": 130,
81
+ "common_friend_count": 309,
82
+ "distance_mi": 1
83
+ }
3
84
  }
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Tinderbot::Tinder::Models::User do
4
+ describe '#build_from_tinder_json' do
5
+ let(:user_tinder_json) { JSON.parse(open('spec/fixtures/user.json').read)['results'] }
6
+
7
+ subject { Tinderbot::Tinder::Models::User.build_from_tinder_json user_tinder_json }
8
+
9
+ it { expect(subject.original_tinder_json).to eq user_tinder_json }
10
+ it { expect(subject.id).to eq user_tinder_json['_id'] }
11
+ it { expect(subject.name).to eq user_tinder_json['name'] }
12
+ it { expect(subject.bio).to eq user_tinder_json['bio'] }
13
+ it { expect(subject.birth_date).to eq Date.parse(user_tinder_json['birth_date']) }
14
+ it { expect(subject.photo_urls).to eq %w(http://images.gotinder.com/user_id/image_1_id.jpg http://images.gotinder.com/user_id/image_2_id.jpg) }
15
+
16
+ context 'user is a male' do
17
+ it { expect(subject.gender).to eq :male }
18
+ end
19
+
20
+ context 'user is a female' do
21
+ before { user_tinder_json['gender'] = 1 }
22
+ it { expect(subject.gender).to eq :female }
23
+ end
24
+ end
25
+ end
@@ -9,33 +9,33 @@ describe Tinderbot::Tinder::Bot do
9
9
  end
10
10
 
11
11
  describe '.like_recommended_people' do
12
- let(:recommended_people_results) { JSON.parse(open('spec/fixtures/recommended_users.json').read)['results'] }
12
+ let(:recommended_users) { JSON.parse(open('spec/fixtures/recommended_users.json').read)['results'].each { |user| Tinderbot::Tinder::Models::User.build_from_tinder_json user } }
13
13
 
14
14
  context 'there is no recommended people' do
15
15
  before { expect_any_instance_of(Tinderbot::Tinder::Client).to receive(:recommended_users).and_return(nil) }
16
16
 
17
17
  before { expect_any_instance_of(Tinderbot::Tinder::Client).not_to receive(:like_all) }
18
18
 
19
- it { tinder_bot.like_recommended_people }
19
+ it { tinder_bot.like_recommended_users }
20
20
  end
21
21
 
22
22
  context 'there is one set of recommended people' do
23
- before { expect_any_instance_of(Tinderbot::Tinder::Client).to receive(:recommended_users).and_return(recommended_people_results) }
23
+ before { expect_any_instance_of(Tinderbot::Tinder::Client).to receive(:recommended_users).and_return(recommended_users) }
24
24
  before { expect_any_instance_of(Tinderbot::Tinder::Client).to receive(:recommended_users).and_return(nil) }
25
25
 
26
- before { expect_any_instance_of(Tinderbot::Tinder::Client).not_to receive(:like_all).with(recommended_people_results.map { |r| r['_id'] }).exactly(1).times }
26
+ before { recommended_users.each { |user| expect_any_instance_of(Tinderbot::Tinder::Client).not_to receive(:like).with(user).exactly(1).times } }
27
27
 
28
- it { tinder_bot.like_recommended_people }
28
+ it { tinder_bot.like_recommended_users }
29
29
  end
30
30
 
31
31
  context 'there is two sets of recommended people' do
32
- before { expect_any_instance_of(Tinderbot::Tinder::Client).to receive(:recommended_users).and_return(recommended_people_results) }
33
- before { expect_any_instance_of(Tinderbot::Tinder::Client).to receive(:recommended_users).and_return(recommended_people_results) }
32
+ before { expect_any_instance_of(Tinderbot::Tinder::Client).to receive(:recommended_users).and_return(recommended_users) }
33
+ before { expect_any_instance_of(Tinderbot::Tinder::Client).to receive(:recommended_users).and_return(recommended_users) }
34
34
  before { expect_any_instance_of(Tinderbot::Tinder::Client).to receive(:recommended_users).and_return(nil) }
35
35
 
36
- before { expect_any_instance_of(Tinderbot::Tinder::Client).not_to receive(:like_all).with(recommended_people_results.map { |r| r['_id'] }).exactly(2).times }
36
+ before { recommended_users.each { |user| expect_any_instance_of(Tinderbot::Tinder::Client).not_to receive(:like).with(user).exactly(2).times } }
37
37
 
38
- it { tinder_bot.like_recommended_people }
38
+ it { tinder_bot.like_recommended_users }
39
39
  end
40
40
  end
41
41
  end
@@ -11,26 +11,26 @@ describe Tinderbot::Tinder::Client do
11
11
  end
12
12
 
13
13
  describe '.me' do
14
- let(:user_response) { open('spec/fixtures/recommended_users.json').read }
14
+ let(:me_tinder_raw_json) { open('spec/fixtures/me.json').read }
15
15
 
16
16
  before { expect(connection).to receive(:get).with('profile').and_return(connection) }
17
- before { expect(connection).to receive(:body).and_return(user_response) }
17
+ before { expect(connection).to receive(:body).and_return(me_tinder_raw_json) }
18
18
 
19
19
  subject { tinder_client.me }
20
20
 
21
- it { should eq JSON.parse(user_response) }
21
+ it { should eql? Tinderbot::Tinder::Models::User.build_from_tinder_json(JSON.parse(me_tinder_raw_json)) }
22
22
  end
23
23
 
24
24
  describe '.user' do
25
25
  let(:user_id) { 'user_id' }
26
- let(:user_response) { open('spec/fixtures/user.json').read }
26
+ let(:user_tinder_raw_json) { open('spec/fixtures/user.json').read }
27
27
 
28
28
  before { expect(connection).to receive(:get).with("user/#{user_id}").and_return(connection) }
29
- before { expect(connection).to receive(:body).and_return(user_response) }
29
+ before { expect(connection).to receive(:body).and_return(user_tinder_raw_json) }
30
30
 
31
31
  subject { tinder_client.user user_id }
32
32
 
33
- it { should eq JSON.parse(user_response) }
33
+ it { should eql? Tinderbot::Tinder::Models::User.build_from_tinder_json(JSON.parse(user_tinder_raw_json)['results']) }
34
34
  end
35
35
 
36
36
  describe '.updates' do
@@ -45,65 +45,51 @@ describe Tinderbot::Tinder::Client do
45
45
  end
46
46
 
47
47
  describe '.recommended_users' do
48
- let(:recommended_people_response) { open('spec/fixtures/recommended_users.json').read }
48
+ let(:recommended_users_tinder_raw_json) { open('spec/fixtures/recommended_users.json').read }
49
49
 
50
50
  before { expect(connection).to receive(:post).with('user/recs').and_return(connection) }
51
- before { expect(connection).to receive(:body).and_return(recommended_people_response) }
51
+ before { expect(connection).to receive(:body).and_return(recommended_users_tinder_raw_json) }
52
52
 
53
53
  subject { tinder_client.recommended_users }
54
54
 
55
- it { should eq JSON.parse(recommended_people_response)['results'] }
55
+ it { should eql? JSON.parse(recommended_users_tinder_raw_json)['results'].map { |r| Tinderbot::Tinder::Models::User.build_from_tinder_json r } }
56
56
  end
57
57
 
58
58
  describe '.like' do
59
- let(:user_id) { 'user_id' }
60
-
61
- before { expect(connection).to receive(:get).with("like/#{user_id}") }
62
-
63
- it { tinder_client.like user_id }
64
- end
65
-
66
- describe '.like_all' do
67
- context 'there is no people' do
68
- let(:people_ids) { [] }
59
+ context 'from user id' do
60
+ let(:user_id) { 'user_id' }
69
61
 
70
- before { expect_any_instance_of(Tinderbot::Tinder::Client).not_to receive(:like) }
62
+ before { expect(connection).to receive(:get).with("like/#{user_id}") }
71
63
 
72
- it { tinder_client.like_all people_ids }
64
+ it { tinder_client.like user_id }
73
65
  end
74
66
 
75
- context 'there two people' do
76
- let(:people_ids) { %w(user_1_id user_2_id) }
67
+ context 'from user model' do
68
+ let(:user_tinder_json) { JSON.parse(open('spec/fixtures/user.json').read)['results'] }
69
+ let(:user) { Tinderbot::Tinder::Models::User.build_from_tinder_json user_tinder_json }
77
70
 
78
- before { people_ids.each { |user_id| expect_any_instance_of(Tinderbot::Tinder::Client).to receive(:like).with(user_id) } }
71
+ before { expect(connection).to receive(:get).with("like/#{user.id}") }
79
72
 
80
- it { tinder_client.like_all people_ids }
73
+ it { tinder_client.like user }
81
74
  end
82
75
  end
83
76
 
84
77
  describe '.dislike' do
85
- let(:user_id) { 'user_id' }
86
-
87
- before { expect(connection).to receive(:get).with("pass/#{user_id}") }
88
-
89
- it { tinder_client.dislike user_id }
90
- end
91
-
92
- describe '.dislike_all' do
93
- context 'there is no people' do
94
- let(:people_ids) { [] }
78
+ context 'from user id' do
79
+ let(:user_id) { 'user_id' }
95
80
 
96
- before { expect_any_instance_of(Tinderbot::Tinder::Client).not_to receive(:dislike) }
81
+ before { expect(connection).to receive(:get).with("pass/#{user_id}") }
97
82
 
98
- it { tinder_client.dislike_all people_ids }
83
+ it { tinder_client.dislike user_id }
99
84
  end
100
85
 
101
- context 'there two people' do
102
- let(:people_ids) { %w(user_1_id user_2_id) }
86
+ context 'from user model' do
87
+ let(:user_tinder_json) { JSON.parse(open('spec/fixtures/user.json').read)['results'] }
88
+ let(:user) { Tinderbot::Tinder::Models::User.build_from_tinder_json user_tinder_json }
103
89
 
104
- before { people_ids.each { |user_id| expect_any_instance_of(Tinderbot::Tinder::Client).to receive(:dislike).with(user_id) } }
90
+ before { expect(connection).to receive(:get).with("pass/#{user.id}") }
105
91
 
106
- it { tinder_client.dislike_all people_ids }
92
+ it { tinder_client.dislike user }
107
93
  end
108
94
  end
109
95
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tinderbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Venezia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-25 00:00:00.000000000 Z
11
+ date: 2014-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -142,10 +142,13 @@ files:
142
142
  - lib/tinderbot/facebook.rb
143
143
  - lib/tinderbot/tinder/bot.rb
144
144
  - lib/tinderbot/tinder/client.rb
145
+ - lib/tinderbot/tinder/models/user.rb
145
146
  - lib/tinderbot/version.rb
147
+ - spec/fixtures/me.json
146
148
  - spec/fixtures/recommended_users.json
147
149
  - spec/fixtures/updates.json
148
150
  - spec/fixtures/user.json
151
+ - spec/models/user_spec.rb
149
152
  - spec/spec_helper.rb
150
153
  - spec/tinder/bot_spec.rb
151
154
  - spec/tinder/client_spec.rb
@@ -175,9 +178,11 @@ signing_key:
175
178
  specification_version: 4
176
179
  summary: Ruby wrapper for the Tinder API and automatic liker bot.
177
180
  test_files:
181
+ - spec/fixtures/me.json
178
182
  - spec/fixtures/recommended_users.json
179
183
  - spec/fixtures/updates.json
180
184
  - spec/fixtures/user.json
185
+ - spec/models/user_spec.rb
181
186
  - spec/spec_helper.rb
182
187
  - spec/tinder/bot_spec.rb
183
188
  - spec/tinder/client_spec.rb