Sha256: 431ec7bf3af6cef75e41578e3ac61f143c642e426a3c0079bf407d1e54ffedd2
Contents?: true
Size: 579 Bytes
Versions: 3
Compression:
Stored size: 579 Bytes
Contents
require 'bundler/setup' require 'httparty' class APIClient def initialize(http_client:HTTParty) @base_uri = ENV['DATABASE_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
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
allegro_api_client-0.0.3 | lib/allegro_api_client.rb |
allegro_api_client-0.0.2 | lib/APIClient.rb |
allegro_api_client-0.0.1 | src/APIClient.rb |