Exception: ChatWork::AuthenticateError

Inherits:
ChatWorkError show all
Defined in:
lib/chatwork/chatwork_error.rb

Instance Attribute Summary collapse

Attributes inherited from ChatWorkError

#error_response, #status

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ChatWorkError

from_response

Constructor Details

#initialize(message, status, error_response, error, error_description) ⇒ AuthenticateError

Returns a new instance of AuthenticateError.



63
64
65
66
67
68
# File 'lib/chatwork/chatwork_error.rb', line 63

def initialize(message, status, error_response, error, error_description)
  @error = error
  @error_description = error_description

  super(message, status, error_response)
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



61
62
63
# File 'lib/chatwork/chatwork_error.rb', line 61

def error
  @error
end

#error_descriptionObject (readonly)

Returns the value of attribute error_description.



61
62
63
# File 'lib/chatwork/chatwork_error.rb', line 61

def error_description
  @error_description
end

Class Method Details

.from_www_authenticate(www_authenticate:, status:, error_response:) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/chatwork/chatwork_error.rb', line 70

def self.from_www_authenticate(www_authenticate:, status:, error_response:)
  www_authenticate =~ /error="([^"]+)"/
  error = Regexp.last_match(1)

  www_authenticate =~ /error_description="([^"]+)"/
  error_description = Regexp.last_match(1)

  AuthenticateError.new(
    www_authenticate,
    status,
    error_response,
    error,
    error_description,
  )
end