Class: Emarsys::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/emarsys/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account = nil) ⇒ Client

Returns a new instance of Client.



6
7
8
# File 'lib/emarsys/client.rb', line 6

def initialize( = nil)
  self. = 
end

Instance Attribute Details

#accountObject

Returns the value of attribute account.



4
5
6
# File 'lib/emarsys/client.rb', line 4

def 
  @account
end

Instance Method Details

#calculated_digestObject



40
41
42
# File 'lib/emarsys/client.rb', line 40

def calculated_digest
  Digest::SHA1.hexdigest(header_nonce + header_created + password)
end

#endpointObject



10
11
12
# File 'lib/emarsys/client.rb', line 10

def endpoint
  Emarsys::Configuration.for().api_endpoint
end

#header_createdObject



36
37
38
# File 'lib/emarsys/client.rb', line 36

def header_created
  @header_created ||= Time.now.utc.iso8601
end

#header_nonceObject



32
33
34
# File 'lib/emarsys/client.rb', line 32

def header_nonce
  @header_nonce ||= SecureRandom::random_bytes(16).each_byte.map { |b| sprintf("%02X",b) }.join
end

#header_password_digestObject



28
29
30
# File 'lib/emarsys/client.rb', line 28

def header_password_digest
  Base64.encode64(calculated_digest).gsub("\n", "")
end

#open_timeoutObject



44
45
46
# File 'lib/emarsys/client.rb', line 44

def open_timeout
  Emarsys::Configuration.for().open_timeout
end

#passwordObject



18
19
20
# File 'lib/emarsys/client.rb', line 18

def password
  Emarsys::Configuration.for().api_password
end

#read_timeoutObject



48
49
50
# File 'lib/emarsys/client.rb', line 48

def read_timeout
  Emarsys::Configuration.for().read_timeout
end

#usernameObject



14
15
16
# File 'lib/emarsys/client.rb', line 14

def username
  Emarsys::Configuration.for().api_username
end

#x_wsse_stringObject



22
23
24
25
26
# File 'lib/emarsys/client.rb', line 22

def x_wsse_string
  <<-STRING.strip
  UsernameToken Username="#{username}", PasswordDigest="#{header_password_digest}", Nonce="#{header_nonce}", Created="#{header_created}"
  STRING
end