Class: Bixby::SignedJsonRequest

Inherits:
JsonRequest show all
Defined in:
lib/bixby-common/api/signed_json_request.rb

Instance Attribute Summary collapse

Attributes inherited from JsonRequest

#operation, #params

Instance Method Summary collapse

Methods inherited from JsonRequest

#==, #to_s

Methods included from HttpClient

#http_get, #http_get_json, #http_post, #http_post_download, #http_post_json

Methods included from Jsonify

included, #to_json

Methods included from Hashify

#to_hash

Constructor Details

#initialize(json_request, access_key = nil, secret_key = nil) ⇒ SignedJsonRequest

Returns a new instance of SignedJsonRequest.



9
10
11
12
13
14
15
# File 'lib/bixby-common/api/signed_json_request.rb', line 9

def initialize(json_request, access_key=nil, secret_key=nil)
  @operation = json_request.operation
  @params = json_request.params
  @access_key = access_key
  @secret_key = secret_key
  @headers = {}
end

Instance Attribute Details

#headersObject

Returns the value of attribute headers.



7
8
9
# File 'lib/bixby-common/api/signed_json_request.rb', line 7

def headers
  @headers
end

Instance Method Details

#bodyObject



26
27
28
29
30
31
32
# File 'lib/bixby-common/api/signed_json_request.rb', line 26

def body
  if @body.nil? then
    hash = { :operation => operation, :params => params }
    @body = MultiJson.dump(hash)
  end
  return @body
end

#body=(str) ⇒ Object



22
23
24
# File 'lib/bixby-common/api/signed_json_request.rb', line 22

def body=(str)
  @body = str
end

#pathObject

api-auth requires a path



18
19
20
# File 'lib/bixby-common/api/signed_json_request.rb', line 18

def path
  "/api"
end

#to_wireObject



34
35
36
37
# File 'lib/bixby-common/api/signed_json_request.rb', line 34

def to_wire
  ApiAuth.sign!(self, @access_key, @secret_key)
  body
end