Sha256: 8e688679254d8c9c5efd4159a1a59d8bd362c6bab836ba9502afd6201ea29b83

Contents?: true

Size: 637 Bytes

Versions: 2

Compression:

Stored size: 637 Bytes

Contents

module Mashery
  class RestClient
    def build_url(query_params)
      Query.new(query_params).url
    end

    def call(resource, service_id, options)
      query_options = {service_id: service_id, resource: resource}.merge(options)
      query         = Query.new(query_options)
      perform_query(query)
    end

    def perform_query(query)
      puts "[mashery_rails] Calling Mashery REST API with URL: #{query.url.inspect}"
      response = ::RestClient.get(query.url)

      if query.format == "json" or query.format == "csv"
        response
      else
        raise UnknownFormat.new(query.format)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mashery_rails-0.6.9.pre4 lib/mashery/rest_client.rb
mashery_rails-0.6.9.pre3 lib/mashery/rest_client.rb