starkinfra 0.6.0 → 0.7.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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/lib/brcode_preview/brcode_preview.rb +22 -4
  3. data/lib/brcode_preview/subscription.rb +2 -2
  4. data/lib/business_account_request/business_account_request.rb +276 -0
  5. data/lib/{individual_document → business_account_request}/log.rb +35 -35
  6. data/lib/business_attachment/business_attachment.rb +6 -3
  7. data/lib/business_identity/business_identity.rb +7 -4
  8. data/lib/credit_holmes/credit_holmes.rb +2 -1
  9. data/lib/credit_holmes/log.rb +125 -0
  10. data/lib/credit_note/credit_note.rb +42 -5
  11. data/lib/credit_note/rule.rb +9 -0
  12. data/lib/credit_note/transfer.rb +1 -1
  13. data/lib/credit_preview/credit_note_preview.rb +10 -2
  14. data/lib/credit_preview/credit_preview.rb +2 -1
  15. data/lib/credit_signer/credit_signer.rb +27 -2
  16. data/lib/dynamic_brcode/dynamic_brcode.rb +5 -2
  17. data/lib/event/event.rb +2 -2
  18. data/lib/individual_account_attachment/individual_account_attachment.rb +178 -0
  19. data/lib/individual_account_attachment/log.rb +124 -0
  20. data/lib/individual_account_request/individual_account_request.rb +271 -0
  21. data/lib/individual_account_request/log.rb +124 -0
  22. data/lib/individual_identity/individual_identity.rb +4 -7
  23. data/lib/issuing_card/issuing_card.rb +5 -4
  24. data/lib/issuing_design/issuing_design.rb +9 -0
  25. data/lib/issuing_embossing_request/issuing_embossing_request.rb +3 -2
  26. data/lib/issuing_holder/issuing_holder.rb +6 -5
  27. data/lib/issuing_product/issuing_product.rb +2 -2
  28. data/lib/issuing_purchase/issuing_purchase.rb +25 -1
  29. data/lib/issuing_restock/issuing_restock.rb +3 -2
  30. data/lib/issuing_rule/issuing_rule.rb +36 -0
  31. data/lib/issuing_stock_rule/issuing_stock_rule.rb +6 -5
  32. data/lib/issuing_token/issuing_token.rb +2 -2
  33. data/lib/issuing_token/log.rb +127 -0
  34. data/lib/issuing_token_activation/issuing_token_activation.rb +62 -0
  35. data/lib/issuing_token_request/issuing_token_request.rb +1 -1
  36. data/lib/issuing_withdrawal/issuing_withdrawal.rb +2 -2
  37. data/lib/ledger/ledger.rb +175 -0
  38. data/lib/ledger/log.rb +122 -0
  39. data/lib/ledger/rule.rb +55 -0
  40. data/lib/ledger_transaction/ledger_transaction.rb +179 -0
  41. data/lib/pix_balance/pix_balance.rb +1 -1
  42. data/lib/pix_chargeback/pix_chargeback.rb +10 -7
  43. data/lib/pix_claim/pix_claim.rb +14 -6
  44. data/lib/pix_director/pix_director.rb +1 -1
  45. data/lib/pix_dispute/pix_dispute.rb +1 -1
  46. data/lib/pix_dispute/transaction.rb +4 -4
  47. data/lib/pix_fraud/pix_fraud.rb +1 -1
  48. data/lib/pix_infraction/pix_infraction.rb +21 -5
  49. data/lib/pix_internal_transaction_report/pix_internal_transaction_report.rb +1 -1
  50. data/lib/pix_key/pix_key.rb +1 -1
  51. data/lib/pix_key_holmes/log.rb +129 -0
  52. data/lib/pix_key_holmes/pix_key_holmes.rb +19 -2
  53. data/lib/pix_pull_request/pix_pull_request.rb +6 -3
  54. data/lib/pix_pull_subscription/pix_pull_subscription.rb +31 -5
  55. data/lib/pix_request/pix_request.rb +13 -7
  56. data/lib/pix_reversal/pix_reversal.rb +14 -8
  57. data/lib/pix_statement/pix_statement.rb +11 -5
  58. data/lib/pix_user/pix_user.rb +52 -0
  59. data/lib/pix_user/statistics.rb +64 -0
  60. data/lib/starkinfra.rb +20 -3
  61. data/lib/static_brcode/static_brcode.rb +8 -4
  62. data/lib/utils/bacen_id.rb +27 -0
  63. data/lib/utils/end_to_end_id.rb +20 -0
  64. data/lib/utils/pix_subscription_bacen_id.rb +21 -0
  65. data/lib/utils/return_id.rb +1 -4
  66. data/lib/webhook/webhook.rb +2 -2
  67. metadata +21 -4
  68. data/lib/individual_document/individual_document.rb +0 -164
data/lib/starkinfra.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative('brcode_preview/brcode_preview')
4
+ require_relative('business_account_request/business_account_request')
5
+ require_relative('business_account_request/log')
4
6
  require_relative('business_attachment/business_attachment')
5
7
  require_relative('business_attachment/log')
6
8
  require_relative('business_identity/business_identity')
@@ -15,12 +17,15 @@ require_relative('credit_note/rule')
15
17
  require_relative('credit_note/log')
16
18
  require_relative('credit_note/transfer')
17
19
  require_relative('credit_holmes/credit_holmes')
20
+ require_relative('credit_holmes/log')
18
21
  require_relative('credit_preview/credit_preview')
19
22
  require_relative('credit_preview/credit_note_preview')
20
23
  require_relative('credit_signer/credit_signer')
21
24
  require_relative('dynamic_brcode/dynamic_brcode')
22
- require_relative('individual_document/individual_document')
23
- require_relative('individual_document/log')
25
+ require_relative('individual_account_request/individual_account_request')
26
+ require_relative('individual_account_request/log')
27
+ require_relative('individual_account_attachment/individual_account_attachment')
28
+ require_relative('individual_account_attachment/log')
24
29
  require_relative('individual_identity/individual_identity')
25
30
  require_relative('individual_identity/log')
26
31
  require_relative('issuing_balance/issuing_balance')
@@ -46,10 +51,16 @@ require_relative('issuing_purchase/issuing_purchase')
46
51
  require_relative('issuing_purchase/log')
47
52
  require_relative('issuing_rule/issuing_rule')
48
53
  require_relative('issuing_token/issuing_token')
54
+ require_relative('issuing_token/log')
55
+ require_relative('issuing_token_activation/issuing_token_activation')
49
56
  require_relative('issuing_token_request/issuing_token_request')
50
57
  require_relative('issuing_token_design/issuing_token_design')
51
58
  require_relative('issuing_transaction/issuing_transaction')
52
59
  require_relative('issuing_withdrawal/issuing_withdrawal')
60
+ require_relative('ledger/ledger')
61
+ require_relative('ledger/rule')
62
+ require_relative('ledger/log')
63
+ require_relative('ledger_transaction/ledger_transaction')
53
64
  require_relative('merchant_category/merchant_category')
54
65
  require_relative('merchant_country/merchant_country')
55
66
  require_relative('pix_balance/pix_balance')
@@ -63,6 +74,7 @@ require_relative('pix_dispute/transaction')
63
74
  require_relative('pix_dispute/log')
64
75
  require_relative('pix_domain/pix_domain')
65
76
  require_relative('pix_key_holmes/pix_key_holmes')
77
+ require_relative('pix_key_holmes/log')
66
78
  require_relative('pix_fraud/pix_fraud')
67
79
  require_relative('pix_fraud/log')
68
80
  require_relative('pix_infraction/pix_infraction')
@@ -80,17 +92,22 @@ require_relative('pix_request/log')
80
92
  require_relative('pix_reversal/pix_reversal')
81
93
  require_relative('pix_reversal/log')
82
94
  require_relative('pix_statement/pix_statement')
95
+ require_relative('pix_user/pix_user')
96
+ require_relative('pix_user/statistics')
83
97
  require_relative('static_brcode/static_brcode')
84
98
  require_relative('webhook/webhook')
85
99
  require_relative('event/event')
86
100
  require_relative('event/attempt')
87
101
  require_relative('request/request')
102
+ require_relative('utils/bacen_id')
103
+ require_relative('utils/end_to_end_id')
88
104
  require_relative('utils/return_id')
105
+ require_relative('utils/pix_subscription_bacen_id')
89
106
 
90
107
  module StarkInfra
91
108
 
92
109
  API_VERSION = 'v2'
93
- SDK_VERSION = '0.6.0'
110
+ SDK_VERSION = '0.7.0'
94
111
  HOST = "infra"
95
112
  public_constant :API_VERSION, :SDK_VERSION, :HOST;
96
113
 
@@ -17,7 +17,7 @@ module StarkInfra
17
17
  ## Parameters (required):
18
18
  # - name [string]: receiver's name. ex: 'Tony Stark'
19
19
  # - key_id [string]: receiver's Pixkey id. ex: '+5541999999999'
20
- # - city [string, default São Paulo]: receiver's city name. ex: 'Rio de Janeiro'
20
+ # - city [string]: receiver's city name. ex: 'Rio de Janeiro'
21
21
  #
22
22
  # ## Parameters (optional):
23
23
  # - amount [integer, default nil]: positive integer that represents the amount in cents of the resulting Pix transaction. If the amount is zero, the sender can choose any amount in the moment of payment. ex: 1234 (= R$ 12.34)
@@ -25,6 +25,7 @@ module StarkInfra
25
25
  # - reconciliation_id [string, default nil]: id to be used for conciliation of the resulting Pix transaction. This id must have up to 25 alphanumeric digits ex: 'ah27s53agj6493hjds6836v49'
26
26
  # - description [string, default None]: optional description to override default description to be shown in the bank statement. ex: "Payment for service #1234"
27
27
  # - tags [list of strings, default nil]: list of strings for tagging. ex: ['travel', 'food']
28
+ # - type [string, default 'instant']: type of the StaticBrcode. Options: 'instant', 'instantAndOrSubscription'
28
29
  #
29
30
  # ## Attributes (return-only):
30
31
  # - id [string]: id returned on creation, this is the BR Code. ex: '00020126360014br.gov.bcb.pix0114+552840092118152040000530398654040.095802BR5915Jamie Lannister6009Sao Paulo620705038566304FC6C'
@@ -33,9 +34,10 @@ module StarkInfra
33
34
  # - created [DateTime]: creation datetime for the StaticBrcode. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
34
35
  # - updated [DateTime]: latest update datetime for the StaticBrcode. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
35
36
  class StaticBrcode < StarkCore::Utils::Resource
36
- attr_reader :name, :key_id, :city, :amount, :cashier_bank_code, :description, :reconciliation_id, :id, :tags, :uuid, :url, :created, :updated
37
+ attr_reader :name, :key_id, :city, :amount, :cashier_bank_code, :description, :reconciliation_id, :id, :tags, :uuid, :url, :created, :updated, :type
37
38
  def initialize(
38
- name:, key_id:, city:, amount:, cashier_bank_code: nil, description: nil, reconciliation_id: nil, id: nil, tags:nil, uuid: nil, url: nil, created: nil, updated: nil
39
+ name:, key_id:, city:, amount:, cashier_bank_code: nil, description: nil, reconciliation_id: nil, id: nil, tags:nil, uuid: nil, url: nil, created: nil, updated: nil,
40
+ type: nil
39
41
  )
40
42
  super(id)
41
43
  @name = name
@@ -50,6 +52,7 @@ module StarkInfra
50
52
  @url = url
51
53
  @created = StarkCore::Utils::Checks.check_datetime(created)
52
54
  @updated = StarkCore::Utils::Checks.check_datetime(updated)
55
+ @type = type
53
56
  end
54
57
 
55
58
  # # Create StaticBrcodes
@@ -160,7 +163,8 @@ module StarkInfra
160
163
  uuid: json['uuid'],
161
164
  url: json['url'],
162
165
  created: json['created'],
163
- updated: json['updated']
166
+ updated: json['updated'],
167
+ type: json['type']
164
168
  )
165
169
  }
166
170
  }
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module StarkInfra
4
+ # # BacenId object
5
+ #
6
+ # A BacenId is the common body of the identifiers used at the BACEN (Banco Central do Brasil) level.
7
+ # It is composed of the bank's ISPB code, a datetime stamp and 11 random alphanumeric characters.
8
+ # The datetime stamp is always generated in UTC, regardless of the machine timezone.
9
+ # It is the base of EndToEndId, ReturnId and PixSubscriptionBacenId.
10
+ #
11
+ # ## Parameters (required):
12
+ # - bank_code [string]: 8-digit ISPB code of the bank. ex: '20018183'
13
+ #
14
+ # ## Parameters (optional):
15
+ # - date_format [string, default '%Y%m%d%H%M']: strftime format of the UTC datetime stamp.
16
+ #
17
+ # ## Return:
18
+ # - BacenId string. ex: '200181832022012014505GD19lzAbCdE'
19
+ class BacenId
20
+ RANDOM_SOURCE = (('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a).freeze
21
+
22
+ def self.create(bank_code, date_format = '%Y%m%d%H%M')
23
+ random_string = (0...11).map { RANDOM_SOURCE.sample }.join
24
+ "#{bank_code}#{Time.now.utc.strftime(date_format)}#{random_string}"
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module StarkInfra
4
+ # # EndToEndId object
5
+ #
6
+ # An EndToEndId is a 32-character string that uniquely identifies a Pix transaction
7
+ # at the BACEN (Banco Central do Brasil) level. It is composed of an "E" prefix,
8
+ # the sender bank's ISPB code, a datetime stamp (yyyyMMddHHmm) and 11 random alphanumeric characters.
9
+ #
10
+ # ## Parameters (required):
11
+ # - bank_code [string]: 8-digit ISPB code of the sending bank. ex: '20018183'
12
+ #
13
+ # ## Return:
14
+ # - EndToEndId string. ex: 'E200181832022012014505GD19lzAbCdE'
15
+ class EndToEndId
16
+ def self.create(bank_code)
17
+ "E#{BacenId.create(bank_code)}"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module StarkInfra
4
+ # # PixSubscriptionBacenId object
5
+ #
6
+ # A PixSubscriptionBacenId is a 29-character string that uniquely identifies a Pix subscription
7
+ # at the BACEN (Banco Central do Brasil) level. It is composed of a prefix (e.g. "RR"),
8
+ # the receiver bank's ISPB code, a date stamp (yyyyMMdd) and 11 random alphanumeric characters.
9
+ #
10
+ # ## Parameters (required):
11
+ # - bank_code [string]: 8-digit ISPB code of the bank. ex: '20018183'
12
+ # - prefix [string]: prefix of the bacen id. ex: 'RR'
13
+ #
14
+ # ## Return:
15
+ # - PixSubscriptionBacenId string. ex: 'RR2001818320220120GD19lzAbCdE'
16
+ class PixSubscriptionBacenId
17
+ def self.create(bank_code, prefix)
18
+ "#{prefix}#{BacenId.create(bank_code, '%Y%m%d')}"
19
+ end
20
+ end
21
+ end
@@ -14,11 +14,8 @@ module StarkInfra
14
14
  # ## Return:
15
15
  # - ReturnId string. ex: 'D200181832022012014505GD19lzAbCdE'
16
16
  class ReturnId
17
- RANDOM_SOURCE = (('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a).freeze
18
-
19
17
  def self.create(bank_code)
20
- random_string = (0...11).map { RANDOM_SOURCE.sample }.join
21
- "D#{bank_code}#{Time.now.strftime('%Y%m%d%H%M')}#{random_string}"
18
+ "D#{BacenId.create(bank_code)}"
22
19
  end
23
20
  end
24
21
  end
@@ -7,7 +7,7 @@ module StarkInfra
7
7
  # # Webhook object
8
8
  #
9
9
  # A Webhook is used to subscribe to notification events on a user-selected endpoint.
10
- # Currently available services for subscription are contract, credit-note, signer, issuing-card, issuing-invoice, issuing-purchase, pix-request.in, pix-request.out, pix-reversal.in, pix-reversal.out, pix-claim, pix-key, pix-chargeback, pix-infraction, pix-pull-request, pix-pull-subscription.
10
+ # Currently available services for subscription include contract, credit-note, signer, issuing-card, issuing-invoice, issuing-purchase, pix-request.in, pix-request.out, pix-reversal.in, pix-reversal.out, pix-claim, pix-key, pix-chargeback, pix-infraction, pix-dispute, pix-pull-request, pix-pull-subscription, business-identity (see StarkInfra::Event for the authoritative, currently-wired list).
11
11
  #
12
12
  # ## Parameters (required):
13
13
  # - url [string]: URL that will be notified when an event occurs.
@@ -93,7 +93,7 @@ module StarkInfra
93
93
 
94
94
  # # Delete a Webhook entity
95
95
  #
96
- # Delete a Webhook entity previously created in the Stark Infra API
96
+ # Delete a Webhook entity previously created in the Stark Infra API. This action cannot be undone.
97
97
  #
98
98
  # ## Parameters (required):
99
99
  # - id [string]: Webhook unique id. ex: '5656565656565656'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: starkinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - starkinfra
@@ -71,12 +71,15 @@ extra_rdoc_files: []
71
71
  files:
72
72
  - lib/brcode_preview/brcode_preview.rb
73
73
  - lib/brcode_preview/subscription.rb
74
+ - lib/business_account_request/business_account_request.rb
75
+ - lib/business_account_request/log.rb
74
76
  - lib/business_attachment/business_attachment.rb
75
77
  - lib/business_attachment/log.rb
76
78
  - lib/business_identity/business_identity.rb
77
79
  - lib/business_identity/log.rb
78
80
  - lib/card_method/card_method.rb
79
81
  - lib/credit_holmes/credit_holmes.rb
82
+ - lib/credit_holmes/log.rb
80
83
  - lib/credit_note/credit_note.rb
81
84
  - lib/credit_note/invoice/description.rb
82
85
  - lib/credit_note/invoice/discount.rb
@@ -91,8 +94,10 @@ files:
91
94
  - lib/error.rb
92
95
  - lib/event/attempt.rb
93
96
  - lib/event/event.rb
94
- - lib/individual_document/individual_document.rb
95
- - lib/individual_document/log.rb
97
+ - lib/individual_account_attachment/individual_account_attachment.rb
98
+ - lib/individual_account_attachment/log.rb
99
+ - lib/individual_account_request/individual_account_request.rb
100
+ - lib/individual_account_request/log.rb
96
101
  - lib/individual_identity/individual_identity.rb
97
102
  - lib/individual_identity/log.rb
98
103
  - lib/issuing_balance/issuing_balance.rb
@@ -118,10 +123,16 @@ files:
118
123
  - lib/issuing_stock/log.rb
119
124
  - lib/issuing_stock_rule/issuing_stock_rule.rb
120
125
  - lib/issuing_token/issuing_token.rb
126
+ - lib/issuing_token/log.rb
127
+ - lib/issuing_token_activation/issuing_token_activation.rb
121
128
  - lib/issuing_token_design/issuing_token_design.rb
122
129
  - lib/issuing_token_request/issuing_token_request.rb
123
130
  - lib/issuing_transaction/issuing_transaction.rb
124
131
  - lib/issuing_withdrawal/issuing_withdrawal.rb
132
+ - lib/ledger/ledger.rb
133
+ - lib/ledger/log.rb
134
+ - lib/ledger/rule.rb
135
+ - lib/ledger_transaction/ledger_transaction.rb
125
136
  - lib/merchant_category/merchant_category.rb
126
137
  - lib/merchant_country/merchant_country.rb
127
138
  - lib/pix_balance/pix_balance.rb
@@ -143,6 +154,7 @@ files:
143
154
  - lib/pix_internal_transaction_report/pix_internal_transaction_report.rb
144
155
  - lib/pix_key/log.rb
145
156
  - lib/pix_key/pix_key.rb
157
+ - lib/pix_key_holmes/log.rb
146
158
  - lib/pix_key_holmes/pix_key_holmes.rb
147
159
  - lib/pix_pull_request/log.rb
148
160
  - lib/pix_pull_request/pix_pull_request.rb
@@ -153,10 +165,15 @@ files:
153
165
  - lib/pix_reversal/log.rb
154
166
  - lib/pix_reversal/pix_reversal.rb
155
167
  - lib/pix_statement/pix_statement.rb
168
+ - lib/pix_user/pix_user.rb
169
+ - lib/pix_user/statistics.rb
156
170
  - lib/request/request.rb
157
171
  - lib/starkinfra.rb
158
172
  - lib/static_brcode/static_brcode.rb
173
+ - lib/utils/bacen_id.rb
174
+ - lib/utils/end_to_end_id.rb
159
175
  - lib/utils/parse.rb
176
+ - lib/utils/pix_subscription_bacen_id.rb
160
177
  - lib/utils/rest.rb
161
178
  - lib/utils/return_id.rb
162
179
  - lib/webhook/webhook.rb
@@ -178,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
195
  - !ruby/object:Gem::Version
179
196
  version: '0'
180
197
  requirements: []
181
- rubygems_version: 4.0.16
198
+ rubygems_version: 4.0.20
182
199
  specification_version: 4
183
200
  summary: SDK to facilitate Ruby integrations with Stark Infra
184
201
  test_files: []
@@ -1,164 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require('starkcore')
4
- require_relative('../utils/rest')
5
- require_relative('../utils/parse')
6
-
7
- module StarkInfra
8
- # # IndividualDocument object
9
- #
10
- # Individual documents are images containing either side of a document or a selfie
11
- # to be used in a matching validation. When created, they must be attached to an individual
12
- # identity to be used for its validation.
13
- #
14
- # When you initialize a IndividualDocument, the entity will not be automatically
15
- # created in the Stark Infra API. The 'create' function sends the objects
16
- # to the Stark Infra API and returns the list of created objects.
17
- #
18
- # ## Parameters (required):
19
- # - type [string]: type of the IndividualDocument. Options: "drivers-license-front", "drivers-license-back", "identity-front", "identity-back" or "selfie"
20
- # - content [string]: Base64 data url of the picture. ex: data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD...
21
- # - content_type [string]: content MIME type. This parameter is required as input only. ex: "image/png" or "image/jpeg"
22
- # - identity_id [string]: Unique id of IndividualIdentity. ex: "5656565656565656"
23
- #
24
- # ## Parameters (optional):
25
- # - tags [list of strings, default nil]: list of strings for reference when searching for IndividualDocuments. ex: ["employees", "monthly"]
26
- #
27
- # ## Attributes (return-only):
28
- # - id [string]: unique id returned when the IndividualDocument is created. ex: "5656565656565656"
29
- # - status [string]: current status of the IndividualDocument. Options: "created", "canceled", "processing", "failed", "success"
30
- # - created [DateTime]: creation datetime for the IndividualDocument. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
31
- class IndividualDocument < StarkCore::Utils::Resource
32
- attr_reader :type, :content, :content_type, :identity_id, :tags, :id, :status, :created
33
- def initialize(type:, content:, content_type:, identity_id:, tags: nil, id: nil, status: nil, created: nil)
34
- super(id)
35
- @type = type
36
- @identity_id = identity_id
37
- @tags = tags
38
- @status = status
39
- @created = StarkCore::Utils::Checks.check_datetime(created)
40
- @content = content
41
- @content_type = content_type
42
-
43
- if @content_type
44
- @content = "data:#{content_type};base64,#{Base64.encode64(content)}"
45
- @content_type = nil
46
- end
47
- end
48
-
49
- # # Create IndividualDocuments
50
- #
51
- # Send a list of IndividualDocument objects for creation at the Stark Infra API
52
- #
53
- # ## Parameters (required):
54
- # - documents [list of IndividualDocument objects]: list of IndividualDocument objects to be created in the API.
55
- #
56
- # ## Parameters (optional):
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
- # - list of IndividualDocument object with updated attributes
61
- def self.create(documents, user: nil)
62
- StarkInfra::Utils::Rest.post(entities: documents, user: user, **resource)
63
- end
64
-
65
- # # Retrieve a specific IndividualDocument
66
- #
67
- # Receive a single IndividualDocument object previously created in the Stark Infra API by its id
68
- #
69
- # ## Parameters (required):
70
- # - id [string]: object unique id. ex: "5656565656565656"
71
- #
72
- # ## Parameters (optional):
73
- # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
74
- #
75
- # ## Return:
76
- # - IndividualDocument object with updated attributes
77
- def self.get(id, user: nil)
78
- StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
79
- end
80
-
81
- # # Retrieve IndividualDocuments
82
- #
83
- # Receive a generator of IndividualDocument objects previously created in the Stark Infra API
84
- #
85
- # ## Parameters (optional):
86
- # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
87
- # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
88
- # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
89
- # - status [list of strings, default nil]: filter for status of retrieved objects. Options: ["created", "canceled", "processing", "failed", "success"]
90
- # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
91
- # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
92
- # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
93
- #
94
- # ## Return:
95
- # - generator of IndividualDocument objects with updated attributes
96
- def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
97
- after = StarkCore::Utils::Checks.check_date(after)
98
- before = StarkCore::Utils::Checks.check_date(before)
99
- StarkInfra::Utils::Rest.get_stream(
100
- limit: limit,
101
- after: after,
102
- before: before,
103
- status: status,
104
- tags: tags,
105
- ids: ids,
106
- user: user,
107
- **resource
108
- )
109
- end
110
-
111
- # # Retrieve paged IndividualDocuments
112
- #
113
- # Receive a list of up to 100 IndividualDocument objects previously created in the Stark Infra API and the cursor to the next page.
114
- # Use this function instead of query if you want to manually page your requests.
115
- #
116
- # ## Parameters (optional):
117
- # - cursor [string, default nil]: cursor returned on the previous page function call
118
- # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex 35
119
- # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
120
- # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
121
- # - status [list of strings, default nil]: filter for status of retrieved objects. Options: ["created", "canceled", "processing", "failed", "success"]
122
- # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
123
- # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
124
- # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
125
- #
126
- # ## Return:
127
- # - list of IndividualDocument objects with updated attributes
128
- # - cursor to retrieve the next page of IndividualDocument objects
129
- def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
130
- after = StarkCore::Utils::Checks.check_date(after)
131
- before = StarkCore::Utils::Checks.check_date(before)
132
- StarkInfra::Utils::Rest.get_page(
133
- cursor: cursor,
134
- limit: limit,
135
- after: after,
136
- before: before,
137
- status: status,
138
- tags: tags,
139
- ids: ids,
140
- user: user,
141
- **resource
142
- )
143
- end
144
-
145
-
146
- def self.resource
147
- {
148
- resource_name: 'IndividualDocument',
149
- resource_maker: proc { |json|
150
- IndividualDocument.new(
151
- type: json['type'],
152
- content: json['content'],
153
- content_type: json['content_type'],
154
- identity_id: json['identity_id'],
155
- tags: json['tags'],
156
- id: json['id'],
157
- status: json['status'],
158
- created: json['created']
159
- )
160
- }
161
- }
162
- end
163
- end
164
- end