Sha256: 247b1e525a45826a9bf009c9e17198f85524b6d8cf5338c4fca1b2dda4065f07
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true module TopsConnect class Client include HTTParty include TopsConnect::Communities include TopsConnect::Owners headers 'Content-Type' => 'application/json' headers 'api-version' => '1' base_uri 'https://topsconnectapi.azure-api.net' def initialize authorization = Base64.strict_encode64 [ TopsConnect.configuration.client_id, TopsConnect.configuration.software_key ].join(':') self.class.headers( 'authorization' => "Basic #{authorization}", 'community-api-key' => TopsConnect.configuration.community_api_key ) @subscription_key = TopsConnect.configuration.subscription_key end def get(endpoint, parameters = {}) response = self.class.get( "/#{TopsConnect.configuration.zone}/api#{endpoint}", query: parameters.merge('subscription-key' => @subscription_key) ) case response.code when 200 response.parsed_response when 400..499 raise BadRequest, response.parsed_response['message'] else raise "#{response.code}: #{response.parsed_response['message']}" end end class BadRequest < Exception end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tops_connect-0.1.2 | lib/tops_connect/client.rb |