Class: Button::Client

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#accountsObject (readonly)

Returns the value of attribute accounts.



46
47
48
# File 'lib/button/client.rb', line 46

def accounts
  @accounts
end

#customersObject (readonly)

Returns the value of attribute customers.



46
47
48
# File 'lib/button/client.rb', line 46

def customers
  @customers
end

#merchantsObject (readonly)

Returns the value of attribute merchants.



46
47
48
# File 'lib/button/client.rb', line 46

def merchants
  @merchants
end

#ordersObject (readonly)

Returns the value of attribute orders.



46
47
48
# File 'lib/button/client.rb', line 46

def orders
  @orders
end