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 +4 -4
- data/README.md +22 -9
- data/lib/tinderbot/cli/application.rb +7 -7
- data/lib/tinderbot/tinder/bot.rb +5 -6
- data/lib/tinderbot/tinder/client.rb +28 -17
- data/lib/tinderbot/tinder/models/user.rb +21 -0
- data/lib/tinderbot/version.rb +1 -1
- data/spec/fixtures/me.json +95 -0
- data/spec/fixtures/recommended_users.json +156 -2
- data/spec/fixtures/user.json +82 -1
- data/spec/models/user_spec.rb +25 -0
- data/spec/tinder/bot_spec.rb +9 -9
- data/spec/tinder/client_spec.rb +27 -41
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98fa0c94eb84588a78f917644c41c5a53cb46bed
|
4
|
+
data.tar.gz: 6a9a980b9d191d4b85fa7921d80aaa16264fdbd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
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.
|
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
|
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
|
-
|
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
|
-
|
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.
|
56
|
+
tinder_bot.like_recommended_users
|
57
57
|
end
|
58
58
|
|
59
59
|
private
|
data/lib/tinderbot/tinder/bot.rb
CHANGED
@@ -7,12 +7,11 @@ module Tinderbot
|
|
7
7
|
@client = client
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
|
12
|
-
while
|
13
|
-
|
14
|
-
@client.
|
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(
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
54
|
-
|
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
|
data/lib/tinderbot/version.rb
CHANGED
@@ -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
|
-
"
|
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
|
-
"
|
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
|
}
|
data/spec/fixtures/user.json
CHANGED
@@ -1,3 +1,84 @@
|
|
1
1
|
{
|
2
|
-
"
|
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
|
data/spec/tinder/bot_spec.rb
CHANGED
@@ -9,33 +9,33 @@ describe Tinderbot::Tinder::Bot do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
describe '.like_recommended_people' do
|
12
|
-
let(:
|
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.
|
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(
|
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(:
|
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.
|
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(
|
33
|
-
before { expect_any_instance_of(Tinderbot::Tinder::Client).to receive(:recommended_users).and_return(
|
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(:
|
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.
|
38
|
+
it { tinder_bot.like_recommended_users }
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
data/spec/tinder/client_spec.rb
CHANGED
@@ -11,26 +11,26 @@ describe Tinderbot::Tinder::Client do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
describe '.me' do
|
14
|
-
let(:
|
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(
|
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
|
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(:
|
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(
|
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
|
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(:
|
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(
|
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
|
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
|
-
|
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 {
|
62
|
+
before { expect(connection).to receive(:get).with("like/#{user_id}") }
|
71
63
|
|
72
|
-
it { tinder_client.
|
64
|
+
it { tinder_client.like user_id }
|
73
65
|
end
|
74
66
|
|
75
|
-
context '
|
76
|
-
let(:
|
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 {
|
71
|
+
before { expect(connection).to receive(:get).with("like/#{user.id}") }
|
79
72
|
|
80
|
-
it { tinder_client.
|
73
|
+
it { tinder_client.like user }
|
81
74
|
end
|
82
75
|
end
|
83
76
|
|
84
77
|
describe '.dislike' do
|
85
|
-
|
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 {
|
81
|
+
before { expect(connection).to receive(:get).with("pass/#{user_id}") }
|
97
82
|
|
98
|
-
it { tinder_client.
|
83
|
+
it { tinder_client.dislike user_id }
|
99
84
|
end
|
100
85
|
|
101
|
-
context '
|
102
|
-
let(:
|
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 {
|
90
|
+
before { expect(connection).to receive(:get).with("pass/#{user.id}") }
|
105
91
|
|
106
|
-
it { tinder_client.
|
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.
|
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-
|
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
|