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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2044d12c6c7ac2d7a5a17977bab5efea1f3f2e06
4
- data.tar.gz: 889c82be7e57d528be2236d9748fbf1894ab19fc
3
+ metadata.gz: 8c99e53a991580d4ccf787e866dfc435ed99090d
4
+ data.tar.gz: 3b9d4af4a221e92e4f870fd4c706955690091c12
5
5
  SHA512:
6
- metadata.gz: f6ad5f1844dd9bd486908695cd5a625a00bf2e24ac38081e2f75381c5b8e9ecf6f74abb67c52dc208d7f5f060ec6df85982d7a6ce7bc788db1e948d47d0a3e3e
7
- data.tar.gz: 849199911f68fae4512d5c640ac3cdba527fd5dabcc822d8b3b834f27f6934a42760566cf9c14627ea27634b7d56c01646eb404a2153b57a407bb197038716ce
6
+ metadata.gz: 918982fd3a17f23def37a8630f14b871aa0eabf9e375bf96a3a2827c93d3b9976605e5cb0e8324050d23ac90aef876293398ec75f412ad5c1332f9a544d34d49
7
+ data.tar.gz: 735d632b7e1f1c2efe208142942623827fbb8acc2c40f5c870379810277de4021377d74454ba6a8568140709a290a7edac759aa2e27d8a914114d4ce64dd3659
@@ -1,6 +1,11 @@
1
1
  Current Version
2
2
  -
3
3
 
4
+ 2.5.0 September 25, 2019
5
+ - Added CODEOWNERS
6
+ - Add `Offers` resource
7
+ - Add `Transactions` resource and time field support
8
+
4
9
  2.4.0 December 6, 2017
5
10
  - Add `Links` resource
6
11
 
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.
@@ -1,3 +1,4 @@
1
1
  require 'button/client'
2
+ require 'button/constants'
2
3
  require 'button/version'
3
4
  require 'button/utils'
@@ -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
@@ -0,0 +1,6 @@
1
+ module Button
2
+ module Constants
3
+ TIME_FIELD_CREATED = 'created_date'.freeze
4
+ TIME_FIELD_MODIFIED = 'modified_date'.freeze
5
+ end
6
+ 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
@@ -1,3 +1,3 @@
1
1
  module Button
2
- VERSION = '2.4.0'.freeze
2
+ VERSION = '2.5.0'.freeze
3
3
  end
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.0
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: 2018-05-18 00:00:00.000000000 Z
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.1
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