Class: Rapleaf::Marketo::AuthenticationHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/marketo/authentication_header.rb

Overview

This class exists only to encapsulate the authentication header part of a soap request to marketo Marketo requires a somewhat complex calculation of an encrypted signature and so it seemed sensible to pull this code out here

Constant Summary collapse

DIGEST =
OpenSSL::Digest::Digest.new('sha1')

Instance Method Summary collapse

Constructor Details

#initialize(access_key, secret_key, time = DateTime.now) ⇒ AuthenticationHeader

Returns a new instance of AuthenticationHeader.



8
9
10
11
12
# File 'lib/marketo/authentication_header.rb', line 8

def initialize(access_key, secret_key, time = DateTime.now)
  @access_key = access_key
  @secret_key = secret_key
  @time       = time
end

Instance Method Details

#get_mktows_user_idObject



20
21
22
# File 'lib/marketo/authentication_header.rb', line 20

def get_mktows_user_id
  @access_key
end

#get_request_signatureObject



24
25
26
# File 'lib/marketo/authentication_header.rb', line 24

def get_request_signature
  calculate_signature
end

#get_request_timestampObject



28
29
30
# File 'lib/marketo/authentication_header.rb', line 28

def get_request_timestamp
  @time.to_s
end

#set_time(time) ⇒ Object

time should be a DateTime instance



16
17
18
# File 'lib/marketo/authentication_header.rb', line 16

def set_time(time)
  @time = time
end

#to_hashObject



32
33
34
35
36
37
38
# File 'lib/marketo/authentication_header.rb', line 32

def to_hash
  {
      "mktowsUserId"     => get_mktows_user_id,
      "requestSignature" => get_request_signature,
      "requestTimestamp" => get_request_timestamp
  }
end