Class: Creem::Client
- Inherits:
-
Object
- Object
- Creem::Client
- Defined in:
- lib/creem/client.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #checkouts ⇒ Object
- #customers ⇒ Object
- #discounts ⇒ Object
- #get(path, params = {}) ⇒ Object
-
#initialize(api_key: nil, test_mode: nil, timeout: nil, open_timeout: nil) ⇒ Client
constructor
A new instance of Client.
- #licenses ⇒ Object
- #post(path, body = {}) ⇒ Object
- #products ⇒ Object
- #subscriptions ⇒ Object
- #transactions ⇒ Object
Constructor Details
#initialize(api_key: nil, test_mode: nil, timeout: nil, open_timeout: nil) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 18 19 |
# File 'lib/creem/client.rb', line 11 def initialize(api_key: nil, test_mode: nil, timeout: nil, open_timeout: nil) @config = Configuration.new @config.api_key = api_key || Creem.configuration.api_key @config.test_mode = test_mode.nil? ? Creem.configuration.test_mode : test_mode @config.timeout = timeout || Creem.configuration.timeout @config.open_timeout = open_timeout || Creem.configuration.open_timeout raise ConfigurationError, "API key is required" if @config.api_key.nil? || @config.api_key.empty? end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
9 10 11 |
# File 'lib/creem/client.rb', line 9 def config @config end |
Instance Method Details
#checkouts ⇒ Object
25 26 27 |
# File 'lib/creem/client.rb', line 25 def checkouts @checkouts ||= Resources::Checkouts.new(self) end |
#customers ⇒ Object
33 34 35 |
# File 'lib/creem/client.rb', line 33 def customers @customers ||= Resources::Customers.new(self) end |
#discounts ⇒ Object
45 46 47 |
# File 'lib/creem/client.rb', line 45 def discounts @discounts ||= Resources::Discounts.new(self) end |
#get(path, params = {}) ⇒ Object
49 50 51 |
# File 'lib/creem/client.rb', line 49 def get(path, params = {}) request(:get, path, params: params) end |
#licenses ⇒ Object
41 42 43 |
# File 'lib/creem/client.rb', line 41 def licenses @licenses ||= Resources::Licenses.new(self) end |
#post(path, body = {}) ⇒ Object
53 54 55 |
# File 'lib/creem/client.rb', line 53 def post(path, body = {}) request(:post, path, body: body) end |
#products ⇒ Object
21 22 23 |
# File 'lib/creem/client.rb', line 21 def products @products ||= Resources::Products.new(self) end |
#subscriptions ⇒ Object
29 30 31 |
# File 'lib/creem/client.rb', line 29 def subscriptions @subscriptions ||= Resources::Subscriptions.new(self) end |
#transactions ⇒ Object
37 38 39 |
# File 'lib/creem/client.rb', line 37 def transactions @transactions ||= Resources::Transactions.new(self) end |