class Callback::API::Base
Attributes
access_token[RW]
base_path[RW]
Public Class Methods
new(access_token: nil, base_path: nil)
click to toggle source
# File lib/callback/api/base.rb, line 11 def initialize(access_token: nil, base_path: nil) @access_token = access_token @base_path = base_path end
Protected Instance Methods
request(method, path, parameters={})
click to toggle source
# File lib/callback/api/base.rb, line 18 def request(method, path, parameters={}) full_path = "#{base_path}#{path}" options = { headers: { "Accept" => "application/json", "Authorization" => "Bearer #{access_token}", "Content-Type" => "application/json; charset=utf-8" }, format: :json } if method.to_sym == :post options[:body] = parameters.to_json else options[:query] = parameters end response = HTTParty.send method, full_path, options JSON.parse(response.body, symbolize_names: true) end