button 2.4.0 → 2.5.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 +5 -0
- data/README.md +53 -0
- data/lib/button.rb +1 -0
- data/lib/button/client.rb +5 -1
- data/lib/button/constants.rb +6 -0
- data/lib/button/resources/accounts.rb +2 -0
- data/lib/button/resources/offers.rb +20 -0
- data/lib/button/resources/transactions.rb +27 -0
- data/lib/button/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c99e53a991580d4ccf787e866dfc435ed99090d
|
4
|
+
data.tar.gz: 3b9d4af4a221e92e4f870fd4c706955690091c12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 918982fd3a17f23def37a8630f14b871aa0eabf9e375bf96a3a2827c93d3b9976605e5cb0e8324050d23ac90aef876293398ec75f412ad5c1332f9a544d34d49
|
7
|
+
data.tar.gz: 735d632b7e1f1c2efe208142942623827fbb8acc2c40f5c870379810277de4021377d74454ba6a8568140709a290a7edac759aa2e27d8a914114d4ce64dd3659
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -84,6 +84,8 @@ We currently expose the following resources to manage:
|
|
84
84
|
* [`Merchants`](#merchants)
|
85
85
|
* [`Orders`](#orders)
|
86
86
|
* [`Links`](#links)
|
87
|
+
* [`Offers`](#offers)
|
88
|
+
* [`Transactions`](#transactions)
|
87
89
|
|
88
90
|
### Accounts
|
89
91
|
|
@@ -109,6 +111,7 @@ Along with the required account id, you may also pass the following optional arg
|
|
109
111
|
* `:cursor` (String): An API cursor to fetch a specific set of results.
|
110
112
|
* `:start` (ISO-8601 datetime String): Fetch transactions after this time.
|
111
113
|
* `:end` (ISO-8601 datetime String): Fetch transactions before this time.
|
114
|
+
* `:time_field` (String): Which time field start and end filter on.
|
112
115
|
|
113
116
|
```ruby
|
114
117
|
require 'button'
|
@@ -281,6 +284,56 @@ puts response
|
|
281
284
|
# => Button::Response()
|
282
285
|
```
|
283
286
|
|
287
|
+
### Offers
|
288
|
+
|
289
|
+
##### Get Offers
|
290
|
+
|
291
|
+
```ruby
|
292
|
+
require 'button'
|
293
|
+
|
294
|
+
client = Button::Client.new('sk-XXX')
|
295
|
+
|
296
|
+
response = client.offers.get({
|
297
|
+
user_id: "some-user-id",
|
298
|
+
device_ids: ["123"]
|
299
|
+
})
|
300
|
+
|
301
|
+
puts response
|
302
|
+
# => Button::Response()
|
303
|
+
```
|
304
|
+
|
305
|
+
### Transactions
|
306
|
+
|
307
|
+
#### All
|
308
|
+
|
309
|
+
_n.b. all is a paged endpoint. Take care to inspect `response.next_cursor` in case there's more data to be read._
|
310
|
+
|
311
|
+
You may pass the following optional arguments as a Hash:
|
312
|
+
|
313
|
+
* `:cursor` (String): An API cursor to fetch a specific set of results.
|
314
|
+
* `:start` (ISO-8601 datetime String): Fetch transactions after this time.
|
315
|
+
* `:end` (ISO-8601 datetime String): Fetch transactions before this time.
|
316
|
+
* `:time_field` (String): Which time field start and end filter on.
|
317
|
+
|
318
|
+
```ruby
|
319
|
+
require 'button'
|
320
|
+
|
321
|
+
client = Button::Client.new('sk-XXX')
|
322
|
+
|
323
|
+
response = client.transactions.all
|
324
|
+
cursor = response.next_cursor
|
325
|
+
|
326
|
+
puts response
|
327
|
+
# => Button::Response(75 elements)
|
328
|
+
|
329
|
+
# Unpage all results
|
330
|
+
#
|
331
|
+
while !cursor.nil? do
|
332
|
+
response = client.transactions.all(cursor: cursor)
|
333
|
+
cursor = response.next_cursor
|
334
|
+
end
|
335
|
+
```
|
336
|
+
|
284
337
|
## Response
|
285
338
|
|
286
339
|
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.rb
CHANGED
data/lib/button/client.rb
CHANGED
@@ -2,7 +2,9 @@ require 'button/resources/accounts'
|
|
2
2
|
require 'button/resources/customers'
|
3
3
|
require 'button/resources/links'
|
4
4
|
require 'button/resources/merchants'
|
5
|
+
require 'button/resources/offers'
|
5
6
|
require 'button/resources/orders'
|
7
|
+
require 'button/resources/transactions'
|
6
8
|
require 'button/errors'
|
7
9
|
|
8
10
|
NO_API_KEY_MESSAGE = 'Must provide a Button API key. Find yours at '\
|
@@ -31,7 +33,9 @@ module Button
|
|
31
33
|
@customers = Customers.new(api_key, config_with_defaults)
|
32
34
|
@links = Links.new(api_key, config_with_defaults)
|
33
35
|
@merchants = Merchants.new(api_key, config_with_defaults)
|
36
|
+
@offers = Offers.new(api_key, config_with_defaults)
|
34
37
|
@orders = Orders.new(api_key, config_with_defaults)
|
38
|
+
@transactions = Transactions.new(api_key, config_with_defaults)
|
35
39
|
end
|
36
40
|
|
37
41
|
def merge_defaults(config)
|
@@ -46,7 +50,7 @@ module Button
|
|
46
50
|
}
|
47
51
|
end
|
48
52
|
|
49
|
-
attr_reader :accounts, :customers, :merchants, :orders, :links
|
53
|
+
attr_reader :accounts, :customers, :merchants, :offers, :orders, :links, :transactions
|
50
54
|
private :merge_defaults
|
51
55
|
end
|
52
56
|
end
|
@@ -25,6 +25,7 @@ module Button
|
|
25
25
|
# transactions
|
26
26
|
# @option [ISO-8601 datetime String] end The end date to filter
|
27
27
|
# transactions
|
28
|
+
# @option [String] time_field time field start and end filter on
|
28
29
|
# @return [Button::Response] the API response
|
29
30
|
#
|
30
31
|
def transactions(account_id, opts = {})
|
@@ -32,6 +33,7 @@ module Button
|
|
32
33
|
query['cursor'] = opts[:cursor] if opts[:cursor]
|
33
34
|
query['start'] = opts[:start] if opts[:start]
|
34
35
|
query['end'] = opts[:end] if opts[:end]
|
36
|
+
query['time_field'] = opts[:time_field] if opts[:time_field]
|
35
37
|
|
36
38
|
api_get(path(account_id), query)
|
37
39
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'button/resources/resource'
|
2
|
+
|
3
|
+
module Button
|
4
|
+
# https://www.usebutton.com/developers/api-reference/
|
5
|
+
#
|
6
|
+
class Offers < Resource
|
7
|
+
def path
|
8
|
+
'/v1/offers'
|
9
|
+
end
|
10
|
+
|
11
|
+
# Retrieve offers that are available to Publishers user
|
12
|
+
#
|
13
|
+
# @param [Hash] user to retrieve offers for
|
14
|
+
# @return [Button::Response] the API response
|
15
|
+
#
|
16
|
+
def get(user)
|
17
|
+
api_post(path, user)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'button/resources/resource'
|
2
|
+
|
3
|
+
module Button
|
4
|
+
# https://www.usebutton.com/developers/api-reference/
|
5
|
+
#
|
6
|
+
class Transactions < Resource
|
7
|
+
# Gets a list of transactions
|
8
|
+
#
|
9
|
+
# @option [String] cursor the account id to look up transactions for
|
10
|
+
# @option [ISO-8601 datetime String] start The start date to filter
|
11
|
+
# transactions
|
12
|
+
# @option [ISO-8601 datetime String] end The end date to filter
|
13
|
+
# transactions
|
14
|
+
# @option [String] time_field time field start and end filter on
|
15
|
+
# @return [Button::Response] the API response
|
16
|
+
#
|
17
|
+
def all(opts = {})
|
18
|
+
query = {}
|
19
|
+
query['cursor'] = opts[:cursor] if opts[:cursor]
|
20
|
+
query['start'] = opts[:start] if opts[:start]
|
21
|
+
query['end'] = opts[:end] if opts[:end]
|
22
|
+
query['time_field'] = opts[:time_field] if opts[:time_field]
|
23
|
+
|
24
|
+
api_get('/v1/affiliation/transactions', query)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
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.5.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: 2019-09-25 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.
|
@@ -23,13 +23,16 @@ files:
|
|
23
23
|
- README.md
|
24
24
|
- lib/button.rb
|
25
25
|
- lib/button/client.rb
|
26
|
+
- lib/button/constants.rb
|
26
27
|
- lib/button/errors.rb
|
27
28
|
- lib/button/resources/accounts.rb
|
28
29
|
- lib/button/resources/customers.rb
|
29
30
|
- lib/button/resources/links.rb
|
30
31
|
- lib/button/resources/merchants.rb
|
32
|
+
- lib/button/resources/offers.rb
|
31
33
|
- lib/button/resources/orders.rb
|
32
34
|
- lib/button/resources/resource.rb
|
35
|
+
- lib/button/resources/transactions.rb
|
33
36
|
- lib/button/response.rb
|
34
37
|
- lib/button/utils.rb
|
35
38
|
- lib/button/version.rb
|
@@ -53,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
56
|
version: '0'
|
54
57
|
requirements: []
|
55
58
|
rubyforge_project:
|
56
|
-
rubygems_version: 2.5.
|
59
|
+
rubygems_version: 2.5.2.3
|
57
60
|
signing_key:
|
58
61
|
specification_version: 4
|
59
62
|
summary: ruby client for the Button Order API
|