starkinfra 0.5.0 → 0.6.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 (89) hide show
  1. checksums.yaml +4 -4
  2. data/lib/{brcodepreview/brcodepreview.rb → brcode_preview/brcode_preview.rb} +5 -2
  3. data/lib/brcode_preview/subscription.rb +102 -0
  4. data/lib/business_attachment/business_attachment.rb +186 -0
  5. data/lib/business_attachment/log.rb +127 -0
  6. data/lib/business_identity/business_identity.rb +225 -0
  7. data/lib/business_identity/log.rb +127 -0
  8. data/lib/{creditnote/creditnote.rb → credit_note/credit_note.rb} +11 -5
  9. data/lib/{creditnote → credit_note}/log.rb +1 -1
  10. data/lib/credit_note/rule.rb +46 -0
  11. data/lib/event/event.rb +10 -2
  12. data/lib/{individualdocument → individual_document}/log.rb +1 -1
  13. data/lib/{individualidentity → individual_identity}/log.rb +1 -1
  14. data/lib/{issuingbalance/issuingbalance.rb → issuing_balance/issuing_balance.rb} +8 -2
  15. data/lib/issuing_billing_invoice/issuing_billing_invoice.rb +155 -0
  16. data/lib/issuing_billing_transaction/issuing_billing_transaction.rb +142 -0
  17. data/lib/{issuingcard/issuingcard.rb → issuing_card/issuing_card.rb} +5 -2
  18. data/lib/{issuingcard → issuing_card}/log.rb +1 -1
  19. data/lib/{issuingembossingrequest → issuing_embossing_request}/log.rb +1 -1
  20. data/lib/{issuingholder → issuing_holder}/log.rb +1 -1
  21. data/lib/{issuinginvoice → issuing_invoice}/log.rb +1 -1
  22. data/lib/{issuingproduct/issuingproduct.rb → issuing_product/issuing_product.rb} +5 -2
  23. data/lib/{issuingpurchase/issuingpurchase.rb → issuing_purchase/issuing_purchase.rb} +18 -9
  24. data/lib/{issuingpurchase → issuing_purchase}/log.rb +1 -1
  25. data/lib/{issuingrestock → issuing_restock}/log.rb +1 -1
  26. data/lib/{issuingrule/issuingrule.rb → issuing_rule/issuing_rule.rb} +9 -3
  27. data/lib/{issuingstock/issuingstock.rb → issuing_stock/issuing_stock.rb} +5 -2
  28. data/lib/{issuingstock → issuing_stock}/log.rb +1 -1
  29. data/lib/issuing_stock_rule/issuing_stock_rule.rb +213 -0
  30. data/lib/issuing_token/issuing_token.rb +309 -0
  31. data/lib/issuing_token_design/issuing_token_design.rb +118 -0
  32. data/lib/issuing_token_request/issuing_token_request.rb +63 -0
  33. data/lib/{merchantcategory/merchantcategory.rb → merchant_category/merchant_category.rb} +6 -3
  34. data/lib/{pixchargeback → pix_chargeback}/log.rb +1 -1
  35. data/lib/{pixchargeback/pixchargeback.rb → pix_chargeback/pix_chargeback.rb} +26 -2
  36. data/lib/{pixclaim → pix_claim}/log.rb +1 -1
  37. data/lib/pix_dispute/log.rb +127 -0
  38. data/lib/pix_dispute/pix_dispute.rb +210 -0
  39. data/lib/pix_dispute/transaction.rb +91 -0
  40. data/lib/pix_fraud/log.rb +128 -0
  41. data/lib/pix_fraud/pix_fraud.rb +180 -0
  42. data/lib/{pixinfraction → pix_infraction}/log.rb +1 -1
  43. data/lib/{pixinfraction/pixinfraction.rb → pix_infraction/pix_infraction.rb} +18 -4
  44. data/lib/pix_internal_transaction_report/log.rb +129 -0
  45. data/lib/pix_internal_transaction_report/pix_internal_transaction_report.rb +200 -0
  46. data/lib/{pixkey → pix_key}/log.rb +1 -1
  47. data/lib/pix_key_holmes/pix_key_holmes.rb +139 -0
  48. data/lib/pix_pull_request/log.rb +127 -0
  49. data/lib/pix_pull_request/pix_pull_request.rb +265 -0
  50. data/lib/pix_pull_subscription/log.rb +127 -0
  51. data/lib/pix_pull_subscription/pix_pull_subscription.rb +281 -0
  52. data/lib/{pixrequest → pix_request}/log.rb +1 -1
  53. data/lib/{pixrequest/pixrequest.rb → pix_request/pix_request.rb} +9 -2
  54. data/lib/{pixreversal → pix_reversal}/log.rb +1 -1
  55. data/lib/starkinfra.rb +83 -59
  56. data/lib/utils/parse.rb +2 -2
  57. data/lib/utils/return_id.rb +24 -0
  58. data/lib/webhook/webhook.rb +2 -2
  59. metadata +87 -67
  60. /data/lib/{cardmethod/cardmethod.rb → card_method/card_method.rb} +0 -0
  61. /data/lib/{creditholmes/creditholmes.rb → credit_holmes/credit_holmes.rb} +0 -0
  62. /data/lib/{creditnote → credit_note}/invoice/description.rb +0 -0
  63. /data/lib/{creditnote → credit_note}/invoice/discount.rb +0 -0
  64. /data/lib/{creditnote → credit_note}/invoice/invoice.rb +0 -0
  65. /data/lib/{creditnote → credit_note}/transfer.rb +0 -0
  66. /data/lib/{creditpreview/creditnotepreview.rb → credit_preview/credit_note_preview.rb} +0 -0
  67. /data/lib/{creditpreview/creditpreview.rb → credit_preview/credit_preview.rb} +0 -0
  68. /data/lib/{creditsigner/creditsigner.rb → credit_signer/credit_signer.rb} +0 -0
  69. /data/lib/{dynamicbrcode/dynamicbrcode.rb → dynamic_brcode/dynamic_brcode.rb} +0 -0
  70. /data/lib/{individualdocument/individualdocument.rb → individual_document/individual_document.rb} +0 -0
  71. /data/lib/{individualidentity/individualidentity.rb → individual_identity/individual_identity.rb} +0 -0
  72. /data/lib/{issuingdesign/issuingdesign.rb → issuing_design/issuing_design.rb} +0 -0
  73. /data/lib/{issuingembossingkit/issuingembossingkit.rb → issuing_embossing_kit/issuing_embossing_kit.rb} +0 -0
  74. /data/lib/{issuingembossingrequest/issuingembossingrequest.rb → issuing_embossing_request/issuing_embossing_request.rb} +0 -0
  75. /data/lib/{issuingholder/issuingholder.rb → issuing_holder/issuing_holder.rb} +0 -0
  76. /data/lib/{issuinginvoice/issuinginvoice.rb → issuing_invoice/issuing_invoice.rb} +0 -0
  77. /data/lib/{issuingrestock/issuingrestock.rb → issuing_restock/issuing_restock.rb} +0 -0
  78. /data/lib/{issuingtransaction/issuingtransaction.rb → issuing_transaction/issuing_transaction.rb} +0 -0
  79. /data/lib/{issuingwithdrawal/issuingwithdrawal.rb → issuing_withdrawal/issuing_withdrawal.rb} +0 -0
  80. /data/lib/{merchantcountry/merchantcountry.rb → merchant_country/merchant_country.rb} +0 -0
  81. /data/lib/{pixbalance/pixbalance.rb → pix_balance/pix_balance.rb} +0 -0
  82. /data/lib/{pixclaim/pixclaim.rb → pix_claim/pix_claim.rb} +0 -0
  83. /data/lib/{pixdirector/pixdirector.rb → pix_director/pix_director.rb} +0 -0
  84. /data/lib/{pixdomain → pix_domain}/certificate.rb +0 -0
  85. /data/lib/{pixdomain/pixdomain.rb → pix_domain/pix_domain.rb} +0 -0
  86. /data/lib/{pixkey/pixkey.rb → pix_key/pix_key.rb} +0 -0
  87. /data/lib/{pixreversal/pixreversal.rb → pix_reversal/pix_reversal.rb} +0 -0
  88. /data/lib/{pixstatement/pixstatement.rb → pix_statement/pix_statement.rb} +0 -0
  89. /data/lib/{staticbrcode/staticbrcode.rb → static_brcode/static_brcode.rb} +0 -0
@@ -0,0 +1,200 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/rest')
5
+
6
+
7
+ module StarkInfra
8
+ # # PixInternalTransactionReport object
9
+ #
10
+ # Transactions that happen internally — outside of the SPI — must be reported to
11
+ # the Central Bank so they are reflected in the participant's statements. A
12
+ # PixInternalTransactionReport is the report you create for each such transaction.
13
+ #
14
+ # When you initialize a PixInternalTransactionReport, the entity will not be
15
+ # automatically created in the Stark Infra API. The 'create' function sends the
16
+ # objects to the Stark Infra API and returns the list of created objects.
17
+ #
18
+ # ## Parameters (required):
19
+ # - amount [integer]: amount in cents of the reported transaction. ex: 1234 (= R$ 12.34)
20
+ # - created [DateTime or string]: datetime when the reported transaction occurred. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
21
+ # - end_to_end_id [string]: central bank's unique transaction id. ex: 'E20018183202201201213u34sav898j'
22
+ # - method [string]: execution method of the transaction. ex: 'contactless', 'dict', 'dynamicQrcode', 'initiator', 'manual', 'payerQrcode', 'staticContactless', 'staticQrcode' or 'subscription'
23
+ # - reference_type [string]: type of the reported transaction. ex: 'request' or 'reversal'
24
+ # - sender_account_number [string]: sender's bank account number. ex: '876543-2'
25
+ # - sender_branch_code [string]: sender's bank account branch code. ex: '1357-9'
26
+ # - sender_account_type [string]: sender's bank account type. ex: 'checking', 'savings', 'salary' or 'payment'
27
+ # - sender_bank_code [string]: sender's participant code (ISPB). ex: '20018183'
28
+ # - sender_tax_id [string]: sender's tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
29
+ # - receiver_account_number [string]: receiver's bank account number. ex: '876543-2'
30
+ # - receiver_branch_code [string]: receiver's bank account branch code. ex: '1357-9'
31
+ # - receiver_account_type [string]: receiver's bank account type. ex: 'checking', 'savings', 'salary' or 'payment'
32
+ # - receiver_bank_code [string]: receiver's participant code (ISPB). ex: '20018183'
33
+ # - receiver_tax_id [string]: receiver's tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
34
+ #
35
+ # ## Parameters (conditionally-required):
36
+ # - return_id [string, default nil]: central bank's unique reversal id. Required when reference_type is 'reversal'. ex: 'D20018183202201201213u34sav898j'
37
+ #
38
+ # ## Parameters (optional):
39
+ # - receiver_key_id [string, default nil]: receiver's Pix key. ex: '+5511989898989'
40
+ #
41
+ # ## Attributes (return-only):
42
+ # - id [string]: unique id returned when the PixInternalTransactionReport is created. ex: '5656565656565656'
43
+ # - status [string]: current PixInternalTransactionReport status. ex: 'created', 'failed', 'sent' or 'success'
44
+ # - updated [DateTime]: latest update datetime for the PixInternalTransactionReport. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
45
+ class PixInternalTransactionReport < StarkCore::Utils::Resource
46
+ attr_reader :amount, :created, :end_to_end_id, :method, :reference_type, :sender_account_number,
47
+ :sender_branch_code, :sender_account_type, :sender_bank_code, :sender_tax_id,
48
+ :receiver_account_number, :receiver_branch_code, :receiver_account_type, :receiver_bank_code,
49
+ :receiver_tax_id, :receiver_key_id, :return_id, :id, :status, :updated
50
+ def initialize(
51
+ amount:, created:, end_to_end_id:, method:, reference_type:, sender_account_number:, sender_branch_code:,
52
+ sender_account_type:, sender_bank_code:, sender_tax_id:, receiver_account_number:, receiver_branch_code:,
53
+ receiver_account_type:, receiver_bank_code:, receiver_tax_id:, receiver_key_id: nil, return_id: nil,
54
+ id: nil, status: nil, updated: nil
55
+ )
56
+ super(id)
57
+ @amount = amount
58
+ @created = StarkCore::Utils::Checks.check_datetime(created)
59
+ @end_to_end_id = end_to_end_id
60
+ @method = method
61
+ @reference_type = reference_type
62
+ @sender_account_number = sender_account_number
63
+ @sender_branch_code = sender_branch_code
64
+ @sender_account_type = sender_account_type
65
+ @sender_bank_code = sender_bank_code
66
+ @sender_tax_id = sender_tax_id
67
+ @receiver_account_number = receiver_account_number
68
+ @receiver_branch_code = receiver_branch_code
69
+ @receiver_account_type = receiver_account_type
70
+ @receiver_bank_code = receiver_bank_code
71
+ @receiver_tax_id = receiver_tax_id
72
+ @receiver_key_id = receiver_key_id
73
+ @return_id = return_id
74
+ @status = status
75
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
76
+ end
77
+
78
+ # # Create PixInternalTransactionReports
79
+ #
80
+ # Send a list of PixInternalTransactionReport objects for creation in the Stark Infra API
81
+ #
82
+ # ## Parameters (required):
83
+ # - reports [list of PixInternalTransactionReport objects]: list of PixInternalTransactionReport objects to be created in the API
84
+ #
85
+ # ## Parameters (optional):
86
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
87
+ #
88
+ # ## Return:
89
+ # - list of PixInternalTransactionReport objects with updated attributes
90
+ def self.create(reports, user: nil)
91
+ StarkInfra::Utils::Rest.post(entities: reports, user: user, **resource)
92
+ end
93
+
94
+ # # Retrieve a specific PixInternalTransactionReport
95
+ #
96
+ # Receive a single PixInternalTransactionReport object previously created in the Stark Infra API by passing its id
97
+ #
98
+ # ## Parameters (required):
99
+ # - id [string]: object unique id. ex: '5656565656565656'
100
+ #
101
+ # ## Parameters (optional):
102
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
103
+ #
104
+ # ## Return:
105
+ # - PixInternalTransactionReport object with updated attributes
106
+ def self.get(id, user: nil)
107
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
108
+ end
109
+
110
+ # # Retrieve PixInternalTransactionReports
111
+ #
112
+ # Receive a generator of PixInternalTransactionReport objects previously created in the Stark Infra API
113
+ #
114
+ # ## Parameters (optional):
115
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
116
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
117
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
118
+ # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['success'] or ['sent', 'failed']
119
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
120
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
121
+ #
122
+ # ## Return:
123
+ # - generator of PixInternalTransactionReport objects with updated attributes
124
+ def self.query(limit: nil, after: nil, before: nil, status: nil, ids: nil, user: nil)
125
+ after = StarkCore::Utils::Checks.check_date(after)
126
+ before = StarkCore::Utils::Checks.check_date(before)
127
+ StarkInfra::Utils::Rest.get_stream(
128
+ limit: limit,
129
+ after: after,
130
+ before: before,
131
+ status: status,
132
+ ids: ids,
133
+ user: user,
134
+ **resource
135
+ )
136
+ end
137
+
138
+ # # Retrieve paged PixInternalTransactionReports
139
+ #
140
+ # Receive a list of up to 100 PixInternalTransactionReport objects previously created in the Stark Infra API and the cursor to the next page.
141
+ # Use this function instead of query if you want to manually page your requests.
142
+ #
143
+ # ## Parameters (optional):
144
+ # - cursor [string, default nil]: cursor returned on the previous page function call
145
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
146
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
147
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
148
+ # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['success'] or ['sent', 'failed']
149
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
150
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
151
+ #
152
+ # ## Return:
153
+ # - list of PixInternalTransactionReport objects with updated attributes
154
+ # - cursor to retrieve the next page of PixInternalTransactionReport objects
155
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, ids: nil, user: nil)
156
+ after = StarkCore::Utils::Checks.check_date(after)
157
+ before = StarkCore::Utils::Checks.check_date(before)
158
+ StarkInfra::Utils::Rest.get_page(
159
+ cursor: cursor,
160
+ limit: limit,
161
+ after: after,
162
+ before: before,
163
+ status: status,
164
+ ids: ids,
165
+ user: user,
166
+ **resource
167
+ )
168
+ end
169
+
170
+ def self.resource
171
+ {
172
+ resource_name: 'PixInternalTransactionReport',
173
+ resource_maker: proc { |json|
174
+ PixInternalTransactionReport.new(
175
+ id: json['id'],
176
+ amount: json['amount'],
177
+ created: json['created'],
178
+ end_to_end_id: json['end_to_end_id'],
179
+ method: json['method'],
180
+ reference_type: json['reference_type'],
181
+ sender_account_number: json['sender_account_number'],
182
+ sender_branch_code: json['sender_branch_code'],
183
+ sender_account_type: json['sender_account_type'],
184
+ sender_bank_code: json['sender_bank_code'],
185
+ sender_tax_id: json['sender_tax_id'],
186
+ receiver_account_number: json['receiver_account_number'],
187
+ receiver_branch_code: json['receiver_branch_code'],
188
+ receiver_account_type: json['receiver_account_type'],
189
+ receiver_bank_code: json['receiver_bank_code'],
190
+ receiver_tax_id: json['receiver_tax_id'],
191
+ receiver_key_id: json['receiver_key_id'],
192
+ return_id: json['return_id'],
193
+ status: json['status'],
194
+ updated: json['updated']
195
+ )
196
+ }
197
+ }
198
+ end
199
+ end
200
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require('starkcore')
4
- require_relative('pixkey')
4
+ require_relative('pix_key')
5
5
  require_relative('../utils/rest')
6
6
 
7
7
  module StarkInfra
@@ -0,0 +1,139 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/rest')
5
+
6
+ module StarkInfra
7
+ # # PixKeyHolmes object
8
+ #
9
+ # A PixKeyHolmes investigates the registration status of a Pix Key in the
10
+ # Central Bank's DICT. You open one per key you want to check; the API
11
+ # resolves it asynchronously and reports back whether the key is registered.
12
+ #
13
+ # When you initialize a PixKeyHolmes, the entity will not be automatically
14
+ # created in the Stark Infra API. The 'create' function sends the objects
15
+ # to the Stark Infra API and returns the list of created objects.
16
+ #
17
+ # ## Parameters (required):
18
+ # - key_id [string]: Pix Key to be investigated. ex: "+5511989898989", "11.222.333/0001-00", "valid@sandbox.com"
19
+ #
20
+ # ## Parameters (optional):
21
+ # - tags [list of strings, default nil]: list of strings for reference when searching for PixKeyHolmes. ex: ["travel", "food"]
22
+ #
23
+ # ## Attributes (return-only):
24
+ # - id [string]: unique id returned when the PixKeyHolmes is created. ex: "5656565656565656"
25
+ # - result [string]: investigation result once the case is solved. ex: "registered", "unregistered"
26
+ # - status [string]: current status of the PixKeyHolmes. ex: "created", "solving", "solved", "failed"
27
+ # - created [DateTime]: creation datetime for the PixKeyHolmes. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
28
+ # - updated [DateTime]: latest update datetime for the PixKeyHolmes. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
29
+ class PixKeyHolmes < StarkCore::Utils::Resource
30
+ attr_reader :key_id, :tags, :id, :result, :status, :updated, :created
31
+ def initialize(key_id:, tags: nil, id: nil, result: nil, status: nil, updated: nil, created: nil)
32
+ super(id)
33
+ @key_id = key_id
34
+ @tags = tags
35
+ @id = id
36
+ @result = result
37
+ @status = status
38
+ @created = StarkCore::Utils::Checks.check_datetime(created)
39
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
40
+ end
41
+
42
+ # # Create PixKeyHolmes
43
+ #
44
+ # Send a list of PixKeyHolmes objects for creation at the Stark Infra API
45
+ #
46
+ # ## Parameters (required):
47
+ # - holmes [list of PixKeyHolmes objects]: list of PixKeyHolmes objects to be created in the API.
48
+ #
49
+ # ## Parameters (optional):
50
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
51
+ #
52
+ # ## Return:
53
+ # - list of PixKeyHolmes objects with updated attributes
54
+ def self.create(holmes, user: nil)
55
+ StarkInfra::Utils::Rest.post(entities: holmes, user: user, **resource)
56
+ end
57
+
58
+ # # Retrieve PixKeyHolmes
59
+ #
60
+ # Receive a generator of PixKeyHolmes objects previously created in the Stark Infra API
61
+ #
62
+ # ## Parameters (optional):
63
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
64
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
65
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
66
+ # - status [list of strings, default nil]: filter for status of retrieved objects. The live API accepts only "solved" or "solving" as filter values. ex: ["solved", "solving"]
67
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ["travel", "food"]
68
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
69
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
70
+ #
71
+ # ## Return:
72
+ # - generator of PixKeyHolmes objects with updated attributes
73
+ def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
74
+ after = StarkCore::Utils::Checks.check_date(after)
75
+ before = StarkCore::Utils::Checks.check_date(before)
76
+ StarkInfra::Utils::Rest.get_stream(
77
+ limit: limit,
78
+ after: after,
79
+ before: before,
80
+ status: status,
81
+ tags: tags,
82
+ ids: ids,
83
+ user: user,
84
+ **resource
85
+ )
86
+ end
87
+
88
+ # # Retrieve PixKeyHolmes
89
+ #
90
+ # Receive a list of up to 100 PixKeyHolmes objects previously created in the Stark Infra API and the cursor to the next page.
91
+ # Use this function instead of query if you want to manually page your requests.
92
+ #
93
+ # ## Parameters (optional):
94
+ # - cursor [string, default nil]: cursor returned on the previous page function call
95
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex 35
96
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
97
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
98
+ # - status [list of strings, default nil]: filter for status of retrieved objects. The live API accepts only "solved" or "solving" as filter values. ex: ["solved", "solving"]
99
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ["travel", "food"]
100
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
101
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
102
+ #
103
+ # ## Return:
104
+ # - list of PixKeyHolmes objects with updated attributes
105
+ # - cursor to retrieve the next page of PixKeyHolmes objects
106
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
107
+ after = StarkCore::Utils::Checks.check_date(after)
108
+ before = StarkCore::Utils::Checks.check_date(before)
109
+ StarkInfra::Utils::Rest.get_page(
110
+ cursor: cursor,
111
+ limit: limit,
112
+ after: after,
113
+ before: before,
114
+ status: status,
115
+ tags: tags,
116
+ ids: ids,
117
+ user: user,
118
+ **resource
119
+ )
120
+ end
121
+
122
+ def self.resource
123
+ {
124
+ resource_name: 'PixKeyHolmes',
125
+ resource_maker: proc { |json|
126
+ PixKeyHolmes.new(
127
+ key_id: json['key_id'],
128
+ tags: json['tags'],
129
+ id: json['id'],
130
+ result: json['result'],
131
+ status: json['status'],
132
+ created: json['created'],
133
+ updated: json['updated']
134
+ )
135
+ }
136
+ }
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,127 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('pix_pull_request')
5
+ require_relative('../utils/rest')
6
+
7
+ module StarkInfra
8
+ class PixPullRequest
9
+ # # PixPullRequest::Log object
10
+ #
11
+ # Every time a PixPullRequest entity is modified, a corresponding PixPullRequest::Log
12
+ # is generated for the entity. This log is never generated by the user.
13
+ #
14
+ # ## Attributes (return-only):
15
+ # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
16
+ # - request [PixPullRequest]: PixPullRequest entity to which the log refers to.
17
+ # - type [string]: type of the PixPullRequest event which triggered the log creation. Options: 'created', 'sent', 'scheduled', 'denied', 'success', 'canceling', 'canceled', 'expired'
18
+ # - errors [list of strings]: list of errors linked to this PixPullRequest event. Empty list when the type is non-failing.
19
+ # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
20
+ class Log < StarkCore::Utils::Resource
21
+ attr_reader :id, :request, :type, :errors, :created
22
+ def initialize(id:, request:, type:, errors:, created:)
23
+ super(id)
24
+ @request = request
25
+ @type = type
26
+ @errors = errors.nil? ? [] : errors
27
+ @created = StarkCore::Utils::Checks.check_datetime(created)
28
+ end
29
+
30
+ # # Retrieve a specific PixPullRequest::Log
31
+ #
32
+ # Receive a single PixPullRequest::Log object previously created by the Stark Infra API by passing its id
33
+ #
34
+ # ## Parameters (required):
35
+ # - id [string]: object unique id. ex: '5656565656565656'
36
+ #
37
+ # ## Parameters (optional):
38
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
39
+ #
40
+ # ## Return:
41
+ # - PixPullRequest::Log object with updated attributes
42
+ def self.get(id, user: nil)
43
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
44
+ end
45
+
46
+ # # Retrieve PixPullRequest::Logs
47
+ #
48
+ # Receive a generator of PixPullRequest::Log objects previously created in the Stark Infra API
49
+ #
50
+ # ## Parameters (optional):
51
+ # - ids [list of strings, default nil]: Log ids to filter PixPullRequest Logs. ex: ['5656565656565656']
52
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
53
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
54
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
55
+ # - types [list of strings, default nil]: filter retrieved objects by types. Options: 'created', 'sent', 'scheduled', 'denied', 'success', 'canceling', 'canceled', 'expired'
56
+ # - request_ids [list of strings, default nil]: list of PixPullRequest ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
57
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
58
+ #
59
+ # ## Return:
60
+ # - generator of PixPullRequest::Log objects with updated attributes
61
+ def self.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, request_ids: nil, user: nil)
62
+ after = StarkCore::Utils::Checks.check_date(after)
63
+ before = StarkCore::Utils::Checks.check_date(before)
64
+ StarkInfra::Utils::Rest.get_stream(
65
+ ids: ids,
66
+ limit: limit,
67
+ after: after,
68
+ before: before,
69
+ types: types,
70
+ request_ids: request_ids,
71
+ user: user,
72
+ **resource
73
+ )
74
+ end
75
+
76
+ # # Retrieve paged PixPullRequest::Logs
77
+ #
78
+ # Receive a list of up to 100 PixPullRequest::Log objects previously created in the Stark Infra API and the cursor to the next page.
79
+ # Use this function instead of query if you want to manually page your requests.
80
+ #
81
+ # ## Parameters (optional):
82
+ # - cursor [string, default nil]: cursor returned on the previous page function call
83
+ # - ids [list of strings, default nil]: Log ids to filter PixPullRequest Logs. ex: ['5656565656565656']
84
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
85
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
86
+ # - before [Date 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 types. Options: 'created', 'sent', 'scheduled', 'denied', 'success', 'canceling', 'canceled', 'expired'
88
+ # - request_ids [list of strings, default nil]: list of PixPullRequest ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
89
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
90
+ #
91
+ # ## Return:
92
+ # - list of PixPullRequest::Log objects with updated attributes
93
+ # - cursor to retrieve the next page of Log objects
94
+ def self.page(cursor: nil, ids: nil, limit: nil, after: nil, before: nil, types: nil, request_ids: nil, user: nil)
95
+ after = StarkCore::Utils::Checks.check_date(after)
96
+ before = StarkCore::Utils::Checks.check_date(before)
97
+ StarkInfra::Utils::Rest.get_page(
98
+ cursor: cursor,
99
+ ids: ids,
100
+ limit: limit,
101
+ after: after,
102
+ before: before,
103
+ types: types,
104
+ request_ids: request_ids,
105
+ user: user,
106
+ **resource
107
+ )
108
+ end
109
+
110
+ def self.resource
111
+ request_maker = StarkInfra::PixPullRequest.resource[:resource_maker]
112
+ {
113
+ resource_name: 'PixPullRequestLog',
114
+ resource_maker: proc { |json|
115
+ Log.new(
116
+ id: json['id'],
117
+ request: StarkCore::Utils::API.from_api_json(request_maker, json['request']),
118
+ type: json['type'],
119
+ errors: json['errors'],
120
+ created: json['created']
121
+ )
122
+ }
123
+ }
124
+ end
125
+ end
126
+ end
127
+ end