tindy 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b7e5abcd6bbc78d44620911bac0c9e7f8be3f16d20f7a87be5e6ce48cfe40e44
4
+ data.tar.gz: be9a1cb65943b89dd829971626ff7ec5bdaacd70cae159df54a2c607fbefe407
5
+ SHA512:
6
+ metadata.gz: e169e1be786ae42c7bca863651c0eac6edf41ccf62bd448b21c8e9214b39399f4610e9ab19bc6572f879d8ab2c572df40e8b9b0fd672dab8d7c4db347ebccaf4
7
+ data.tar.gz: e26f13a30d8a9e3a8ecff462a36ba1eb40a0a08835921b4e5508932bf62050e733ef2572e1a3419a5346fbf3b884d240d9841c72bce304751be16d2e4868ae63
data/.gitignore ADDED
@@ -0,0 +1,73 @@
1
+
2
+ # Created by https://www.gitignore.io/api/ruby
3
+ # Edit at https://www.gitignore.io/?templates=ruby
4
+
5
+ ### Ruby ###
6
+ *.gem
7
+ *.rbc
8
+ /.config
9
+ /coverage/
10
+ /InstalledFiles
11
+ /pkg/
12
+ /spec/reports/
13
+ /spec/examples.txt
14
+ /test/tmp/
15
+ /test/version_tmp/
16
+ /tmp/
17
+
18
+ # Used by dotenv library to load environment variables.
19
+ # .env
20
+
21
+ ## Specific to RubyMotion:
22
+ .dat*
23
+ .repl_history
24
+ build/
25
+ *.bridgesupport
26
+ build-iPhoneOS/
27
+ build-iPhoneSimulator/
28
+
29
+ ## Specific to RubyMotion (use of CocoaPods):
30
+ #
31
+ # We recommend against adding the Pods directory to your .gitignore. However
32
+ # you should judge for yourself, the pros and cons are mentioned at:
33
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
34
+ #
35
+ # vendor/Pods/
36
+
37
+ ## Documentation cache and generated files:
38
+ /.yardoc/
39
+ /_yardoc/
40
+ /doc/
41
+ /rdoc/
42
+
43
+ ## Environment normalization:
44
+ /.bundle/
45
+ /vendor/bundle
46
+ /lib/bundler/man/
47
+
48
+ # for a library or gem, you might want to ignore these files since the code is
49
+ # intended to run in multiple environments; otherwise, check them in:
50
+ # Gemfile.lock
51
+ # .ruby-version
52
+ # .ruby-gemset
53
+
54
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
55
+ .rvmrc
56
+
57
+ # End of https://www.gitignore.io/api/ruby
58
+
59
+ # Created by https://www.gitignore.io/api/visualstudiocode
60
+ # Edit at https://www.gitignore.io/?templates=visualstudiocode
61
+
62
+ ### VisualStudioCode ###
63
+ .vscode/*
64
+ !.vscode/settings.json
65
+ !.vscode/tasks.json
66
+ !.vscode/launch.json
67
+ !.vscode/extensions.json
68
+
69
+ ### VisualStudioCode Patch ###
70
+ # Ignore all local history of files
71
+ .history
72
+
73
+ # End of https://www.gitignore.io/api/visualstudiocode
data/.rubocop.yml ADDED
@@ -0,0 +1,18 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'bin/*'
4
+
5
+ Metrics/LineLength:
6
+ Max: 140
7
+
8
+ Metrics/MethodLength:
9
+ Max: 30
10
+
11
+ Style/Documentation:
12
+ Enabled: false
13
+
14
+ Layout/EmptyLinesAroundAccessModifier:
15
+ Enabled: false
16
+
17
+ Style/SymbolArray:
18
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gem 'httparty'
6
+ gem 'retries'
7
+
8
+ group :test do
9
+ gem 'rake'
10
+ gem 'turn'
11
+ gem 'vcr'
12
+ gem 'webmock'
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,43 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.5.2)
5
+ public_suffix (>= 2.0.2, < 4.0)
6
+ ansi (1.5.0)
7
+ crack (0.4.3)
8
+ safe_yaml (~> 1.0.0)
9
+ hashdiff (0.3.7)
10
+ httparty (0.16.3)
11
+ mime-types (~> 3.0)
12
+ multi_xml (>= 0.5.2)
13
+ mime-types (3.2.2)
14
+ mime-types-data (~> 3.2015)
15
+ mime-types-data (3.2018.0812)
16
+ minitest (4.7.5)
17
+ multi_xml (0.6.0)
18
+ public_suffix (3.0.3)
19
+ rake (12.3.1)
20
+ retries (0.0.5)
21
+ safe_yaml (1.0.4)
22
+ turn (0.9.7)
23
+ ansi
24
+ minitest (~> 4)
25
+ vcr (4.0.0)
26
+ webmock (3.4.2)
27
+ addressable (>= 2.3.6)
28
+ crack (>= 0.3.2)
29
+ hashdiff
30
+
31
+ PLATFORMS
32
+ ruby
33
+
34
+ DEPENDENCIES
35
+ httparty
36
+ rake
37
+ retries
38
+ turn
39
+ vcr
40
+ webmock
41
+
42
+ BUNDLED WITH
43
+ 1.17.1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Daniel Gilchrist
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # tindy
2
+ Ruby client for Tinder (using [this doc](https://gist.github.com/rtt/10403467) as a reference)
3
+ (this is currently a WIP)
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler/gem_tasks'
2
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tindy"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,105 @@
1
+ module Tindy
2
+ class Client
3
+ include HTTParty
4
+
5
+ BASE_ENDPOINT = 'https://api.gotinder.com'.freeze
6
+ TINDER_APP_ID = '464891386855067'.freeze
7
+
8
+ REPORT_OPTIONS = {
9
+ spam: 1,
10
+ offensive: 2,
11
+ inappropriate: 2
12
+ }.freeze
13
+
14
+ GENDER_OPTIONS = {
15
+ male: 0,
16
+ female: 1
17
+ }.freeze
18
+
19
+ def initialize(fb_token)
20
+ @token = authenticate(fb_token)
21
+ end
22
+
23
+ def like(id)
24
+ post("/like/#{id}")
25
+ end
26
+
27
+ def pass
28
+ post("/pass/#{id}")
29
+ end
30
+
31
+ def updates
32
+ post('/updates', { last_activity_date: '' }.to_json)
33
+ end
34
+
35
+ def recommendations
36
+ post('/recs')
37
+ end
38
+
39
+ def report_user(id, cause)
40
+ raise 'Incorrect cause provided (:spam, :offensive/:inappropriate)' unless REPORT_OPTIONS.key?(cause)
41
+
42
+ post("/report/#{id}", { cause: REPORT_OPTIONS.dig(cause) }.to_json)
43
+ end
44
+
45
+ def send_message(id, message)
46
+ post("/matches/#{id}", { message: message }.to_json)
47
+ end
48
+
49
+ def update_location(latitude, longitude)
50
+ post('/user/ping', { lat: latitude, lon: longitude }.to_json)
51
+ end
52
+
53
+ def update_gender(gender)
54
+ raise 'Incorrect gender provided (:male or :female)' unless GENDER_OPTIONS.key?(gender)
55
+
56
+ update_profile(gender: GENDER_OPTIONS.dig(gender))
57
+ end
58
+
59
+ def update_min_age(age)
60
+ update_profile(age_filter_min: age)
61
+ end
62
+
63
+ def update_max_age(age)
64
+ update_profile(age_filter_max: age)
65
+ end
66
+
67
+ def update_distance(distance)
68
+ update_profile(distance_filter: distance)
69
+ end
70
+
71
+ def update_profile(options = {})
72
+ post('/profile', options.to_json)
73
+ end
74
+
75
+ private
76
+ def authenticate(fb_token)
77
+ auth_obj = {
78
+ facebook_token: fb_token,
79
+ facebook_id: TINDER_APP_ID
80
+ }.to_json
81
+
82
+ res = post('/auth', auth_obj)
83
+
84
+ raise "Failed to authenticate. Response body: #{res.body}" if res.code != 200
85
+
86
+ JSON.parse(res.body).dig('token')
87
+ end
88
+
89
+ def post(path, body = '')
90
+ res = with_retries { self.class.post(BASE_ENDPOINT + path, headers: headers, body: body) }
91
+ res.parsed_response
92
+ end
93
+
94
+ def headers
95
+ headers = {}
96
+
97
+ headers['X-Auth-Token'] = @token if defined?(@token)
98
+ headers['content-type'] = 'application/json'
99
+ headers['User-agent'] = 'Tinder/4.0.9 (iPhone; iOS 8.1.1; Scale/2.00)'
100
+ headers['platform'] = 'ios'
101
+
102
+ headers
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,3 @@
1
+ module Tindy
2
+ VERSION = '0.1.0'.freeze
3
+ end
data/lib/tindy.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'tindy/version'
2
+ require 'httparty'
3
+ require 'retries'
4
+
5
+ Dir[File.dirname(__FILE__) + '/tindy/*.rb'].each { |file| require file }
6
+
7
+ module Tindy
8
+ class Error < StandardError; end
9
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tindy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - DanielGilchrist
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-12-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: A simple Ruby client for Tinder
42
+ email:
43
+ - danniieelg@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".rubocop.yml"
50
+ - Gemfile
51
+ - Gemfile.lock
52
+ - LICENSE
53
+ - README.md
54
+ - Rakefile
55
+ - bin/console
56
+ - bin/setup
57
+ - lib/tindy.rb
58
+ - lib/tindy/client.rb
59
+ - lib/tindy/version.rb
60
+ homepage: https://github.com/DanielGilchrist/tindy
61
+ licenses: []
62
+ metadata:
63
+ allowed_push_host: https://rubygems.org/
64
+ homepage_uri: https://github.com/DanielGilchrist/tindy
65
+ source_code_uri: https://github.com/DanielGilchrist/tindy
66
+ changelog_uri: https://github.com/DanielGilchrist/tindy
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.7.6
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: A simple Ruby client for Tinder
87
+ test_files: []