def send(data, promise, endpoint = @config.endpoint)
      return promise if rate_limited_ip?(promise)

      response = nil
      req = build_request(endpoint, data)

      return promise if missing_body?(req, promise)

      https = build_https(endpoint)

      begin
        response = https.request(req)
      rescue StandardError => ex
        reason = "#{LOG_LABEL} HTTP error: #{ex}"
        logger.error(reason)
        return promise.reject(reason)
      end

      parsed_resp = Response.parse(response)
      if parsed_resp.key?('rate_limit_reset')
        @rate_limit_reset = parsed_resp['rate_limit_reset']
      end

      return promise.reject(parsed_resp['error']) if parsed_resp.key?('error')
      promise.resolve(parsed_resp)
    end
def send(data, promise, endpoint = @config.endpoint)
      return promise if rate_limited_ip?(promise)

      response = nil
      req = build_request(endpoint, data)

      return promise if missing_body?(req, promise)

      https = build_https(endpoint)

      begin
        response = https.request(req)
      rescue StandardError => ex
        reason = "#{LOG_LABEL} HTTP error: #{ex}"
        logger.error(reason)
        return promise.reject(reason)
      end

      parsed_resp = Response.parse(response)
      if parsed_resp.key?('rate_limit_reset')
        @rate_limit_reset = parsed_resp['rate_limit_reset']
      end

      return promise.reject(parsed_resp['error']) if parsed_resp.key?('error')
      promise.resolve(parsed_resp)
    end
@param [Symbol] method HTTP method to use to send payload
 Sends a POST or PUT request to the given +endpoint+ with the +data+ payload.

 @param [#to_json] data
 @param [URI::HTTPS] endpoint
 @return [Hash{String=>String}] the parsed HTTP response