Sha256: deac5405d112f9927fee03be84bfb5faf04ca6ae436a1acc90d0ed1ab2a29349
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true require 'httparty' require 'max_exchange_api/helper' module MaxExchangeApi class BaseApi include HTTParty attr_reader :config def initialize(config: nil) @config = Config.new(config) @config.reverse_merge!(MaxExchangeApi.default_config) end protected def send_request(method, path, headers, query) uuid = SecureRandom.uuid print_log(:info, "[API] #{uuid} #{method.upcase} '#{path}' query = #{query}") begin response = self.class.send( method, path, headers: headers, query: query, timeout: @config.timeout, ).parsed_response print_log(:info, "[API] #{uuid} response #{response}") return response rescue => error print_log(:error, "[API] #{uuid} raise exception #{error.message}") raise error end end private def print_log(method, message) logger = @config.logger logger.send(method, message) if logger end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
max_exchange_api-1.2.0 | lib/max_exchange_api/base_api.rb |
max_exchange_api-1.1.1 | lib/max_exchange_api/base_api.rb |
max_exchange_api-1.1.0 | lib/max_exchange_api/base_api.rb |