Sha256: eee2a42a40be164c2936a00d23cbb52b04786836c0b8ebab67ce14fbcfb8583b
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
require 'simple_aws/api' require 'simple_aws/call_types/action_param' module SimpleAWS ## # Amazon's Mechanical Turk # # http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html # # All requests are POST and always through HTTPS. # Instead of regions, this API supports normal and sandbox mode. Use the third # parameter of #initialize to specify sandbox mode. # # For a more fleshed out object API for interacting with MechanicalTurk, you should # give rturk a try here: https://github.com/mdp/rturk # # @see SimpleAWS::CallTypes::ActionParam Calling rules # @see SimpleAWS::Response Response handling ## class MechanicalTurk < API endpoint "mechanicalturk" use_https true version "2011-10-01" def initialize(key, secret, sandbox = false) super(key, secret, sandbox ? "sandbox" : nil) end include CallTypes::ActionParam protected # Sign the Turk request according to SignatureVersion 0 rules. # # As this is coming from CallTypes::ActionParam we need to fix # the Action param first thing. def finish_and_sign_request(request) request.params["Operation"] = request.params.delete("Action") request.params.merge!({ "Service" => "AWSMechanicalTurkRequester", "AWSAccessKeyId" => self.access_key, "Timestamp" => Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ"), "Version" => self.version }) request.params["Signature"] = Base64.encode64(sign_request(request.params.clone)).chomp request end def sign_request(params) to_sign = [params["Service"], params["Operation"], params["Timestamp"]].join "" OpenSSL::HMAC.digest("sha1", self.secret_key, to_sign) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
simple_aws-1.1.0 | lib/simple_aws/mechanical_turk.rb |