Class: AmplifySyndication::Client
- Inherits:
-
Object
- Object
- AmplifySyndication::Client
- Defined in:
- lib/amplify_syndication/client.rb
Instance Method Summary collapse
- #get(endpoint, params = {}) ⇒ Object
- #get_with_options(endpoint, options = {}) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 |
# File 'lib/amplify_syndication/client.rb', line 7 def initialize @http_client = HTTPClient.new @base_url = AmplifySyndication.configuration.base_url @access_token = AmplifySyndication.configuration.access_token end |
Instance Method Details
#get(endpoint, params = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/amplify_syndication/client.rb', line 13 def get(endpoint, params = {}) url = "#{@base_url}/#{endpoint}".gsub(%r{//}, '/').sub(%r{:/}, '://') headers = { "Authorization" => "Bearer #{@access_token}", "Accept" => "application/json" } response = @http_client.get(url, params, headers) parse_response(response) end |
#get_with_options(endpoint, options = {}) ⇒ Object
23 24 25 26 |
# File 'lib/amplify_syndication/client.rb', line 23 def (endpoint, = {}) query_string = .map { |key, value| "#{key}=#{value}" }.join("&") get("#{endpoint}?#{query_string}") end |