Sha256: 4189ade881cb04af6a779e3946ee764b9580b11f46bb71680481c18db758833f
Contents?: true
Size: 692 Bytes
Versions: 2
Compression:
Stored size: 692 Bytes
Contents
module NintendoEshop class APIRequest class << self; end private def request(method, to_json: {}) case method when :post post(json: to_json) end end def post(json: {}) uri = URI("#{NintendoEshop.base_url}#{self.class::RESOURCE_PATH}?#{url_params}") response = NintendoEshop.client.post(uri, json: json) parsed_response = JSON.parse(response.body, symbolize_names: true) raise InvalidRequestError, "ID not found" if parsed_response.dig(:nbHits).zero? parsed_response end def url_params "x-algolia-api-key=#{NintendoEshop.api_key}&x-algolia-application-id=#{NintendoEshop.app_id}" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nintendo_eshop-0.1.0.alpha4 | lib/nintendo_eshop/api_request.rb |
nintendo_eshop-0.1.0.alpha3 | lib/nintendo_eshop/api_request.rb |