Module: Appoxy::ServerApi::Signatures

Defined in:
lib/server_api/signatures.rb

Class Method Summary collapse

Class Method Details

.generate_signature(operation, timestamp, secret_key) ⇒ Object



11
12
13
14
15
# File 'lib/server_api/signatures.rb', line 11

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



6
7
8
# File 'lib/server_api/signatures.rb', line 6

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

.hash_to_s(hash) ⇒ Object



18
19
20
21
22
23
# File 'lib/server_api/signatures.rb', line 18

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 server_api
  return str.delete "\"\/:{}[]\' T"
end