Class: SocketLabs::InjectionApi::Core::Serialization::InjectionRequest
- Inherits:
-
Object
- Object
- SocketLabs::InjectionApi::Core::Serialization::InjectionRequest
- Defined in:
- lib/socketlabs/injectionapi/core/serialization/injection_request.rb
Overview
Represents a injection request for sending to the Injection Api. To be serialized into JSON string before sending to the Injection Api.
Instance Attribute Summary collapse
-
#api_key ⇒ Object
the SocketLabs Injection API key for the Injection Request.
-
#messages ⇒ Object
the list of messages (MessageJson) to send.
-
#server_id ⇒ Object
the server id for the injection Request.
Instance Method Summary collapse
-
#initialize(server_id = nil, api_key = nil, messages = nil) ⇒ InjectionRequest
constructor
Initializes a new instance of the InjectionRequest class.
-
#to_hash ⇒ hash
build json hash for InjectionRequest.
Constructor Details
#initialize(server_id = nil, api_key = nil, messages = nil) ⇒ InjectionRequest
Initializes a new instance of the InjectionRequest class
21 22 23 24 25 26 27 28 29 |
# File 'lib/socketlabs/injectionapi/core/serialization/injection_request.rb', line 21 def initialize( server_id = nil, api_key = nil, = nil ) @api_key = api_key @server_id = server_id = end |
Instance Attribute Details
#api_key ⇒ Object
the SocketLabs Injection API key for the Injection Request.
11 12 13 |
# File 'lib/socketlabs/injectionapi/core/serialization/injection_request.rb', line 11 def api_key @api_key end |
#messages ⇒ Object
the list of messages (MessageJson) to send. This library is limited to one
15 16 17 |
# File 'lib/socketlabs/injectionapi/core/serialization/injection_request.rb', line 15 def end |
#server_id ⇒ Object
the server id for the injection Request.
13 14 15 |
# File 'lib/socketlabs/injectionapi/core/serialization/injection_request.rb', line 13 def server_id @server_id end |
Instance Method Details
#to_hash ⇒ hash
build json hash for InjectionRequest
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/socketlabs/injectionapi/core/serialization/injection_request.rb', line 33 def to_hash json = { :serverId => @server_id, :apiKey => @api_key } if .length > 0 e = Array.new .each do |value| e.push(value.to_hash) end json[:messages] = e end json end |