tinderbot 0.0.8 → 0.0.9

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: 455a2bcb49a008f8de8e8d7663b5a7ee111a3afe
4
- data.tar.gz: a2f55072970526bb6663e4ee0dea2cbcf47d9b79
3
+ metadata.gz: b0b1dad2f25741d25506da64708cc3f69d28d0ca
4
+ data.tar.gz: 0fe61ce02894fd540ef5c1d11d18868beee4ff3a
5
5
  SHA512:
6
- metadata.gz: 98d4fcf63c78ba51bda08f98adae38bea7aba9277bd28b69b94894241539238677aeca6c6bbcbc7a3f295955ca30dcdf94b4633e621a4d74232666da0e00e46a
7
- data.tar.gz: f15103549046be9bb66dbafb90ad11ef2e73d68af61768a5db731418dcd7439c552532078bbf811ff45141da97839bccddbaf9417ecd6d129fb58ffba7be6c75
6
+ metadata.gz: 823af092d67c3dcf228d287069b18b46278490dde1db484f205389ba303e007dff2aa373d062638a8f5229075ac97e234bd7567fc6d515c47b75b29f5a9e7396
7
+ data.tar.gz: ce02442f5e268715b347cbffe7d4399a72a648686048ed89fc0fee78dcb1184ef7177a35d208c8bdeef35055a5be2feb04b50e1fa62a7a343cb5355ff56f771b
data/README.md CHANGED
@@ -69,6 +69,8 @@ tinder_client.updates #=> {...} original json from tinder's API
69
69
 
70
70
  tinder_client.send_message(user_id, message)
71
71
 
72
+ tinder_client.update_location('40.7313029,-73.9884189')
73
+
72
74
  # you can provide a user instance or a user id to like or dislike users
73
75
  tinder_client.like(user)
74
76
  tinder_client.like(user.id)
@@ -92,6 +94,7 @@ Commands:
92
94
  tinderbot dislike USER_ID # Dislike user
93
95
  tinderbot help [COMMAND] # Describe available commands or one specific command
94
96
  tinderbot like USER_ID # Like user
97
+ tinderbot location # Update location using latitude and longitude. e.g. tinderbot location 40.7313029,-73.9884189
95
98
  tinderbot profile # Get your profile data
96
99
  tinderbot recommended # Get recommended users
97
100
  tinderbot send USER_ID MESSAGE # Send message to user
@@ -47,6 +47,12 @@ module Tinderbot
47
47
  puts tinder_client.send_message user_id, message
48
48
  end
49
49
 
50
+ desc 'location', 'Update location using latitude and longitude. e.g. tinderbot location 40.7313029,-73.9884189'
51
+ def location(location)
52
+ tinder_client = sign_in
53
+ tinder_client.update_location(location)
54
+ end
55
+
50
56
  desc 'autolike', 'Automatically like recommended people (Stops when there is no more people to like)'
51
57
  def autolike
52
58
  tinder_client = sign_in
@@ -0,0 +1,4 @@
1
+ module Tinderbot
2
+ class Error < Exception
3
+ end
4
+ end
@@ -61,6 +61,23 @@ module Tinderbot
61
61
  puts "Sent message to #{user_id}" if @logs_enabled
62
62
  end
63
63
 
64
+ def update_location(location)
65
+ latitude = location.split(',')[0]
66
+ longitude = location.split(',')[1]
67
+
68
+ if latitude && longitude
69
+ result = JSON.parse(@connection.post('user/ping', {lat: latitude, lon: longitude}).body)
70
+
71
+ if result['status'] == 200
72
+ puts "Location has been updated to #{location}" if @logs_enabled
73
+ else
74
+ puts result['error'] if @logs_enabled
75
+ end
76
+ else
77
+ raise Tinderbot::Error, 'Invalid location provided'
78
+ end
79
+ end
80
+
64
81
  protected
65
82
 
66
83
  def like_from_user_id(user_id)
@@ -15,6 +15,10 @@ module Tinderbot
15
15
  user.photo_urls = tinder_json['photos'].map { |t| t['url'] }
16
16
  user
17
17
  end
18
+
19
+ def to_yaml_properties
20
+ instance_variables - [:@original_tinder_json]
21
+ end
18
22
  end
19
23
  end
20
24
  end
@@ -1,3 +1,3 @@
1
1
  module Tinderbot
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end
@@ -22,4 +22,13 @@ describe Tinderbot::Tinder::Models::User do
22
22
  it { expect(subject.gender).to eq :female }
23
23
  end
24
24
  end
25
+
26
+ describe '.to_yaml' do
27
+ let(:user_tinder_json) { JSON.parse(open('spec/fixtures/user.json').read)['results'] }
28
+ let(:user) { Tinderbot::Tinder::Models::User.build_from_tinder_json user_tinder_json }
29
+
30
+ subject { user.to_yaml }
31
+
32
+ it { should_not match('original_tinder_json') }
33
+ end
25
34
  end
@@ -101,4 +101,26 @@ describe Tinderbot::Tinder::Client do
101
101
 
102
102
  it { tinder_client.send_message user_id, message }
103
103
  end
104
+
105
+ describe '.update_location' do
106
+ context 'location is correct' do
107
+ let(:location) { '40.7313029,-73.9884189' }
108
+ let(:latitude) { location.split(',')[0] }
109
+ let(:longitude) { location.split(',')[1] }
110
+ let(:response) { '{"status":200}' }
111
+
112
+ before { expect(connection).to receive(:post).with('user/ping', {lat: latitude, lon: longitude}).and_return(connection) }
113
+ before { expect(connection).to receive(:body).and_return(response) }
114
+
115
+ it { tinder_client.update_location location }
116
+ end
117
+
118
+ context 'one location is missing' do
119
+ let(:location) { '40.7313029' }
120
+
121
+ before { expect(connection).not_to receive(:post) }
122
+
123
+ it { expect(-> { tinder_client.update_location location }).to raise_error(Tinderbot::Error) }
124
+ end
125
+ end
104
126
  end
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.8
4
+ version: 0.0.9
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-26 00:00:00.000000000 Z
11
+ date: 2014-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -139,6 +139,7 @@ files:
139
139
  - bin/tinderbot
140
140
  - lib/tinderbot.rb
141
141
  - lib/tinderbot/cli/application.rb
142
+ - lib/tinderbot/error.rb
142
143
  - lib/tinderbot/facebook.rb
143
144
  - lib/tinderbot/tinder/bot.rb
144
145
  - lib/tinderbot/tinder/client.rb