Class: AmazonFPS
- Inherits:
-
Object
- Object
- AmazonFPS
- Includes:
- SOAP::RPC, WSS4R::Tokenresolver
- Defined in:
- lib/amazon_fps.rb,
lib/aws_credentials.rb
Defined Under Namespace
Classes: AWSError, Credentials, HeaderHandler
Constant Summary collapse
- VERSION =
'1.0.0'
- SANDBOX_ENDPOINT =
'https://fps.sandbox.amazonaws.com'
- LIVE_ENDPOINT =
'https://fps.amazonaws.com'
- CERTIFICATE_DIR =
File.join(File.dirname(__FILE__), '..', 'certs')
Instance Method Summary collapse
-
#initialize(credentials, opts = {}, sandbox = false) ⇒ AmazonFPS
constructor
Initializes the connection to AmazonFPS and sets up cryptographic signature features.
Constructor Details
#initialize(credentials, opts = {}, sandbox = false) ⇒ AmazonFPS
Initializes the connection to AmazonFPS and sets up cryptographic signature features
Credentials hash should include:
- AWSAccessKeyId
-
Your AWS Access Key
Opts hash can include:
- :certificate_dir
-
Directory in which certificates live
- :subject
-
Subject for x509 certificate
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/amazon_fps.rb', line 36 def initialize(credentials, opts={}, sandbox=false) @options = opts @endpoint_url = sandbox ? SANDBOX_ENDPOINT : LIVE_ENDPOINT @certificate_dir = @options[:certificate_dir] ? @options[:certificate_dir] : CERTIFICATE_DIR @aws = AmazonFPSPortType.new(@endpoint_url) @aws.wiredump_dev = STDERR if $DEBUG @aws.["protocol.http.ssl_config.verify_mode"] = nil sign() @credentials = Credentials.new(credentials) @credentials.handlers.each do |h| @aws.headerhandler << h end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object (private)
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/amazon_fps.rb', line 63 def method_missing(method, *args) begin res = eval "@aws.#{method}(*args)" raise AWSError.new(method, res.errors) if res.respond_to?(:errors) && ! res.errors.nil? rescue SOAP::FaultError => fault msg = "#{method} Call Failed: [#{fault.faultcode.to_s}]#{fault.faultstring.to_s}" $stderr.puts(msg) end res end |