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.



19
20
21
22
23
24
25
26
27
# File 'lib/button/client.rb', line 19

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)

  @orders = Orders.new(api_key, config_with_defaults)
end

Instance Attribute Details

#ordersObject (readonly)

Returns the value of attribute orders.



40
41
42
# File 'lib/button/client.rb', line 40

def orders
  @orders
end