Class: Markety::AuthenticationHeader

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

Overview

This class exists only to encapsulate the authentication header part of a soap request to Marketo.

Constant Summary collapse

DIGEST =
OpenSSL::Digest::SHA1.new

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of AuthenticationHeader.



6
7
8
9
10
# 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

Instance Method Details

#get_mktows_user_idObject



18
19
20
# File 'lib/markety/authentication_header.rb', line 18

def get_mktows_user_id
  @access_key
end

#get_request_signatureObject



22
23
24
# File 'lib/markety/authentication_header.rb', line 22

def get_request_signature
  calculate_signature
end

#get_request_timestampObject



26
27
28
# File 'lib/markety/authentication_header.rb', line 26

def get_request_timestamp
  @time.to_s
end

#set_time(time) ⇒ Object

time should be a DateTime instance



14
15
16
# File 'lib/markety/authentication_header.rb', line 14

def set_time(time)
  @time = time
end

#to_hashObject



30
31
32
33
34
35
36
37
38
# 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