class Mashery::RestClient

Public Instance Methods

build_url(query_params) click to toggle source
# File lib/mashery/rest_client.rb, line 3
def build_url(query_params)
  Query.new(query_params).url
end
call(activity_type, service_id, options) click to toggle source
# File lib/mashery/rest_client.rb, line 7
def call(activity_type, service_id, options)
  if activity_type == "developer_activity"
    query_options = {service_id: service_id, resource: "developer_activity"}.merge(options)
    query         = Query.new(query_options)
    perform_query(query)
  elsif activity_type == "errorcodes"
    query_options = {service_id: service_id, resource: "errorcodes"}.merge(options)
    query         = Query.new(query_options)
    perform_query(query)
  else
    raise "No such activity type!"
  end
end
perform_query(query) click to toggle source
# File lib/mashery/rest_client.rb, line 21
def perform_query(query)
  response = ::RestClient.get(query.url)

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