Module: SimpleWorker::Api::Signatures

Defined in:
lib/simple_worker/api.rb

Class Method Summary collapse

Class Method Details

.generate_signature(operation, timestamp, secret_key) ⇒ Object



27
28
29
30
31
# File 'lib/simple_worker/api.rb', line 27

def self.generate_signature(operation, timestamp, secret_key)
  my_sha_hmac = Digest::HMAC.digest(operation + timestamp, secret_key, Digest::SHA1)
  my_b64_hmac_digest = Base64.encode64(my_sha_hmac).strip
  return my_b64_hmac_digest
end

.generate_timestamp(gmtime) ⇒ Object



22
23
24
# File 'lib/simple_worker/api.rb', line 22

def self.generate_timestamp(gmtime)
  return gmtime.strftime("%Y-%m-%dT%H:%M:%SZ")
end

.hash_to_s(hash) ⇒ Object



34
35
36
37
38
39
# File 'lib/simple_worker/api.rb', line 34

def self.hash_to_s(hash)
  str = ""
  hash.sort.each { |a| str+= "#{a[0]}#{a[1]}" }
  #removing all characters that could differ after parsing with rails
  return str.delete "\"\/:{}[]\' T"
end