Sha256: c1faad379f9c17f51af317bdb221ff20b39d41ae97d3eed900632233eb9a2e8d
Contents?: true
Size: 772 Bytes
Versions: 3
Compression:
Stored size: 772 Bytes
Contents
require 'faraday' require 'faraday_middleware' require 'erb' 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}=#{ERB::Util.url_encode(v.to_s)}"}.join('&') end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pokemon_tcg_sdk-3.0.0 | lib/pokemon_tcg_sdk/rest_client.rb |
pokemon_tcg_sdk-2.5.0 | lib/pokemon_tcg_sdk/rest_client.rb |
pokemon_tcg_sdk-2.4.0 | lib/pokemon_tcg_sdk/rest_client.rb |