unit-ruby 1.1.1 → 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/CHANGELOG.md +5 -0
- data/README.md +14 -0
- 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 +2 -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
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
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
|
+
|
|
3
8
|
## 1.1.1
|
|
4
9
|
|
|
5
10
|
- Publish releases automatically to RubyGems.org via OIDC trusted publishing when `version.rb` changes on `main`.
|
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]
|
|
@@ -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
|
|
@@ -172,6 +172,7 @@ files:
|
|
|
172
172
|
- lib/unit-ruby/application_form.rb
|
|
173
173
|
- lib/unit-ruby/atm_location.rb
|
|
174
174
|
- lib/unit-ruby/authorization.rb
|
|
175
|
+
- lib/unit-ruby/book_payment.rb
|
|
175
176
|
- lib/unit-ruby/customer_bank_migration.rb
|
|
176
177
|
- lib/unit-ruby/customer_token.rb
|
|
177
178
|
- lib/unit-ruby/customer_token_verification.rb
|