Class: Wework::Result
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Wework::Result
- Defined in:
- lib/wework/request.rb
Instance Method Summary collapse
-
#initialize(data) ⇒ Result
constructor
A new instance of Result.
- #success? ⇒ Boolean
- #throw_error ⇒ Object
- #token_expired? ⇒ Boolean
Constructor Details
#initialize(data) ⇒ Result
Returns a new instance of Result.
89 90 91 92 93 |
# File 'lib/wework/request.rb', line 89 def initialize(data) data['message'] = GLOBAL_CODES[data['errcode'].to_i] data['full_message'] = "#{data['errcode']}:#{data['errmsg']}(#{data['message']})" super data end |
Instance Method Details
#success? ⇒ Boolean
106 107 108 |
# File 'lib/wework/request.rb', line 106 def success? errcode == SUCCESS_CODE end |
#throw_error ⇒ Object
102 103 104 |
# File 'lib/wework/request.rb', line 102 def throw_error raise ResultErrorException.new() unless success? end |
#token_expired? ⇒ Boolean
95 96 97 98 99 100 |
# File 'lib/wework/request.rb', line 95 def token_expired? # 42001: access_token timeout # 40014: invalid access_token # 40001, invalid credential, access_token is invalid or not latest hint [42001, 40014, 40001].include?(errcode) end |