module Tinderb::Request
Public Instance Methods
delete(path, params = {})
click to toggle source
# File lib/tinderb/request.rb, line 37 def delete(path, params = {}) request(:delete, path, params) end
get(path, params = {})
click to toggle source
# File lib/tinderb/request.rb, line 25 def get(path, params = {}) request(:get, path, params) end
post(path, params = {})
click to toggle source
# File lib/tinderb/request.rb, line 29 def post(path, params = {}) request(:post, path, params) end
put(path, params = {})
click to toggle source
# File lib/tinderb/request.rb, line 33 def put(path, params = {}) request(:put, path, params) end
Private Instance Methods
assigne_header(conn)
click to toggle source
# File lib/tinderb/request.rb, line 62 def assigne_header(conn) conn.headers['User-agent'] ||= 'Tinder/7.5.3 (iPhone; iOS 10.3.2; Scale/2.00)' conn.headers['Content-type'] ||= 'application/json' end
connection()
click to toggle source
# File lib/tinderb/request.rb, line 49 def connection return @connection if instance_variable_defined?(:@connection) && @connection.headers.key?('X-Auth-Token') @connection = Faraday.new(Tinderb::API_ENDPOINT) do |conn| conn.request :tinderb_oauth2, @token if @token conn.request :url_encoded conn.request :json assigne_header(conn) conn.response :json, content_type: /\bjson$/ conn.adapter Faraday.default_adapter end end
request(method, path, params = {})
click to toggle source
# File lib/tinderb/request.rb, line 43 def request(method, path, params = {}) connection.send(method.to_sym, path, params).env rescue Faraday::Error::ClientError raise 'client error' end