Class: Sidemash::Sdk::HttpRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/sidemash/sdk/http_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(signed_headers, method, path, query_string, body_hash) ⇒ HttpRequest

Returns a new instance of HttpRequest.



11
12
13
14
15
16
17
18
19
# File 'lib/sidemash/sdk/http_request.rb', line 11

def initialize(signed_headers, method, path, query_string, body_hash)
  now = Time.now
  @nonce = now.to_i + now.usec / 1000
  @signed_headers = signed_headers
  @method = method
  @path = path
  @query_string = query_string
  @body_hash = body_hash
end

Instance Attribute Details

#body_hashObject (readonly)

Returns the value of attribute body_hash.



9
10
11
# File 'lib/sidemash/sdk/http_request.rb', line 9

def body_hash
  @body_hash
end

#methodObject (readonly)

Returns the value of attribute method.



6
7
8
# File 'lib/sidemash/sdk/http_request.rb', line 6

def method
  @method
end

#nonceObject (readonly)

Returns the value of attribute nonce.



4
5
6
# File 'lib/sidemash/sdk/http_request.rb', line 4

def nonce
  @nonce
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/sidemash/sdk/http_request.rb', line 7

def path
  @path
end

#query_stringObject (readonly)

Returns the value of attribute query_string.



8
9
10
# File 'lib/sidemash/sdk/http_request.rb', line 8

def query_string
  @query_string
end

#signed_headersObject (readonly)

Returns the value of attribute signed_headers.



5
6
7
# File 'lib/sidemash/sdk/http_request.rb', line 5

def signed_headers
  @signed_headers
end

Instance Method Details

#to_messageObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/sidemash/sdk/http_request.rb', line 21

def to_message
  result = ''
  result += @nonce.to_s
  result += @signed_headers.map { |header_name, header_value| header_name + ':' + header_value }.join('')
  result += @method
  result += @path
  result += !@query_string.nil? ? @query_string : ''
  result += !@body_hash.nil?    ? @body_hash : ''
  result
end