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.



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

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.



57
58
59
# File 'lib/chatwork/chatwork_error.rb', line 57

def error
  @error
end

#error_descriptionObject (readonly)

Returns the value of attribute error_description.



57
58
59
# File 'lib/chatwork/chatwork_error.rb', line 57

def error_description
  @error_description
end

Class Method Details

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



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/chatwork/chatwork_error.rb', line 66

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