Class: EposNowClient::Connection
- Inherits:
-
Object
- Object
- EposNowClient::Connection
- Defined in:
- lib/epos_now_client/connection.rb
Constant Summary collapse
- RETRYABLE_ERRORS =
[ Errno::ECONNRESET, Errno::ECONNREFUSED, Errno::ETIMEDOUT, Net::OpenTimeout, Net::ReadTimeout, SocketError ].freeze
- RETRYABLE_STATUS_CODES =
[502, 503, 504].freeze
Instance Method Summary collapse
- #delete(path, body: nil) ⇒ Object
- #get(path, params: {}) ⇒ Object
-
#initialize(configuration) ⇒ Connection
constructor
A new instance of Connection.
- #post(path, body: {}) ⇒ Object
- #put(path, body: {}) ⇒ Object
Constructor Details
#initialize(configuration) ⇒ Connection
Returns a new instance of Connection.
19 20 21 |
# File 'lib/epos_now_client/connection.rb', line 19 def initialize(configuration) @configuration = configuration end |
Instance Method Details
#delete(path, body: nil) ⇒ Object
35 36 37 38 39 |
# File 'lib/epos_now_client/connection.rb', line 35 def delete(path, body: nil) = {} [:body] = body.to_json if body request(:delete, path, **) end |
#get(path, params: {}) ⇒ Object
23 24 25 |
# File 'lib/epos_now_client/connection.rb', line 23 def get(path, params: {}) request(:get, path, query: params) end |
#post(path, body: {}) ⇒ Object
27 28 29 |
# File 'lib/epos_now_client/connection.rb', line 27 def post(path, body: {}) request(:post, path, body: body.to_json) end |
#put(path, body: {}) ⇒ Object
31 32 33 |
# File 'lib/epos_now_client/connection.rb', line 31 def put(path, body: {}) request(:put, path, body: body.to_json) end |