class Anego::Client
Constants
- API_ENDPOINT
Public Class Methods
new(api_key: nil)
click to toggle source
# File lib/anego/client.rb, line 5 def initialize(api_key: nil) @api_key = api_key end
Public Instance Methods
accounts()
click to toggle source
# File lib/anego/client.rb, line 9 def accounts request :get, "/accounts" end
product_details(market, product_id)
click to toggle source
# File lib/anego/client.rb, line 17 def product_details(market, product_id) request :get, "/apps/#{market}/app/#{product_id}/details" end
product_ranks(market, product_id, start_date, end_date, country, category, feed)
click to toggle source
# File lib/anego/client.rb, line 33 def product_ranks(market, product_id, start_date, end_date, country, category, feed) request :get, "/apps/#{market}/app/#{product_id}/ranks", { start_date: start_date, end_date: end_date, countries: country, category: category, feed: feed } end
product_ratings(market, product_id)
click to toggle source
# File lib/anego/client.rb, line 21 def product_ratings(market, product_id) request :get, "/apps/#{market}/app/#{product_id}/ratings" end
product_reviews(market, product_id, start_date, end_date, country)
click to toggle source
# File lib/anego/client.rb, line 25 def product_reviews(market, product_id, start_date, end_date, country) request :get, "/apps/#{market}/app/#{product_id}/reviews", { start_date: start_date, end_date: end_date, countries: country } end
products(account_id)
click to toggle source
# File lib/anego/client.rb, line 13 def products(account_id) request :get, "/accounts/#{account_id}/products" end
Private Instance Methods
api_endpoint(path)
click to toggle source
# File lib/anego/client.rb, line 61 def api_endpoint(path) "#{API_ENDPOINT}#{path}" end
api_key()
click to toggle source
# File lib/anego/client.rb, line 76 def api_key @api_key || ENV["APP_ANNIE_API_KEY"] end
default_headers()
click to toggle source
# File lib/anego/client.rb, line 69 def default_headers { Accept: "application/json", Authorization: "Bearer #{api_key}", } end
execute(method, path, params)
click to toggle source
# File lib/anego/client.rb, line 49 def execute(method, path, params) begin RestClient::Request.execute( method: method, url: api_endpoint(path), headers: headers(params), ) rescue RestClient::ExceptionWithResponse => err raise err end end
headers(params)
click to toggle source
# File lib/anego/client.rb, line 65 def headers(params) params.empty? ? default_headers : default_headers.merge(params: params) end
request(method, path, params = {})
click to toggle source
# File lib/anego/client.rb, line 45 def request(method, path, params = {}) Anego::Response.new(execute(method, path, params)) end