Class: EposNowClient::Connection

Inherits:
Object
  • Object
show all
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

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)
  options = {}
  options[:body] = body.to_json if body
  request(:delete, path, **options)
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