button 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +45 -4
- data/lib/button/client.rb +3 -1
- data/lib/button/resources/links.rb +29 -0
- data/lib/button/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2044d12c6c7ac2d7a5a17977bab5efea1f3f2e06
|
4
|
+
data.tar.gz: 889c82be7e57d528be2236d9748fbf1894ab19fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6ad5f1844dd9bd486908695cd5a625a00bf2e24ac38081e2f75381c5b8e9ecf6f74abb67c52dc208d7f5f060ec6df85982d7a6ce7bc788db1e948d47d0a3e3e
|
7
|
+
data.tar.gz: 849199911f68fae4512d5c640ac3cdba527fd5dabcc822d8b3b834f27f6934a42760566cf9c14627ea27634b7d56c01646eb404a2153b57a407bb197038716ce
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -18,7 +18,7 @@ Please see the full [API Docs](https://www.usebutton.com/developers/api-referenc
|
|
18
18
|
gem install button
|
19
19
|
```
|
20
20
|
|
21
|
-
To create a client capable of making network requests, instantiate a `Button::Client` with your [API key](https://app.usebutton.com/settings/organization).
|
21
|
+
To create a client capable of making network requests, instantiate a `Button::Client` with your [API key](https://app.usebutton.com/settings/organization).
|
22
22
|
|
23
23
|
```ruby
|
24
24
|
require 'button'
|
@@ -26,7 +26,7 @@ require 'button'
|
|
26
26
|
client = Button::Client.new('sk-XXX')
|
27
27
|
```
|
28
28
|
|
29
|
-
The client will always attempt to raise a `Button::ButtonClientError` in an error condition.
|
29
|
+
The client will always attempt to raise a `Button::ButtonClientError` in an error condition.
|
30
30
|
|
31
31
|
All API requests will return a `Button::Response` instance. To access the response data, invoke `#data`.
|
32
32
|
|
@@ -83,6 +83,7 @@ We currently expose the following resources to manage:
|
|
83
83
|
* [`Customers`](#customers)
|
84
84
|
* [`Merchants`](#merchants)
|
85
85
|
* [`Orders`](#orders)
|
86
|
+
* [`Links`](#links)
|
86
87
|
|
87
88
|
### Accounts
|
88
89
|
|
@@ -139,7 +140,7 @@ client = Button::Client.new('sk-XXX')
|
|
139
140
|
|
140
141
|
response = client.customers.create({
|
141
142
|
id: 'internal-customer-id',
|
142
|
-
email_sha256: '
|
143
|
+
email_sha256: Digest::SHA256.hexdigest('user@example.com'.downcase.strip)
|
143
144
|
})
|
144
145
|
|
145
146
|
puts response
|
@@ -194,7 +195,11 @@ response = client.orders.create({
|
|
194
195
|
currency: 'USD',
|
195
196
|
order_id: '1994',
|
196
197
|
finalization_date: '2017-08-02T19:26:08Z',
|
197
|
-
btn_ref: 'srctok-XXX'
|
198
|
+
btn_ref: 'srctok-XXX',
|
199
|
+
customer: {
|
200
|
+
id: 'mycustomer-1234',
|
201
|
+
email_sha256: Digest::SHA256.hexdigest('user@example.com'.downcase.strip)
|
202
|
+
}
|
198
203
|
})
|
199
204
|
|
200
205
|
puts response
|
@@ -240,6 +245,42 @@ puts response
|
|
240
245
|
# => Button::Response()
|
241
246
|
```
|
242
247
|
|
248
|
+
### Links
|
249
|
+
|
250
|
+
##### Create
|
251
|
+
|
252
|
+
```ruby
|
253
|
+
require 'button'
|
254
|
+
|
255
|
+
client = Button::Client.new('sk-XXX')
|
256
|
+
|
257
|
+
response = client.links.create({
|
258
|
+
url: "https://www.jet.com",
|
259
|
+
experience: {
|
260
|
+
btn_pub_ref: "my-pub-ref",
|
261
|
+
btn_pub_user: "user-id"
|
262
|
+
}
|
263
|
+
})
|
264
|
+
|
265
|
+
puts response
|
266
|
+
# => Button::Response()
|
267
|
+
```
|
268
|
+
|
269
|
+
##### Get Info
|
270
|
+
|
271
|
+
```ruby
|
272
|
+
require 'button'
|
273
|
+
|
274
|
+
client = Button::Client.new('sk-XXX')
|
275
|
+
|
276
|
+
response = client.links.get_info({
|
277
|
+
url: "https://www.jet.com"
|
278
|
+
})
|
279
|
+
|
280
|
+
puts response
|
281
|
+
# => Button::Response()
|
282
|
+
```
|
283
|
+
|
243
284
|
## Response
|
244
285
|
|
245
286
|
An instance of the `Button::Response` class will be returned by all API methods. It is used to read the response data as well as collect any meta data about the response, like potential next and previous cursors to more data in a paged endpoint.
|
data/lib/button/client.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'button/resources/accounts'
|
2
2
|
require 'button/resources/customers'
|
3
|
+
require 'button/resources/links'
|
3
4
|
require 'button/resources/merchants'
|
4
5
|
require 'button/resources/orders'
|
5
6
|
require 'button/errors'
|
@@ -28,6 +29,7 @@ module Button
|
|
28
29
|
|
29
30
|
@accounts = Accounts.new(api_key, config_with_defaults)
|
30
31
|
@customers = Customers.new(api_key, config_with_defaults)
|
32
|
+
@links = Links.new(api_key, config_with_defaults)
|
31
33
|
@merchants = Merchants.new(api_key, config_with_defaults)
|
32
34
|
@orders = Orders.new(api_key, config_with_defaults)
|
33
35
|
end
|
@@ -44,7 +46,7 @@ module Button
|
|
44
46
|
}
|
45
47
|
end
|
46
48
|
|
47
|
-
attr_reader :accounts, :customers, :merchants, :orders
|
49
|
+
attr_reader :accounts, :customers, :merchants, :orders, :links
|
48
50
|
private :merge_defaults
|
49
51
|
end
|
50
52
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'button/resources/resource'
|
2
|
+
|
3
|
+
module Button
|
4
|
+
# https://www.usebutton.com/developers/api-reference/
|
5
|
+
#
|
6
|
+
class Links < Resource
|
7
|
+
def path
|
8
|
+
'/v1/links'
|
9
|
+
end
|
10
|
+
|
11
|
+
# Create a Link
|
12
|
+
#
|
13
|
+
# @param [Hash] link the link to create
|
14
|
+
# @return [Button::Response] the API response
|
15
|
+
#
|
16
|
+
def create(link)
|
17
|
+
api_post(path, link)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Get information for Link
|
21
|
+
#
|
22
|
+
# @param [Hash] link the link to get information on
|
23
|
+
# @return [Button::Response] the API response
|
24
|
+
#
|
25
|
+
def get_info(link)
|
26
|
+
api_post(path + '/info', link)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/button/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: button
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Button
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Button is a contextual acquisition channel and closed-loop attribution
|
14
14
|
and affiliation system for mobile commerce.
|
@@ -26,6 +26,7 @@ files:
|
|
26
26
|
- lib/button/errors.rb
|
27
27
|
- lib/button/resources/accounts.rb
|
28
28
|
- lib/button/resources/customers.rb
|
29
|
+
- lib/button/resources/links.rb
|
29
30
|
- lib/button/resources/merchants.rb
|
30
31
|
- lib/button/resources/orders.rb
|
31
32
|
- lib/button/resources/resource.rb
|