Sha256: 89d247101c105d9f8a68b29f3c4f87763fbd7526252a57551d97f7a840bfc090
Contents?: true
Size: 721 Bytes
Versions: 2
Compression:
Stored size: 721 Bytes
Contents
require 'faraday' require 'faraday_middleware' module MTG 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#{MTG.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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mtg_sdk-1.0.1 | lib/mtg_sdk/rest_client.rb |
mtg_sdk-1.0.0 | lib/mtg_sdk/rest_client.rb |