Class: Tinder::Util
- Inherits:
-
Object
- Object
- Tinder::Util
- Defined in:
- lib/tinder/util.rb
Constant Summary collapse
- HEADERS =
{ 'Content-Type': 'application/json', 'User-agent': 'Tinder/7.5.3 (iPhone; iOS 10.3.2; Scale/2.00)' }
Class Method Summary collapse
- .get(endpoint, payload, headers = {}) ⇒ Object
- .post(endpoint, payload, headers = {}) ⇒ Object
- .request(method, endpoint, payload, headers) ⇒ Object
Class Method Details
.get(endpoint, payload, headers = {}) ⇒ Object
28 29 30 |
# File 'lib/tinder/util.rb', line 28 def get(endpoint, payload, headers = {}) request(:get, endpoint, payload, headers) end |
.post(endpoint, payload, headers = {}) ⇒ Object
32 33 34 |
# File 'lib/tinder/util.rb', line 32 def post(endpoint, payload, headers = {}) request(:post, endpoint, payload, headers) end |
.request(method, endpoint, payload, headers) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/tinder/util.rb', line 9 def request(method, endpoint, payload, headers) uri = URI.parse('https://api.gotinder.com' + endpoint) https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true req = if method == :post Net::HTTP::Post.new(uri.request_uri) else Net::HTTP::Get.new(uri.request_uri) end HEADERS.merge(headers).each {|k, v| req[k] = v} req.body = payload.to_json https.request(req) end |