Sha256: 8ce11851519cc15f5b2d32f8e59f47da4f37e774015809ba34a804e8879e1fac
Contents?: true
Size: 745 Bytes
Versions: 4
Compression:
Stored size: 745 Bytes
Contents
require 'faraday' require 'faraday_middleware' require 'erb' 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}=#{ERB::Util.url_encode(v.to_s)}"}.join('&') end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
mtg_sdk-3.2.1 | lib/mtg_sdk/rest_client.rb |
mtg_sdk-3.0.0 | lib/mtg_sdk/rest_client.rb |
mtg_sdk-2.2.0 | lib/mtg_sdk/rest_client.rb |
mtg_sdk-2.1.0 | lib/mtg_sdk/rest_client.rb |