Class: SamcartAPI::Client
- Inherits:
-
Object
- Object
- SamcartAPI::Client
- Defined in:
- lib/samcart_api/client.rb
Overview
Client for interacting with the SamCart API
Instance Method Summary collapse
- #delete(path) ⇒ Object
- #get(path, params = {}) ⇒ Object
-
#initialize(api_key = nil) ⇒ Client
constructor
A new instance of Client.
- #orders ⇒ Object
- #post(path, body = {}) ⇒ Object
- #products ⇒ Object
- #put(path, body = {}) ⇒ Object
Constructor Details
#initialize(api_key = nil) ⇒ Client
Returns a new instance of Client.
6 7 8 9 |
# File 'lib/samcart_api/client.rb', line 6 def initialize(api_key = nil) @api_key = api_key || SamcartAPI.configuration.api_key raise ConfigurationError, 'API key is required' unless @api_key end |
Instance Method Details
#delete(path) ⇒ Object
31 32 33 |
# File 'lib/samcart_api/client.rb', line 31 def delete(path) request(:delete, path) end |
#get(path, params = {}) ⇒ Object
19 20 21 |
# File 'lib/samcart_api/client.rb', line 19 def get(path, params = {}) request(:get, path, params) end |
#orders ⇒ Object
15 16 17 |
# File 'lib/samcart_api/client.rb', line 15 def orders @orders ||= Order.new(self) end |
#post(path, body = {}) ⇒ Object
23 24 25 |
# File 'lib/samcart_api/client.rb', line 23 def post(path, body = {}) request(:post, path, body) end |
#products ⇒ Object
11 12 13 |
# File 'lib/samcart_api/client.rb', line 11 def products @products ||= Product.new(self) end |
#put(path, body = {}) ⇒ Object
27 28 29 |
# File 'lib/samcart_api/client.rb', line 27 def put(path, body = {}) request(:put, path, body) end |