class Button::Client
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”)
Attributes
accounts[R]
customers[R]
links[R]
merchants[R]
offers[R]
orders[R]
transactions[R]
Public Class Methods
new(api_key, config = {})
click to toggle source
# File lib/button/client.rb, line 25 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) @links = Links.new(api_key, config_with_defaults) @merchants = Merchants.new(api_key, config_with_defaults) @offers = Offers.new(api_key, config_with_defaults) @orders = Orders.new(api_key, config_with_defaults) @transactions = Transactions.new(api_key, config_with_defaults) end
Private Instance Methods
merge_defaults(config)
click to toggle source
# File lib/button/client.rb, line 41 def merge_defaults(config) secure = config.fetch(:secure, true) { secure: secure, timeout: config.fetch(:timeout, nil), hostname: config.fetch(:hostname, 'api.usebutton.com'), port: config.fetch(:port, secure ? 443 : 80), api_version: config.fetch(:api_version, nil) } end