Class: Rapa::Signer

Inherits:
Object
  • Object
show all
Defined in:
lib/rapa/signer.rb

Instance Method Summary collapse

Constructor Details

#initialize(host:, http_method:, key:, path:, query_string:) ⇒ Signer

Returns a new instance of Signer.

Parameters:

  • host (String)
  • http_method (String)
  • key (String)
  • path (String)
  • query_string (String)


12
13
14
15
16
17
18
# File 'lib/rapa/signer.rb', line 12

def initialize(host:, http_method:, key:, path:, query_string:)
  @host = host
  @http_method = http_method
  @key = key
  @path = path
  @query_string = query_string
end

Instance Method Details

#signString

Returns:

  • (String)


21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rapa/signer.rb', line 21

def sign
  ::CGI.escape(
    ::Base64.encode64(
      ::OpenSSL::HMAC.digest(
        digest,
        key,
        source,
      ),
    ).chomp
  )
end