starkinfra 0.0.3 → 0.2.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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/lib/brcodepreview/brcodepreview.rb +121 -0
  3. data/lib/cardmethod/cardmethod.rb +56 -0
  4. data/lib/creditnote/creditnote.rb +58 -341
  5. data/lib/creditnote/invoice/description.rb +51 -0
  6. data/lib/creditnote/invoice/discount.rb +49 -0
  7. data/lib/creditnote/invoice/invoice.rb +123 -0
  8. data/lib/creditnote/log.rb +2 -2
  9. data/lib/creditnote/transfer.rb +90 -0
  10. data/lib/creditpreview/creditnotepreview.rb +85 -0
  11. data/lib/creditpreview/creditpreview.rb +83 -0
  12. data/lib/creditsigner/creditsigner.rb +57 -0
  13. data/lib/dynamicbrcode/dynamicbrcode.rb +350 -0
  14. data/lib/event/attempt.rb +4 -3
  15. data/lib/event/event.rb +10 -10
  16. data/lib/issuingbalance/issuingbalance.rb +4 -4
  17. data/lib/issuingcard/issuingcard.rb +40 -36
  18. data/lib/issuingcard/log.rb +3 -3
  19. data/lib/issuingholder/issuingholder.rb +14 -9
  20. data/lib/issuingholder/log.rb +3 -3
  21. data/lib/issuinginvoice/issuinginvoice.rb +24 -10
  22. data/lib/issuinginvoice/log.rb +3 -3
  23. data/lib/issuingproduct/issuingproduct.rb +86 -0
  24. data/lib/issuingpurchase/issuingpurchase.rb +100 -24
  25. data/lib/issuingpurchase/log.rb +2 -2
  26. data/lib/issuingrule/issuingrule.rb +74 -30
  27. data/lib/issuingtransaction/issuingtransaction.rb +6 -8
  28. data/lib/issuingwithdrawal/issuingwithdrawal.rb +11 -7
  29. data/lib/merchantcategory/merchantcategory.rb +63 -0
  30. data/lib/merchantcountry/merchantcountry.rb +59 -0
  31. data/lib/pixbalance/pixbalance.rb +5 -5
  32. data/lib/pixchargeback/log.rb +3 -3
  33. data/lib/pixchargeback/pixchargeback.rb +32 -20
  34. data/lib/pixclaim/log.rb +8 -11
  35. data/lib/pixclaim/pixclaim.rb +43 -32
  36. data/lib/pixdirector/pixdirector.rb +9 -11
  37. data/lib/pixdomain/certificate.rb +1 -1
  38. data/lib/pixdomain/pixdomain.rb +4 -4
  39. data/lib/pixinfraction/log.rb +2 -2
  40. data/lib/pixinfraction/pixinfraction.rb +21 -13
  41. data/lib/pixkey/log.rb +5 -5
  42. data/lib/pixkey/pixkey.rb +12 -10
  43. data/lib/pixrequest/log.rb +2 -2
  44. data/lib/pixrequest/pixrequest.rb +51 -21
  45. data/lib/pixreversal/log.rb +2 -2
  46. data/lib/pixreversal/pixreversal.rb +48 -20
  47. data/lib/pixstatement/pixstatement.rb +12 -7
  48. data/lib/starkinfra.rb +27 -15
  49. data/lib/staticbrcode/staticbrcode.rb +164 -0
  50. data/lib/user/project.rb +1 -1
  51. data/lib/utils/api.rb +1 -0
  52. data/lib/utils/parse.rb +7 -3
  53. data/lib/utils/request.rb +1 -1
  54. data/lib/utils/resource.rb +1 -1
  55. data/lib/utils/rest.rb +1 -2
  56. data/lib/utils/sub_resource.rb +21 -22
  57. data/lib/webhook/webhook.rb +3 -3
  58. metadata +16 -4
  59. data/lib/issuingauthorization/issuingauthorization.rb +0 -141
  60. data/lib/issuingbin/issuingbin.rb +0 -89
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d456d927d988604b83c18adacb7d92fe77f299ba95e89c15ed5ae0e7a5cc4fc
4
- data.tar.gz: 8ec44ecac1652b99596506d7a6234dde1ebfe94eb1299b70e27ae39809dde463
3
+ metadata.gz: 407cfd041d62916d22344d376a24ff392b4ef1fcf38cf3ae1c6ab38f01916e3a
4
+ data.tar.gz: 29d6b4e29af482ce49862a6e77eb72c570bad1844e66fcf1171f6148497179ec
5
5
  SHA512:
6
- metadata.gz: 79ac2d80db5a48923b6d0c34fbecd148a9b1e9ea82f5d4d6dc46bec8011dc8959fcdffbb3a40d4661a64a6d0516a24a13b2cfa94e5d70bbe7aec38c8511f1024
7
- data.tar.gz: '03180e37ba1c743016d8356a6851f7659e994b302ba55144747d9d9be216eaefad569779128f6f90f8a6ed7c5aece229d353e7ccfa683faa9c3aad8e8dd7d82c'
6
+ metadata.gz: d4a549b1f028df0b976c790587c5f7c3989a5290f356e93816aa6051537241f6a490617c5cd19fabf6755ec31ec9a085b1049907d2b6df35d342def6e0b065b8
7
+ data.tar.gz: 22556e362fb270328d57d12875797961ecb06bf87f2e19a15fa6a37b598c4d37fe76209f0a9be93289ce68c0e6c82f63fc6156745b93eb662403bb73671f618a
@@ -0,0 +1,121 @@
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
+ # When you initialize a BrcodePreview, 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
+ # - 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'
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, :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:, 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
+ @account_number = account_number
53
+ @account_type = account_type
54
+ @amount = amount
55
+ @amount_type = amount_type
56
+ @bank_code = bank_code
57
+ @branch_code = branch_code
58
+ @cash_amount = cash_amount
59
+ @cashier_bank_code = cashier_bank_code
60
+ @cashier_type = cashier_type
61
+ @discount_amount = discount_amount
62
+ @fine_amount = fine_amount
63
+ @key_id = key_id
64
+ @interest_amount = interest_amount
65
+ @name = name
66
+ @nominal_amount = nominal_amount
67
+ @reconciliation_id = reconciliation_id
68
+ @reduction_amount = reduction_amount
69
+ @scheduled = scheduled
70
+ @status = status
71
+ @tax_id = tax_id
72
+ end
73
+
74
+ # # Retrieve BrcodePreviews
75
+ #
76
+ # Process BR Codes before paying them.
77
+ #
78
+ # ## Parameters (required):
79
+ # - 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')]
80
+ #
81
+ # ## Parameters (optional):
82
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
83
+ #
84
+ # ## Return:
85
+ # - list of BrcodePreview objects with updated attributes
86
+ def self.create(previews, user: nil)
87
+ StarkInfra::Utils::Rest.post(entities: previews, user: user, **resource)
88
+ end
89
+
90
+ def self.resource
91
+ {
92
+ resource_name: 'BrcodePreview',
93
+ resource_maker: proc { |json|
94
+ BrcodePreview.new(
95
+ id: json['id'],
96
+ account_number: json['account_number'],
97
+ account_type: json['account_type'],
98
+ amount: json['amount'],
99
+ amount_type: json['amount_type'],
100
+ bank_code: json['bank_code'],
101
+ branch_code: json['branch_code'],
102
+ cash_amount: json['cash_amount'],
103
+ cashier_bank_code: json['cashier_bank_code'],
104
+ cashier_type: json['cashier_type'],
105
+ discount_amount: json['discount_amount'],
106
+ fine_amount: json['fine_amount'],
107
+ key_id: json['key_id'],
108
+ interest_amount: json['interest_amount'],
109
+ name: json['name'],
110
+ nominal_amount: json['nominal_amount'],
111
+ reconciliation_id: json['reconciliation_id'],
112
+ reduction_amount: json['reduction_amount'],
113
+ scheduled: json['scheduled'],
114
+ status: json['status'],
115
+ tax_id: json['tax_id']
116
+ )
117
+ }
118
+ }
119
+ end
120
+ end
121
+ 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. ex: 'token'
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