Module: Sqoot::Request
- Included in:
- Client
- Defined in:
- lib/sqoot/request.rb
Instance Method Summary collapse
- #convert_params(path, data = {}) ⇒ Object
- #get(path, options) ⇒ Object
- #request(method, path, options) ⇒ Object
Instance Method Details
#convert_params(path, data = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/sqoot/request.rb', line 8 def convert_params(path, data={}) auth_endpoints = ['commissions', 'clicks'] if auth_endpoints.include? path.split('/')[2] data['authentication_token'] = authentication_token else data['affiliate_token'] = affiliate_token end data end |
#get(path, options) ⇒ Object
4 5 6 |
# File 'lib/sqoot/request.rb', line 4 def get(path, ) request(:get, path, convert_params(path, )) end |
#request(method, path, options) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sqoot/request.rb', line 21 def request(method, path, ) response = connection.send(method) do |request| case method when :delete, :get request.url(path, ) when :post, :put request.path = path request.body = MultiJson.encode() unless .empty? end end response.body end |