Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2.2.0 March 29, 2017
- Add GET support for `Customers` resource

2.1.0 March 29, 2017
- Add `Customers` resource

Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@ response = client.customers.create({
puts response
# => Button::Response(id: internal-customer-id, email_sha256: a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3)
```
##### Get

```ruby
require 'button'

client = Button::Client.new('sk-XXX')

response = client.customers.get('btncustomer-XXX')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm almost afraid to ask... but can partners CRUD in their own namespace like orders?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is basically a TODO for me to update docs showing that partner's can pass their own order ids (and update the order reporting tool's snippets to use the partner order id)--this is an important feature of an integration because it means partners don't have to persist our ids for adjustments and cancellations.


puts response
# => Button::Response(id: btncustomer-XXX, segments:[], ... )
```

### Merchants

Expand Down
9 changes: 9 additions & 0 deletions lib/button/resources/customers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ def path(customer_id = nil)
'/v1/customers'
end

# Gets a customer
#
# @param [String] customer_id the customer id
# @return [Button::Response] the API response
#
def get(customer_id)
api_get(path(customer_id))
end

# Create a Customer
#
# @param [Hash] customer the customer to create
Expand Down
2 changes: 1 addition & 1 deletion lib/button/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Button
VERSION = '2.1.0'.freeze
VERSION = '2.2.0'.freeze
end
9 changes: 9 additions & 0 deletions test/button/resources/customers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ def teardown
WebMock.reset!
end

def test_get
stub_request(:get, 'https://api.usebutton.com/v1/customers/btncustomer-XXX')
.with(headers: @headers)
.to_return(status: 200, body: '{ "meta": { "status": "ok" }, "object": { "a": 1 } }')

response = @customers.get('btncustomer-XXX')
assert_equal(response.data[:a], 1)
end

def test_create
stub_request(:post, 'https://api.usebutton.com/v1/customers')
.with(body: '{"id":"1234"}', headers: @headers)
Expand Down