unit-ruby 0.2.3 → 0.2.5
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/Gemfile.lock +6 -8
- data/Rakefile +3 -3
- data/lib/unit-ruby/customer_token.rb +18 -0
- data/lib/unit-ruby/customer_token_verification.rb +14 -0
- data/lib/unit-ruby/deposit_account.rb +12 -0
- data/lib/unit-ruby/util/api_resource.rb +28 -1
- data/lib/unit-ruby/util/resource_operations.rb +3 -2
- data/lib/unit-ruby/version.rb +1 -1
- data/lib/unit-ruby.rb +2 -0
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36a4adc5ac66ecac5eeb0b01a57d131f26ce1457e1aefd766e9c75cc0b11599b
|
4
|
+
data.tar.gz: 3c37bdf8d9eb16acb01389838ce8798d7d50b9b4c6d815474ccff1e4f5c37c8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ce9efd4376713ad8815f69df865baf3137889cc82de088be5fd8951aab2d08613d4a7d3f39106c8f78fe431e6a173144eb413b0bf23f211abd229c9e7af3770
|
7
|
+
data.tar.gz: 278d00d967a57090d42038781e8f0bc63437398a33bb1d620301c60d13a81e0583f76e22fc76d7362b0618ac3d1be9efee414848a4014a207abbb6b61560fee2
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
unit-ruby (0.2.
|
4
|
+
unit-ruby (0.2.5)
|
5
5
|
activesupport
|
6
6
|
faraday (~> 1.8.0)
|
7
7
|
faraday_middleware (~> 1.0.0)
|
@@ -9,12 +9,11 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activesupport (
|
12
|
+
activesupport (7.0.4.1)
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
14
|
i18n (>= 1.6, < 2)
|
15
15
|
minitest (>= 5.1)
|
16
16
|
tzinfo (~> 2.0)
|
17
|
-
zeitwerk (~> 2.3)
|
18
17
|
ast (2.4.2)
|
19
18
|
coderay (1.1.3)
|
20
19
|
concurrent-ruby (1.1.10)
|
@@ -41,11 +40,11 @@ GEM
|
|
41
40
|
faraday-rack (1.0.0)
|
42
41
|
faraday_middleware (1.0.0)
|
43
42
|
faraday (~> 1.0)
|
44
|
-
i18n (1.
|
43
|
+
i18n (1.12.0)
|
45
44
|
concurrent-ruby (~> 1.0)
|
46
45
|
method_source (1.0.0)
|
47
|
-
minitest (5.
|
48
|
-
multipart-post (2.
|
46
|
+
minitest (5.17.0)
|
47
|
+
multipart-post (2.2.3)
|
49
48
|
parallel (1.21.0)
|
50
49
|
parser (3.1.0.0)
|
51
50
|
ast (~> 2.4.1)
|
@@ -82,10 +81,9 @@ GEM
|
|
82
81
|
parser (>= 3.0.1.1)
|
83
82
|
ruby-progressbar (1.11.0)
|
84
83
|
ruby2_keywords (0.0.5)
|
85
|
-
tzinfo (2.0.
|
84
|
+
tzinfo (2.0.5)
|
86
85
|
concurrent-ruby (~> 1.0)
|
87
86
|
unicode-display_width (2.1.0)
|
88
|
-
zeitwerk (2.5.4)
|
89
87
|
|
90
88
|
PLATFORMS
|
91
89
|
ruby
|
data/Rakefile
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Unit
|
2
|
+
class CustomerToken < APIResource
|
3
|
+
path '/customers'
|
4
|
+
|
5
|
+
attribute :scope, Types::String
|
6
|
+
attribute :verification_token, Types::String
|
7
|
+
attribute :verification_code, Types::String
|
8
|
+
attribute :expires_in, Types::Integer
|
9
|
+
|
10
|
+
attribute :token, Types::String, readonly: true
|
11
|
+
|
12
|
+
def self.resources_path(id)
|
13
|
+
"#{super(id)}/token"
|
14
|
+
end
|
15
|
+
|
16
|
+
include ResourceOperations::Create
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Unit
|
2
|
+
class CustomerTokenVerification < APIResource
|
3
|
+
path '/customers'
|
4
|
+
|
5
|
+
attribute :channel, Types::String
|
6
|
+
attribute :verification_token, Types::String, readonly: true
|
7
|
+
|
8
|
+
def self.resources_path(id)
|
9
|
+
"#{super(id)}/token/verification"
|
10
|
+
end
|
11
|
+
|
12
|
+
include ResourceOperations::Create
|
13
|
+
end
|
14
|
+
end
|
@@ -19,6 +19,18 @@ module Unit
|
|
19
19
|
attribute :close_reason, Types::String, readonly: true # Optional. The reason the account was closed, either ByCustomer or Fraud.
|
20
20
|
|
21
21
|
belongs_to :customer, class_name: 'Unit::IndividualCustomer'
|
22
|
+
has_many :customers, class_name: 'Unit::IndividualCustomer'
|
23
|
+
|
24
|
+
def add_customer(customer_id)
|
25
|
+
self.class.connection.post(
|
26
|
+
"accounts/#{id}/relationships/customers",
|
27
|
+
{
|
28
|
+
data: [{ type: 'customer', id: customer_id }]
|
29
|
+
}
|
30
|
+
)
|
31
|
+
|
32
|
+
self.class.find(id)
|
33
|
+
end
|
22
34
|
|
23
35
|
include ResourceOperations::List
|
24
36
|
include ResourceOperations::Create
|
@@ -70,7 +70,9 @@ module Unit
|
|
70
70
|
"#{path}/#{id}"
|
71
71
|
end
|
72
72
|
|
73
|
-
def self.resources_path
|
73
|
+
def self.resources_path(id = nil)
|
74
|
+
return "#{path}/#{id}" if id
|
75
|
+
|
74
76
|
path
|
75
77
|
end
|
76
78
|
|
@@ -99,6 +101,31 @@ module Unit
|
|
99
101
|
end
|
100
102
|
end
|
101
103
|
|
104
|
+
def self.has_many(resource_name, class_name: nil)
|
105
|
+
class_name ||= resource_name.to_s.camelize
|
106
|
+
|
107
|
+
define_method(resource_name) do
|
108
|
+
# if there is only one of the resources, Unit will return the
|
109
|
+
# singular name of that relationship in their response.
|
110
|
+
# For example, if a deposit account has one customer, `customer`
|
111
|
+
# will be returned from Unit as a resource, whereas if there
|
112
|
+
# are more than one customer, then customers will be returned from Unit
|
113
|
+
|
114
|
+
# the below will translate these singular relationship
|
115
|
+
# into a plural relationship - ie `customer` -> `customers`
|
116
|
+
|
117
|
+
singular_resource_name = resource_name.to_s.singularize.to_sym
|
118
|
+
|
119
|
+
if relationships.keys.include?(resource_name)
|
120
|
+
relationships.dig(resource_name.to_sym, :data).map do |resource|
|
121
|
+
Kernel.const_get(class_name).find(resource[:id])
|
122
|
+
end
|
123
|
+
elsif defined?(singular_resource_name)
|
124
|
+
[send(singular_resource_name)].compact
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
102
129
|
# Hyrdates an instance of the resource from data returned from the API
|
103
130
|
def self.build_resource_from_json_api(data_item)
|
104
131
|
new.tap do |resource|
|
@@ -21,7 +21,8 @@ module Unit
|
|
21
21
|
|
22
22
|
module ClassMethods
|
23
23
|
def create(attributes)
|
24
|
-
|
24
|
+
id = attributes.fetch(:id, nil)
|
25
|
+
resource = new(attributes.except(:id))
|
25
26
|
|
26
27
|
data = {
|
27
28
|
type: resource.resource_type,
|
@@ -32,7 +33,7 @@ module Unit
|
|
32
33
|
resource.relationships
|
33
34
|
end
|
34
35
|
|
35
|
-
created_resource = connection.post(resources_path, { data: data })
|
36
|
+
created_resource = connection.post(resources_path(id), { data: data })
|
36
37
|
|
37
38
|
build_resource_from_json_api(created_resource)
|
38
39
|
end
|
data/lib/unit-ruby/version.rb
CHANGED
data/lib/unit-ruby.rb
CHANGED
@@ -23,6 +23,8 @@ require 'unit-ruby/types/string'
|
|
23
23
|
require 'unit-ruby/ach_payment'
|
24
24
|
require 'unit-ruby/application_form'
|
25
25
|
require 'unit-ruby/atm_location'
|
26
|
+
require 'unit-ruby/customer_token_verification'
|
27
|
+
require 'unit-ruby/customer_token'
|
26
28
|
require 'unit-ruby/deposit_account'
|
27
29
|
require 'unit-ruby/individual_application'
|
28
30
|
require 'unit-ruby/individual_customer'
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unit-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chloe Isacke
|
8
8
|
- Ian Yamey
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-01-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -137,7 +137,7 @@ dependencies:
|
|
137
137
|
- - "~>"
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: 1.24.1
|
140
|
-
description:
|
140
|
+
description:
|
141
141
|
email:
|
142
142
|
- chloe@retirable.com
|
143
143
|
- ian@retirable.com
|
@@ -163,6 +163,8 @@ files:
|
|
163
163
|
- lib/unit-ruby/ach_payment.rb
|
164
164
|
- lib/unit-ruby/application_form.rb
|
165
165
|
- lib/unit-ruby/atm_location.rb
|
166
|
+
- lib/unit-ruby/customer_token.rb
|
167
|
+
- lib/unit-ruby/customer_token_verification.rb
|
166
168
|
- lib/unit-ruby/deposit_account.rb
|
167
169
|
- lib/unit-ruby/individual_application.rb
|
168
170
|
- lib/unit-ruby/individual_customer.rb
|
@@ -202,7 +204,7 @@ metadata:
|
|
202
204
|
source_code_uri: https://github.com/retirable/unit-ruby
|
203
205
|
changelog_uri: https://github.com/retirable/unit-ruby/blob/main/CHANGELOG.md
|
204
206
|
rubygems_mfa_required: 'true'
|
205
|
-
post_install_message:
|
207
|
+
post_install_message:
|
206
208
|
rdoc_options: []
|
207
209
|
require_paths:
|
208
210
|
- lib
|
@@ -217,8 +219,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
219
|
- !ruby/object:Gem::Version
|
218
220
|
version: '0'
|
219
221
|
requirements: []
|
220
|
-
rubygems_version: 3.
|
221
|
-
signing_key:
|
222
|
+
rubygems_version: 3.4.4
|
223
|
+
signing_key:
|
222
224
|
specification_version: 4
|
223
225
|
summary: A Ruby gem for communicating with the Unit API.
|
224
226
|
test_files: []
|