Class: KnapsackPro::Client::Connection
- Inherits:
-
Object
- Object
- KnapsackPro::Client::Connection
- Defined in:
- lib/knapsack_pro/client/connection.rb
Constant Summary collapse
- TIMEOUT =
15- REQUEST_RETRY_TIMEBOX =
2
Instance Method Summary collapse
- #call ⇒ Object
- #errors? ⇒ Boolean
-
#initialize(action) ⇒ Connection
constructor
A new instance of Connection.
- #success? ⇒ Boolean
Constructor Details
#initialize(action) ⇒ Connection
Returns a new instance of Connection.
7 8 9 |
# File 'lib/knapsack_pro/client/connection.rb', line 7 def initialize(action) @action = action end |
Instance Method Details
#call ⇒ Object
11 12 13 |
# File 'lib/knapsack_pro/client/connection.rb', line 11 def call send(action.http_method) end |
#errors? ⇒ Boolean
22 23 24 |
# File 'lib/knapsack_pro/client/connection.rb', line 22 def errors? !!(response_body && (response_body['errors'] || response_body['error'])) end |
#success? ⇒ Boolean
15 16 17 18 19 20 |
# File 'lib/knapsack_pro/client/connection.rb', line 15 def success? return false if !response_body status = http_response.code.to_i status >= 200 && status < 500 end |