Class: Remit::SignedQuery
- Inherits:
-
Relax::Query
- Object
- Relax::Query
- Remit::SignedQuery
- Defined in:
- lib/remit/common.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(uri, secret_key, query = {}) ⇒ SignedQuery
constructor
A new instance of SignedQuery.
- #sign ⇒ Object
- #to_s(signed = true) ⇒ Object
Constructor Details
#initialize(uri, secret_key, query = {}) ⇒ SignedQuery
Returns a new instance of SignedQuery.
59 60 61 62 63 |
# File 'lib/remit/common.rb', line 59 def initialize(uri, secret_key, query={}) super(query) @uri = URI.parse(uri.to_s) @secret_key = secret_key end |
Class Method Details
.parse(uri, secret_key, query_string) ⇒ Object
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/remit/common.rb', line 76 def parse(uri, secret_key, query_string) query = self.new(uri, secret_key) query_string.split('&').each do |parameter| key, value = parameter.split('=', 2) query[key] = unescape_value(value) end query end |
Instance Method Details
#sign ⇒ Object
65 66 67 68 |
# File 'lib/remit/common.rb', line 65 def sign delete(:awsSignature) store(:awsSignature, Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::SHA1.new, @secret_key, "#{@uri.path}?#{to_s(false)}".gsub('%20', '+'))).strip) end |
#to_s(signed = true) ⇒ Object
70 71 72 73 |
# File 'lib/remit/common.rb', line 70 def to_s(signed=true) sign if signed super() end |