class SocketLabs::InjectionApi::Core::Serialization::InjectionRequest

Represents a injection request for sending to the Injection Api. To be serialized into JSON string before sending to the Injection Api.

Attributes

api_key[RW]

the SocketLabs Injection API key for the Injection Request.

messages[RW]

the list of messages (MessageJson) to send. This library is limited to one

server_id[RW]

the server id for the injection Request.

Public Class Methods

new( server_id = nil, api_key = nil, messages = nil ) click to toggle source

Initializes a new instance of the InjectionRequest class @param [String] api_key @param [String] server_id @param [String] messages

# File lib/socketlabs/injectionapi/core/serialization/injection_request.rb, line 21
def initialize(
  server_id = nil,
  api_key = nil,
  messages = nil
)
  @api_key = api_key
  @server_id = server_id
  @messages = messages
end

Public Instance Methods

to_hash() click to toggle source

build json hash for InjectionRequest @return [hash]

# File lib/socketlabs/injectionapi/core/serialization/injection_request.rb, line 33
def to_hash

  json = {
    :serverId => @server_id,
    :apiKey => @api_key
  }

  if @messages.length > 0
    e = Array.new
    @messages.each do |value|
      e.push(value.to_hash)
    end
    json[:messages] = e
  end
  
  json
end