class Maia::FCM::Response
Public Class Methods
new(response)
click to toggle source
# File lib/maia/fcm/response.rb, line 4 def initialize(response) @response = response end
Public Instance Methods
body()
click to toggle source
# File lib/maia/fcm/response.rb, line 8 def body @response.body end
error()
click to toggle source
# File lib/maia/fcm/response.rb, line 24 def error case json.dig('error', 'status') when 'UNREGISTERED' Maia::Error::Unregistered.new else Maia::Error::Generic.new json.dig('error', 'message') end end
fail?()
click to toggle source
# File lib/maia/fcm/response.rb, line 20 def fail? !success? end
status()
click to toggle source
# File lib/maia/fcm/response.rb, line 12 def status @response.code.to_i end
success?()
click to toggle source
# File lib/maia/fcm/response.rb, line 16 def success? (200..399).cover? status end
Private Instance Methods
json()
click to toggle source
# File lib/maia/fcm/response.rb, line 34 def json JSON.parse body rescue JSON::ParserError {} end