tazworks-api 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e7eb79fefb6c50c423aecdd1ab8fc00cf083525219d9fa3b5550e89a3b07c0c3
4
+ data.tar.gz: 142b6edf03ffa9ecb70076c7b947cd67add521d030da49d600fff3eee2a3c694
5
+ SHA512:
6
+ metadata.gz: 612315964a2bbb3c44f5cc4ac75f594082488f1b28f8906fd07d832b139bcdaa96fde6bce548af0f5cc06dad07b772711c7c4afdd77a86af3a483eefb4875b57
7
+ data.tar.gz: b91feab1e5e90e188abdf3a4fa6b2c82aeac1ba1e9c9a3a4e4ea15bce0c46d98e8479e6a550cfe39dedebc4f0e0ac83dc741d44fb461c42c8b20de344e38f45d
data/.rubocop.yml ADDED
@@ -0,0 +1,228 @@
1
+ require:
2
+ - rubocop-rspec
3
+ - rubocop-rake
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 3.1
7
+ NewCops: enable
8
+
9
+ Naming/VariableName:
10
+ Enabled: false
11
+ Naming/MethodParameterName:
12
+ Enabled: false
13
+ Naming/MethodName:
14
+ Enabled: false
15
+ Metrics/BlockLength:
16
+ Exclude:
17
+ - 'spec/**/*.rb'
18
+ RSpec/InstanceVariable:
19
+ Enabled: false
20
+ RSpec/ExampleLength:
21
+ Enabled: false
22
+ RSpec/BeforeAfterAll:
23
+ Enabled: false
24
+ RSpec/NestedGroups:
25
+ Enabled: false
26
+ RSpec/MultipleExpectations:
27
+ Enabled: false
28
+ RSpec/MessageSpies:
29
+ Enabled: false
30
+
31
+
32
+
33
+
34
+ Gemspec/DeprecatedAttributeAssignment: # new in 1.30
35
+ Enabled: true
36
+ Gemspec/DevelopmentDependencies: # new in 1.44
37
+ Enabled: true
38
+ Gemspec/RequireMFA: # new in 1.23
39
+ Enabled: true
40
+ Layout/LineContinuationLeadingSpace: # new in 1.31
41
+ Enabled: true
42
+ Layout/LineContinuationSpacing: # new in 1.31
43
+ Enabled: true
44
+ Layout/LineEndStringConcatenationIndentation: # new in 1.18
45
+ Enabled: true
46
+ Layout/SpaceBeforeBrackets: # new in 1.7
47
+ Enabled: true
48
+ Lint/AmbiguousAssignment: # new in 1.7
49
+ Enabled: true
50
+ Lint/AmbiguousOperatorPrecedence: # new in 1.21
51
+ Enabled: true
52
+ Lint/AmbiguousRange: # new in 1.19
53
+ Enabled: true
54
+ Lint/ConstantOverwrittenInRescue: # new in 1.31
55
+ Enabled: true
56
+ Lint/DeprecatedConstants: # new in 1.8
57
+ Enabled: true
58
+ Lint/DuplicateBranch: # new in 1.3
59
+ Enabled: true
60
+ Lint/DuplicateMagicComment: # new in 1.37
61
+ Enabled: true
62
+ Lint/DuplicateMatchPattern: # new in 1.50
63
+ Enabled: true
64
+ Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
65
+ Enabled: true
66
+ Lint/EmptyBlock: # new in 1.1
67
+ Enabled: true
68
+ Lint/EmptyClass: # new in 1.3
69
+ Enabled: true
70
+ Lint/EmptyInPattern: # new in 1.16
71
+ Enabled: true
72
+ Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
73
+ Enabled: true
74
+ Lint/LambdaWithoutLiteralBlock: # new in 1.8
75
+ Enabled: true
76
+ Lint/MixedCaseRange: # new in 1.53
77
+ Enabled: true
78
+ Lint/NoReturnInBeginEndBlocks: # new in 1.2
79
+ Enabled: true
80
+ Lint/NonAtomicFileOperation: # new in 1.31
81
+ Enabled: true
82
+ Lint/NumberedParameterAssignment: # new in 1.9
83
+ Enabled: true
84
+ Lint/OrAssignmentToConstant: # new in 1.9
85
+ Enabled: true
86
+ Lint/RedundantDirGlobSort: # new in 1.8
87
+ Enabled: true
88
+ Lint/RedundantRegexpQuantifiers: # new in 1.53
89
+ Enabled: true
90
+ Lint/RefinementImportMethods: # new in 1.27
91
+ Enabled: true
92
+ Lint/RequireRangeParentheses: # new in 1.32
93
+ Enabled: true
94
+ Lint/RequireRelativeSelfPath: # new in 1.22
95
+ Enabled: true
96
+ Lint/SymbolConversion: # new in 1.9
97
+ Enabled: true
98
+ Lint/ToEnumArguments: # new in 1.1
99
+ Enabled: true
100
+ Lint/TripleQuotes: # new in 1.9
101
+ Enabled: true
102
+ Lint/UnexpectedBlockArity: # new in 1.5
103
+ Enabled: true
104
+ Lint/UnmodifiedReduceAccumulator: # new in 1.1
105
+ Enabled: true
106
+ Lint/UselessRescue: # new in 1.43
107
+ Enabled: true
108
+ Lint/UselessRuby2Keywords: # new in 1.23
109
+ Enabled: true
110
+ Metrics/CollectionLiteralLength: # new in 1.47
111
+ Enabled: true
112
+ Naming/BlockForwarding: # new in 1.24
113
+ Enabled: true
114
+ Security/CompoundHash: # new in 1.28
115
+ Enabled: true
116
+ Security/IoMethods: # new in 1.22
117
+ Enabled: true
118
+ Style/ArgumentsForwarding: # new in 1.1
119
+ Enabled: true
120
+ Style/ArrayIntersect: # new in 1.40
121
+ Enabled: true
122
+ Style/CollectionCompact: # new in 1.2
123
+ Enabled: true
124
+ Style/ComparableClamp: # new in 1.44
125
+ Enabled: true
126
+ Style/ConcatArrayLiterals: # new in 1.41
127
+ Enabled: true
128
+ Style/DataInheritance: # new in 1.49
129
+ Enabled: true
130
+ Style/DirEmpty: # new in 1.48
131
+ Enabled: true
132
+ Style/DocumentDynamicEvalDefinition: # new in 1.1
133
+ Enabled: true
134
+ Style/EmptyHeredoc: # new in 1.32
135
+ Enabled: true
136
+ Style/EndlessMethod: # new in 1.8
137
+ Enabled: true
138
+ Style/EnvHome: # new in 1.29
139
+ Enabled: true
140
+ Style/ExactRegexpMatch: # new in 1.51
141
+ Enabled: true
142
+ Style/FetchEnvVar: # new in 1.28
143
+ Enabled: true
144
+ Style/FileEmpty: # new in 1.48
145
+ Enabled: true
146
+ Style/FileRead: # new in 1.24
147
+ Enabled: true
148
+ Style/FileWrite: # new in 1.24
149
+ Enabled: true
150
+ Style/HashConversion: # new in 1.10
151
+ Enabled: true
152
+ Style/HashExcept: # new in 1.7
153
+ Enabled: true
154
+ Style/IfWithBooleanLiteralBranches: # new in 1.9
155
+ Enabled: true
156
+ Style/InPatternThen: # new in 1.16
157
+ Enabled: true
158
+ Style/MagicCommentFormat: # new in 1.35
159
+ Enabled: true
160
+ Style/MapCompactWithConditionalBlock: # new in 1.30
161
+ Enabled: true
162
+ Style/MapToHash: # new in 1.24
163
+ Enabled: true
164
+ Style/MapToSet: # new in 1.42
165
+ Enabled: true
166
+ Style/MinMaxComparison: # new in 1.42
167
+ Enabled: true
168
+ Style/MultilineInPatternThen: # new in 1.16
169
+ Enabled: true
170
+ Style/NegatedIfElseCondition: # new in 1.2
171
+ Enabled: true
172
+ Style/NestedFileDirname: # new in 1.26
173
+ Enabled: true
174
+ Style/NilLambda: # new in 1.3
175
+ Enabled: true
176
+ Style/NumberedParameters: # new in 1.22
177
+ Enabled: true
178
+ Style/NumberedParametersLimit: # new in 1.22
179
+ Enabled: true
180
+ Style/ObjectThen: # new in 1.28
181
+ Enabled: true
182
+ Style/OpenStructUse: # new in 1.23
183
+ Enabled: true
184
+ Style/OperatorMethodCall: # new in 1.37
185
+ Enabled: true
186
+ Style/QuotedSymbols: # new in 1.16
187
+ Enabled: true
188
+ Style/RedundantArgument: # new in 1.4
189
+ Enabled: true
190
+ Style/RedundantArrayConstructor: # new in 1.52
191
+ Enabled: true
192
+ Style/RedundantConstantBase: # new in 1.40
193
+ Enabled: true
194
+ Style/RedundantCurrentDirectoryInPath: # new in 1.53
195
+ Enabled: true
196
+ Style/RedundantDoubleSplatHashBraces: # new in 1.41
197
+ Enabled: true
198
+ Style/RedundantEach: # new in 1.38
199
+ Enabled: true
200
+ Style/RedundantFilterChain: # new in 1.52
201
+ Enabled: true
202
+ Style/RedundantHeredocDelimiterQuotes: # new in 1.45
203
+ Enabled: true
204
+ Style/RedundantInitialize: # new in 1.27
205
+ Enabled: true
206
+ Style/RedundantLineContinuation: # new in 1.49
207
+ Enabled: true
208
+ Style/RedundantRegexpArgument: # new in 1.53
209
+ Enabled: true
210
+ Style/RedundantRegexpConstructor: # new in 1.52
211
+ Enabled: true
212
+ Style/RedundantSelfAssignmentBranch: # new in 1.19
213
+ Enabled: true
214
+ Style/RedundantStringEscape: # new in 1.37
215
+ Enabled: true
216
+ Style/ReturnNilInPredicateMethodDefinition: # new in 1.53
217
+ Enabled: true
218
+ Style/SelectByRegexp: # new in 1.22
219
+ Enabled: true
220
+ Style/SingleLineDoEndBlock: # new in 1.57
221
+ Enabled: true
222
+ Style/StringChars: # new in 1.12
223
+ Enabled: true
224
+ Style/SwapValues: # new in 1.1
225
+ Enabled: true
226
+ Style/YAMLFileRead: # new in 1.53
227
+ Enabled: true
228
+
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-11-18
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at TODO: Write your email address. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in tazworks-api.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
9
+ gem 'rspec', '~> 3.0'
10
+ gem 'rubocop', '~> 1.21'
11
+ gem 'rubocop-rake'
12
+ gem 'rubocop-rspec'
13
+ gem 'simplecov'
14
+ gem 'vcr'
15
+ gem 'webmock'
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Wayhome Services Co
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,108 @@
1
+ # Tazworks::Api
2
+
3
+ Simple API wrapper implementation for Tazworks RESTful JSON Background/Credit Screening API version 2 found [here](https://docs.developer.tazworks.com/).
4
+
5
+ This gem implements a very limited set of endpoints that we needed for our use case. PRs welcome for expanding the number of implemented endpoints!
6
+
7
+ ## Installation
8
+
9
+ Install the gem and add to the application's Gemfile by executing:
10
+
11
+ $ bundle add tazworks-api
12
+
13
+ If bundler is not being used to manage dependencies, install the gem by executing:
14
+
15
+ $ gem install tazworks-api
16
+
17
+ ## Usage
18
+
19
+
20
+ ### Configuration
21
+
22
+ Load the tazworks gem and set the configuration:
23
+
24
+ ```
25
+ require 'tazworks'
26
+
27
+ Tazworks.configure do |c|
28
+ c.api_key = 'your_api_key'
29
+
30
+ # set this to true if you want to use the sandbox host, otherwise, defaults to production
31
+ #c.sandbox = true
32
+ end
33
+ ```
34
+
35
+ ### Calls
36
+
37
+ Tazworks utilize pascalCase. As this is only a lightweight wrapper, all parameters must be passed as pascalCasing instead of ruby idiomatic snake_casing.
38
+
39
+
40
+ General Workflow:
41
+ ```ruby
42
+ # querying client
43
+ @clientGuid = 'MY_CLIENT_GUID'
44
+ client=Tazworks::Client.find(@clientGuid)
45
+ # OR
46
+ client=Tazworks::Client.all.clients.first
47
+
48
+ # view the client attributes
49
+ client.attributes
50
+
51
+ # querying the client products
52
+ client_product = client.client_products.client_products.first
53
+
54
+ # view the client_product attributes
55
+ client_product.attributes
56
+
57
+ # creating a new applicant
58
+ applicant = client.create_applicant( { firstName: 'Bob', lastName: 'Smith', email: 'bob.smith@gmail.com' } )
59
+
60
+ # view the applicant attributes
61
+ applicant.attributes
62
+
63
+ # submitting order
64
+ order = client.submit_order({applicantGuid: applicant.applicantGuid, clientProductGuid: client_product.clientProductGuid, useQuickApp: true})
65
+
66
+ # view the order attributes
67
+ order.attributes
68
+
69
+ # get the quickappApplicantLink
70
+ order.quickappApplicantLink
71
+
72
+ # checking order status
73
+ order.order_status
74
+
75
+ # getting pdf results for order (will only work after order goes to 'complete' status)
76
+ order.results_as_pdf
77
+ ```
78
+
79
+ Until rubydocs are written, the best bet is to look at the source for usage information, especially the specs folder where most of the implemented endpoints have been tested.
80
+
81
+
82
+ ## Development
83
+
84
+ 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.
85
+
86
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
87
+
88
+ To regenerate or record new [vcr](https://benoittgt.github.io/vcr/) cassettes, set the `TAZAPI_KEY` environment variable:
89
+
90
+ ```
91
+ export TAZAPI_KEY=myfancykey
92
+
93
+ bin/rspec
94
+ ```
95
+
96
+
97
+
98
+ ## Contributing
99
+
100
+ Bug reports and pull requests are welcome on GitHub at https://github.com/wayhomeservices/tazworks-api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/wayhomeservices/tazworks-api/blob/master/CODE_OF_CONDUCT.md).
101
+
102
+ ## License
103
+
104
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
105
+
106
+ ## Code of Conduct
107
+
108
+ Everyone interacting in the Tazworks::Api project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/wayhomeservices/tazworks-api/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tazworks
4
+ # Tazworks Applicants Model
5
+ class Applicant < Model
6
+ # https://docs.developer.tazworks.com/#097f5a2a-85f5-4bb7-b208-facc7e66b98f
7
+ def self.get(ids)
8
+ RestClient.get("/v1/clients/#{ids[:clientGuid]}/applicants/#{ids[:applicantGuid]}")
9
+ end
10
+
11
+ # https://docs.developer.tazworks.com/#8f16d1e6-7ec4-497b-bf89-161be35c53b7
12
+ def self.create(clientGuid, params)
13
+ required_params = %w[firstName lastName email]
14
+ required_params.each do |rp|
15
+ raise ArgumentError, "#{rp} is missing in params hash." unless params.key?(rp.to_sym)
16
+ end
17
+
18
+ response = RestClient.post("/v1/clients/#{clientGuid}/applicants", params)
19
+
20
+ applicant = Applicant.initialize_from_response({ clientGuid: }, response)
21
+ applicant.ids[:applicantGuid] = applicant.attributes[:applicantGuid]
22
+ applicant
23
+ end
24
+
25
+ def self.submit_order(params)
26
+ Tazworks::Order.create(clientGuid, params)
27
+ end
28
+
29
+ # https://docs.developer.tazworks.com/#a90fd0b6-2584-4ccd-b22c-f67e8bfa7ffa
30
+ def self.all(clientGuid, params = {})
31
+ raw_response = RestClient.get("/v1/clients/#{clientGuid}/applicants", { params: })
32
+ ApplicantPagedResponse.new(raw_response, { clientGuid: })
33
+ end
34
+
35
+ def applicantGuid
36
+ @ids[:applicantGuid]
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tazworks
4
+ # Handles pagination for Applicant responses such as GET All Applicants
5
+ class ApplicantPagedResponse < PagedResponse
6
+ def self.base_class
7
+ Applicant
8
+ end
9
+
10
+ def applicants
11
+ response_to_models
12
+ end
13
+
14
+ def map_individual_object_ids(ids, attributes)
15
+ ids[:applicantGuid] = attributes[:applicantGuid]
16
+ ids
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tazworks
4
+ # Tazworks Clients Model
5
+ class Client < Model
6
+ # https://docs.developer.tazworks.com/#3a09caba-349b-4969-a55a-1cbcaea0136c
7
+ # TODO: WARNING - UNTESTED - maintainer doesn't have a proper token for this endpoint!
8
+ def self.get(ids)
9
+ RestClient.get("/v1/clients/#{ids[:clientGuid]}")
10
+ end
11
+
12
+ # https://docs.developer.tazworks.com/#e008c159-b8d7-4843-a08f-ff483315a067
13
+ # tazapi defaults to params { page: 0, size: 30 }
14
+ def self.all(params = {})
15
+ raw_response = RestClient.get('/v1/clients', { params: })
16
+ ClientPagedResponse.new(raw_response, {})
17
+ end
18
+
19
+ # https://docs.developer.tazworks.com/#da4edfa1-a2b0-4015-a622-23998864b14c
20
+ def self.descendents(_clientGuid)
21
+ raise 'Unimplemented'
22
+ end
23
+
24
+ # https://docs.developer.tazworks.com/#31f1c04e-6cba-4e6d-9499-23d5dafe16f8
25
+ def self.ancestors(_clientGuid)
26
+ raise 'Unimplemented'
27
+ end
28
+
29
+ ## consider splitting these up into mixins if they get too big
30
+
31
+ # Orders/Applicants
32
+
33
+ def applicants(params = {})
34
+ Applicant.all(clientGuid, params)
35
+ end
36
+
37
+ def orders(params = {})
38
+ Order.all(clientGuid, params)
39
+ end
40
+
41
+ def client_products(params = {})
42
+ ClientProduct.all(clientGuid, params)
43
+ end
44
+
45
+ def create_applicant(params)
46
+ Tazworks::Applicant.create(clientGuid, params)
47
+ end
48
+
49
+ # https://docs.developer.tazworks.com/#097f5a2a-85f5-4bb7-b208-facc7e66b98f
50
+ def find_applicant(applicantGuid)
51
+ Tazworks::Applicant.find(ids: { clientGuid:, applicantGuid: })
52
+ end
53
+
54
+ def submit_order(params)
55
+ Order.create(clientGuid, params)
56
+ end
57
+
58
+ def ancestors
59
+ Client.ancestors(clientGuid)
60
+ end
61
+
62
+ def descendents(clientGuid)
63
+ Client.descendents(clientGuid)
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tazworks
4
+ # Handles pagination for Client Responses such as GET All Clients
5
+ class ClientPagedResponse < PagedResponse
6
+ def self.base_class
7
+ Client
8
+ end
9
+
10
+ def clients
11
+ response_to_models
12
+ end
13
+
14
+ def map_individual_object_ids(ids, attributes)
15
+ ids[:clientGuid] = attributes[:clientGuid]
16
+ ids
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tazworks
4
+ # Tazworks Clients Model
5
+ class ClientProduct < Model
6
+ # https://docs.developer.tazworks.com/#bc9ed960-33e3-4eed-9f25-7b052b0d4e6f
7
+ # tazapi defaults to params { page: 0, size: 30 }
8
+ def self.all(clientGuid, params = {})
9
+ raw_response = RestClient.get("/v1/clients/#{clientGuid}/products", { params: })
10
+ ClientProductPagedResponse.new(raw_response, { clientGuid: })
11
+ end
12
+
13
+ # TODO: WARNING - this method is untested; maintainer does not a key that is authorized to use this endpoint
14
+ def self.get(ids)
15
+ RestClient.get("/v1/clients/#{ids[:clientGuid]}/products/#{ids[:clientProductGuid]}")
16
+ end
17
+
18
+ def clientProductGuid
19
+ @ids[:clientProductGuid]
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tazworks
4
+ # Handles pagination for ClientProduct responses such as Get All ClientProducts
5
+ class ClientProductPagedResponse < PagedResponse
6
+ def self.base_class
7
+ ClientProduct
8
+ end
9
+
10
+ def client_products
11
+ response_to_models
12
+ end
13
+
14
+ def map_individual_object_ids(ids, attributes)
15
+ ids[:clientProductGuid] = attributes[:clientProductGuid]
16
+ ids
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tazworks
4
+ # Tazworks Set Configuration
5
+ class Config
6
+ DEFAULT_SANDBOX_HOST = 'https://api-sandbox.instascreen.net'
7
+ DEFAULT_PRODUCTION_HOST = 'https://api.instascreen.net'
8
+ DEFAULT_PORT = 443
9
+
10
+ attr_accessor :api_key, :sandbox, :host, :port
11
+
12
+ def base_uri
13
+ host = @host
14
+ host ||= @sandbox ? DEFAULT_SANDBOX_HOST : DEFAULT_PRODUCTION_HOST
15
+ URI.parse("#{host}:#{@port || DEFAULT_PORT}")
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tazworks
4
+ # Base model
5
+ class Model
6
+ attr_accessor :attributes, :ids
7
+ attr_reader :attributes_loaded
8
+
9
+ def self.find(ids)
10
+ initialize_from_response(ids, get(ids))
11
+ end
12
+
13
+ def self.get(_ids)
14
+ raise 'Must Implement Me in the Concrete Class'
15
+ end
16
+
17
+ def load_attributes
18
+ response = self.class.get(ids)
19
+ @attributes = JSON.parse(response.body, { symbolize_names: true })
20
+ @attributes_loaded = true
21
+ end
22
+
23
+ def initialize(ids:, attributes: {}, attributes_loaded: false)
24
+ @attributes = attributes
25
+ @ids = ids
26
+ @attributes_loaded = attributes_loaded
27
+ end
28
+
29
+ def self.initialize_from_response(ids, response)
30
+ json_response = JSON.parse(response.body, { symbolize_names: true })
31
+ new(ids:, attributes: json_response, attributes_loaded: true)
32
+ end
33
+
34
+ def attributes_loaded?
35
+ !!@attributes_loaded
36
+ end
37
+
38
+ def clientGuid
39
+ @ids[:clientGuid]
40
+ end
41
+
42
+ # ensures attributes are loaded from the server
43
+ def loaded_attributes
44
+ load_attributes unless attributes_loaded?
45
+ @attributes
46
+ end
47
+
48
+ def reload
49
+ load_attributes
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
5
+ module Tazworks
6
+ # Tazworks Orders Model
7
+ class Order < Model
8
+ # https://docs.developer.tazworks.com/#cc17be7c-6b55-4329-991d-6414fad702de
9
+ def self.get(ids)
10
+ RestClient.get("/v1/clients/#{ids[:clientGuid]}/orders/#{ids[:orderGuid]}")
11
+ end
12
+
13
+ # https://docs.developer.tazworks.com/#7f41facc-fa45-4d09-a25a-9943d00bfb57
14
+ def self.all(clientGuid, params = {})
15
+ raw_response = RestClient.get("/v1/clients/#{clientGuid}/orders", { params: })
16
+ OrderPagedResponse.new(raw_response, { clientGuid: })
17
+ end
18
+
19
+ # https://docs.developer.tazworks.com/#494c3491-bb92-41a9-bee8-c1601fe957aa
20
+ def self.create(clientGuid, params)
21
+ required_params = %w[applicantGuid clientProductGuid]
22
+ required_params.each do |rp|
23
+ raise ArgumentError, "#{rp} is missing in params hash." unless params.key?(rp.to_sym)
24
+ end
25
+
26
+ response = RestClient.post("/v1/clients/#{clientGuid}/orders", params)
27
+
28
+ order = Order.initialize_from_response({ clientGuid: }, response)
29
+ order.ids[:orderGuid] = order.attributes[:orderGuid]
30
+ order
31
+ end
32
+
33
+ # https://docs.developer.tazworks.com/#16c2bff6-501c-432b-a89d-19141f277fc6
34
+ def order_status
35
+ response = RestClient.get("/v1/clients/#{clientGuid}/orders/#{orderGuid}/status")
36
+ JSON.parse(response.body)
37
+ end
38
+
39
+ # https://docs.developer.tazworks.com/#149663fc-2923-4836-a3c7-1dc62a293fba
40
+ def results_as_pdf
41
+ begin
42
+ response = RestClient.get("/v1/clients/#{clientGuid}/orders/#{orderGuid}/resultsAsPdf")
43
+ rescue ::RestClient::BadRequest => e
44
+ raise Error, e.response.body
45
+ end
46
+ json_parsed = JSON.parse(response.body, { symbolize_names: true })
47
+ json_parsed[:resultsUrl]
48
+ end
49
+
50
+ def orderGuid
51
+ @ids[:orderGuid]
52
+ end
53
+
54
+ def quickappApplicantLink
55
+ loaded_attributes[:quickappApplicantLink]
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tazworks
4
+ # Handles pagination for Order responses such as GET All Orders
5
+ class OrderPagedResponse < PagedResponse
6
+ def self.base_class
7
+ Order
8
+ end
9
+
10
+ def orders
11
+ response_to_models
12
+ end
13
+
14
+ def map_individual_object_ids(ids, attributes)
15
+ ids[:orderGuid] = attributes[:orderGuid]
16
+ ids
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
5
+ module Tazworks
6
+ # Paged Response Model to Handle Paginated Results
7
+ class PagedResponse
8
+ attr_accessor :raw_response, :ids
9
+
10
+ def initialize(response, ids)
11
+ @ids = ids
12
+ @raw_response = response
13
+ end
14
+
15
+ def self.base_class
16
+ raise 'Must Implement Me in the Concrete Class'
17
+ end
18
+
19
+ def raw_json_response
20
+ @raw_response.body
21
+ end
22
+
23
+ def response_to_models
24
+ return @collection if @collection
25
+
26
+ json_response = JSON.parse(raw_response.body, { symbolize_names: true })
27
+ @collection = json_response.map do |json_object|
28
+ self.class.base_class.new(ids: map_individual_object_ids(@ids, json_object), attributes: json_object,
29
+ attributes_loaded: true)
30
+ end
31
+ end
32
+
33
+ # this method is utilized to create proper ids for individual objects from the attributes
34
+ def map_individual_object_ids(_ids, _attributes)
35
+ raise 'Must Implement Me in the Concrete Class'
36
+ end
37
+
38
+ def next
39
+ # might be nice to have a way that automatically calls the next page with the parameters already known here.
40
+ raise 'Unimplemented'
41
+ end
42
+
43
+ def last
44
+ # might be nice to have a way that automatically calls the next page with the parameters already known here.
45
+ raise 'Unimplemented'
46
+ end
47
+
48
+ def response_links
49
+ @raw_response.headers[:link]&.split(',')
50
+ end
51
+
52
+ def next_page
53
+ return nil unless response_links
54
+
55
+ next_link = response_links.grep(/rel="next"/).first
56
+ return nil if next_link.nil?
57
+
58
+ # scary regex to pull the parameter off the url.
59
+ next_link[/.*page=(\d+)&.*/, 1].to_i
60
+ end
61
+
62
+ # pages seem to start with 0, so defaulting to 0 when there are only "1" page.
63
+ def total_number_of_pages
64
+ return 0 unless response_links
65
+
66
+ last_link = response_links.grep(/rel="last"/).first
67
+ return 0 if last_link.nil?
68
+
69
+ # scary regex to pull the parameter off the url.
70
+ last_link[/.*page=(\d+)&.*/, 1].to_i
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rest-client'
4
+ require 'json'
5
+
6
+ module Tazworks
7
+ # Wrapper for rest-client
8
+ class RestClient
9
+ def self.url(uri)
10
+ "#{Tazworks.config.base_uri}#{uri}"
11
+ end
12
+
13
+ def self.merged_headers(headers)
14
+ raise ArgumentError, 'api_key is not set in Tazworks configuration' unless Tazworks.config.api_key
15
+
16
+ default_headers = {
17
+ 'Content-Type': 'application/json',
18
+ Authorization: "Bearer #{Tazworks.config.api_key}"
19
+ }
20
+ default_headers.merge(headers)
21
+ end
22
+
23
+ def self.get(uri, headers = {})
24
+ ::RestClient.get(url(uri), merged_headers(headers))
25
+ end
26
+
27
+ def self.post(uri, payload, headers = {})
28
+ ::RestClient.post(url(uri), payload.to_json, merged_headers(headers))
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Tazworks Version
4
+ module Tazworks
5
+ VERSION = '0.1.1'
6
+ end
data/lib/tazworks.rb ADDED
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'tazworks/version'
4
+ require_relative 'tazworks/config'
5
+ require_relative 'tazworks/model'
6
+ require_relative 'tazworks/rest_client'
7
+ require_relative 'tazworks/client'
8
+ require_relative 'tazworks/client_product'
9
+ require_relative 'tazworks/applicant'
10
+ require_relative 'tazworks/order'
11
+
12
+ require_relative 'tazworks/paged_response'
13
+ require_relative 'tazworks/client_paged_response'
14
+ require_relative 'tazworks/client_product_paged_response'
15
+ require_relative 'tazworks/applicant_paged_response'
16
+ require_relative 'tazworks/order_paged_response'
17
+
18
+ # Tazworks Configuration
19
+ module Tazworks
20
+ def configure(&)
21
+ config.tap(&)
22
+ end
23
+
24
+ def config
25
+ @config ||= Config.new
26
+ end
27
+
28
+ module_function :configure, :config
29
+
30
+ class Error < StandardError; end
31
+ end
@@ -0,0 +1,6 @@
1
+ module Tazworks
2
+ module Api
3
+ VERSION: String
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tazworks-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Peyton Smith
8
+ - Jonathan Chan
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2023-11-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '2.6'
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.6.3
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - "~>"
29
+ - !ruby/object:Gem::Version
30
+ version: '2.6'
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.6.3
34
+ - !ruby/object:Gem::Dependency
35
+ name: rest-client
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.1'
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.1'
48
+ description:
49
+ email:
50
+ - 19peytonsmith@gmail.com
51
+ - jonathan@rentwayhome.com
52
+ executables: []
53
+ extensions: []
54
+ extra_rdoc_files: []
55
+ files:
56
+ - ".rubocop.yml"
57
+ - ".ruby-version"
58
+ - CHANGELOG.md
59
+ - CODE_OF_CONDUCT.md
60
+ - Gemfile
61
+ - LICENSE
62
+ - README.md
63
+ - Rakefile
64
+ - lib/tazworks.rb
65
+ - lib/tazworks/applicant.rb
66
+ - lib/tazworks/applicant_paged_response.rb
67
+ - lib/tazworks/client.rb
68
+ - lib/tazworks/client_paged_response.rb
69
+ - lib/tazworks/client_product.rb
70
+ - lib/tazworks/client_product_paged_response.rb
71
+ - lib/tazworks/config.rb
72
+ - lib/tazworks/model.rb
73
+ - lib/tazworks/order.rb
74
+ - lib/tazworks/order_paged_response.rb
75
+ - lib/tazworks/paged_response.rb
76
+ - lib/tazworks/rest_client.rb
77
+ - lib/tazworks/version.rb
78
+ - sig/tazworks/api.rbs
79
+ homepage: https://github.com/wayhomeservices/tazworks-api
80
+ licenses:
81
+ - MIT
82
+ metadata:
83
+ allowed_push_host: https://rubygems.org/
84
+ homepage_uri: https://github.com/wayhomeservices/tazworks-api
85
+ source_code_uri: https://github.com/wayhomeservices/tazworks-api
86
+ changelog_uri: https://github.com/wayhomeservices/tazworks-api/blob/master/CHANGELOG.md
87
+ rubygems_mfa_required: 'true'
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '3.1'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubygems_version: 3.4.10
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Ruby Wrapper for Tazworks background screening TazAPI.
107
+ test_files: []