Class: ApnMachine::Server::ErrorResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/apnmachine/server/error_response.rb

Constant Summary collapse

DESCRIPTION =
{
  0   => "No errors encountered",
  1   => "Processing error",
  2   => "Missing device token",
  3   => "Missing topic",
  4   => "Missing payload",
  5   => "Invalid token size",
  6   => "Invalid topic size",
  7   => "Invalid payload size",
  8   => "Invalid token",
  255 => "None (unknown)"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, status_code, identifier) ⇒ ErrorResponse

Returns a new instance of ErrorResponse.



20
21
22
23
24
# File 'lib/apnmachine/server/error_response.rb', line 20

def initialize(command, status_code, identifier)
  @command     = command
  @status_code = status_code
  @identifier  = identifier
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



18
19
20
# File 'lib/apnmachine/server/error_response.rb', line 18

def command
  @command
end

#identifierObject (readonly)

Returns the value of attribute identifier.



18
19
20
# File 'lib/apnmachine/server/error_response.rb', line 18

def identifier
  @identifier
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



18
19
20
# File 'lib/apnmachine/server/error_response.rb', line 18

def status_code
  @status_code
end

Instance Method Details

#descriptionObject



30
31
32
# File 'lib/apnmachine/server/error_response.rb', line 30

def description
  DESCRIPTION[@status_code] || "Missing description"
end

#to_sObject



26
27
28
# File 'lib/apnmachine/server/error_response.rb', line 26

def to_s
  "CODE=#{@status_code} ID=#{@identifier} DESC=#{description}"
end