class Tide::API::HTTPClient
Responsible for the HTTP interactions. The only entity aware of HTTP concerns such as status codes and headers.
@api private
Attributes
access_token[RW]
An OAuth2 access token
refresh_token[RW]
An OAuth2 refresh token
Public Instance Methods
get(endpoint)
click to toggle source
Performs a GET request to Tide's API
. Every request returns the status code 200.
@example Retrieving a resource
client = HTTPClient.new result = client.get('https://api.tide.co/tide-backend/rest/api/v1/oauth2/tokens')
@param [String] endpoint URL of the API
endpoint of the GET request
@return [Response] Generic response of a request to Tide's API
# File lib/tide/api/http_client.rb, line 27 def get(endpoint) response = HTTP.headers(headers).get(endpoint) Response.new(JSON.parse(response.body), response.status != 200) end
Private Instance Methods
headers()
click to toggle source
# File lib/tide/api/http_client.rb, line 35 def headers return {} if access_token.nil? { Authorization: "Bearer #{access_token}" } end