require 'bundler/setup' require 'httparty' class APIClient def initialize(http_client:HTTParty) @base_uri = ENV['API_URI'] @auth = {username:'snap', password:ENV['AUTH_TOKEN']} @http_client = http_client end def get(path:path) JSON.parse @http_client.get("#{@base_uri}#{encoded path}", {basic_auth:@auth}).body end def patch(path:path, body:body) @http_client.patch("#{@base_uri}#{encoded path}", :basic_auth =>@auth, :body => body.to_json, headers:{ 'Content-Type' => 'application/json' }).body end def encoded path path.gsub ' ', '%20' end end