class BitlyExporter::Client

Constants

API_URL
API_VERSION

Attributes

oauth_token[R]
params[R]

Public Class Methods

new(oauth_token) click to toggle source
# File lib/bitly_exporter/client.rb, line 12
def initialize(oauth_token)
  @oauth_token = oauth_token
  @params = { access_token: oauth_token }
end

Protected Instance Methods

make_request(endpoint, options={}) click to toggle source
# File lib/bitly_exporter/client.rb, line 19
def make_request(endpoint, options={})
  response = HTTParty.get("#{API_URL}#{endpoint}", query: params.merge(options))
  if response.code == 200
    JSON.parse(response.body)
  else
    raise StandardError, "The request to bitly failed with a HTTP #{response.code}\n#{response.message}"
  end
end