class Kempelen::API::Client
Constants
- SERVICE_NAME
Service name of the Mechanical Turk
API
.- SERVICE_URLS
URLs for Mechanical Turk APIs, indexed by environment.
Attributes
access_key[R]
Amazon AWS access key.
debug_output[RW]
HTTParty debug options
environment[R]
Mechanical Turk environment to make API
calls to - defaults to :production.
secret_key[R]
Secret key for AWS access key. Used to sign the requests.
Public Class Methods
new(access_key, secret_key, environment = :production)
click to toggle source
# File lib/kempelen/API/client.rb, line 25 def initialize(access_key, secret_key, environment = :production) @access_key = access_key @secret_key = secret_key @environment = environment.to_sym @debug_output = nil raise ArgumentError.new("Unknown environment".freeze) if SERVICE_URLS[@environment].nil? end
Public Instance Methods
perform_request(query_string, response_object)
click to toggle source
# File lib/kempelen/API/client.rb, line 43 def perform_request(query_string, response_object) response = HTTParty.get(query_string, debug_output: @debug_output) response.parsed_response[response_object] end
service_name()
click to toggle source
# File lib/kempelen/API/client.rb, line 35 def service_name SERVICE_NAME end
service_url()
click to toggle source
# File lib/kempelen/API/client.rb, line 39 def service_url SERVICE_URLS[@environment] end