starkbank 2.8.0 → 2.9.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.
@@ -0,0 +1,150 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'starkcore'
4
+ require_relative('../utils/rest')
5
+
6
+ module StarkBank
7
+ # # CorporateWithdrawal object
8
+ #
9
+ # The CorporateWithdrawal objects created in your Workspace return cash from your Corporate balance to your Banking balance.
10
+ #
11
+ # ## Parameters (required):
12
+ # - amount [integer]: CorporateWithdrawal value in cents. Minimum = 0 (any value will be accepted). ex: 1234 (= R$ 12.34)
13
+ # - external_id [string] CorporateWithdrawal external ID. ex: '12345'
14
+ #
15
+ # ## Parameters (optional):
16
+ # - tags [list of strings, default nil]: list of strings for tagging. ex: ['tony', 'stark']
17
+ #
18
+ # ## Attributes (return-only):
19
+ # - id [string]: unique id returned when CorporateWithdrawal is created. ex: '5656565656565656'
20
+ # - transaction_id [string]: Stark Bank ledger transaction ids linked to this CorporateWithdrawal
21
+ # - corporate_transaction_id [string]: corporate ledger transaction ids linked to this CorporateWithdrawal
22
+ # - updated [DateTime]: latest update datetime for the CorporateWithdrawal. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
23
+ # - created [DateTime]: creation datetime for the CorporateWithdrawal. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
24
+ class CorporateWithdrawal < StarkCore::Utils::Resource
25
+ attr_reader :amount, :external_id, :tags, :id, :transaction_id, :corporate_transaction_id, :updated, :created
26
+ def initialize(
27
+ amount:, external_id:, tags: nil, id: nil, transaction_id: nil, corporate_transaction_id: nil,
28
+ updated: nil, created: nil
29
+ )
30
+ super(id)
31
+ @amount = amount
32
+ @external_id = external_id
33
+ @tags = tags
34
+ @transaction_id = transaction_id
35
+ @corporate_transaction_id = corporate_transaction_id
36
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
37
+ @created = StarkCore::Utils::Checks.check_datetime(created)
38
+ end
39
+
40
+ # # Create a CorporateWithdrawal
41
+ #
42
+ # Send a single CorporateWithdrawal object for creation in the Stark Bank API
43
+ #
44
+ # ## Parameters (required):
45
+ # - withdrawal [CorporateWithdrawal object]: CorporateWithdrawal object to be created in the API.
46
+ #
47
+ # ## Parameters (optional):
48
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkbank.user was set before function call
49
+ #
50
+ # ## Return:
51
+ # - CorporateWithdrawal object with updated attributes
52
+ def self.create(withdrawal, user: nil)
53
+ StarkBank::Utils::Rest.post_single(entity: withdrawal, user: user, **resource)
54
+ end
55
+
56
+ # # Retrieve a specific CorporateWithdrawal
57
+ #
58
+ # Receive a single CorporateWithdrawal object previously created in the Stark Bank API by its id
59
+ #
60
+ # ## Parameters (required):
61
+ # - id [string]: object unique id. ex: '5656565656565656'
62
+ #
63
+ # ## Parameters (optional):
64
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkbank.user was set before function call
65
+ #
66
+ # ## Return:
67
+ # - CorporateWithdrawal object with updated attributes
68
+ def self.get(id, user: nil)
69
+ StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
70
+ end
71
+
72
+ # # Retrieve CorporateWithdrawals
73
+ #
74
+ # Receive a generator of CorporateWithdrawal objects previously created in the Stark Bank API
75
+ #
76
+ # ## Parameters (optional):
77
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
78
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
79
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
80
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
81
+ # - external_ids [list of strings, default nil]: external IDs. ex: ['5656565656565656', '4545454545454545']
82
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkbank.user was set before function call
83
+ #
84
+ # ## Return:
85
+ # - generator of CorporateWithdrawal objects with updated attributes
86
+ def self.query(limit: nil, external_ids: nil, after: nil, before: nil, tags: nil, user: nil)
87
+ after = StarkCore::Utils::Checks.check_date(after)
88
+ before = StarkCore::Utils::Checks.check_date(before)
89
+ StarkBank::Utils::Rest.get_stream(
90
+ limit: limit,
91
+ external_ids: external_ids,
92
+ after: after,
93
+ before: before,
94
+ tags: tags,
95
+ user: user,
96
+ **resource
97
+ )
98
+ end
99
+
100
+ # # Retrieve paged CorporateWithdrawals
101
+ #
102
+ # Receive a list of up to 100 CorporateWithdrawal objects previously created in the Stark Bank API and the cursor to the next page.
103
+ # Use this function instead of query if you want to manually page your requests.
104
+ #
105
+ # ## Parameters (optional):
106
+ # - cursor [string, default nil]: cursor returned on the previous page function call.
107
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
108
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
109
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
110
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
111
+ # - external_ids [list of strings, default nil]: external IDs. ex: ['5656565656565656', '4545454545454545']
112
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkbank.user was set before function call
113
+ #
114
+ # ## Return:
115
+ # - list of CorporateWithdrawal objects with updated attributes
116
+ # - cursor to retrieve the next page of CorporateWithdrawal objects
117
+ def self.page(cursor: nil, limit: nil, external_ids: nil, after: nil, before: nil, tags: nil, user: nil)
118
+ after = StarkCore::Utils::Checks.check_date(after)
119
+ before = StarkCore::Utils::Checks.check_date(before)
120
+ StarkBank::Utils::Rest.get_page(
121
+ cursor: cursor,
122
+ limit: limit,
123
+ external_ids: external_ids,
124
+ after: after,
125
+ before: before,
126
+ tags: tags,
127
+ user: user,
128
+ **resource
129
+ )
130
+ end
131
+
132
+ def self.resource
133
+ {
134
+ resource_name: 'CorporateWithdrawal',
135
+ resource_maker: proc { |json|
136
+ CorporateWithdrawal.new(
137
+ id: json['id'],
138
+ amount: json['amount'],
139
+ external_id: json['external_id'],
140
+ tags: json['tags'],
141
+ transaction_id: json['transaction_id'],
142
+ corporate_transaction_id: json['corporate_transaction_id'],
143
+ updated: json['updated'],
144
+ created: json['created']
145
+ )
146
+ }
147
+ }
148
+ end
149
+ end
150
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'starkcore'
4
+ require_relative('../utils/rest')
5
+
6
+ module StarkBank
7
+ # # MerchantCategory object
8
+ #
9
+ # MerchantCategory's codes and types are used to define categories filters in CorporateRules.
10
+ #
11
+ # A MerchantCategory filter must define exactly one parameter between code and type.
12
+ # A type, such as 'food', 'services', etc., defines an entire group of merchant codes,
13
+ # whereas a code only specifies a specific MCC.
14
+ #
15
+ # ## Parameters (conditionally required):
16
+ # - code [string, default nil]: category's code. ex: 'veterinaryServices', 'fastFoodRestaurants'
17
+ # - type [string, default nil]: category's type. ex: 'pets', 'food'
18
+ #
19
+ # Attributes (return-only):
20
+ # - name [string]: category's name. ex: 'Veterinary services', 'Fast food restaurants'
21
+ # - number [string]: category's number. ex: '742', '5814'
22
+ class MerchantCategory < StarkCore::Utils::SubResource
23
+ attr_reader :code, :type, :name, :number
24
+ def initialize(code:, type:, name: nil, number: nil)
25
+ @code = code
26
+ @type = type
27
+ @name = name
28
+ @number = number
29
+ end
30
+
31
+ # # Retrieve MerchantCategories
32
+ #
33
+ # Receive a generator of MerchantCategory objects available in the Stark Bank API
34
+ #
35
+ # ## Parameters (optional):
36
+ # - search [string, default nil]: keyword to search for code, name, number or short_code
37
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkbank.user was set before function call
38
+ #
39
+ # ## Return:
40
+ # - generator of MerchantCategory objects with updated attributes
41
+ def self.query(search: nil, user: nil)
42
+ StarkBank::Utils::Rest.get_stream(
43
+ search: search,
44
+ user: user,
45
+ **resource
46
+ )
47
+ end
48
+
49
+ def self.resource
50
+ {
51
+ resource_name: 'MerchantCategory',
52
+ resource_maker: proc { |json|
53
+ MerchantCategory.new(
54
+ code: json['code'],
55
+ type: json['type'],
56
+ name: json['name'],
57
+ number: json['number']
58
+ )
59
+ }
60
+ }
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'starkcore'
4
+ require_relative('../utils/rest')
5
+
6
+ module StarkBank
7
+ # # MerchantCountry object
8
+ #
9
+ # MerchantCountry's codes are used to define countries filters in CorporateRules.
10
+ #
11
+ # ## Parameters (required):
12
+ # - code [string]: country's code. ex: 'BRA'
13
+ #
14
+ # Attributes (return-only):
15
+ # - name [string]: country's name. ex: 'Brazil'
16
+ # - number [string]: country's number. ex: '076'
17
+ # - short_code [string]: country's short code. ex: 'BR'
18
+ class MerchantCountry < StarkCore::Utils::SubResource
19
+ attr_reader :code, :short_code, :name, :number
20
+ def initialize(code:, name: nil, number: nil, short_code: nil)
21
+ @code = code
22
+ @name = name
23
+ @number = number
24
+ @short_code = short_code
25
+ end
26
+
27
+ # # Retrieve MerchantCountries
28
+ #
29
+ # Receive a generator of MerchantCountry objects available in the Stark Bank API
30
+ #
31
+ # ## Parameters (optional):
32
+ # - search [string, default nil]: keyword to search for code, name, number or short_code
33
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkbank.user was set before function call
34
+ #
35
+ # ## Return:
36
+ # - generator of MerchantCountry objects with updated attributes
37
+ def self.query(search: nil, user: nil)
38
+ StarkBank::Utils::Rest.get_stream(
39
+ search: search,
40
+ user: user,
41
+ **resource
42
+ )
43
+ end
44
+
45
+ def self.resource
46
+ {
47
+ resource_name: 'MerchantCountry',
48
+ resource_maker: proc { |json|
49
+ MerchantCountry.new(
50
+ code: json['code'],
51
+ name: json['name'],
52
+ number: json['number'],
53
+ short_code: json['short_code']
54
+ )
55
+ }
56
+ }
57
+ end
58
+ end
59
+ end
@@ -47,8 +47,8 @@ module StarkBank
47
47
  @status = status
48
48
  @actions = actions
49
49
  @description = description
50
- @updated = updated
51
- @created = created
50
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
51
+ @created = StarkCore::Utils::Checks.check_datetime(created)
52
52
 
53
53
  @payment, @type = parse_payment(payment: payment, type: type)
54
54
  end
data/lib/starkbank.rb CHANGED
@@ -10,6 +10,21 @@ require_relative('dict_key/dict_key')
10
10
  require_relative('dynamic_brcode/dynamic_brcode')
11
11
  require_relative('deposit/deposit')
12
12
  require_relative('deposit/log')
13
+ require_relative('card_method/cardmethod')
14
+ require_relative('corporate_balance/corporatebalance')
15
+ require_relative('corporate_card/corporatecard')
16
+ require_relative('corporate_card/log')
17
+ require_relative('corporate_holder/corporateholder')
18
+ require_relative('corporate_holder/log')
19
+ require_relative('corporate_holder/permission')
20
+ require_relative('corporate_invoice/corporateinvoice')
21
+ require_relative('corporate_purchase/corporatepurchase')
22
+ require_relative('corporate_purchase/log')
23
+ require_relative('corporate_rule/corporaterule')
24
+ require_relative('corporate_transaction/corporatetransaction')
25
+ require_relative('corporate_withdrawal/corporatewithdrawal')
26
+ require_relative('merchant_category/merchantcategory')
27
+ require_relative('merchant_country/merchantcountry')
13
28
  require_relative('brcode_payment/brcode_payment')
14
29
  require_relative('brcode_payment/rule')
15
30
  require_relative('brcode_payment/log')
@@ -43,7 +58,7 @@ require_relative('institution/institution')
43
58
  module StarkBank
44
59
 
45
60
  API_VERSION = 'v2'
46
- SDK_VERSION = '2.8.0'
61
+ SDK_VERSION = '2.9.0'
47
62
  HOST = "bank"
48
63
  public_constant :API_VERSION, :SDK_VERSION, :HOST;
49
64
 
data/lib/utils/rest.rb CHANGED
@@ -126,6 +126,20 @@ module StarkBank
126
126
  )
127
127
  end
128
128
 
129
+ def self.post_raw(path:, payload:, user:, **query)
130
+ return StarkCore::Utils::Rest.post_raw(
131
+ host: StarkBank::HOST,
132
+ sdk_version: StarkBank::SDK_VERSION,
133
+ user: user ? user : StarkBank.user,
134
+ path: path,
135
+ payload: payload,
136
+ api_version: StarkBank::API_VERSION,
137
+ language: StarkBank.language,
138
+ timeout: StarkBank.timeout,
139
+ **query,
140
+ )
141
+ end
142
+
129
143
  def self.delete_id(resource_name:, resource_maker:, user:, id:)
130
144
  return StarkCore::Utils::Rest.delete_id(
131
145
  resource_name: resource_name,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: starkbank
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.0
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - starkbank
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-23 00:00:00.000000000 Z
11
+ date: 2023-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: starkcore
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.1
19
+ version: 0.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.0.1
26
+ version: 0.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -82,6 +82,19 @@ files:
82
82
  - lib/brcode_payment/brcode_payment.rb
83
83
  - lib/brcode_payment/log.rb
84
84
  - lib/brcode_payment/rule.rb
85
+ - lib/card_method/cardmethod.rb
86
+ - lib/corporate_balance/corporatebalance.rb
87
+ - lib/corporate_card/corporatecard.rb
88
+ - lib/corporate_card/log.rb
89
+ - lib/corporate_holder/corporateholder.rb
90
+ - lib/corporate_holder/log.rb
91
+ - lib/corporate_holder/permission.rb
92
+ - lib/corporate_invoice/corporateinvoice.rb
93
+ - lib/corporate_purchase/corporatepurchase.rb
94
+ - lib/corporate_purchase/log.rb
95
+ - lib/corporate_rule/corporaterule.rb
96
+ - lib/corporate_transaction/corporatetransaction.rb
97
+ - lib/corporate_withdrawal/corporatewithdrawal.rb
85
98
  - lib/darf_payment/darf_payment.rb
86
99
  - lib/darf_payment/log.rb
87
100
  - lib/deposit/deposit.rb
@@ -95,6 +108,8 @@ files:
95
108
  - lib/invoice/invoice.rb
96
109
  - lib/invoice/log.rb
97
110
  - lib/invoice/payment.rb
111
+ - lib/merchant_category/merchantcategory.rb
112
+ - lib/merchant_country/merchantcountry.rb
98
113
  - lib/payment_preview/boleto_preview.rb
99
114
  - lib/payment_preview/brcode_preview.rb
100
115
  - lib/payment_preview/payment_preview.rb