Class: Easyship::Client
- Inherits:
-
Object
- Object
- Easyship::Client
- Includes:
- Singleton
- Defined in:
- lib/easyship/client.rb
Overview
Represents a client to interact with the Easyship API
Instance Method Summary collapse
- #delete(path, params = {}) ⇒ Object
- #get(path, params = {}, &block) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #post(path, params = {}) ⇒ Object
- #put(path, params = {}) ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
14 15 16 17 |
# File 'lib/easyship/client.rb', line 14 def initialize @url = Easyship.configuration.url @api_key = Easyship.configuration.api_key end |
Instance Method Details
#delete(path, params = {}) ⇒ Object
41 42 43 44 45 |
# File 'lib/easyship/client.rb', line 41 def delete(path, params = {}) response = connection.delete(path, params) handle_response(response) end |
#get(path, params = {}, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/easyship/client.rb', line 19 def get(path, params = {}, &block) if block Easyship::Pagination::Cursor.new(self, path, params).all(&block) else response = connection.get(path, params) handle_response(response) end end |
#post(path, params = {}) ⇒ Object
29 30 31 32 33 |
# File 'lib/easyship/client.rb', line 29 def post(path, params = {}) response = connection.post(path, params.to_json) handle_response(response) end |
#put(path, params = {}) ⇒ Object
35 36 37 38 39 |
# File 'lib/easyship/client.rb', line 35 def put(path, params = {}) response = connection.put(path, params.to_json) handle_response(response) end |