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