unit-ruby 1.1.0 → 1.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.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +86 -0
- data/CHANGELOG.md +25 -2
- data/README.md +19 -7
- data/lib/unit-ruby/book_payment.rb +25 -0
- data/lib/unit-ruby/util/api_resource.rb +7 -2
- data/lib/unit-ruby/version.rb +1 -1
- data/lib/unit-ruby.rb +1 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 18b867d8d8816b49b9f6fc3c5ad56cf9d8f880ef7cde8d00967ada67c466b382
|
|
4
|
+
data.tar.gz: 834f229a02e5d24662e4ac0ed9726d1c0bb1122bb29ec567ed63989bbcdf9be4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6c2dbbbd2b14d234b4452dfc6cbe1a425cb7709cf7577e3e3a7c616315efaab1c914b2471d7e3a1be0dd3e2c86b51c73bae75a0e7e6f949f7de5a6ed29436818
|
|
7
|
+
data.tar.gz: eeb6aff99dfd1c0cc9d3660714987a71ee7f269573f3a227bd532aa034eeb42e263ccce608bebc54e2f1f1dc9bef45ca312c56eb8140e1697bbdd8adbae5acfe
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Publishes the gem to RubyGems.org via OIDC trusted publishing whenever
|
|
2
|
+
# lib/unit-ruby/version.rb changes on main. No long-lived API key is stored:
|
|
3
|
+
# configure-rubygems-credentials exchanges a short-lived GitHub OIDC token for
|
|
4
|
+
# RubyGems credentials by assuming the OIDC API key role configured on
|
|
5
|
+
# rubygems.org. `bundle exec rake release` then builds the gem, creates and
|
|
6
|
+
# pushes the vX.Y.Z tag, and publishes to RubyGems.org.
|
|
7
|
+
name: Release
|
|
8
|
+
|
|
9
|
+
on:
|
|
10
|
+
push:
|
|
11
|
+
branches: [main]
|
|
12
|
+
paths:
|
|
13
|
+
- lib/unit-ruby/version.rb
|
|
14
|
+
|
|
15
|
+
# Never run two releases at once.
|
|
16
|
+
concurrency:
|
|
17
|
+
group: release
|
|
18
|
+
cancel-in-progress: false
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
push:
|
|
22
|
+
name: Push gem to RubyGems.org
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
permissions:
|
|
25
|
+
contents: write # push the version tag
|
|
26
|
+
id-token: write # mint the OIDC token for trusted publishing
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
|
29
|
+
with:
|
|
30
|
+
fetch-depth: 0
|
|
31
|
+
fetch-tags: true
|
|
32
|
+
persist-credentials: false
|
|
33
|
+
- name: Set up Ruby
|
|
34
|
+
uses: ruby/setup-ruby@12fd324f1d0b43274fdc8130f6980590a667c455 # v1.312.0
|
|
35
|
+
with:
|
|
36
|
+
ruby-version: "3.4"
|
|
37
|
+
bundler-cache: true
|
|
38
|
+
- name: Read and validate gem version
|
|
39
|
+
id: version
|
|
40
|
+
run: |
|
|
41
|
+
version="$(ruby -e 'require "./lib/unit-ruby/version"; print Unit::VERSION')"
|
|
42
|
+
# Enforce semver before the value is used anywhere else, so a crafted
|
|
43
|
+
# version string can't smuggle shell metacharacters into later steps.
|
|
44
|
+
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
|
|
45
|
+
echo "Invalid version format: $version" >&2
|
|
46
|
+
exit 1
|
|
47
|
+
fi
|
|
48
|
+
echo "version=$version" >> "$GITHUB_OUTPUT"
|
|
49
|
+
- name: Check whether this version is already tagged
|
|
50
|
+
id: tag
|
|
51
|
+
env:
|
|
52
|
+
VERSION: ${{ steps.version.outputs.version }}
|
|
53
|
+
run: |
|
|
54
|
+
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
|
|
55
|
+
echo "Version v$VERSION already released; skipping."
|
|
56
|
+
echo "exists=true" >> "$GITHUB_OUTPUT"
|
|
57
|
+
else
|
|
58
|
+
echo "exists=false" >> "$GITHUB_OUTPUT"
|
|
59
|
+
fi
|
|
60
|
+
- name: Configure RubyGems credentials
|
|
61
|
+
if: steps.tag.outputs.exists == 'false'
|
|
62
|
+
uses: rubygems/configure-rubygems-credentials@762a4b77c3300434bb57c7ce80b20e36231927aa # v2.0.0
|
|
63
|
+
with:
|
|
64
|
+
role-to-assume: rg_oidc_akr_54hgswsa4knajxk89skj
|
|
65
|
+
- name: Set git identity and push URL
|
|
66
|
+
if: steps.tag.outputs.exists == 'false'
|
|
67
|
+
run: |
|
|
68
|
+
# Attribute the release tag to the last committer on HEAD.
|
|
69
|
+
git config --global user.email "$(git log -1 --pretty=format:'%ae')"
|
|
70
|
+
git config --global user.name "$(git log -1 --pretty=format:'%an')"
|
|
71
|
+
# Restore push credentials (checkout ran with persist-credentials: false)
|
|
72
|
+
# so `rake release` can push the tag.
|
|
73
|
+
git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY"
|
|
74
|
+
- name: Release
|
|
75
|
+
if: steps.tag.outputs.exists == 'false'
|
|
76
|
+
run: bundle exec rake release
|
|
77
|
+
- name: Wait for release to propagate
|
|
78
|
+
if: steps.tag.outputs.exists == 'false'
|
|
79
|
+
run: |
|
|
80
|
+
gem install rubygems-await
|
|
81
|
+
gem_tuple="$(ruby -rbundler/setup -rbundler -e '
|
|
82
|
+
spec = Bundler.definition.specs.find {|s| s.name == ARGV[0] }
|
|
83
|
+
raise "No spec for #{ARGV[0]}" unless spec
|
|
84
|
+
print [spec.name, spec.version, spec.platform].join(":")
|
|
85
|
+
' "unit-ruby")"
|
|
86
|
+
gem await "${gem_tuple}"
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 1.2.0
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- Add `Unit::BookPayment` for booking transfers between Unit accounts.
|
|
6
|
+
- Allow `belongs_to` relationships to specify the JSON:API `type` sent to Unit.
|
|
7
|
+
|
|
8
|
+
## 1.1.1
|
|
9
|
+
|
|
10
|
+
- Publish releases automatically to RubyGems.org via OIDC trusted publishing when `version.rb` changes on `main`.
|
|
11
|
+
|
|
12
|
+
## 1.1.0
|
|
13
|
+
|
|
14
|
+
- Support Rails 8 / Active Support 8 (widen the `activesupport` dependency to `>= 7.0, < 9`).
|
|
15
|
+
- Stop committing `Gemfile.lock` so applications resolve dependencies against the gemspec
|
|
16
|
+
|
|
17
|
+
## 1.0.1
|
|
18
|
+
|
|
19
|
+
- Resolve dependency vulnerabilities by bumping vulnerable transitive dependencies.
|
|
20
|
+
|
|
21
|
+
## 1.0.0
|
|
22
|
+
|
|
23
|
+
- First stable release, promoting the 0.12.x API to 1.0 with no breaking changes.
|
|
24
|
+
- Expanded README documentation and cleaned up the gemspec and CI configuration.
|
|
25
|
+
|
|
26
|
+
## 0.1.0
|
|
27
|
+
|
|
28
|
+
Initial release
|
data/README.md
CHANGED
|
@@ -95,6 +95,20 @@ debit_card = Unit::IndividualDebitCard.create(
|
|
|
95
95
|
shipping_address: customer.address,
|
|
96
96
|
tags: { externalUserId: my_user_id }
|
|
97
97
|
)
|
|
98
|
+
|
|
99
|
+
# Book a transfer between two Unit accounts
|
|
100
|
+
other_account = Unit::DepositAccount.create(
|
|
101
|
+
deposit_product: 'checking',
|
|
102
|
+
customer: customer
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
book_payment = Unit::BookPayment.create(
|
|
106
|
+
amount: 10_000, # in cents
|
|
107
|
+
description: 'Transfer between accounts',
|
|
108
|
+
idempotency_key: "book-payment-for-#{my_user_id}",
|
|
109
|
+
account: deposit_account,
|
|
110
|
+
counterparty_account: other_account
|
|
111
|
+
)
|
|
98
112
|
```
|
|
99
113
|
|
|
100
114
|
> [!TIP]
|
|
@@ -129,15 +143,13 @@ $ bundle exec rake install
|
|
|
129
143
|
|
|
130
144
|
## Releasing
|
|
131
145
|
|
|
132
|
-
|
|
146
|
+
Releases are minted automatically. When a change to `lib/unit-ruby/version.rb` lands on `main`, the [Release workflow](.github/workflows/release.yml) builds the gem, tags the commit `vX.Y.Z`, and publishes to [RubyGems.org](https://rubygems.org/gems/unit-ruby/). No manual `gem push` is required, and no RubyGems API key is stored — the workflow authenticates via [OIDC trusted publishing](https://guides.rubygems.org/trusted-publishing/).
|
|
133
147
|
|
|
134
|
-
|
|
148
|
+
To cut a release:
|
|
135
149
|
|
|
136
|
-
1.
|
|
137
|
-
2.
|
|
138
|
-
3.
|
|
139
|
-
4. Push this latest version of the gem to RubyGems.org by calling `gem push unit-ruby-[gem version number].gem`
|
|
140
|
-
5. Merge PR into `main` branch
|
|
150
|
+
1. Make your changes, then bump the version in `lib/unit-ruby/version.rb` following [semantic versioning](https://semver.org/) and add an entry to `CHANGELOG.md`.
|
|
151
|
+
2. Open a PR and get it approved by the appropriate member(s) of the engineering team.
|
|
152
|
+
3. Merge to `main`. The Release workflow publishes the new version automatically. If the version is unchanged, no release is cut.
|
|
141
153
|
|
|
142
154
|
## Contributing
|
|
143
155
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Unit
|
|
2
|
+
# A transfer of funds between two Unit accounts
|
|
3
|
+
class BookPayment < APIResource
|
|
4
|
+
path '/payments'
|
|
5
|
+
|
|
6
|
+
attribute :amount, Types::Integer # Amount to transfer in cents.
|
|
7
|
+
attribute :description, Types::String # Description of the payment. Max of 50 characters.
|
|
8
|
+
attribute :transaction_summary_override, Types::String # Optional. Overrides the transaction summary. Max of 100 characters.
|
|
9
|
+
attribute :idempotency_key, Types::String # Optional
|
|
10
|
+
attribute :tags, Types::Hash # Optional
|
|
11
|
+
|
|
12
|
+
attribute :direction, Types::String, readonly: true
|
|
13
|
+
attribute :summary, Types::String, readonly: true
|
|
14
|
+
attribute :status, Types::String, readonly: true
|
|
15
|
+
attribute :reason, Types::String, readonly: true
|
|
16
|
+
attribute :created_at, Types::DateTime, readonly: true
|
|
17
|
+
|
|
18
|
+
belongs_to :account, class_name: 'Unit::DepositAccount'
|
|
19
|
+
belongs_to :counterparty_account, class_name: 'Unit::DepositAccount', type: :depositAccount
|
|
20
|
+
belongs_to :customer, class_name: 'Unit::IndividualCustomer'
|
|
21
|
+
belongs_to :counterparty_customer, class_name: 'Unit::IndividualCustomer'
|
|
22
|
+
|
|
23
|
+
include ResourceOperations::Create
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -98,8 +98,13 @@ module Unit
|
|
|
98
98
|
|
|
99
99
|
# Creates an association to a related resource
|
|
100
100
|
# This will create a helper method to traverse into a resource's related resource(s)
|
|
101
|
-
|
|
101
|
+
#
|
|
102
|
+
# @param resource_name [Symbol] the name of the relationship
|
|
103
|
+
# @param class_name [String] the class of the related resource
|
|
104
|
+
# @param type [Symbol] the JSON:API type sent for the relationship, when it differs from the relationship name
|
|
105
|
+
def self.belongs_to(resource_name, class_name: nil, type: nil)
|
|
102
106
|
class_name ||= resource_name.to_s.camelize
|
|
107
|
+
type ||= resource_name.to_s.camelize(:lower).to_sym
|
|
103
108
|
|
|
104
109
|
define_method(resource_name) do
|
|
105
110
|
relationship_id = relationships.dig(resource_name, :data, :id)
|
|
@@ -111,7 +116,7 @@ module Unit
|
|
|
111
116
|
|
|
112
117
|
define_method("#{resource_name}=") do |resource|
|
|
113
118
|
relationships[resource_name] = {
|
|
114
|
-
data: { type:
|
|
119
|
+
data: { type: type, id: resource.id }
|
|
115
120
|
}
|
|
116
121
|
end
|
|
117
122
|
end
|
data/lib/unit-ruby/version.rb
CHANGED
data/lib/unit-ruby.rb
CHANGED
|
@@ -29,6 +29,7 @@ require 'unit-ruby/ach_payment'
|
|
|
29
29
|
require 'unit-ruby/application_form'
|
|
30
30
|
require 'unit-ruby/atm_location'
|
|
31
31
|
require 'unit-ruby/authorization'
|
|
32
|
+
require 'unit-ruby/book_payment'
|
|
32
33
|
require 'unit-ruby/ach_counterparty'
|
|
33
34
|
require 'unit-ruby/customer_token_verification'
|
|
34
35
|
require 'unit-ruby/customer_token'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: unit-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chloe Isacke
|
|
@@ -153,6 +153,7 @@ extra_rdoc_files: []
|
|
|
153
153
|
files:
|
|
154
154
|
- ".env.example"
|
|
155
155
|
- ".github/workflows/ci.yml"
|
|
156
|
+
- ".github/workflows/release.yml"
|
|
156
157
|
- ".gitignore"
|
|
157
158
|
- ".rspec"
|
|
158
159
|
- ".rubocop.yml"
|
|
@@ -171,6 +172,7 @@ files:
|
|
|
171
172
|
- lib/unit-ruby/application_form.rb
|
|
172
173
|
- lib/unit-ruby/atm_location.rb
|
|
173
174
|
- lib/unit-ruby/authorization.rb
|
|
175
|
+
- lib/unit-ruby/book_payment.rb
|
|
174
176
|
- lib/unit-ruby/customer_bank_migration.rb
|
|
175
177
|
- lib/unit-ruby/customer_token.rb
|
|
176
178
|
- lib/unit-ruby/customer_token_verification.rb
|