starkinfra 0.1.0 → 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 (58) 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 +37 -342
  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 +32 -29
  18. data/lib/issuingcard/log.rb +2 -2
  19. data/lib/issuingholder/issuingholder.rb +13 -8
  20. data/lib/issuingholder/log.rb +2 -2
  21. data/lib/issuinginvoice/issuinginvoice.rb +23 -9
  22. data/lib/issuinginvoice/log.rb +2 -2
  23. data/lib/{issuingbin/issuingbin.rb → issuingproduct/issuingproduct.rb} +27 -30
  24. data/lib/issuingpurchase/issuingpurchase.rb +99 -23
  25. data/lib/issuingpurchase/log.rb +1 -1
  26. data/lib/issuingrule/issuingrule.rb +64 -18
  27. data/lib/issuingtransaction/issuingtransaction.rb +5 -7
  28. data/lib/issuingwithdrawal/issuingwithdrawal.rb +10 -6
  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 +42 -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 +10 -9
  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 -21
  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/sub_resource.rb +21 -22
  56. data/lib/webhook/webhook.rb +3 -3
  57. metadata +16 -4
  58. data/lib/issuingauthorization/issuingauthorization.rb +0 -141
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require_relative("sub_resource")
2
+ require_relative('sub_resource')
3
3
 
4
4
  module StarkInfra
5
5
  module Utils
@@ -1,28 +1,27 @@
1
1
 
2
2
 
3
3
  module StarkInfra
4
- module Utils
5
- class SubResource
6
- def to_s
7
- string_vars = []
8
- instance_variables.each do |key|
9
- value = instance_variable_get(key).to_s.lines.map(&:chomp).join("\n ")
10
- string_vars << "#{key[1..-1]}: #{value}"
11
- end
12
- fields = string_vars.join(",\n ")
13
- "#{class_name}(\n #{fields}\n)"
14
- end
15
-
16
- def inspect
17
- "#{class_name}[#{@id}]"
18
- end
19
-
20
- private
21
-
22
- def class_name
23
- self.class.name.split('::').last.downcase
24
- end
4
+ module Utils
5
+ class SubResource
6
+ def to_s
7
+ string_vars = []
8
+ instance_variables.each do |key|
9
+ value = instance_variable_get(key).to_s.lines.map(&:chomp).join("\n ")
10
+ string_vars << "#{key[1..-1]}: #{value}"
25
11
  end
12
+ fields = string_vars.join(",\n ")
13
+ "#{class_name}(\n #{fields}\n)"
14
+ end
15
+
16
+ def inspect
17
+ "#{class_name}[#{@id}]"
18
+ end
19
+
20
+ private
21
+
22
+ def class_name
23
+ self.class.name.split('::').last.downcase
24
+ end
26
25
  end
26
+ end
27
27
  end
28
-
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
4
3
  require_relative('../utils/rest')
5
4
  require_relative('../utils/checks')
5
+ require_relative('../utils/resource')
6
6
 
7
7
  module StarkInfra
8
8
  # # Webhook subscription object
@@ -29,7 +29,7 @@ module StarkInfra
29
29
  # Send a single Webhook subscription for creation in the Stark Infra API
30
30
  #
31
31
  # ## Parameters (required):
32
- # - webhook [Webhook object or hash]: Webhook subscription to be created to receive Events. ex: Webhook.new()
32
+ # - webhook [Webhook object]: Webhook subscription to be created to receive Events. ex: Webhook.new()
33
33
  #
34
34
  # ## Parameters (optional):
35
35
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
@@ -84,7 +84,7 @@ module StarkInfra
84
84
  # - list of Webhook objects with updated attributes
85
85
  # - cursor to retrieve the next page of Webhook objects
86
86
  def self.page(cursor: nil, limit: nil, user: nil)
87
- return StarkInfra::Utils::Rest.get_page(
87
+ StarkInfra::Utils::Rest.get_page(
88
88
  cursor: cursor,
89
89
  limit: limit,
90
90
  user: user,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: starkinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - starkinfra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-03 00:00:00.000000000 Z
11
+ date: 2022-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: starkbank-ecdsa
@@ -72,26 +72,37 @@ executables: []
72
72
  extensions: []
73
73
  extra_rdoc_files: []
74
74
  files:
75
+ - lib/brcodepreview/brcodepreview.rb
76
+ - lib/cardmethod/cardmethod.rb
75
77
  - lib/creditnote/creditnote.rb
78
+ - lib/creditnote/invoice/description.rb
79
+ - lib/creditnote/invoice/discount.rb
80
+ - lib/creditnote/invoice/invoice.rb
76
81
  - lib/creditnote/log.rb
82
+ - lib/creditnote/transfer.rb
83
+ - lib/creditpreview/creditnotepreview.rb
84
+ - lib/creditpreview/creditpreview.rb
85
+ - lib/creditsigner/creditsigner.rb
86
+ - lib/dynamicbrcode/dynamicbrcode.rb
77
87
  - lib/error.rb
78
88
  - lib/event/attempt.rb
79
89
  - lib/event/event.rb
80
- - lib/issuingauthorization/issuingauthorization.rb
81
90
  - lib/issuingbalance/issuingbalance.rb
82
- - lib/issuingbin/issuingbin.rb
83
91
  - lib/issuingcard/issuingcard.rb
84
92
  - lib/issuingcard/log.rb
85
93
  - lib/issuingholder/issuingholder.rb
86
94
  - lib/issuingholder/log.rb
87
95
  - lib/issuinginvoice/issuinginvoice.rb
88
96
  - lib/issuinginvoice/log.rb
97
+ - lib/issuingproduct/issuingproduct.rb
89
98
  - lib/issuingpurchase/issuingpurchase.rb
90
99
  - lib/issuingpurchase/log.rb
91
100
  - lib/issuingrule/issuingrule.rb
92
101
  - lib/issuingtransaction/issuingtransaction.rb
93
102
  - lib/issuingwithdrawal/issuingwithdrawal.rb
94
103
  - lib/key.rb
104
+ - lib/merchantcategory/merchantcategory.rb
105
+ - lib/merchantcountry/merchantcountry.rb
95
106
  - lib/pixbalance/pixbalance.rb
96
107
  - lib/pixchargeback/log.rb
97
108
  - lib/pixchargeback/pixchargeback.rb
@@ -110,6 +121,7 @@ files:
110
121
  - lib/pixreversal/pixreversal.rb
111
122
  - lib/pixstatement/pixstatement.rb
112
123
  - lib/starkinfra.rb
124
+ - lib/staticbrcode/staticbrcode.rb
113
125
  - lib/user/organization.rb
114
126
  - lib/user/project.rb
115
127
  - lib/user/user.rb
@@ -1,141 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative('../utils/resource')
4
- require_relative('../utils/rest')
5
- require_relative('../utils/checks')
6
- require('json')
7
-
8
- module StarkInfra
9
- # # IssuingAuthorization object
10
- #
11
- # An IssuingAuthorization presents purchase data to be analysed and answered with an approval or a declination.
12
- #
13
- # ## Attributes (return-only):
14
- # - id [string]: unique id returned when the IssuingAuthorization is created. ex: '5656565656565656'
15
- # - end_to_end_id [string]: central bank's unique transaction ID. ex: "E79457883202101262140HHX553UPqeq"
16
- # - amount [integer]: IssuingPurchase value in cents. Minimum = 0. ex: 1234 (= R$ 12.34)
17
- # - tax [integer]: IOF amount taxed for international purchases. ex: 1234 (= R$ 12.34)
18
- # - card_id [string]: unique id returned when IssuingCard is created. ex: "5656565656565656"
19
- # - issuer_amount [integer]: issuer amount. ex: 1234 (= R$ 12.34)
20
- # - issuer_currency_code [string]: issuer currency code. ex: "USD"
21
- # - merchant_amount [integer]: merchant amount. ex: 1234 (= R$ 12.34)
22
- # - merchant_currency_code [string]: merchant currency code. ex: "USD"
23
- # - merchant_category_code [string]: merchant category code. ex: "fastFoodRestaurants"
24
- # - merchant_country_code [string]: merchant country code. ex: "USA"
25
- # - acquirer_id [string]: acquirer ID. ex: "5656565656565656"
26
- # - merchant_id [string]: merchant ID. ex: "5656565656565656"
27
- # - merchant_name [string]: merchant name. ex: "Google Cloud Platform"
28
- # - merchant_fee [integer]: merchant fee charged. ex: 200 (= R$ 2.00)
29
- # - wallet_id [string]: virtual wallet ID. ex: "googlePay"
30
- # - method_code [string]: method code. ex: "chip", "token", "server", "manual", "magstripe" or "contactless"
31
- # - score [float]: internal score calculated for the authenticity of the purchase. nil in case of insufficient data. ex: 7.6
32
- # - is_partial_allowed [bool]: true if the the merchant allows partial purchases. ex: False
33
- # - purpose [string]: purchase purpose. ex: "purchase"
34
- # - card_tags [list of strings]: tags of the IssuingCard responsible for this purchase. ex: ["travel", "food"]
35
- # - holder_tags [list of strings]: tags of the IssuingHolder responsible for this purchase. ex: ["technology", "john snow"]
36
- class IssuingAuthorization < StarkInfra::Utils::Resource
37
- attr_reader :id, :end_to_end_id, :amount, :tax, :card_id, :issuer_amount, :issuer_currency_code, :merchant_amount,
38
- :merchant_currency_code, :merchant_category_code, :merchant_country_code, :acquirer_id, :merchant_id,
39
- :merchant_name, :merchant_fee, :wallet_id, :method_code, :score, :is_partial_allowed, :purpose,
40
- :card_tags, :holder_tags
41
- def initialize(
42
- id: nil, end_to_end_id: nil, amount: nil, tax: nil, card_id: nil, issuer_amount: nil,
43
- issuer_currency_code: nil, merchant_amount: nil, merchant_currency_code: nil,
44
- merchant_category_code: nil, merchant_country_code: nil, acquirer_id: nil, merchant_id: nil,
45
- merchant_name: nil, merchant_fee: nil, wallet_id: nil, method_code: nil, score: nil,
46
- is_partial_allowed: nil, purpose: nil, card_tags: nil, holder_tags: nil
47
- )
48
- super(id)
49
- @end_to_end_id = end_to_end_id
50
- @amount = amount
51
- @tax = tax
52
- @card_id = card_id
53
- @issuer_amount = issuer_amount
54
- @issuer_currency_code = issuer_currency_code
55
- @merchant_amount = merchant_amount
56
- @merchant_currency_code = merchant_currency_code
57
- @merchant_category_code = merchant_category_code
58
- @merchant_country_code = merchant_country_code
59
- @acquirer_id = acquirer_id
60
- @merchant_id = merchant_id
61
- @merchant_name = merchant_name
62
- @merchant_fee = merchant_fee
63
- @wallet_id = wallet_id
64
- @method_code = method_code
65
- @score = score
66
- @is_partial_allowed = is_partial_allowed
67
- @purpose = purpose
68
- @card_tags = card_tags
69
- @holder_tags = holder_tags
70
- end
71
-
72
- # # Create single IssuingAuthorization from a content string
73
- #
74
- # Create a single IssuingAuthorization object received from IssuingAuthorization at the informed endpoint.
75
- # If the provided digital signature does not check out with the StarkInfra public key, a
76
- # StarkInfra.Error.InvalidSignatureError will be raised.
77
- #
78
- # ## Parameters (optional):
79
- # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
80
- #
81
- # ## Return:
82
- # - IssuingAuthorization object with updated attributes
83
- def self.parse(content:, signature:, user: nil)
84
- StarkInfra::Utils::Parse.parse_and_verify(content: content, signature: signature, user: user, resource: resource)
85
- end
86
-
87
- # # Helps you respond IssuingAuthorization requests.
88
- #
89
- # ## Parameters (required):
90
- # - status [string]: sub-issuer response to the authorization. ex: 'accepted' or 'denied'
91
- #
92
- # ## Parameters (optional):
93
- # - amount [integer, default 0]: amount in cents that was authorized. ex: 1234 (= R$ 12.34)
94
- # - reason [string, default '']: denial reason. ex: 'other'
95
- # - tags [list of strings, default []]: tags to filter retrieved object. ex: ['tony', 'stark']
96
- #
97
- # ## Return:
98
- # - Dumped JSON string that must be returned to us on the IssuingAuthorization request
99
- def self.response(status:, amount: nil, reason: nil, tags: nil)
100
- response_hash = {
101
- "status": status,
102
- "amount": amount || 0,
103
- "reason": reason || '',
104
- "tags": tags || []
105
- }
106
- response_hash.to_json
107
- end
108
-
109
- def self.resource
110
- {
111
- resource_name: 'IssuingAuthorization',
112
- resource_maker: proc { |json|
113
- IssuingAuthorization.new(
114
- id: json['id'],
115
- end_to_end_id: json['end_to_end_id'],
116
- amount: json['amount'],
117
- tax: json['tax'],
118
- card_id: json['card_id'],
119
- issuer_amount: json['issuer_amount'],
120
- issuer_currency_code: json['issuer_currency_code'],
121
- merchant_amount: json['merchant_amount'],
122
- merchant_currency_code: json['merchant_currency_code'],
123
- merchant_category_code: json['merchant_category_code'],
124
- merchant_country_code: json['merchant_country_code'],
125
- acquirer_id: json['acquirer_id'],
126
- merchant_id: json['merchant_id'],
127
- merchant_name: json['merchant_name'],
128
- merchant_fee: json['merchant_fee'],
129
- wallet_id: json['wallet_id'],
130
- method_code: json['method_code'],
131
- score: json['score'],
132
- is_partial_allowed: json['is_partial_allowed'],
133
- purpose: json['purpose'],
134
- card_tags: json['card_tags'],
135
- holder_tags: json['holder_tags']
136
- )
137
- }
138
- }
139
- end
140
- end
141
- end