Sha256: ce7bdcafaa699897413bfbf80cba53eb99a80e37cc28992ce08d8a1e67a13a60
Contents?: true
Size: 736 Bytes
Versions: 1
Compression:
Stored size: 736 Bytes
Contents
require 'faraday' require 'faraday_middleware' require 'open-uri' module Pokemon module RestClient def self.get(endpoint, params=nil) if params.nil? query = endpoint else query = "#{endpoint}?#{params_to_query(params)}" end client.get(query) end protected def self.client @client = Faraday.new "#{API_URL}/v#{Pokemon.configuration.api_version}" do |conn| conn.response :xml, :content_type => /\bxml$/ conn.response :json, :content_type => /\bjson$/ conn.adapter Faraday.default_adapter end end def self.params_to_query(params) params.map {|p, v| "#{p}=#{URI.escape(v.to_s)}"}.join('&') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pokemon_tcg_sdk-1.0.0 | lib/pokemon_tcg_sdk/rest_client.rb |