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) ⇒ Client

Returns a new instance of Client.



16
17
18
19
20
21
22
# File 'lib/button/client.rb', line 16

def initialize(api_key)
  if api_key.nil? || api_key.empty?
    raise ButtonClientError, 'Must provide a Button API key.  Find yours at https://app.usebutton.com/settings/organization'
  end

  @orders = Orders.new(api_key)
end

Instance Attribute Details

#ordersObject (readonly)

Returns the value of attribute orders.



24
25
26
# File 'lib/button/client.rb', line 24

def orders
  @orders
end