class Markety::AuthenticationHeader
This class exists only to encapsulate the authentication header part of a soap request to Marketo.
Constants
- DIGEST
Public Class Methods
new(access_key, secret_key, time = DateTime.now)
click to toggle source
# File lib/markety/authentication_header.rb, line 6 def initialize(access_key, secret_key, time = DateTime.now) @access_key = access_key @secret_key = secret_key @time = time end
Public Instance Methods
get_mktows_user_id()
click to toggle source
# File lib/markety/authentication_header.rb, line 18 def get_mktows_user_id @access_key end
get_request_signature()
click to toggle source
# File lib/markety/authentication_header.rb, line 22 def get_request_signature calculate_signature end
get_request_timestamp()
click to toggle source
# File lib/markety/authentication_header.rb, line 26 def get_request_timestamp @time.to_s end
set_time(time)
click to toggle source
time should be a DateTime instance
# File lib/markety/authentication_header.rb, line 14 def set_time(time) @time = time end
to_hash()
click to toggle source
# File lib/markety/authentication_header.rb, line 30 def to_hash { "ns1:AuthenticationHeader" => { "mktowsUserId" => get_mktows_user_id, "requestSignature" => get_request_signature, "requestTimestamp" => get_request_timestamp } } end
Private Instance Methods
calculate_signature()
click to toggle source
# File lib/markety/authentication_header.rb, line 41 def calculate_signature request_timestamp = get_request_timestamp string_to_encrypt = request_timestamp + @access_key OpenSSL::HMAC.hexdigest(DIGEST, @secret_key, string_to_encrypt) end