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.
87 88 89 90 91 |
# File 'lib/wework/request.rb', line 87 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
104 105 106 |
# File 'lib/wework/request.rb', line 104 def success? errcode == SUCCESS_CODE end |
#throw_error ⇒ Object
100 101 102 |
# File 'lib/wework/request.rb', line 100 def throw_error raise ResultErrorException.new() unless success? end |
#token_expired? ⇒ Boolean
93 94 95 96 97 98 |
# File 'lib/wework/request.rb', line 93 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 |