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.



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

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.



5
6
7
# File 'lib/bixby-common/api/signed_json_request.rb', line 5

def headers
  @headers
end

Instance Method Details

#bodyObject



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

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

#body=(str) ⇒ Object



20
21
22
# File 'lib/bixby-common/api/signed_json_request.rb', line 20

def body=(str)
  @body = str
end

#pathObject

api-auth requires a path



16
17
18
# File 'lib/bixby-common/api/signed_json_request.rb', line 16

def path
  "/api"
end

#to_wireObject



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

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