class Lazada::API::Response
Attributes
response[R]
Public Class Methods
new(response)
click to toggle source
# File lib/lazada_dino/api/response.rb, line 6 def initialize(response) @response = response end
Public Instance Methods
body_error_messages()
click to toggle source
# File lib/lazada_dino/api/response.rb, line 47 def body_error_messages return if response.dig('ErrorResponse').nil? # Parent error coming in the header hash = { error: error_message } # Error coming in the body response.dig('ErrorResponse', 'Body', 'Errors')&.each do |error| hash[error['Field'].dup] = error['Message'] end hash end
error?()
click to toggle source
# File lib/lazada_dino/api/response.rb, line 18 def error? response['ErrorResponse'].present? end
error_code()
click to toggle source
# File lib/lazada_dino/api/response.rb, line 43 def error_code response.dig('ErrorResponse', 'Head', 'ErrorCode') end
error_message()
click to toggle source
# File lib/lazada_dino/api/response.rb, line 35 def error_message response.dig('ErrorResponse', 'Head', 'ErrorMessage') end
error_type()
click to toggle source
# File lib/lazada_dino/api/response.rb, line 39 def error_type response.dig('ErrorResponse', 'Head', 'ErrorType') end
request_id()
click to toggle source
# File lib/lazada_dino/api/response.rb, line 10 def request_id response.dig('SuccessResponse', 'Head', 'RequestId') end
success?()
click to toggle source
# File lib/lazada_dino/api/response.rb, line 14 def success? response['SuccessResponse'].present? end
warning?()
click to toggle source
# File lib/lazada_dino/api/response.rb, line 22 def warning? response.dig('SuccessResponse', 'Body', 'Warnings').present? end
warning_messages()
click to toggle source
# File lib/lazada_dino/api/response.rb, line 26 def warning_messages hash = {} response.dig('SuccessResponse', 'Body', 'Warnings').each do |warning| hash[warning['Field'].dup] = warning['Message'] end hash end