fintoc 1.8.0 → 1.10.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86cb95f11227365b5cc658916f6cf151503b495e07ecfb3f105cea3556b57a36
4
- data.tar.gz: c50e35e79db4e944f7d930924be55211afe940130980f56470fb294a27f7fc4c
3
+ metadata.gz: 60e9c0d402a45ce1462059bf4cb5b5f206e7b5a1c79ff2bd61834299af6fce01
4
+ data.tar.gz: 89a7c33461389bb3a5190e63d99df22d5afe1c7091fb1cc50595426ff6e84311
5
5
  SHA512:
6
- metadata.gz: 7ad5d6d2d7b5bfe4cb3adc3864c5671042b3085d703a3f01981e6088141f40f62ae17b4b837d957e596965d2a64f28fdf87a0f0aadbb9b5d415bb9d9f64e9019
7
- data.tar.gz: cbae5df406a5a1f571fecb0aef8bd921985c31893fa79c1520641e6b49922b63996da581912db8aeb56cdf3f364f6004ff390bb4598e7ccd577cd8a32ed449e5
6
+ metadata.gz: 28388ad1d43d031493f881874ed5f0a6370c4113500c3e0a8a15ea4bab031c330ab7ed54340aab2ec1852274a1c4615021f8a994a1d61756c89cbd8f6887d918
7
+ data.tar.gz: 2d6f01f3d34afc8a68ed2a212734b1f48f5c61381714179c5b6333790abfa4f589486a04206bc56e476b65fdb28014129de60ca727b75be26cda522f07569004
@@ -24,6 +24,15 @@ de cambios específicos también es bienvenido.
24
24
  - [x] Tests unitarios para x
25
25
  - [x] Tests de integración entre x e y
26
26
 
27
+ ## Release notes
28
+
29
+ <!--
30
+ Si este PR debe publicar una versión, agrega el label release:patch, release:minor
31
+ o release:major y escribe aquí, en inglés, lo que verán los usuarios del SDK.
32
+ Si queda vacío, se usan las notas autogeneradas de GitHub.
33
+ Los PRs sin label no publican.
34
+ -->
35
+
27
36
  ## Safety Checks
28
37
 
29
38
  - [ ] Versión y CHANGELOG actualizados (si corresponde)
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env bash
2
+ # Decide the bump and release notes for the release workflow.
3
+ # Writes `bump` (empty means skip the release) and `notes` to $GITHUB_OUTPUT.
4
+ #
5
+ # Required env: EVENT_NAME, GITHUB_OUTPUT
6
+ # workflow_dispatch: INPUT_BUMP, INPUT_NOTES
7
+ # push: SHA, PULLS_JSON (response of GET repos/{repo}/commits/{sha}/pulls)
8
+ set -euo pipefail
9
+
10
+ extract_release_notes() {
11
+ perl -0777 -ne '
12
+ s/\r//g;
13
+ s/<!--.*?-->//gs;
14
+ if (/^##[ \t]+Release notes[ \t]*$(.*?)(?=^##[ \t]|\z)/msi) {
15
+ my $notes = $1;
16
+ $notes =~ s/^\s+|\s+$//g;
17
+ print $notes;
18
+ }
19
+ '
20
+ }
21
+
22
+ trim() {
23
+ perl -0777 -pe 's/^\s+|\s+$//g'
24
+ }
25
+
26
+ write_output() {
27
+ local bump=$1 notes=$2 delimiter
28
+ delimiter="RELEASE_NOTES_$(openssl rand -hex 16)"
29
+ {
30
+ echo "bump=$bump"
31
+ echo "notes<<$delimiter"
32
+ printf '%s\n' "$notes"
33
+ echo "$delimiter"
34
+ } >> "$GITHUB_OUTPUT"
35
+ }
36
+
37
+ skip_release() {
38
+ echo "::notice::$1 Skipping release."
39
+ write_output "" ""
40
+ }
41
+
42
+ resolve_from_dispatch() {
43
+ write_output "$INPUT_BUMP" "$(printf '%s' "${INPUT_NOTES:-}" | trim)"
44
+ }
45
+
46
+ resolve_from_push() {
47
+ local pr number labels label_count bump
48
+ pr=$(jq -c --arg sha "$SHA" \
49
+ 'map(select(.merged_at != null and .merge_commit_sha == $sha)) | first // empty' \
50
+ <<< "$PULLS_JSON")
51
+ if [ -z "$pr" ]; then
52
+ skip_release "No merged PR found for $SHA."
53
+ return
54
+ fi
55
+
56
+ number=$(jq -r '.number' <<< "$pr")
57
+ labels=$(jq -r '[.labels[].name | select(startswith("release:"))] | join(" ")' <<< "$pr")
58
+ label_count=$(jq '[.labels[].name | select(startswith("release:"))] | length' <<< "$pr")
59
+
60
+ if [ "$label_count" -eq 0 ]; then
61
+ skip_release "PR #$number has no release:* label."
62
+ return
63
+ fi
64
+ if [ "$label_count" -gt 1 ]; then
65
+ echo "::error::PR #$number has more than one release:* label ($labels). Keep only one."
66
+ exit 1
67
+ fi
68
+
69
+ bump=${labels#release:}
70
+ case "$bump" in
71
+ patch|minor|major) ;;
72
+ *)
73
+ echo "::error::PR #$number has an unknown label $labels. Use release:patch, release:minor or release:major."
74
+ exit 1
75
+ ;;
76
+ esac
77
+
78
+ echo "Releasing PR #$number with bump $bump."
79
+ write_output "$bump" "$(jq -r '.body // ""' <<< "$pr" | extract_release_notes)"
80
+ }
81
+
82
+ case "$EVENT_NAME" in
83
+ workflow_dispatch) resolve_from_dispatch ;;
84
+ push) resolve_from_push ;;
85
+ *)
86
+ echo "::error::Unsupported event $EVENT_NAME."
87
+ exit 1
88
+ ;;
89
+ esac
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env bash
2
+ set -uo pipefail
3
+
4
+ SCRIPT="$(dirname "$0")/resolve-release.sh"
5
+ SHA=abc123
6
+ failures=0
7
+
8
+ pulls_json() {
9
+ local labels=$1 body=$2
10
+ jq -nc --arg sha "$SHA" --arg body "$body" --argjson labels "$labels" \
11
+ '[{number: 7, merged_at: "2026-01-01T00:00:00Z", merge_commit_sha: $sha,
12
+ body: $body, labels: ($labels | map({name: .}))}]'
13
+ }
14
+
15
+ read_output() {
16
+ local file=$1 name=$2
17
+ awk -v name="$name" '
18
+ index($0, name "=") == 1 { print substr($0, length(name) + 2); exit }
19
+ index($0, name "<<") == 1 { delimiter = substr($0, length(name) + 3); reading = 1; next }
20
+ reading && $0 == delimiter { exit }
21
+ reading { print }
22
+ ' "$file"
23
+ }
24
+
25
+ assert_release() {
26
+ local description=$1 expected_status=$2 expected_bump=$3 expected_notes=$4
27
+ shift 4
28
+ local output status
29
+ output=$(mktemp)
30
+ env GITHUB_OUTPUT="$output" "$@" bash "$SCRIPT" > /dev/null
31
+ status=$?
32
+
33
+ if [ "$status" -ne "$expected_status" ]; then
34
+ echo "FAIL: $description (exit $status, expected $expected_status)"
35
+ failures=$((failures + 1))
36
+ elif [ "$expected_status" -eq 0 ] &&
37
+ { [ "$(read_output "$output" bump)" != "$expected_bump" ] ||
38
+ [ "$(read_output "$output" notes)" != "$expected_notes" ]; }; then
39
+ echo "FAIL: $description"
40
+ echo " bump: '$(read_output "$output" bump)' expected '$expected_bump'"
41
+ echo " notes: '$(read_output "$output" notes)' expected '$expected_notes'"
42
+ failures=$((failures + 1))
43
+ else
44
+ echo "ok: $description"
45
+ fi
46
+ rm -f "$output"
47
+ }
48
+
49
+ assert_push() {
50
+ local description=$1 expected_status=$2 expected_bump=$3 expected_notes=$4 labels=$5 body=$6
51
+ assert_release "$description" "$expected_status" "$expected_bump" "$expected_notes" \
52
+ EVENT_NAME=push SHA="$SHA" PULLS_JSON="$(pulls_json "$labels" "$body")"
53
+ }
54
+
55
+ assert_push "notes section at the end, comments stripped" 0 minor $'- Added X.\n- Removed Y.' \
56
+ '["bug", "release:minor"]' \
57
+ $'## Contexto\nctx\n\n## Release notes\n\n<!-- instructions\nspanning lines -->\n\n- Added X.\n- Removed Y.\n'
58
+
59
+ assert_push "notes section followed by another section" 0 patch $'Fixed X.\n### Details\nmore' \
60
+ '["release:patch"]' \
61
+ $'## Release notes\r\n\r\nFixed X.\r\n### Details\r\nmore\r\n\r\n## Rollback\r\nsafe\r\n'
62
+
63
+ assert_push "notes section with only a comment" 0 major "" \
64
+ '["release:major"]' $'## Release notes\n<!-- empty -->\n## Rollback\nx'
65
+
66
+ assert_push "no notes section" 0 patch "" '["release:patch"]' $'## Contexto\nctx'
67
+
68
+ assert_push "PR without release label is skipped" 0 "" "" '["bug"]' $'## Release notes\nx'
69
+
70
+ assert_push "more than one release label fails" 1 "" "" '["release:patch", "release:minor"]' "x"
71
+
72
+ assert_push "unknown release label fails" 1 "" "" '["release:hotfix"]' "x"
73
+
74
+ assert_release "push without merged PR is skipped" 0 "" "" \
75
+ EVENT_NAME=push SHA="$SHA" PULLS_JSON='[{"number": 8, "merged_at": null, "merge_commit_sha": "abc123", "labels": [{"name": "release:patch"}], "body": ""}]'
76
+
77
+ assert_release "workflow_dispatch uses the inputs" 0 minor "notes here" \
78
+ EVENT_NAME=workflow_dispatch INPUT_BUMP=minor INPUT_NOTES=$' \n notes here\n'
79
+
80
+ assert_release "workflow_dispatch with empty notes" 0 patch "" \
81
+ EVENT_NAME=workflow_dispatch INPUT_BUMP=patch INPUT_NOTES=""
82
+
83
+ [ "$failures" -eq 0 ] || { echo "$failures failing case(s)"; exit 1; }
@@ -26,6 +26,17 @@ jobs:
26
26
  - name: Run RuboCop
27
27
  run: bundle exec rubocop
28
28
 
29
+ release-scripts:
30
+ runs-on: ubuntu-latest
31
+ name: Test release scripts
32
+
33
+ steps:
34
+ - name: Checkout code
35
+ uses: actions/checkout@v4
36
+
37
+ - name: Test resolve-release
38
+ run: .github/scripts/resolve-release.test.sh
39
+
29
40
  test:
30
41
  runs-on: ubuntu-latest
31
42
  strategy:
@@ -1,6 +1,8 @@
1
1
  name: release
2
2
 
3
3
  on:
4
+ push:
5
+ branches: [main]
4
6
  workflow_dispatch:
5
7
  inputs:
6
8
  bump:
@@ -14,15 +16,72 @@ on:
14
16
  type: string
15
17
  required: false
16
18
 
19
+ permissions: {}
20
+
17
21
  jobs:
22
+ resolve:
23
+ runs-on: blacksmith-2vcpu-ubuntu-2404
24
+ permissions:
25
+ contents: read
26
+ pull-requests: read
27
+ outputs:
28
+ bump: ${{ steps.resolve.outputs.bump }}
29
+ notes: ${{ steps.resolve.outputs.notes }}
30
+ steps:
31
+ - uses: actions/checkout@v4
32
+ with:
33
+ persist-credentials: false
34
+
35
+ - name: Find merged PR
36
+ id: pulls
37
+ if: github.event_name == 'push'
38
+ env:
39
+ GH_TOKEN: ${{ github.token }}
40
+ run: |
41
+ for attempt in 1 2 3; do
42
+ pulls=$(gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/pulls" --jq 'tojson')
43
+ if [ "$pulls" != "[]" ] || [ "$attempt" -eq 3 ]; then break; fi
44
+ sleep 10
45
+ done
46
+ echo "json=$pulls" >> "$GITHUB_OUTPUT"
47
+
48
+ - name: Resolve bump and release notes
49
+ id: resolve
50
+ env:
51
+ EVENT_NAME: ${{ github.event_name }}
52
+ SHA: ${{ github.sha }}
53
+ INPUT_BUMP: ${{ inputs.bump }}
54
+ INPUT_NOTES: ${{ inputs.release-notes }}
55
+ PULLS_JSON: ${{ steps.pulls.outputs.json }}
56
+ run: .github/scripts/resolve-release.sh
57
+
18
58
  release:
19
- if: github.ref == 'refs/heads/main'
20
- runs-on: ubuntu-latest
59
+ needs: resolve
60
+ if: github.ref == 'refs/heads/main' && needs.resolve.outputs.bump != ''
61
+ runs-on: blacksmith-2vcpu-ubuntu-2404
62
+ concurrency:
63
+ group: release
64
+ cancel-in-progress: false
21
65
  permissions:
22
66
  contents: write
23
67
  id-token: write
24
68
  steps:
25
69
  - uses: actions/checkout@v4
70
+ with:
71
+ ref: main
72
+
73
+ - name: Check main has no other changes after the merged PR
74
+ if: github.event_name == 'push'
75
+ env:
76
+ GH_TOKEN: ${{ github.token }}
77
+ run: |
78
+ head=$(git rev-parse HEAD)
79
+ later=$(gh api "repos/$GITHUB_REPOSITORY/compare/$GITHUB_SHA...$head" \
80
+ --jq '[.commits[] | select(.author.login != "fin-releases[bot]" or (.commit.message | startswith("release: ") | not)) | .sha[0:7]] | join(" ")')
81
+ if [ -n "$later" ]; then
82
+ echo "::error::main has commits merged after $GITHUB_SHA ($later). Aborting so they are not published with this PR's bump and notes. The next release will include this PR; use workflow_dispatch if it needs a bigger bump."
83
+ exit 1
84
+ fi
26
85
 
27
86
  - uses: ruby/setup-ruby@v1
28
87
  with:
@@ -37,17 +96,36 @@ jobs:
37
96
  - uses: fintoc-com/release-action/prepare@main
38
97
  id: prep
39
98
  with:
40
- bump: ${{ inputs.bump }}
99
+ bump: ${{ needs.resolve.outputs.bump }}
41
100
  version-format: ruby
42
101
  tag-prefix: v
102
+ push: 'true'
43
103
  app-id: ${{ vars.FIN_RELEASES_APP_ID }}
44
104
  app-private-key: ${{ secrets.FIN_RELEASES_PRIVATE_KEY }}
45
105
 
106
+ - name: Fall back to auto-generated release notes
107
+ id: notes
108
+ env:
109
+ GH_TOKEN: ${{ github.token }}
110
+ TAG: ${{ steps.prep.outputs.tag }}
111
+ NOTES: ${{ needs.resolve.outputs.notes }}
112
+ run: |
113
+ if [ -z "${NOTES//[[:space:]]/}" ]; then
114
+ NOTES=$(gh api -X POST "repos/$GITHUB_REPOSITORY/releases/generate-notes" \
115
+ -f tag_name="$TAG" -f target_commitish="$GITHUB_SHA" --jq '.body')
116
+ fi
117
+ delimiter="RELEASE_NOTES_$(openssl rand -hex 16)"
118
+ {
119
+ echo "body<<$delimiter"
120
+ printf '%s\n' "$NOTES"
121
+ echo "$delimiter"
122
+ } >> "$GITHUB_OUTPUT"
123
+
46
124
  - uses: rubygems/release-gem@v1
47
125
 
48
126
  - uses: fintoc-com/release-action/finalize@main
49
127
  with:
50
128
  tag: ${{ steps.prep.outputs.tag }}
51
- release-notes: ${{ inputs.release-notes }}
129
+ release-notes: ${{ steps.notes.outputs.body }}
52
130
  app-id: ${{ vars.FIN_RELEASES_APP_ID }}
53
131
  app-private-key: ${{ secrets.FIN_RELEASES_PRIVATE_KEY }}
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fintoc (1.8.0)
4
+ fintoc (1.10.0)
5
5
  http
6
6
  money-rails
7
7
  tabulate
data/README.md CHANGED
@@ -33,6 +33,7 @@ Do yourself a favor: go grab some ice cubes by installing this refreshing librar
33
33
  - [Account Numbers](#account-numbers)
34
34
  - [Transfers](#transfers)
35
35
  - [Transfer Batches](#transfer-batches)
36
+ - [Recipients](#recipients)
36
37
  - [Simulate](#simulate)
37
38
  - [Account Verifications](#account-verifications)
38
39
  - [Entity onboardings API Examples](#entity-onboardings-api-examples)
@@ -148,6 +149,20 @@ resources = client.v1.payouts.list_resources('payout_id', resource_type: 'paymen
148
149
  disputes = client.v1.disputes.list(status: 'needs_response')
149
150
  client.v1.disputes.create_document('dispute_id', file: 'path/to/evidence.pdf')
150
151
  client.v1.disputes.submit_for_review('dispute_id')
152
+
153
+ # Referred organizations
154
+ organization = client.v1.organizations.create(
155
+ name: 'Empresa SpA',
156
+ tax_id: '11.111.111-1',
157
+ founder_email: 'founder@example.com',
158
+ products: { business_accounts: {} },
159
+ external_reference: 'SOL-123'
160
+ )
161
+ client.v1.organizations.update(
162
+ organization.id,
163
+ founder_email: 'new-founder@example.com',
164
+ previous_founder_email: 'founder@example.com'
165
+ )
151
166
  ```
152
167
 
153
168
  ### **API V2 Client**
@@ -193,6 +208,17 @@ transfer_batch = client.v2.transfer_batches.create(
193
208
  transfers: [{...}]
194
209
  )
195
210
 
211
+ # Recipients
212
+ recipients = client.v2.recipients.list(entity_id: 'entity_id')
213
+ recipient = client.v2.recipients.get('recipient_id')
214
+ recipient = client.v2.recipients.create(
215
+ entity_id: 'entity_id',
216
+ account_number: 'account_number',
217
+ holder_name: 'Jon Snow'
218
+ )
219
+ recipient = client.v2.recipients.update('recipient_id', alias: 'Jon')
220
+ client.v2.recipients.delete('recipient_id')
221
+
196
222
  # Simulate
197
223
  simulated_transfer = client.v2.simulate.receive_transfer(
198
224
  account_number_id: 'account_number_id',
@@ -505,6 +531,39 @@ transfer_batches = client.v2.transfer_batches.list(
505
531
  transfers = client.v2.transfers.list(transfer_batch_id: 'transfer_batch_id')
506
532
  ```
507
533
 
534
+ #### Recipients
535
+
536
+ ```ruby
537
+ require 'fintoc'
538
+
539
+ client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
540
+
541
+ # Create a recipient
542
+ recipient = client.v2.recipients.create(
543
+ entity_id: 'entity_id',
544
+ account_number: '000000001',
545
+ holder_name: 'Jon Snow',
546
+ account_type: 'checking_account',
547
+ holder_id: '11.111.111-1',
548
+ holder_type: 'person',
549
+ institution_id: 'cl_banco_de_chile',
550
+ alias: 'Jon',
551
+ email: 'jon.snow@example.com'
552
+ )
553
+
554
+ # Get a specific recipient
555
+ recipient = client.v2.recipients.get('recipient_id')
556
+
557
+ # List recipients, optionally filtered
558
+ recipients = client.v2.recipients.list(entity_id: 'entity_id', holder_type: 'person')
559
+
560
+ # Update a recipient
561
+ recipient = client.v2.recipients.update('recipient_id', alias: 'Lord Snow')
562
+
563
+ # Delete a recipient
564
+ client.v2.recipients.delete('recipient_id')
565
+ ```
566
+
508
567
  #### Simulate
509
568
 
510
569
  ```ruby
@@ -51,7 +51,7 @@ module Fintoc
51
51
  content = JSON.parse(response.body, symbolize_names: true)
52
52
 
53
53
  if response.status.client_error? || response.status.server_error?
54
- raise_custom_error(content[:error])
54
+ raise_custom_error(content[:error], response.status.code)
55
55
  end
56
56
 
57
57
  @link_headers = response.headers.get('link')
@@ -147,8 +147,10 @@ module Fintoc
147
147
  value.respond_to?(:read) || (value.is_a?(String) && File.file?(value))
148
148
  end
149
149
 
150
- def raise_custom_error(error)
151
- raise error_class(error[:code]).new(error[:message], error[:doc_url])
150
+ def raise_custom_error(error, status)
151
+ raise error_class(error[:code]).new(
152
+ error[:message], error[:doc_url], status:, code: error[:code]
153
+ )
152
154
  end
153
155
 
154
156
  def error_class(snake_code)
data/lib/fintoc/client.rb CHANGED
@@ -9,7 +9,7 @@ module Fintoc
9
9
  end
10
10
 
11
11
  def v1
12
- @v1 ||= Fintoc::V1::Client.new(@api_key)
12
+ @v1 ||= Fintoc::V1::Client.new(@api_key, jws_private_key: @jws_private_key)
13
13
  end
14
14
 
15
15
  def v2
data/lib/fintoc/errors.rb CHANGED
@@ -3,11 +3,19 @@ require 'fintoc/constants'
3
3
  module Fintoc
4
4
  module Errors
5
5
  class FintocError < StandardError
6
- def initialize(message, doc_url = Fintoc::Constants::GENERAL_DOC_URL)
6
+ # HTTP status of the API response (Integer), or nil when not raised from a response.
7
+ # API error code, such as 'invalid_institution_id' (String), or nil.
8
+ attr_reader :status, :code
9
+
10
+ def initialize(
11
+ message, doc_url = Fintoc::Constants::GENERAL_DOC_URL, status: nil, code: nil
12
+ )
7
13
  super(message)
8
14
 
9
15
  @message = message
10
16
  @doc_url = doc_url
17
+ @status = status
18
+ @code = code
11
19
  end
12
20
 
13
21
  def message
@@ -83,6 +91,8 @@ module Fintoc
83
91
  class MinimumAmountError < FintocError; end
84
92
  class MutuallyExclusiveParamsError < FintocError; end
85
93
  class NotSupportedRefundableResourceTypeError < FintocError; end
94
+ class SplitFlatNotAllowedInIndexedSubscriptionError < FintocError; end
95
+ class SplitNotAvailableError < FintocError; end
86
96
  class SplitSumMismatchError < FintocError; end
87
97
 
88
98
  # 401 Unauthorized Errors
@@ -129,6 +139,7 @@ module Fintoc
129
139
  class InvalidUrlError < FintocError; end
130
140
  class OrganizationWithoutEntitiesError < FintocError; end
131
141
  class ResourceNotFoundError < FintocError; end
142
+ class FounderEmailMismatchError < FintocError; end
132
143
 
133
144
  # 405 Method Not Allowed Errors
134
145
  class OperationNotAllowedError < FintocError; end
@@ -154,18 +165,25 @@ module Fintoc
154
165
  class DisputeNotOpenForDocumentsError < FintocError; end
155
166
  class DuplicateRecipientError < FintocError; end
156
167
  class EntityHolderIdAlreadyExistsForOrganizationError < FintocError; end
168
+ class FounderAlreadyActivatedError < FintocError; end
157
169
  class InvalidEmptySubscriptionError < FintocError; end
158
170
  class InvoiceNotEditableError < FintocError; end
159
171
  class InvoiceNotFinalizableError < FintocError; end
160
172
  class InvoiceNotMarkableUncollectibleError < FintocError; end
161
173
  class NoDocumentsToSubmitError < FintocError; end
174
+ class OrganizationAlreadyExistsError < FintocError; end
162
175
  class PaymentMethodNonCancelableError < FintocError; end
163
176
  class PaymentNonCancelableError < FintocError; end
164
177
  class PaymentNonExpirableError < FintocError; end
165
178
  class SubscriptionNotEditableError < FintocError; end
166
179
 
167
180
  # 422 Unprocessable Entity Errors
181
+ class AccountBlockedForDirectDebitError < FintocError; end
182
+ class FounderEmailChangeLimitReachedError < FintocError; end
183
+ class InvalidHolderNameError < FintocError; end
168
184
  class InvalidOtpCodeError < FintocError; end
185
+ class InvalidProductsError < FintocError; end
186
+ class InvalidTaxIdError < FintocError; end
169
187
  class OtpNotFoundError < FintocError; end
170
188
  class OtpBlockedError < FintocError; end
171
189
  class OtpVerificationFailedError < FintocError; end
@@ -17,6 +17,7 @@ require 'fintoc/v1/managers/charges_manager'
17
17
  require 'fintoc/v1/managers/refunds_manager'
18
18
  require 'fintoc/v1/managers/payouts_manager'
19
19
  require 'fintoc/v1/managers/disputes_manager'
20
+ require 'fintoc/v1/managers/organizations_manager'
20
21
 
21
22
  module Fintoc
22
23
  module V1
@@ -92,6 +93,10 @@ module Fintoc
92
93
  def disputes
93
94
  @disputes ||= Managers::DisputesManager.new(self)
94
95
  end
96
+
97
+ def organizations
98
+ @organizations ||= Managers::OrganizationsManager.new(self)
99
+ end
95
100
  end
96
101
  end
97
102
  end
@@ -0,0 +1,32 @@
1
+ require 'fintoc/v1/resources/organization'
2
+
3
+ module Fintoc
4
+ module V1
5
+ module Managers
6
+ class OrganizationsManager
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def create(name:, tax_id:, founder_email:, products:, **params)
12
+ data = @client.post(version: :v1)
13
+ .call('organizations', name:, tax_id:, founder_email:, products:, **params)
14
+ build_organization(data)
15
+ end
16
+
17
+ def update(organization_id, founder_email:, previous_founder_email:)
18
+ data = @client.patch(version: :v1)
19
+ .call("organizations/#{organization_id}", founder_email:,
20
+ previous_founder_email:)
21
+ build_organization(data)
22
+ end
23
+
24
+ private
25
+
26
+ def build_organization(data)
27
+ Fintoc::V1::Organization.new(**data)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -2,7 +2,8 @@ module Fintoc
2
2
  module V1
3
3
  class Dispute
4
4
  attr_reader :id, :object, :amount, :created_at, :currency, :documentation_upload_deadline,
5
- :documents, :mode, :resource_id, :resource_type, :status, :updated_at
5
+ :documents, :mode, :payment_method_type, :resource_id, :resource_type, :status,
6
+ :updated_at
6
7
 
7
8
  def initialize(
8
9
  id:,
@@ -13,6 +14,7 @@ module Fintoc
13
14
  documentation_upload_deadline: nil,
14
15
  documents: nil,
15
16
  mode: nil,
17
+ payment_method_type: nil,
16
18
  resource_id: nil,
17
19
  resource_type: nil,
18
20
  status: nil,
@@ -27,6 +29,7 @@ module Fintoc
27
29
  @documentation_upload_deadline = documentation_upload_deadline
28
30
  @documents = documents
29
31
  @mode = mode
32
+ @payment_method_type = payment_method_type
30
33
  @resource_id = resource_id
31
34
  @resource_type = resource_type
32
35
  @status = status
@@ -0,0 +1,31 @@
1
+ module Fintoc
2
+ module V1
3
+ class Organization
4
+ attr_reader :id, :object, :external_reference, :interested_products, :metadata, :name,
5
+ :tax_id
6
+
7
+ def initialize(
8
+ id:,
9
+ object:,
10
+ external_reference: nil,
11
+ interested_products: nil,
12
+ metadata: nil,
13
+ name: nil,
14
+ tax_id: nil,
15
+ **
16
+ )
17
+ @id = id
18
+ @object = object
19
+ @external_reference = external_reference
20
+ @interested_products = interested_products
21
+ @metadata = metadata
22
+ @name = name
23
+ @tax_id = tax_id
24
+ end
25
+
26
+ def to_s
27
+ "Organization (#{@id}) - #{@name}"
28
+ end
29
+ end
30
+ end
31
+ end
@@ -2,7 +2,8 @@ module Fintoc
2
2
  module V1
3
3
  class PaymentLink
4
4
  attr_reader :id, :object, :amount, :checkout, :created_at, :currency, :customer_email,
5
- :expires_at, :metadata, :mode, :recipient_account, :status, :url
5
+ :expires_at, :max_completed_sessions, :metadata, :mode, :recipient_account,
6
+ :status, :url
6
7
 
7
8
  def initialize(
8
9
  id:,
@@ -13,6 +14,7 @@ module Fintoc
13
14
  currency: nil,
14
15
  customer_email: nil,
15
16
  expires_at: nil,
17
+ max_completed_sessions: nil,
16
18
  metadata: nil,
17
19
  mode: nil,
18
20
  recipient_account: nil,
@@ -28,6 +30,7 @@ module Fintoc
28
30
  @currency = currency
29
31
  @customer_email = customer_email
30
32
  @expires_at = expires_at
33
+ @max_completed_sessions = max_completed_sessions
31
34
  @metadata = metadata
32
35
  @mode = mode
33
36
  @recipient_account = recipient_account
@@ -5,8 +5,8 @@ module Fintoc
5
5
  class Invoice
6
6
  attr_reader :id, :object, :attempt_count, :collection_method, :created_at, :currency,
7
7
  :customer, :default_payment_method, :external_payment, :hosted_invoice_url,
8
- :lines, :metadata, :mode, :next_payment_attempt_at, :payments, :status,
9
- :subscription, :total
8
+ :lines, :metadata, :mode, :next_payment_attempt_at, :payments, :reason,
9
+ :split, :split_applied, :status, :subscription, :total
10
10
 
11
11
  def initialize( # rubocop:disable Metrics/MethodLength
12
12
  id:,
@@ -24,6 +24,9 @@ module Fintoc
24
24
  mode: nil,
25
25
  next_payment_attempt_at: nil,
26
26
  payments: nil,
27
+ reason: nil,
28
+ split: nil,
29
+ split_applied: nil,
27
30
  status: nil,
28
31
  subscription: nil,
29
32
  total: nil,
@@ -45,6 +48,9 @@ module Fintoc
45
48
  @mode = mode
46
49
  @next_payment_attempt_at = next_payment_attempt_at
47
50
  @payments = payments
51
+ @reason = reason
52
+ @split = split
53
+ @split_applied = split_applied
48
54
  @status = status
49
55
  @subscription = subscription
50
56
  @total = total
@@ -4,9 +4,10 @@ module Fintoc
4
4
  module V2
5
5
  class Subscription
6
6
  attr_reader :id, :object, :billing_cycle_anchor, :cancel_at, :collection_method, :created_at,
7
- :customer, :items, :metadata, :mode, :payment_method, :status, :trial_end
7
+ :customer, :items, :metadata, :mode, :payment_method, :reason, :split, :status,
8
+ :trial_end
8
9
 
9
- def initialize(
10
+ def initialize( # rubocop:disable Metrics/MethodLength
10
11
  id:,
11
12
  object:,
12
13
  billing_cycle_anchor: nil,
@@ -18,6 +19,8 @@ module Fintoc
18
19
  metadata: nil,
19
20
  mode: nil,
20
21
  payment_method: nil,
22
+ reason: nil,
23
+ split: nil,
21
24
  status: nil,
22
25
  trial_end: nil,
23
26
  client: nil,
@@ -34,6 +37,8 @@ module Fintoc
34
37
  @metadata = metadata
35
38
  @mode = mode
36
39
  @payment_method = payment_method
40
+ @reason = reason
41
+ @split = split
37
42
  @status = status
38
43
  @trial_end = trial_end
39
44
  @client = client
@@ -1,3 +1,3 @@
1
1
  module Fintoc
2
- VERSION = '1.8.0'
2
+ VERSION = '1.10.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fintoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Ca Sardin
@@ -59,6 +59,8 @@ extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
61
  - ".github/pull_request_template.md"
62
+ - ".github/scripts/resolve-release.sh"
63
+ - ".github/scripts/resolve-release.test.sh"
62
64
  - ".github/workflows/ci.yml"
63
65
  - ".github/workflows/release.yml"
64
66
  - ".gitignore"
@@ -91,6 +93,7 @@ files:
91
93
  - lib/fintoc/v1/managers/link_intents_manager.rb
92
94
  - lib/fintoc/v1/managers/links_manager.rb
93
95
  - lib/fintoc/v1/managers/movements_manager.rb
96
+ - lib/fintoc/v1/managers/organizations_manager.rb
94
97
  - lib/fintoc/v1/managers/payment_intents_manager.rb
95
98
  - lib/fintoc/v1/managers/payment_links_manager.rb
96
99
  - lib/fintoc/v1/managers/payouts_manager.rb
@@ -111,6 +114,7 @@ files:
111
114
  - lib/fintoc/v1/resources/link.rb
112
115
  - lib/fintoc/v1/resources/link_intent.rb
113
116
  - lib/fintoc/v1/resources/movement.rb
117
+ - lib/fintoc/v1/resources/organization.rb
114
118
  - lib/fintoc/v1/resources/payment_intent.rb
115
119
  - lib/fintoc/v1/resources/payment_link.rb
116
120
  - lib/fintoc/v1/resources/payout.rb