Class: Bixby::JsonRequest
- Inherits:
-
Object
- Object
- Bixby::JsonRequest
- Includes:
- HttpClient, Jsonify
- Defined in:
- lib/bixby-common/api/json_request.rb
Overview
Wraps a JSON Request
Direct Known Subclasses
Instance Attribute Summary collapse
-
#operation ⇒ String
Name of operation.
-
#params ⇒ Array
Array of paramters; must be valid JSON types.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Test if this object is equal to some other object.
-
#initialize(operation, params) ⇒ JsonRequest
constructor
Create a new JsonRequest.
-
#to_s(include_params = true) ⇒ String
Stringify, useful for debugging.
- #to_wire ⇒ Object
Methods included from HttpClient
#http_get, #http_get_json, #http_post, #http_post_download, #http_post_json
Methods included from Jsonify
Methods included from Hashify
Constructor Details
#initialize(operation, params) ⇒ JsonRequest
Create a new JsonRequest
19 20 21 22 |
# File 'lib/bixby-common/api/json_request.rb', line 19 def initialize(operation, params) @operation = operation @params = params end |
Instance Attribute Details
#operation ⇒ String
Name of operation
8 9 10 |
# File 'lib/bixby-common/api/json_request.rb', line 8 def operation @operation end |
#params ⇒ Array
Array of paramters; must be valid JSON types
8 9 10 |
# File 'lib/bixby-common/api/json_request.rb', line 8 def params @params end |
Instance Method Details
#==(other) ⇒ Boolean
Test if this object is equal to some other object
46 47 48 |
# File 'lib/bixby-common/api/json_request.rb', line 46 def ==(other) operation == other.operation && params == other.params end |
#to_s(include_params = true) ⇒ String
Stringify, useful for debugging
29 30 31 32 33 34 35 |
# File 'lib/bixby-common/api/json_request.rb', line 29 def to_s(include_params=true) s = [] s << "JsonRequest:#{self.object_id}" s << " operation: #{self.operation}" s << " params: " + MultiJson.dump(self.params) if include_params s.join("\n") end |
#to_wire ⇒ Object
37 38 39 |
# File 'lib/bixby-common/api/json_request.rb', line 37 def to_wire MultiJson.dump(self) end |