Class: Button::Client
- Inherits:
-
Object
- Object
- Button::Client
- Defined in:
- lib/button/client.rb
Overview
Client is the top-level interface for the Button API. It exposes one resource currently: ‘.orders`. It requires a valid API key to make requests on behalf of your organization, which can be found at app.usebutton.com/settings/organization.
## Usage
client = Button::Client.new(“sk-XXX”) puts client.orders.get(“btnorder-XXX”)
Instance Attribute Summary collapse
-
#accounts ⇒ Object
readonly
Returns the value of attribute accounts.
-
#customers ⇒ Object
readonly
Returns the value of attribute customers.
-
#merchants ⇒ Object
readonly
Returns the value of attribute merchants.
-
#orders ⇒ Object
readonly
Returns the value of attribute orders.
Instance Method Summary collapse
-
#initialize(api_key, config = {}) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(api_key, config = {}) ⇒ Client
Returns a new instance of Client.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/button/client.rb', line 22 def initialize(api_key, config = {}) if api_key.nil? || api_key.empty? raise ButtonClientError, NO_API_KEY_MESSAGE end config_with_defaults = merge_defaults(config) @accounts = Accounts.new(api_key, config_with_defaults) @customers = Customers.new(api_key, config_with_defaults) @merchants = Merchants.new(api_key, config_with_defaults) @orders = Orders.new(api_key, config_with_defaults) end |
Instance Attribute Details
#accounts ⇒ Object (readonly)
Returns the value of attribute accounts.
46 47 48 |
# File 'lib/button/client.rb', line 46 def accounts @accounts end |
#customers ⇒ Object (readonly)
Returns the value of attribute customers.
46 47 48 |
# File 'lib/button/client.rb', line 46 def customers @customers end |
#merchants ⇒ Object (readonly)
Returns the value of attribute merchants.
46 47 48 |
# File 'lib/button/client.rb', line 46 def merchants @merchants end |
#orders ⇒ Object (readonly)
Returns the value of attribute orders.
46 47 48 |
# File 'lib/button/client.rb', line 46 def orders @orders end |