lib/pubnub/events/channel_registration.rb in pubnub-4.0.3 vs lib/pubnub/events/channel_registration.rb in pubnub-4.0.4
- old
+ new
@@ -101,11 +101,11 @@
if error
error_envelope(parsed_response, error, request: request, response: response)
else
valid_envelope(parsed_response, request: request, response: response)
- end
+ end
end
def valid_envelope(parsed_response, req_res_objects)
# {"status"=>200, "message"=>"OK", "service"=>"channel-registry", "error"=>false}
Pubnub::Envelope.new(
@@ -139,71 +139,31 @@
}
)
end
def error_envelope(parsed_response, error, req_res_objects)
- if error
- Pubnub::ErrorEnvelope.new(
+ Pubnub::ErrorEnvelope.new(
event: @event,
event_options: @given_options,
timetoken: nil,
status: {
- code: req_res_objects[:response].code,
- operation: define_operation,
- client_request: req_res_objects[:request],
- server_response: req_res_objects[:response],
- data: nil,
- category: :json_parse_error,
- error: true,
- auto_retried: false,
+ code: req_res_objects[:response].code,
+ operation: define_operation,
+ client_request: req_res_objects[:request],
+ server_response: req_res_objects[:response],
+ data: nil,
+ category: (error ? Pubnub::Constants::STATUS_NON_JSON_RESPONSE : Pubnub::Constants::STATUS_ERROR),
+ error: true,
+ auto_retried: false,
- current_timetoken: nil,
- last_timetoken: nil,
- subscribed_channels: nil,
- subscribed_channel_groups: nil,
+ current_timetoken: nil,
+ last_timetoken: nil,
+ subscribed_channels: nil,
+ subscribed_channel_groups: nil,
- config: get_config
- },
-
- result: {
- data: parsed_response['payload'],
- code: req_res_objects[:response].code,
- operation: define_operation,
- client_request: req_res_objects[:request],
- server_response: req_res_objects[:response]
+ config: get_config
}
- )
- else
- ErrorEnvelope.new(
- event: @event,
- event_options: @given_options,
- timetoken: nil,
- status: {
- code: req_res_objects[:response].code,
- client_request: req_res_objects[:request],
- server_response: req_res_objects[:response],
- category: nil,
- error: true,
- auto_retried: false,
-
- current_timetoken: nil,
- last_timetoken: nil,
- subscribed_channels: nil,
- subscribed_channel_groups: nil,
-
- config: get_config
-
- },
-
- result: {
- data: parsed_response['payload'],
- code: req_res_objects[:response].code,
- operation: define_operation,
- client_request: req_res_objects[:request],
- server_response: req_res_objects[:response]
- }
- )
- end
+ )
end
def define_operation
case @action
when :add