unit-ruby 0.9.0 → 0.10.1
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/ruby.yml +2 -0
- data/Gemfile.lock +4 -1
- data/README.md +1 -1
- data/lib/unit-ruby/tax_form.rb +21 -0
- data/lib/unit-ruby/util/connection.rb +12 -4
- data/lib/unit-ruby/util/resource_operations.rb +20 -0
- data/lib/unit-ruby/version.rb +1 -1
- data/lib/unit-ruby/white_label_language.rb +9 -0
- data/lib/unit-ruby/white_label_theme.rb +5 -0
- data/lib/unit-ruby.rb +2 -0
- data/unit-ruby.gemspec +1 -0
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4771e47bafd526a9a832e0552b1cc67a2e49720a44d87c727e0d2de4b764f1bf
|
4
|
+
data.tar.gz: d96d783374e42fb21168afd0bf86f809f8fc309de3f6e7a0a0cf7fe4f320ef05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e531d141c243bcaf32b651523092c3f543ac7a610026210ac6e165a9018de635bf3408f57dc487a9f66c8044f9659dbb98fe891705820efa413376db9e3242c
|
7
|
+
data.tar.gz: 1bbaa140de53f9350b48ac53c725b591054abac4427ef1ba6e16eff04b0000bca8357469dc1d91b30bc40e7a0ac7534bc5d46bbcb215360c91615c6668fe52a4
|
data/.github/workflows/ruby.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
unit-ruby (0.
|
4
|
+
unit-ruby (0.10.1)
|
5
5
|
activesupport
|
6
6
|
faraday (>= 2.0.1, < 3)
|
7
7
|
faraday-retry
|
@@ -56,6 +56,8 @@ GEM
|
|
56
56
|
rspec-expectations (3.13.3)
|
57
57
|
diff-lcs (>= 1.2.0, < 2.0)
|
58
58
|
rspec-support (~> 3.13.0)
|
59
|
+
rspec-file_fixtures (0.1.9)
|
60
|
+
rspec (~> 3.12)
|
59
61
|
rspec-mocks (3.13.2)
|
60
62
|
diff-lcs (>= 1.2.0, < 2.0)
|
61
63
|
rspec-support (~> 3.13.0)
|
@@ -85,6 +87,7 @@ DEPENDENCIES
|
|
85
87
|
pry
|
86
88
|
rake (~> 13.0)
|
87
89
|
rspec (~> 3.0)
|
90
|
+
rspec-file_fixtures (~> 0.1.9)
|
88
91
|
rubocop (~> 1.24.1)
|
89
92
|
unit-ruby!
|
90
93
|
|
data/README.md
CHANGED
@@ -35,7 +35,7 @@ end
|
|
35
35
|
|
36
36
|
## Development
|
37
37
|
|
38
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
38
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You will also need UNIT_THEME_ID and UNIT_LANGUAGE_ID set in your environment. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
39
39
|
|
40
40
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
41
41
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Unit
|
2
|
+
class TaxForm < APIResource
|
3
|
+
path '/tax-forms'
|
4
|
+
|
5
|
+
attribute :tax_year, Types::String, readonly: true
|
6
|
+
attribute :form_type, Types::String, readonly: true
|
7
|
+
|
8
|
+
belongs_to :customer, class_name: 'Unit::IndividualCustomer'
|
9
|
+
has_many :accounts, class_name: 'Unit::DepositAccount'
|
10
|
+
|
11
|
+
def pdf
|
12
|
+
self.class.connection.get(
|
13
|
+
"tax-forms/#{id}/pdf",
|
14
|
+
raw: true
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
include ResourceOperations::List
|
19
|
+
include ResourceOperations::Find
|
20
|
+
end
|
21
|
+
end
|
@@ -14,6 +14,7 @@ module Unit
|
|
14
14
|
@connection = Faraday.new(self.class.base_url) do |f|
|
15
15
|
f.headers['UNIT_TRUST_TOKEN'] = self.class.trust_token if self.class.trust_token
|
16
16
|
f.headers['Authorization'] = "Bearer #{self.class.api_key}"
|
17
|
+
f.headers['Content-Type'] = 'application/vnd.api+json'
|
17
18
|
f.request :json # encode req bodies as JSON
|
18
19
|
f.request :retry # retry transient failures
|
19
20
|
f.response :json # decode response bodies as JSON
|
@@ -23,12 +24,12 @@ module Unit
|
|
23
24
|
# Executes a GET request to the API
|
24
25
|
#
|
25
26
|
# @return the resource (or array of resources) returned from the API
|
26
|
-
def get(path, params = nil)
|
27
|
+
def get(path, params = nil, raw: false)
|
27
28
|
response = connection.get(path, params)
|
28
29
|
|
29
30
|
handle_errors(response)
|
30
31
|
|
31
|
-
from_json_api(response.body)
|
32
|
+
raw ? response.body : from_json_api(response.body)
|
32
33
|
end
|
33
34
|
|
34
35
|
# Executes a POST request to the API
|
@@ -37,7 +38,6 @@ module Unit
|
|
37
38
|
def post(path, data = nil)
|
38
39
|
response = connection.post do |req|
|
39
40
|
req.url path
|
40
|
-
req.headers['Content-Type'] = 'application/vnd.api+json'
|
41
41
|
req.body = data.deep_transform_keys! { |key| key.to_s.camelize(:lower) } if data
|
42
42
|
end
|
43
43
|
|
@@ -50,7 +50,6 @@ module Unit
|
|
50
50
|
def patch(path, data = nil)
|
51
51
|
response = connection.patch do |req|
|
52
52
|
req.url path
|
53
|
-
req.headers['Content-Type'] = 'application/vnd.api+json'
|
54
53
|
req.body = data.deep_transform_keys! { |key| key.to_s.camelize(:lower) } if data
|
55
54
|
end
|
56
55
|
|
@@ -59,6 +58,15 @@ module Unit
|
|
59
58
|
from_json_api(response.body)
|
60
59
|
end
|
61
60
|
|
61
|
+
# Executes a PUT of a JSON object
|
62
|
+
def put(path, data = nil)
|
63
|
+
response = connection.put(path, data)
|
64
|
+
|
65
|
+
handle_errors(response)
|
66
|
+
|
67
|
+
from_json_api(response.body)
|
68
|
+
end
|
69
|
+
|
62
70
|
def from_json_api(response_body)
|
63
71
|
response_body.deep_transform_keys do |key|
|
64
72
|
key.to_s.underscore.to_sym
|
@@ -77,5 +77,25 @@ module Unit
|
|
77
77
|
update_resource_from_json_api(updated_resource)
|
78
78
|
end
|
79
79
|
end
|
80
|
+
|
81
|
+
# Replace the entire resource, instead of only patching dirty attributes
|
82
|
+
module Replace
|
83
|
+
def replace(attributes)
|
84
|
+
updated_resource = self.class.connection.put(
|
85
|
+
self.class.resource_path(id),
|
86
|
+
{
|
87
|
+
data: {
|
88
|
+
type: resource_type,
|
89
|
+
attributes: attributes
|
90
|
+
}
|
91
|
+
}
|
92
|
+
)
|
93
|
+
update_resource_from_json_api(updated_resource)
|
94
|
+
end
|
95
|
+
|
96
|
+
def replace_json(json_attributes)
|
97
|
+
replace(JSON.parse(json_attributes))
|
98
|
+
end
|
99
|
+
end
|
80
100
|
end
|
81
101
|
end
|
data/lib/unit-ruby/version.rb
CHANGED
data/lib/unit-ruby.rb
CHANGED
@@ -42,8 +42,10 @@ require 'unit-ruby/received_payment'
|
|
42
42
|
require 'unit-ruby/pin_status'
|
43
43
|
require 'unit-ruby/statement'
|
44
44
|
require 'unit-ruby/transaction'
|
45
|
+
require 'unit-ruby/tax_form'
|
45
46
|
require 'unit-ruby/version'
|
46
47
|
require 'unit-ruby/white_label_theme'
|
48
|
+
require 'unit-ruby/white_label_language'
|
47
49
|
|
48
50
|
module Unit
|
49
51
|
# Usage:
|
data/unit-ruby.gemspec
CHANGED
@@ -42,6 +42,7 @@ Gem::Specification.new do |spec|
|
|
42
42
|
spec.add_development_dependency 'pry'
|
43
43
|
spec.add_development_dependency 'rake', '~> 13.0'
|
44
44
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
45
|
+
spec.add_development_dependency 'rspec-file_fixtures', '~> 0.1.9'
|
45
46
|
spec.add_development_dependency 'rubocop', '~> 1.24.1'
|
46
47
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
47
48
|
end
|
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: 0.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chloe Isacke
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2025-02-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -115,6 +115,20 @@ dependencies:
|
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '3.0'
|
118
|
+
- !ruby/object:Gem::Dependency
|
119
|
+
name: rspec-file_fixtures
|
120
|
+
requirement: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.1.9
|
125
|
+
type: :development
|
126
|
+
prerelease: false
|
127
|
+
version_requirements: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.1.9
|
118
132
|
- !ruby/object:Gem::Dependency
|
119
133
|
name: rubocop
|
120
134
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,6 +184,7 @@ files:
|
|
170
184
|
- lib/unit-ruby/pin_status.rb
|
171
185
|
- lib/unit-ruby/received_payment.rb
|
172
186
|
- lib/unit-ruby/statement.rb
|
187
|
+
- lib/unit-ruby/tax_form.rb
|
173
188
|
- lib/unit-ruby/transaction.rb
|
174
189
|
- lib/unit-ruby/types/account_limits.rb
|
175
190
|
- lib/unit-ruby/types/ach_limits.rb
|
@@ -196,6 +211,7 @@ files:
|
|
196
211
|
- lib/unit-ruby/util/resource_operations.rb
|
197
212
|
- lib/unit-ruby/util/schema.rb
|
198
213
|
- lib/unit-ruby/version.rb
|
214
|
+
- lib/unit-ruby/white_label_language.rb
|
199
215
|
- lib/unit-ruby/white_label_theme.rb
|
200
216
|
- unit-ruby.gemspec
|
201
217
|
homepage: https://github.com/retirable/unit-ruby
|
@@ -222,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
238
|
- !ruby/object:Gem::Version
|
223
239
|
version: '0'
|
224
240
|
requirements: []
|
225
|
-
rubygems_version: 3.
|
241
|
+
rubygems_version: 3.2.3
|
226
242
|
signing_key:
|
227
243
|
specification_version: 4
|
228
244
|
summary: A Ruby gem for communicating with the Unit API.
|