starkbank 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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/balance/balance.rb +1 -1
  3. data/lib/boleto/boleto.rb +49 -10
  4. data/lib/boleto/log.rb +35 -4
  5. data/lib/boleto_holmes/boleto_holmes.rb +39 -4
  6. data/lib/boleto_holmes/log.rb +35 -4
  7. data/lib/boleto_payment/boleto_payment.rb +38 -5
  8. data/lib/boleto_payment/log.rb +35 -4
  9. data/lib/brcode_payment/brcode_payment.rb +52 -13
  10. data/lib/brcode_payment/log.rb +35 -4
  11. data/lib/brcode_preview/brcode_preview.rb +2 -2
  12. data/lib/darf_payment/darf_payment.rb +218 -0
  13. data/lib/darf_payment/log.rb +125 -0
  14. data/lib/deposit/deposit.rb +45 -7
  15. data/lib/deposit/log.rb +35 -4
  16. data/lib/dict_key/dict_key.rb +44 -8
  17. data/lib/error.rb +13 -5
  18. data/lib/event/attempt.rb +125 -0
  19. data/lib/event/event.rb +40 -4
  20. data/lib/institution/institution.rb +67 -0
  21. data/lib/invoice/invoice.rb +66 -9
  22. data/lib/invoice/log.rb +51 -4
  23. data/lib/invoice/payment.rb +57 -0
  24. data/lib/payment_request/payment_request.rb +47 -7
  25. data/lib/starkbank.rb +7 -0
  26. data/lib/tax_payment/log.rb +125 -0
  27. data/lib/tax_payment/tax_payment.rb +203 -0
  28. data/lib/transaction/transaction.rb +37 -4
  29. data/lib/transfer/log.rb +35 -4
  30. data/lib/transfer/transfer.rb +47 -8
  31. data/lib/user/organization.rb +1 -1
  32. data/lib/user/project.rb +1 -1
  33. data/lib/utility_payment/log.rb +35 -4
  34. data/lib/utility_payment/utility_payment.rb +38 -5
  35. data/lib/utils/api.rb +1 -0
  36. data/lib/utils/request.rb +1 -1
  37. data/lib/utils/resource.rb +2 -21
  38. data/lib/utils/rest.rb +28 -12
  39. data/lib/utils/sub_resource.rb +28 -0
  40. data/lib/utils/url.rb +3 -1
  41. data/lib/webhook/webhook.rb +23 -2
  42. data/lib/workspace/workspace.rb +57 -8
  43. metadata +15 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 865e407d8c6cc8b02de3bbe91e5303ae996234867282f163a14f495fcdb5408c
4
- data.tar.gz: 96d199d34eabfd9694a55b1b435d84aa008a71dd697141b106b2373b11625070
3
+ metadata.gz: '08a72ad1389e8bcaa2f466c4fc6e3f0d299773da12d934449a389a36410b21eb'
4
+ data.tar.gz: 128f8bb159e098b3c1013332900e3cc949d05f4c62e4fcadead1c70b2f722581
5
5
  SHA512:
6
- metadata.gz: db7c4ff0fb3fc908b2d68c16f984b685a9181e0fc7d43bb2ae5e6085c10778ff91e4fee4575b37ca03379ca976a131039d5a4fdb626757f9b53427336740b621
7
- data.tar.gz: e3b1397b1b8b494f22469d6c8a3b74cd8165498096958d748bbbfeca4d7511efa6c599854b06a6be6d48af7aac1afb2184924d845894a72a08ed0084b4b8b85f
6
+ metadata.gz: 5811d6b08b2cd51589aee78ffb3b01193ff8df586af0ae7dcb401b1f0913448a420175090447cc4ace0cdbd318cc800664ea0d997ff2681a30426be0e0716b41
7
+ data.tar.gz: 00005b82bf82aaa0a2af6ec6df1b4001e2646848562688e874d8ea8a08d985c7ceacea0b34c4762d93c3fcc3aabc67d63594cb35752a49a71fe865c2f34e12e6
@@ -36,7 +36,7 @@ module StarkBank
36
36
  # ## Return:
37
37
  # - Balance object with updated attributes
38
38
  def self.get(user: nil)
39
- StarkBank::Utils::Rest.get_list(user: user, **resource).next
39
+ StarkBank::Utils::Rest.get_stream(user: user, **resource).next
40
40
  end
41
41
 
42
42
  class << self
data/lib/boleto/boleto.rb CHANGED
@@ -38,15 +38,17 @@ module StarkBank
38
38
  # - fee [integer, default nil]: fee charged when Boleto is paid. ex: 200 (= R$ 2.00)
39
39
  # - line [string, default nil]: generated Boleto line for payment. ex: '34191.09008 63571.277308 71444.640008 5 81960000000062'
40
40
  # - bar_code [string, default nil]: generated Boleto bar-code for payment. ex: '34195819600000000621090063571277307144464000'
41
+ # - transaction_ids [list of strings, default nil]: ledger transaction ids linked to this boleto. ex: ['19827356981273']
41
42
  # - status [string, default nil]: current Boleto status. ex: 'registered' or 'paid'
42
43
  # - created [DateTime, default nil]: creation datetime for the Boleto. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
44
+ # - our_number [string, default nil]: Reference number registered at the settlement bank. ex:'10131474'
43
45
  class Boleto < StarkBank::Utils::Resource
44
- attr_reader :amount, :name, :tax_id, :street_line_1, :street_line_2, :district, :city, :state_code, :zip_code, :due, :fine, :interest, :overdue_limit, :receiver_name, :receiver_tax_id, :tags, :descriptions, :discounts, :id, :fee, :line, :bar_code, :status, :created
46
+ attr_reader :amount, :name, :tax_id, :street_line_1, :street_line_2, :district, :city, :state_code, :zip_code, :due, :fine, :interest, :overdue_limit, :receiver_name, :receiver_tax_id, :tags, :descriptions, :discounts, :id, :fee, :line, :bar_code, :status, :transaction_ids, :created, :our_number
45
47
  def initialize(
46
48
  amount:, name:, tax_id:, street_line_1:, street_line_2:, district:, city:, state_code:, zip_code:,
47
49
  due: nil, fine: nil, interest: nil, overdue_limit: nil, receiver_name: nil, receiver_tax_id: nil,
48
50
  tags: nil, descriptions: nil, discounts: nil, id: nil, fee: nil, line: nil, bar_code: nil,
49
- status: nil, created: nil
51
+ status: nil, transaction_ids: nil, created: nil, our_number: nil
50
52
  )
51
53
  super(id)
52
54
  @amount = amount
@@ -71,7 +73,9 @@ module StarkBank
71
73
  @line = line
72
74
  @bar_code = bar_code
73
75
  @status = status
76
+ @transaction_ids = transaction_ids
74
77
  @created = StarkBank::Utils::Checks.check_datetime(created)
78
+ @our_number = our_number
75
79
  end
76
80
 
77
81
  # # Create Boletos
@@ -114,14 +118,14 @@ module StarkBank
114
118
  # - id [string]: object unique id. ex: '5656565656565656'
115
119
  #
116
120
  # ## Parameters (optional):
117
- # - layout [string]: Layout specification. Available options are "default" and "booklet"
118
- # - hidden_fields [list of strings, default nil]: List of string fields to be hidden in Boleto pdf. ex: ["customerAddress"]
121
+ # - layout [string]: Layout specification. Available options are 'default' and 'booklet'
122
+ # - hidden_fields [list of strings, default nil]: List of string fields to be hidden in Boleto pdf. ex: ['customerAddress']
119
123
  # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
120
124
  #
121
125
  # ## Return:
122
126
  # - Boleto pdf file
123
127
  def self.pdf(id, layout: nil, hidden_fields: nil, user: nil)
124
- StarkBank::Utils::Rest.get_pdf(id: id, layout: layout, hidden_fields: hidden_fields, user: user, **resource)
128
+ StarkBank::Utils::Rest.get_content(id: id, layout: layout, hidden_fields: hidden_fields, sub_resource_name: 'pdf', user: user, **resource)
125
129
  end
126
130
 
127
131
  # # Retrieve Boletos
@@ -130,19 +134,52 @@ module StarkBank
130
134
  #
131
135
  # ## Parameters (optional):
132
136
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
133
- # - after [Date , DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
134
- # - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
137
+ # - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
138
+ # - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
135
139
  # - status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'
136
140
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
137
141
  # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
138
- # - user [Organization/Project object]: Organization or Project object. Not necessary if Starkbank.user was set before function call
142
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
139
143
  #
140
144
  # ## Return:
141
145
  # - generator of Boleto objects with updated attributes
142
146
  def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
143
147
  after = StarkBank::Utils::Checks.check_date(after)
144
148
  before = StarkBank::Utils::Checks.check_date(before)
145
- StarkBank::Utils::Rest.get_list(
149
+ StarkBank::Utils::Rest.get_stream(
150
+ limit: limit,
151
+ after: after,
152
+ before: before,
153
+ status: status,
154
+ tags: tags,
155
+ ids: ids,
156
+ user: user,
157
+ **resource
158
+ )
159
+ end
160
+
161
+ # # Retrieve paged Boletos
162
+ #
163
+ # Receive a list of up to 100 Boleto objects previously created in the Stark Bank API and the cursor to the next page.
164
+ # Use this function instead of query if you want to manually page your requests.
165
+ #
166
+ # ## Parameters (optional):
167
+ # - cursor [string, default nil]: cursor returned on the previous page function call
168
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
169
+ # - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
170
+ # - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
171
+ # - status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'
172
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
173
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
174
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
175
+ #
176
+ # ## Return:
177
+ # - list of Boleto objects with updated attributes and cursor to retrieve the next page of Boleto objects
178
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
179
+ after = StarkBank::Utils::Checks.check_date(after)
180
+ before = StarkBank::Utils::Checks.check_date(before)
181
+ return StarkBank::Utils::Rest.get_page(
182
+ cursor: cursor,
146
183
  limit: limit,
147
184
  after: after,
148
185
  before: before,
@@ -198,7 +235,9 @@ module StarkBank
198
235
  line: json['line'],
199
236
  bar_code: json['bar_code'],
200
237
  status: json['status'],
201
- created: json['created']
238
+ transaction_ids: json['transaction_ids'],
239
+ created: json['created'],
240
+ our_number: json['our_number']
202
241
  )
203
242
  }
204
243
  }
data/lib/boleto/log.rb CHANGED
@@ -52,18 +52,49 @@ module StarkBank
52
52
  #
53
53
  # ## Parameters (optional):
54
54
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
55
- # - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
56
- # - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
55
+ # - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
56
+ # - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
57
57
  # - types [list of strings, default nil]: filter for log event types. ex: 'paid' or 'registered'
58
58
  # - boleto_ids [list of strings, default nil]: list of Boleto ids to filter logs. ex: ['5656565656565656', '4545454545454545']
59
- # - user [Organization/Project object]: Organization or Project object. Not necessary if Starkbank.user was set before function call
59
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
60
60
  #
61
61
  # ## Return:
62
62
  # - list of Log objects with updated attributes
63
63
  def self.query(limit: nil, after: nil, before: nil, types: nil, boleto_ids: nil, user: nil)
64
64
  after = StarkBank::Utils::Checks.check_date(after)
65
65
  before = StarkBank::Utils::Checks.check_date(before)
66
- StarkBank::Utils::Rest.get_list(
66
+ StarkBank::Utils::Rest.get_stream(
67
+ limit: limit,
68
+ after: after,
69
+ before: before,
70
+ types: types,
71
+ boleto_ids: boleto_ids,
72
+ user: user,
73
+ **resource
74
+ )
75
+ end
76
+
77
+ # # Retrieve paged Logs
78
+ #
79
+ # Receive a list of up to 100 Log objects previously created in the Stark Bank API and the cursor to the next page.
80
+ # Use this function instead of query if you want to manually page your requests.
81
+ #
82
+ # ## Parameters (optional):
83
+ # - cursor [string, default nil]: cursor returned on the previous page function call
84
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
85
+ # - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
86
+ # - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
87
+ # - types [list of strings, default nil]: filter for log event types. ex: 'paid' or 'registered'
88
+ # - boleto_ids [list of strings, default nil]: list of Boleto ids to filter logs. ex: ['5656565656565656', '4545454545454545']
89
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
90
+ #
91
+ # ## Return:
92
+ # - list of Log objects with updated attributes and cursor to retrieve the next page of Log objects
93
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, boleto_ids: nil, user: nil)
94
+ after = StarkBank::Utils::Checks.check_date(after)
95
+ before = StarkBank::Utils::Checks.check_date(before)
96
+ return StarkBank::Utils::Rest.get_page(
97
+ cursor: cursor,
67
98
  limit: limit,
68
99
  after: after,
69
100
  before: before,
@@ -75,20 +75,55 @@ module StarkBank
75
75
  #
76
76
  # ## Parameters (optional):
77
77
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
78
- # - after [Date , DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
79
- # - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
78
+ # - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
79
+ # - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
80
80
  # - status [string, default nil]: filter for status of retrieved objects. ex: 'solved'
81
81
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
82
82
  # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
83
83
  # - boleto_id [string, default nil]: filter for holmes that investigate a specific boleto by its ID. ex: '5656565656565656'
84
- # - user [Organization/Project object]: Organization or Project object. Not necessary if Starkbank.user was set before function call
84
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
85
85
  #
86
86
  # ## Return:
87
87
  # - generator of BoletoHolmes objects with updated attributes
88
88
  def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, boleto_id: nil, user: nil)
89
89
  after = StarkBank::Utils::Checks.check_date(after)
90
90
  before = StarkBank::Utils::Checks.check_date(before)
91
- StarkBank::Utils::Rest.get_list(
91
+ StarkBank::Utils::Rest.get_stream(
92
+ limit: limit,
93
+ after: after,
94
+ before: before,
95
+ status: status,
96
+ tags: tags,
97
+ ids: ids,
98
+ boleto_id: boleto_id,
99
+ user: user,
100
+ **resource
101
+ )
102
+ end
103
+
104
+ # # Retrieve paged BoletoHolmes
105
+ #
106
+ # Receive a list of up to 100 BoletoHolmes objects previously created in the Stark Bank API and the cursor to the next page.
107
+ # Use this function instead of query if you want to manually page your requests.
108
+ #
109
+ # ## Parameters (optional):
110
+ # - cursor [string, default nil]: cursor returned on the previous page function call
111
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
112
+ # - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
113
+ # - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
114
+ # - status [string, default nil]: filter for status of retrieved objects. ex: 'solved'
115
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
116
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
117
+ # - boleto_id [string, default nil]: filter for holmes that investigate a specific boleto by its ID. ex: '5656565656565656'
118
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
119
+ #
120
+ # ## Return:
121
+ # - list of BoletoHolmes objects with updated attributes and cursor to retrieve the next page of BoletoHolmes objects
122
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, boleto_id: nil, user: nil)
123
+ after = StarkBank::Utils::Checks.check_date(after)
124
+ before = StarkBank::Utils::Checks.check_date(before)
125
+ return StarkBank::Utils::Rest.get_page(
126
+ cursor: cursor,
92
127
  limit: limit,
93
128
  after: after,
94
129
  before: before,
@@ -50,18 +50,49 @@ module StarkBank
50
50
  #
51
51
  # ## Parameters (optional):
52
52
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
53
- # - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
54
- # - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
53
+ # - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
54
+ # - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
55
55
  # - types [list of strings, default nil]: filter for log event types. ex: 'paid' or 'registered'
56
56
  # - holmes_ids [list of strings, default nil]: list of BoletoHolmes ids to filter logs. ex: ['5656565656565656', '4545454545454545']
57
- # - user [Organization/Project object]: Organization or Project object. Not necessary if Starkbank.user was set before function call
57
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
58
58
  #
59
59
  # ## Return:
60
60
  # - list of Log objects with updated attributes
61
61
  def self.query(limit: nil, after: nil, before: nil, types: nil, holmes_ids: nil, user: nil)
62
62
  after = StarkBank::Utils::Checks.check_date(after)
63
63
  before = StarkBank::Utils::Checks.check_date(before)
64
- StarkBank::Utils::Rest.get_list(
64
+ StarkBank::Utils::Rest.get_stream(
65
+ limit: limit,
66
+ after: after,
67
+ before: before,
68
+ types: types,
69
+ holmes_ids: holmes_ids,
70
+ user: user,
71
+ **resource
72
+ )
73
+ end
74
+
75
+ # # Retrieve paged Logs
76
+ #
77
+ # Receive a list of up to 100 Log objects previously created in the Stark Bank API and the cursor to the next page.
78
+ # Use this function instead of query if you want to manually page your requests.
79
+ #
80
+ # ## Parameters (optional):
81
+ # - cursor [string, default nil]: cursor returned on the previous page function call
82
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
83
+ # - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
84
+ # - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
85
+ # - types [list of strings, default nil]: filter for log event types. ex: 'paid' or 'registered'
86
+ # - holmes_ids [list of strings, default nil]: list of BoletoHolmes ids to filter logs. ex: ['5656565656565656', '4545454545454545']
87
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
88
+ #
89
+ # ## Return:
90
+ # - list of Log objects with updated attributes and cursor to retrieve the next page of Log objects
91
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, holmes_ids: nil, user: nil)
92
+ after = StarkBank::Utils::Checks.check_date(after)
93
+ before = StarkBank::Utils::Checks.check_date(before)
94
+ return StarkBank::Utils::Rest.get_page(
95
+ cursor: cursor,
65
96
  limit: limit,
66
97
  after: after,
67
98
  before: before,
@@ -91,7 +91,7 @@ module StarkBank
91
91
  # ## Return:
92
92
  # - BoletoPayment pdf file
93
93
  def self.pdf(id, user: nil)
94
- StarkBank::Utils::Rest.get_pdf(id: id, user: user, **resource)
94
+ StarkBank::Utils::Rest.get_content(id: id, user: user, sub_resource_name: 'pdf', **resource)
95
95
  end
96
96
 
97
97
  # # Retrieve BoletoPayments
@@ -100,19 +100,52 @@ module StarkBank
100
100
  #
101
101
  # ## Parameters (optional):
102
102
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
103
- # - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
104
- # - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
103
+ # - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
104
+ # - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
105
105
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
106
106
  # - ids [list of strings, default nil]: list of strings to get specific entities by ids. ex: ['12376517623', '1928367198236']
107
107
  # - status [string, default nil]: filter for status of retrieved objects. ex: 'paid'
108
- # - user [Organization/Project object]: Organization or Project object. Not necessary if Starkbank.user was set before function call
108
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
109
109
  #
110
110
  # ## Return:
111
111
  # - generator of BoletoPayment objects with updated attributes
112
112
  def self.query(limit: nil, after: nil, before: nil, tags: nil, ids: nil, status: nil, user: nil)
113
113
  after = StarkBank::Utils::Checks.check_date(after)
114
114
  before = StarkBank::Utils::Checks.check_date(before)
115
- StarkBank::Utils::Rest.get_list(
115
+ StarkBank::Utils::Rest.get_stream(
116
+ user: user,
117
+ limit: limit,
118
+ after: after,
119
+ before: before,
120
+ tags: tags,
121
+ ids: ids,
122
+ status: status,
123
+ **resource
124
+ )
125
+ end
126
+
127
+ # # Retrieve paged BoletoPayments
128
+ #
129
+ # Receive a list of up to 100 BoletoPayment objects previously created in the Stark Bank API and the cursor to the next page.
130
+ # Use this function instead of query if you want to manually page your requests.
131
+ #
132
+ # ## Parameters (optional):
133
+ # - cursor [string, default nil]: cursor returned on the previous page function call
134
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
135
+ # - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
136
+ # - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
137
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
138
+ # - ids [list of strings, default nil]: list of strings to get specific entities by ids. ex: ['12376517623', '1928367198236']
139
+ # - status [string, default nil]: filter for status of retrieved objects. ex: 'paid'
140
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
141
+ #
142
+ # ## Return:
143
+ # - list of BoletoPayment objects with updated attributes and cursor to retrieve the next page of BoletoPayment objects
144
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, tags: nil, ids: nil, status: nil, user: nil)
145
+ after = StarkBank::Utils::Checks.check_date(after)
146
+ before = StarkBank::Utils::Checks.check_date(before)
147
+ return StarkBank::Utils::Rest.get_page(
148
+ cursor: cursor,
116
149
  user: user,
117
150
  limit: limit,
118
151
  after: after,
@@ -52,18 +52,49 @@ module StarkBank
52
52
  #
53
53
  # ## Parameters (optional):
54
54
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
55
- # - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
56
- # - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
55
+ # - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
56
+ # - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
57
57
  # - types [list of strings, default nil]: filter retrieved objects by event types. ex: 'success' or 'failed'
58
58
  # - payment_ids [list of strings, default nil]: list of BoletoPayment ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
59
- # - user [Organization/Project object]: Organization or Project object. Not necessary if Starkbank.user was set before function call
59
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
60
60
  #
61
61
  # ## Return:
62
62
  # - list of Log objects with updated attributes
63
63
  def self.query(limit: nil, after: nil, before: nil, types: nil, payment_ids: nil, user: nil)
64
64
  after = StarkBank::Utils::Checks.check_date(after)
65
65
  before = StarkBank::Utils::Checks.check_date(before)
66
- StarkBank::Utils::Rest.get_list(
66
+ StarkBank::Utils::Rest.get_stream(
67
+ limit: limit,
68
+ after: after,
69
+ before: before,
70
+ types: types,
71
+ payment_ids: payment_ids,
72
+ user: user,
73
+ **resource
74
+ )
75
+ end
76
+
77
+ # # Retrieve paged Logs
78
+ #
79
+ # Receive a list of up to 100 Log objects previously created in the Stark Bank API and the cursor to the next page.
80
+ # Use this function instead of query if you want to manually page your requests.
81
+ #
82
+ # ## Parameters (optional):
83
+ # - cursor [string, default nil]: cursor returned on the previous page function call
84
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
85
+ # - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
86
+ # - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
87
+ # - types [list of strings, default nil]: filter retrieved objects by event types. ex: 'success' or 'failed'
88
+ # - payment_ids [list of strings, default nil]: list of BoletoPayment ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
89
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
90
+ #
91
+ # ## Return:
92
+ # - list of Log objects with updated attributes and cursor to retrieve the next page of Log objects
93
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, payment_ids: nil, user: nil)
94
+ after = StarkBank::Utils::Checks.check_date(after)
95
+ before = StarkBank::Utils::Checks.check_date(before)
96
+ return StarkBank::Utils::Rest.get_page(
97
+ cursor: cursor,
67
98
  limit: limit,
68
99
  after: after,
69
100
  before: before,
@@ -12,9 +12,9 @@ module StarkBank
12
12
  # to the Stark Bank API and returns the list of created objects.
13
13
  #
14
14
  # ## Parameters (required):
15
- # - brcode [string]: String loaded directly from the QRCode or copied from the invoice. ex: "00020126580014br.gov.bcb.pix0136a629532e-7693-4846-852d-1bbff817b5a8520400005303986540510.005802BR5908T'Challa6009Sao Paulo62090505123456304B14A"
16
- # - tax_id [string]: receiver tax ID (CPF or CNPJ) with or without formatting. ex: "01234567890" or "20.018.183/0001-80"
17
- # - description [string]: Text to be displayed in your statement (min. 10 characters). ex: "payment ABC"
15
+ # - brcode [string]: String loaded directly from the QRCode or copied from the invoice. ex: '00020126580014br.gov.bcb.pix0136a629532e-7693-4846-852d-1bbff817b5a8520400005303986540510.005802BR5908T'Challa6009Sao Paulo62090505123456304B14A'
16
+ # - tax_id [string]: receiver tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
17
+ # - description [string]: Text to be displayed in your statement (min. 10 characters). ex: 'payment ABC'
18
18
  #
19
19
  # ## Parameters (conditionally required):
20
20
  # - amount [int, default nil]: If the BRCode does not provide an amount, this parameter is mandatory, else it is optional. ex: 23456 (= R$ 234.56)
@@ -24,15 +24,17 @@ module StarkBank
24
24
  # - tags [list of strings, default nil]: list of strings for tagging
25
25
  #
26
26
  # ## Attributes (return-only):
27
- # - id [string, default nil]: unique id returned when payment is created. ex: "5656565656565656"
28
- # - status [string, default nil]: current payment status. ex: "success" or "failed"
29
- # - type [string, default nil]: brcode type. ex: "static" or "dynamic"
27
+ # - id [string, default nil]: unique id returned when payment is created. ex: '5656565656565656'
28
+ # - name [string, nil]: receiver name. ex: 'Jon Snow'
29
+ # - status [string, default nil]: current payment status. ex: 'success' or 'failed'
30
+ # - type [string, default nil]: brcode type. ex: 'static' or 'dynamic'
31
+ # - transaction_ids [list of strings, default nil]: ledger transaction ids linked to this payment. ex: ['19827356981273']
30
32
  # - fee [integer, default nil]: fee charged when the brcode payment is created. ex: 200 (= R$ 2.00)
31
33
  # - updated [datetime.datetime, default nil]: latest update datetime for the payment. ex: datetime.datetime(2020, 3, 10, 10, 30, 0, 0)
32
34
  # - created [datetime.datetime, default nil]: creation datetime for the payment. ex: datetime.datetime(2020, 3, 10, 10, 30, 0, 0)
33
35
  class BrcodePayment < StarkBank::Utils::Resource
34
- attr_reader :brcode, :tax_id, :description, :amount, :scheduled, :tags, :id, :status, :type, :fee, :updated, :created
35
- def initialize(brcode:, tax_id:, description:, amount: nil, scheduled: nil, tags: nil, id: nil, status: nil, type: nil, fee: nil, updated: nil, created: nil)
36
+ attr_reader :brcode, :tax_id, :description, :amount, :scheduled, :tags, :id, :name, :status, :type, :transaction_ids, :fee, :updated, :created
37
+ def initialize(brcode:, tax_id:, description:, amount: nil, scheduled: nil, tags: nil, id: nil, name: nil, status: nil, type: nil, transaction_ids: nil, fee: nil, updated: nil, created: nil)
36
38
  super(id)
37
39
  @brcode = brcode
38
40
  @tax_id = tax_id
@@ -40,8 +42,10 @@ module StarkBank
40
42
  @amount = amount
41
43
  @scheduled = StarkBank::Utils::Checks.check_date_or_datetime(scheduled)
42
44
  @tags = tags
45
+ @name = name
43
46
  @status = status
44
47
  @type = type
48
+ @transaction_ids = transaction_ids
45
49
  @fee = fee
46
50
  @updated = StarkBank::Utils::Checks.check_datetime(updated)
47
51
  @created = StarkBank::Utils::Checks.check_datetime(created)
@@ -92,7 +96,7 @@ module StarkBank
92
96
  # ## Return:
93
97
  # - BrcodePayment pdf file
94
98
  def self.pdf(id, user: nil)
95
- StarkBank::Utils::Rest.get_pdf(id: id, user: user, **resource)
99
+ StarkBank::Utils::Rest.get_content(id: id, user: user, sub_resource_name: 'pdf', **resource)
96
100
  end
97
101
 
98
102
  # # Update a BrcodePayment entity
@@ -118,26 +122,59 @@ module StarkBank
118
122
  #
119
123
  # ## Parameters (optional):
120
124
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
121
- # - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
122
- # - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
125
+ # - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
126
+ # - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
123
127
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
124
128
  # - ids [list of strings, default nil]: list of strings to get specific entities by ids. ex: ['12376517623', '1928367198236']
125
129
  # - status [string, default nil]: filter for status of retrieved objects. ex: 'paid'
126
- # - user [Organization/Project object]: Organization or Project object. Not necessary if Starkbank.user was set before function call
130
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
127
131
  #
128
132
  # ## Return:
129
133
  # - generator of BrcodePayment objects with updated attributes
130
134
  def self.query(limit: nil, after: nil, before: nil, tags: nil, ids: nil, status: nil, user: nil)
131
135
  after = StarkBank::Utils::Checks.check_date(after)
132
136
  before = StarkBank::Utils::Checks.check_date(before)
133
- StarkBank::Utils::Rest.get_list(
137
+ StarkBank::Utils::Rest.get_stream(
138
+ limit: limit,
139
+ after: after,
140
+ before: before,
141
+ tags: tags,
142
+ ids: ids,
143
+ status: status,
134
144
  user: user,
145
+ **resource
146
+ )
147
+ end
148
+
149
+ # # Retrieve paged BrcodePayments
150
+ #
151
+ # Receive a list of up to 100 BrcodePayment objects previously created in the Stark Bank API and the cursor to the next page.
152
+ # Use this function instead of query if you want to manually page your requests.
153
+ #
154
+ # ## Parameters (optional):
155
+ # - cursor [string, default nil]: cursor returned on the previous page function call
156
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
157
+ # - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
158
+ # - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
159
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
160
+ # - ids [list of strings, default nil]: list of strings to get specific entities by ids. ex: ['12376517623', '1928367198236']
161
+ # - status [string, default nil]: filter for status of retrieved objects. ex: 'paid'
162
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
163
+ #
164
+ # ## Return:
165
+ # - list of BrcodePayment objects with updated attributes and cursor to retrieve the next page of BrcodePayment objects
166
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, tags: nil, ids: nil, status: nil, user: nil)
167
+ after = StarkBank::Utils::Checks.check_date(after)
168
+ before = StarkBank::Utils::Checks.check_date(before)
169
+ return StarkBank::Utils::Rest.get_page(
170
+ cursor: cursor,
135
171
  limit: limit,
136
172
  after: after,
137
173
  before: before,
138
174
  tags: tags,
139
175
  ids: ids,
140
176
  status: status,
177
+ user: user,
141
178
  **resource
142
179
  )
143
180
  end
@@ -154,8 +191,10 @@ module StarkBank
154
191
  scheduled: json['scheduled'],
155
192
  tags: json['tags'],
156
193
  id: json['id'],
194
+ name: json['name'],
157
195
  status: json['status'],
158
196
  type: json['type'],
197
+ transaction_ids: json['transaction_ids'],
159
198
  fee: json['fee'],
160
199
  updated: json['updated'],
161
200
  created: json['created']