starkinfra 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/lib/brcodepreview/brcodepreview.rb +125 -0
  3. data/lib/cardmethod/cardmethod.rb +56 -0
  4. data/lib/creditholmes/creditholmes.rb +160 -0
  5. data/lib/creditnote/creditnote.rb +51 -355
  6. data/lib/creditnote/invoice/description.rb +51 -0
  7. data/lib/creditnote/invoice/discount.rb +49 -0
  8. data/lib/creditnote/invoice/invoice.rb +124 -0
  9. data/lib/creditnote/log.rb +18 -19
  10. data/lib/creditnote/transfer.rb +90 -0
  11. data/lib/creditpreview/creditnotepreview.rb +85 -0
  12. data/lib/creditpreview/creditpreview.rb +77 -0
  13. data/lib/creditsigner/creditsigner.rb +57 -0
  14. data/lib/dynamicbrcode/dynamicbrcode.rb +350 -0
  15. data/lib/event/attempt.rb +5 -4
  16. data/lib/event/event.rb +11 -11
  17. data/lib/individualdocument/individualdocument.rb +165 -0
  18. data/lib/individualdocument/log.rb +125 -0
  19. data/lib/individualidentity/individualidentity.rb +193 -0
  20. data/lib/individualidentity/log.rb +124 -0
  21. data/lib/issuingbalance/issuingbalance.rb +4 -4
  22. data/lib/issuingcard/issuingcard.rb +35 -33
  23. data/lib/issuingcard/log.rb +21 -21
  24. data/lib/issuingdesign/issuingdesign.rb +138 -0
  25. data/lib/issuingembossingkit/issuingembossingkit.rb +121 -0
  26. data/lib/issuingembossingrequest/issuingembossingrequest.rb +210 -0
  27. data/lib/issuingembossingrequest/log.rb +128 -0
  28. data/lib/issuingholder/issuingholder.rb +21 -15
  29. data/lib/issuingholder/log.rb +19 -19
  30. data/lib/issuinginvoice/issuinginvoice.rb +29 -14
  31. data/lib/issuinginvoice/log.rb +18 -18
  32. data/lib/{issuingbin/issuingbin.rb → issuingproduct/issuingproduct.rb} +27 -30
  33. data/lib/issuingpurchase/issuingpurchase.rb +111 -31
  34. data/lib/issuingpurchase/log.rb +16 -16
  35. data/lib/issuingrestock/issuingrestock.rb +162 -0
  36. data/lib/issuingrestock/log.rb +127 -0
  37. data/lib/issuingrule/issuingrule.rb +64 -18
  38. data/lib/issuingstock/issuingstock.rb +138 -0
  39. data/lib/issuingstock/log.rb +130 -0
  40. data/lib/issuingtransaction/issuingtransaction.rb +12 -13
  41. data/lib/issuingwithdrawal/issuingwithdrawal.rb +12 -11
  42. data/lib/merchantcategory/merchantcategory.rb +63 -0
  43. data/lib/merchantcountry/merchantcountry.rb +59 -0
  44. data/lib/pixbalance/pixbalance.rb +5 -5
  45. data/lib/pixchargeback/log.rb +15 -15
  46. data/lib/pixchargeback/pixchargeback.rb +32 -20
  47. data/lib/pixclaim/log.rb +21 -24
  48. data/lib/pixclaim/pixclaim.rb +44 -34
  49. data/lib/pixdirector/pixdirector.rb +9 -11
  50. data/lib/pixdomain/certificate.rb +1 -1
  51. data/lib/pixdomain/pixdomain.rb +5 -5
  52. data/lib/pixinfraction/log.rb +20 -20
  53. data/lib/pixinfraction/pixinfraction.rb +23 -15
  54. data/lib/pixkey/log.rb +23 -23
  55. data/lib/pixkey/pixkey.rb +14 -12
  56. data/lib/pixrequest/log.rb +24 -20
  57. data/lib/pixrequest/pixrequest.rb +54 -21
  58. data/lib/pixreversal/log.rb +3 -3
  59. data/lib/pixreversal/pixreversal.rb +48 -21
  60. data/lib/pixstatement/pixstatement.rb +13 -8
  61. data/lib/starkinfra.rb +40 -15
  62. data/lib/staticbrcode/staticbrcode.rb +170 -0
  63. data/lib/user/project.rb +1 -1
  64. data/lib/utils/api.rb +1 -0
  65. data/lib/utils/bacenid.rb +1 -1
  66. data/lib/utils/parse.rb +7 -3
  67. data/lib/utils/request.rb +1 -1
  68. data/lib/utils/resource.rb +1 -1
  69. data/lib/utils/sub_resource.rb +21 -22
  70. data/lib/webhook/webhook.rb +11 -11
  71. metadata +29 -4
  72. data/lib/issuingauthorization/issuingauthorization.rb +0 -141
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d851779a2ac175de1c7c25ec156ff8c9c011bd438dc863e5e99dc031be4540c3
4
- data.tar.gz: 6b0bce15d67fe07e569facaa3023152d865a0886cae0de131bf45ac0bd42916f
3
+ metadata.gz: 84494554057a87004d3c53122b4212049553964d4aae5a06b7045c104debbe61
4
+ data.tar.gz: 227df256622a80f1e2e827c8aef4b7363a0307abb2f727b9ee82876dc942cef1
5
5
  SHA512:
6
- metadata.gz: e667c072faca5588ce99f991bd7f983849667281b0e11314444ed607b66cca7fd372c3a0a90ef33e2d0dbc8321e2ddc22941c6180710691472bc8eaa54cf33fe
7
- data.tar.gz: 7060cff52d7a3634b96e515b18988227b8f1b88696fdccccca1263c48a09a8f73812956c1eecd0e2b1c423d13df9f1135e4f6577f04c189c62620ed3efc29057
6
+ metadata.gz: 7f077615c40b5066952932e8b771838665c203d6d4d238486abd4e2d07eba832da4a69b9610e086f525d7c38f499e1613275bdc7944d9d340d7d489fa2472637
7
+ data.tar.gz: 0e646b2ec34f440339c48dd368e761d30e26a1edea765ee034b89816888135465e11d49b66bb812cb458520117d67af57356f41cfd33f2f0dbc50d8a2b2be8a7
@@ -0,0 +1,125 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('../utils/rest')
4
+ require_relative('../utils/parse')
5
+ require_relative('../utils/checks')
6
+ require_relative('../utils/resource')
7
+
8
+ module StarkInfra
9
+ # # BrcodePreview object
10
+ #
11
+ # A BrcodePreview is used to get information from a BR Code you received to check the information before paying it.
12
+ #
13
+ # Parameters (required):
14
+ # - id [string]: BR Code string for the Pix payment. This is also de information directly encoded in a QR Code. ex: '00020126580014br.gov.bcb.pix0136a629532e-7693-4846-852d-1bbff817b5a8520400005303986540510.005802BR5908T'Challa6009Sao Paulo62090505123456304B14A'
15
+ # - payer_id [string]: tax id (CPF/CNPJ) of the individual or business requesting the PixKey information. This id is used by the Central Bank to limit request rates. ex: "20.018.183/0001-80"
16
+ #
17
+ # Parameters (optional):
18
+ # - end_to_end_id [string]: central bank's unique transaction ID. ex: "E79457883202101262140HHX553UPqeq"
19
+ #
20
+ # Attributes (return-only):
21
+ # - account_number [string]: Payment receiver account number. ex: '1234567'
22
+ # - account_type [string]: Payment receiver account type. ex: 'checking'
23
+ # - amount [integer]: Value in cents that this payment is expecting to receive. If 0, any value is accepted. ex: 123 (= R$1,23)
24
+ # - amount_type [string]: amount type of the BR Code. If the amount type is 'custom' the BR Code's amount can be changed by the sender at the moment of payment. Options: 'fixed' or 'custom'
25
+ # - bank_code [string]: Payment receiver bank code. ex: '20018183'
26
+ # - branch_code [string]: Payment receiver branch code. ex: '0001'
27
+ # - cash_amount [integer]: Amount to be withdrawn from the cashier in cents. ex: 1000 (= R$ 10.00)
28
+ # - cashier_bank_code [string]: Cashier's bank code. ex: '20018183'
29
+ # - cashier_type [string]: Cashier's type. Options: 'merchant', 'participant' and 'other'
30
+ # - discount_amount [integer]: Discount value calculated over nominal_amount. ex: 3000
31
+ # - fine_amount [integer]: Fine value calculated over nominal_amount. ex: 20000
32
+ # - key_id [string]: Receiver's PixKey id. ex: '+5511989898989'
33
+ # - interest_amount [integer]: Interest value calculated over nominal_amount. ex: 10000
34
+ # - name [string]: Payment receiver name. ex: 'Tony Stark'
35
+ # - nominal_amount [integer]: BR Code emission amount, without fines, fees and discounts. ex: 1234 (= R$ 12.34)
36
+ # - reconciliation_id [string]: Reconciliation ID linked to this payment. If the BR Code is dynamic, the reconciliation_id will have from 26 to 35 alphanumeric characters, ex: 'cd65c78aeb6543eaaa0170f68bd741ee'. If the brcode is static, the reconciliation_id will have up to 25 alphanumeric characters 'ah27s53agj6493hjds6836v49'
37
+ # - reduction_amount [integer]: Reduction value to discount from nominal_amount. ex: 1000
38
+ # - scheduled [DateTime]: date of payment execution. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0).
39
+ # - status [string]: Payment status. ex: 'active', 'paid', 'canceled' or 'unknown'
40
+ # - tax_id [string]: Payment receiver tax ID. ex: '012.345.678-90'
41
+ class BrcodePreview < StarkInfra::Utils::Resource
42
+ attr_reader :id, :payer_id, :end_to_end_id, :account_number, :account_type, :amount, :amount_type, :bank_code, :branch_code, :cash_amount,
43
+ :cashier_bank_code, :cashier_type, :discount_amount, :fine_amount, :key_id, :interest_amount, :name,
44
+ :nominal_amount, :reconciliation_id, :reduction_amount, :scheduled, :status, :tax_id
45
+ def initialize(
46
+ id:, payer_id:, end_to_end_id: nil, account_number: nil, account_type: nil, amount: nil, amount_type: nil, bank_code: nil,
47
+ branch_code: nil, cash_amount: nil, cashier_bank_code:nil, cashier_type:nil, discount_amount: nil,
48
+ fine_amount: nil, key_id: nil, interest_amount: nil, name: nil, nominal_amount: nil,
49
+ reconciliation_id: nil, reduction_amount: nil, scheduled: nil, status: nil, tax_id: nil
50
+ )
51
+ super(id)
52
+ @payer_id = payer_id
53
+ @end_to_end_id = end_to_end_id
54
+ @account_number = account_number
55
+ @account_type = account_type
56
+ @amount = amount
57
+ @amount_type = amount_type
58
+ @bank_code = bank_code
59
+ @branch_code = branch_code
60
+ @cash_amount = cash_amount
61
+ @cashier_bank_code = cashier_bank_code
62
+ @cashier_type = cashier_type
63
+ @discount_amount = discount_amount
64
+ @fine_amount = fine_amount
65
+ @interest_amount = interest_amount
66
+ @key_id = key_id
67
+ @name = name
68
+ @nominal_amount = nominal_amount
69
+ @reconciliation_id = reconciliation_id
70
+ @reduction_amount = reduction_amount
71
+ @scheduled = scheduled
72
+ @status = status
73
+ @tax_id = tax_id
74
+ end
75
+
76
+ # # Retrieve BrcodePreviews
77
+ #
78
+ # Process BR Codes before paying them.
79
+ #
80
+ # ## Parameters (required):
81
+ # - previews [list of BrcodePreview objects]: List of BrcodePreview objects to preview. ex: [starkinfra.BrcodePreview('00020126580014br.gov.bcb.pix0136a629532e-7693-4846-852d-1bbff817b5a8520400005303986540510.005802BR5908T'Challa6009Sao Paulo62090505123456304B14A')]
82
+ #
83
+ # ## Parameters (optional):
84
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
85
+ #
86
+ # ## Return:
87
+ # - list of BrcodePreview objects with updated attributes
88
+ def self.create(previews, user: nil)
89
+ StarkInfra::Utils::Rest.post(entities: previews, user: user, **resource)
90
+ end
91
+
92
+ def self.resource
93
+ {
94
+ resource_name: 'BrcodePreview',
95
+ resource_maker: proc { |json|
96
+ BrcodePreview.new(
97
+ id: json['id'],
98
+ payer_id: json['payer_id'],
99
+ end_to_end_id: json['end_to_end_id'],
100
+ account_number: json['account_number'],
101
+ account_type: json['account_type'],
102
+ amount: json['amount'],
103
+ amount_type: json['amount_type'],
104
+ bank_code: json['bank_code'],
105
+ branch_code: json['branch_code'],
106
+ cash_amount: json['cash_amount'],
107
+ cashier_bank_code: json['cashier_bank_code'],
108
+ cashier_type: json['cashier_type'],
109
+ discount_amount: json['discount_amount'],
110
+ fine_amount: json['fine_amount'],
111
+ key_id: json['key_id'],
112
+ interest_amount: json['interest_amount'],
113
+ name: json['name'],
114
+ nominal_amount: json['nominal_amount'],
115
+ reconciliation_id: json['reconciliation_id'],
116
+ reduction_amount: json['reduction_amount'],
117
+ scheduled: json['scheduled'],
118
+ status: json['status'],
119
+ tax_id: json['tax_id']
120
+ )
121
+ }
122
+ }
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('../utils/rest')
4
+ require_relative('../utils/sub_resource')
5
+
6
+ module StarkInfra
7
+ # # CardMethod object
8
+ #
9
+ # CardMethod's codes are used to define method filters in IssuingRules.
10
+ #
11
+ # ## Parameters (required):
12
+ # - code [string]: method's code. Options: 'chip', 'token', 'server', 'manual', 'magstripe', 'contactless'
13
+ #
14
+ # Attributes (return-only):
15
+ # - name [string]: method's name. ex: 'token'
16
+ # - number [string]: method's number. ex: '81'
17
+ class CardMethod < StarkInfra::Utils::SubResource
18
+ attr_reader :code, :name, :number
19
+ def initialize(code:, name: nil, number: nil)
20
+ @code = code
21
+ @name = name
22
+ @number = number
23
+ end
24
+
25
+ # # Retrieve CardMethods
26
+ #
27
+ # Receive a generator of CardMethod objects available in the Stark Infra API
28
+ #
29
+ # ## Parameters (optional):
30
+ # - search [string, default nil]: keyword to search for code, name, number or short_code
31
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
32
+ #
33
+ # ## Return:
34
+ # - generator of CardMethod objects with updated attributes
35
+ def self.query(search: nil, user: nil)
36
+ StarkInfra::Utils::Rest.get_stream(
37
+ search: search,
38
+ user: user,
39
+ **resource
40
+ )
41
+ end
42
+
43
+ def self.resource
44
+ {
45
+ resource_name: 'CardMethod',
46
+ resource_maker: proc { |json|
47
+ CardMethod.new(
48
+ code: json['code'],
49
+ name: json['name'],
50
+ number: json['number']
51
+ )
52
+ }
53
+ }
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,160 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('../utils/rest')
4
+ require_relative('../utils/parse')
5
+ require_relative('../utils/checks')
6
+ require_relative('../utils/resource')
7
+
8
+ module StarkInfra
9
+ # # CreditHolmes object
10
+ #
11
+ # CreditHolmes are used to obtain debt information on your customers.
12
+ # Before you create a CreditHolmes, make sure you have your customer's express
13
+ # authorization to verify their information in the Central Bank's SCR.
14
+ #
15
+ # When you initialize a CreditHolmes, the entity will not be automatically
16
+ # created in the Stark Infra API. The 'create' function sends the objects
17
+ # to the Stark Infra API and returns the list of created objects.
18
+ #
19
+ # ## Parameters (required):
20
+ # - tax_id [string]: customer's tax ID (CPF or CNPJ) for whom the credit operations will be verified. ex: "20.018.183/0001-80"
21
+ #
22
+ # ## Parameters (optional):
23
+ # - competence [string, default 'two months before current date']: competence month of the operation verification, format: "YYYY-MM". ex: "2021-04"
24
+ # - tags [list of strings, default []]: list of strings for reference when searching for CreditHolmes. ex: ["credit", "operation"]
25
+ #
26
+ # ## Attributes (return-only):
27
+ # - id [string]: unique id returned when the CreditHolmes is created. ex: "5656565656565656"
28
+ # - result [dictionary]: result of the investigation after the case is solved.
29
+ # - status [string]: current status of the CreditHolmes. ex: "created", "failed", "success"
30
+ # - created [DateTime]: creation datetime for the CreditHolmes. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
31
+ # - updated [DateTime]: latest update datetime for the CreditHolmes. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
32
+ class CreditHolmes < StarkInfra::Utils::Resource
33
+ attr_reader :tax_id, :competence, :tags, :id, :result, :status, :updated, :created
34
+ def initialize(tax_id:, competence: nil, tags: nil, id: nil, result: nil, status: nil, updated: nil, created: nil)
35
+ super(id)
36
+ @tax_id = tax_id
37
+ @competence = competence
38
+ @tags = tags
39
+ @id = id
40
+ @result = result
41
+ @status = status
42
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
43
+ @updated = StarkInfra::Utils::Checks.check_datetime(updated)
44
+ end
45
+
46
+ # # Create CreditHolmes
47
+ #
48
+ # Send a list of CreditHolmes objects for creation at the Stark Infra API
49
+ #
50
+ # ## Parameters (required):
51
+ # - holmes [list of CreditHolmes objects]: list of CreditHolmes objects to be created in the API.
52
+ #
53
+ # ## Parameters (optional):
54
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
55
+ #
56
+ # ## Return:
57
+ # - list of CreditHolmes object with updated attributes
58
+ def self.create(holmes, user: nil)
59
+ StarkInfra::Utils::Rest.post(entities: holmes, user: user, **resource)
60
+ end
61
+
62
+ # # Retrieve a specific CreditHolmes
63
+ #
64
+ # Receive a single CreditHolmes object previously created in the Stark Infra API by its id
65
+ #
66
+ # ## Parameters (required):
67
+ # - id [string]: object unique id. ex: "5656565656565656"
68
+ #
69
+ # ## Parameters (optional):
70
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
71
+ #
72
+ # ## Return:
73
+ # - CreditHolmes object with updated attributes
74
+ def self.get(id, user: nil)
75
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
76
+ end
77
+
78
+ # # Retrieve CreditHolmes
79
+ #
80
+ # Receive a generator of CreditHolmes objects previously created in the Stark Infra API
81
+ #
82
+ # ## Parameters (optional):
83
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
84
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
85
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
86
+ # - status [list of strings, default nil]: filter for status of retrieved objects. ex: "created", "failed", "success"
87
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ["tony", "stark"]
88
+ # - ids [list of strings, default nil]: list of 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
+ # - generator of CreditHolmes objects with updated attributes
93
+ def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
94
+ after = StarkInfra::Utils::Checks.check_date(after)
95
+ before = StarkInfra::Utils::Checks.check_date(before)
96
+ StarkInfra::Utils::Rest.get_stream(
97
+ limit: limit,
98
+ after: after,
99
+ before: before,
100
+ status: status,
101
+ tags: tags,
102
+ ids: ids,
103
+ user: user,
104
+ **resource
105
+ )
106
+ end
107
+
108
+ # # Retrieve CreditHolmes
109
+ #
110
+ # Receive a list of up to 100 CreditHolmes objects previously created in the Stark Infra API and the cursor to the next page.
111
+ # Use this function instead of query if you want to manually page your requests.
112
+ #
113
+ # ## Parameters (optional):
114
+ # - cursor [string, default nil]: cursor returned on the previous page function call
115
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. 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: "created", "failed", "success"
119
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ["tony", "stark"]
120
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
121
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
122
+ #
123
+ # ## Return:
124
+ # - list of CreditHolmes objects with updated attributes
125
+ # - cursor to retrieve the next page of CreditHolmes objects
126
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
127
+ after = StarkInfra::Utils::Checks.check_date(after)
128
+ before = StarkInfra::Utils::Checks.check_date(before)
129
+ StarkInfra::Utils::Rest.get_page(
130
+ cursor: cursor,
131
+ limit: limit,
132
+ after: after,
133
+ before: before,
134
+ status: status,
135
+ tags: tags,
136
+ ids: ids,
137
+ user: user,
138
+ **resource
139
+ )
140
+ end
141
+
142
+ def self.resource
143
+ {
144
+ resource_name: 'CreditHolmes',
145
+ resource_maker: proc { |json|
146
+ CreditHolmes.new(
147
+ tax_id: json['tax_id'],
148
+ competence: json['competence'],
149
+ tags: json['tags'],
150
+ id: json['id'],
151
+ result: json['result'],
152
+ status: json['status'],
153
+ created: json['created'],
154
+ updated: json['updated']
155
+ )
156
+ }
157
+ }
158
+ end
159
+ end
160
+ end