starkinfra 0.0.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -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
data/lib/utils/rest.rb CHANGED
@@ -61,11 +61,10 @@ module StarkInfra
61
61
  StarkInfra::Utils::API.from_api_json(resource_maker, entity)
62
62
  end
63
63
 
64
- def self.get_content(resource_name:, sub_resource_name:, id:, user: nil, **query)
64
+ def self.get_content(resource_name:, sub_resource_name:, id:, user: nil)
65
65
  StarkInfra::Utils::Request.fetch(
66
66
  method: 'GET',
67
67
  path: "#{StarkInfra::Utils::API.endpoint(resource_name)}/#{id}/#{sub_resource_name}",
68
- query: query,
69
68
  user: user
70
69
  ).content
71
70
  end
@@ -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.0.3
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-05-31 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
@@ -1,89 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative('../utils/resource')
4
- require_relative('../utils/rest')
5
- require_relative('../utils/checks')
6
-
7
- module StarkInfra
8
- # # IssuingBin object
9
- #
10
- # The IssuingBin object displays information of registered BINs to your Workspace.
11
- # They represent a group of cards that begin with the same numbers (BIN) and offer the same product to end customers.
12
- #
13
- # ## Attributes (return-only):
14
- # - id [string]: unique BIN number registered within the card network. ex: '53810200'
15
- # - network [string]: card network flag. ex: 'mastercard'
16
- # - settlement [string]: settlement type. ex: 'credit'
17
- # - category [string]: purchase category. ex: 'prepaid'
18
- # - client [string]: client type. ex: 'business'
19
- # - created [DateTime]: creation datetime for the IssuingBin. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
20
- # - updated [DateTime]: latest update datetime for the IssuingBin. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
21
- class IssuingBin < StarkInfra::Utils::Resource
22
- attr_reader :id, :network, :settlement, :category, :client, :updated, :created
23
- def initialize(id: nil, network: nil, settlement: nil, category: nil, client: nil, updated: nil, created: nil)
24
- super(id)
25
- @network = network
26
- @settlement = settlement
27
- @category = category
28
- @client = client
29
- @updated = StarkInfra::Utils::Checks.check_datetime(updated)
30
- @created = StarkInfra::Utils::Checks.check_datetime(created)
31
- end
32
-
33
- # # Retrieve the IssuingBin object
34
- #
35
- # Receive a generator of IssuingBin objects previously registered in the Stark Infra API
36
- #
37
- # ## Parameters (optional):
38
- # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
39
- # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
40
- #
41
- # ## Return:
42
- # - generator of IssuingBin objects with updated attributes
43
- def self.query(limit: nil, user: nil)
44
- StarkInfra::Utils::Rest.get_stream(
45
- limit: limit,
46
- user: user,
47
- **resource
48
- )
49
- end
50
-
51
- # # Retrieve paged IssuingBins
52
- #
53
- # Receive a list of up to 100 IssuingBin objects previously registered in the Stark Infra API and the cursor to the next page.
54
- #
55
- # ## Parameters (optional):
56
- # - cursor [string, default nil]: cursor returned on the previous page function call.
57
- # - limit [integer, default nil]: maximum number of objects to be retrieved. Max = 100. ex: 35
58
- # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
59
- #
60
- # ## Return:
61
- # - list of IssuingBin objects with updated attributes
62
- # - cursor to retrieve the next page of IssuingBin objects
63
- def self.page(cursor: nil, limit: nil, user: nil)
64
- StarkInfra::Utils::Rest.get_page(
65
- cursor: cursor,
66
- limit: limit,
67
- user: user,
68
- **resource
69
- )
70
- end
71
-
72
- def self.resource
73
- {
74
- resource_name: 'IssuingBin',
75
- resource_maker: proc { |json|
76
- IssuingBin.new(
77
- id: json['id'],
78
- network: json['network'],
79
- settlement: json['settlement'],
80
- category: json['category'],
81
- client: json['client'],
82
- updated: json['updated'],
83
- created: json['created']
84
- )
85
- }
86
- }
87
- end
88
- end
89
- end