persona_api 0.1.6

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.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/CHANGELOG.md +36 -0
  4. data/CODE_OF_CONDUCT.md +72 -0
  5. data/Gemfile +10 -0
  6. data/Gemfile.lock +63 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +179 -0
  9. data/Rakefile +8 -0
  10. data/lib/persona_api/client.rb +70 -0
  11. data/lib/persona_api/collection.rb +20 -0
  12. data/lib/persona_api/error.rb +3 -0
  13. data/lib/persona_api/object.rb +18 -0
  14. data/lib/persona_api/objects/account.rb +7 -0
  15. data/lib/persona_api/objects/api_log.rb +4 -0
  16. data/lib/persona_api/objects/case.rb +4 -0
  17. data/lib/persona_api/objects/document.rb +4 -0
  18. data/lib/persona_api/objects/event.rb +4 -0
  19. data/lib/persona_api/objects/file.rb +4 -0
  20. data/lib/persona_api/objects/inquiry.rb +28 -0
  21. data/lib/persona_api/objects/list.rb +4 -0
  22. data/lib/persona_api/objects/list_item.rb +4 -0
  23. data/lib/persona_api/objects/report.rb +4 -0
  24. data/lib/persona_api/objects/user_audit_log.rb +4 -0
  25. data/lib/persona_api/objects/verification.rb +4 -0
  26. data/lib/persona_api/resource.rb +49 -0
  27. data/lib/persona_api/resources/accounts.rb +42 -0
  28. data/lib/persona_api/resources/api_logs.rb +11 -0
  29. data/lib/persona_api/resources/cases.rb +28 -0
  30. data/lib/persona_api/resources/documents.rb +7 -0
  31. data/lib/persona_api/resources/events.rb +11 -0
  32. data/lib/persona_api/resources/files.rb +8 -0
  33. data/lib/persona_api/resources/inquiries.rb +52 -0
  34. data/lib/persona_api/resources/list_items.rb +79 -0
  35. data/lib/persona_api/resources/lists.rb +51 -0
  36. data/lib/persona_api/resources/reports.rb +37 -0
  37. data/lib/persona_api/resources/user_audit_logs.rb +11 -0
  38. data/lib/persona_api/resources/verifications.rb +7 -0
  39. data/lib/persona_api/version.rb +5 -0
  40. data/lib/persona_api.rb +39 -0
  41. data/sig/persona_api.rbs +4 -0
  42. metadata +114 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3365bb039dfa2864780f8f54261ea2dea92d394a9328050b78bab7621a76984f
4
+ data.tar.gz: c46c19b74478670148948453c5faf8cad81a7d27c528deebc9a788ab4b61dff5
5
+ SHA512:
6
+ metadata.gz: 398ff5050ea4593c0542531cc2c75f523bbc4b5e5328728a4fed7a9938cd9b50533b654162ea13ecc67525b1d62e2e5441772b0e4f3e69d123cb0a04882f58ae
7
+ data.tar.gz: 305d8e1af2b69ebd632acdefad1a146654b8d60e0f024f3853b4fe3d4bf61e18e1547646cd59de62412d2cf6e08f040bcceb4e9d58158b6de894e36b5053adca
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/CHANGELOG.md ADDED
@@ -0,0 +1,36 @@
1
+ == [0.1.6] - 2022-07-14
2
+
3
+ * Update README.md
4
+ * Add Api Logs, User Audit Logs, List Items endpoints
5
+
6
+ == [0.1.5] - 2022-07-11
7
+
8
+ * Update README.md
9
+ * Add Lists, Events, and Files endpoints
10
+ * Minor bug fixes
11
+
12
+ == [0.1.4] - 2022-07-10
13
+
14
+ * Update README.md
15
+ * Add Documents and Reports endpoints
16
+ * Minor bug fixes
17
+
18
+ == [0.1.3] - 2022-07-09
19
+
20
+ * Update README.md
21
+ * Minor bug fixes
22
+
23
+ == [0.1.2] - 2022-07-09
24
+
25
+ * Update README.md
26
+ * Complete Inquiries and add Case endpoints
27
+ * Update gemspec
28
+
29
+ == [0.1.1] - 2022-07-09
30
+
31
+ * Update README.md
32
+ * Include Accounts, Inquiries, and Verifications endpoints
33
+
34
+ == [0.1.0] - 2022-07-05
35
+
36
+ * Hello world!
@@ -0,0 +1,72 @@
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 mattgriffith0@gmail.com. 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. Enforcement guidelines are listed below. These guidelines are strict and will be applied with zeal - assholes will not be tolerated.
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. Warning
51
+
52
+ **Community Impact**: A violation through a single incident or series of actions.
53
+
54
+ **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 permanent ban.
55
+
56
+ ### 2. Permanent Ban
57
+
58
+ **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.
59
+
60
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
61
+
62
+ ## Attribution
63
+
64
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
65
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
66
+
67
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
68
+
69
+ [homepage]: https://www.contributor-covenant.org
70
+
71
+ For answers to common questions about this code of conduct, see the FAQ at
72
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in persona_api.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,63 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ persona_api (0.1.5)
5
+ faraday (~> 1.7)
6
+ faraday_middleware (~> 1.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ diff-lcs (1.5.0)
12
+ faraday (1.10.0)
13
+ faraday-em_http (~> 1.0)
14
+ faraday-em_synchrony (~> 1.0)
15
+ faraday-excon (~> 1.1)
16
+ faraday-httpclient (~> 1.0)
17
+ faraday-multipart (~> 1.0)
18
+ faraday-net_http (~> 1.0)
19
+ faraday-net_http_persistent (~> 1.0)
20
+ faraday-patron (~> 1.0)
21
+ faraday-rack (~> 1.0)
22
+ faraday-retry (~> 1.0)
23
+ ruby2_keywords (>= 0.0.4)
24
+ faraday-em_http (1.0.0)
25
+ faraday-em_synchrony (1.0.0)
26
+ faraday-excon (1.1.0)
27
+ faraday-httpclient (1.0.1)
28
+ faraday-multipart (1.0.4)
29
+ multipart-post (~> 2)
30
+ faraday-net_http (1.0.1)
31
+ faraday-net_http_persistent (1.2.0)
32
+ faraday-patron (1.0.0)
33
+ faraday-rack (1.0.0)
34
+ faraday-retry (1.0.3)
35
+ faraday_middleware (1.2.0)
36
+ faraday (~> 1.0)
37
+ multipart-post (2.2.3)
38
+ rake (13.0.6)
39
+ rspec (3.11.0)
40
+ rspec-core (~> 3.11.0)
41
+ rspec-expectations (~> 3.11.0)
42
+ rspec-mocks (~> 3.11.0)
43
+ rspec-core (3.11.0)
44
+ rspec-support (~> 3.11.0)
45
+ rspec-expectations (3.11.0)
46
+ diff-lcs (>= 1.2.0, < 2.0)
47
+ rspec-support (~> 3.11.0)
48
+ rspec-mocks (3.11.1)
49
+ diff-lcs (>= 1.2.0, < 2.0)
50
+ rspec-support (~> 3.11.0)
51
+ rspec-support (3.11.0)
52
+ ruby2_keywords (0.0.5)
53
+
54
+ PLATFORMS
55
+ arm64-darwin-21
56
+
57
+ DEPENDENCIES
58
+ persona_api!
59
+ rake (~> 13.0)
60
+ rspec (~> 3.0)
61
+
62
+ BUNDLED WITH
63
+ 2.3.17
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Matt Griffith
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,179 @@
1
+ # PersonaApi
2
+
3
+ The easiest and most complete rubygem for the [Persona](https://withpersona.com/) API. Currently supports [API v1](https://docs.withpersona.com/reference/introduction)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'persona_api', github: "mattgriffith0/persona_api"
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself with:
16
+
17
+ $ gem install persona_api
18
+
19
+ ## Usage
20
+
21
+ To access the API, you'll need to create a `PersonaAPI::Client` and pass in your API key. You can find your API key in your [Persona dashboard](https://app.withpersona.com/dashboard/api-configuration).
22
+
23
+ ```ruby
24
+ client = PersonaApi::Client.new(api_key: ENV["PERSONA_API_KEY"])
25
+ ```
26
+ The client then gives you access to all of the resources.
27
+
28
+ ## Resources
29
+
30
+ The gem attempts to map as closely as possible to the Persona API so that you can easily convert API examples in to gem code.
31
+
32
+ Responses are (in *almost* all cases) created as Objects like `PersonaAPI::Account`. Having types like `PersonaAPI::Inquiry` is useful for understanding the type of object you're working with. They're built using OpenStruct so that data is easily accessible in a Rubyish way.
33
+
34
+ ##### Pagination
35
+
36
+ `list` endpoints return pages of results. The result object will have a `data` key to access the results, as well as metadata like `next_page` and `prev_page` for retrieving the next and previous pages. You may also specify the number of results you would like to have returned and, for some resources, other specific filter params.
37
+
38
+ ```ruby
39
+ results = client.inquiries.list("page[size]": 5)
40
+ #=> PersonaAPI::Collection
41
+
42
+ results.data
43
+ #=> [#<PersonaAPI::Inquiry>, #<PersonaAPI::Inquiry>]
44
+
45
+ results.next_page
46
+ #=> "inq_NiHBQW47WfdPT58m4VcqFebx"
47
+
48
+ # Retrieve the next page
49
+ client.inquiries.list("page[size]": 5, "page[after]": results.next_page)
50
+ #=> PersonaAPI::Collection
51
+ ```
52
+
53
+ ### Accounts
54
+
55
+ ```ruby
56
+ client.accounts.list
57
+ client.accounts.create({})
58
+ client.accounts.retrieve(act_id: "id")
59
+ client.accounts.update(act_id: "id", {})
60
+ client.accounts.redact(act_id: "id")
61
+ client.accounts.add_tag(act_id: "id", {})
62
+ client.accounts.remove_tag(act_id: "id", {})
63
+ client.accounts.set_all_tags(act_id: "id", {})
64
+ ```
65
+
66
+ ### API Logs
67
+
68
+ ```ruby
69
+ client.api_logs.list
70
+ client.api_logs.retrieve(req_id: "id")
71
+ ```
72
+
73
+ ### Cases
74
+
75
+ ```ruby
76
+ client.cases.list
77
+ client.cases.create({})
78
+ client.cases.retrieve(case_id: "id")
79
+ client.cases.assign(case_id: "id", {})
80
+ client.cases.set_status(case_id: "id", {})
81
+ client.cases.add_persona_objects(case_id: "id", {})
82
+ ```
83
+
84
+ ### Documents
85
+
86
+ ```ruby
87
+ client.documents.retrieve(doc_id: "id")
88
+ ```
89
+
90
+ ### Events
91
+
92
+ ```ruby
93
+ client.events.list
94
+ client.events.retrive(evt_id:)
95
+ ```
96
+
97
+ ### Files
98
+
99
+ ```ruby
100
+ client.files.download(file_id:, file_name:)
101
+ ```
102
+
103
+ ### Inquiries
104
+
105
+ ```ruby
106
+ client.inquiries.list
107
+ client.inquiries.create({})
108
+ client.inquiries.retrieve(inq_id: "id")
109
+ client.inquiries.update(inq_id: "id", {})
110
+ client.inquiries.redact(inq_id: "id")
111
+ client.inquiries.add_tag(inq_id: "id", {})
112
+ client.inquiries.remove_tag(inq_id: "id", {})
113
+ client.inquiries.set_all_tags(inq_id: "id", {})
114
+ client.inquiries.resume(inq_id: "id")
115
+ client.inquiries.approve(inq_id: "id", {})
116
+ client.inquiries.decline(inq_id: "id", {})
117
+ ```
118
+
119
+ ### Lists
120
+
121
+ ```ruby
122
+ client.lists.list
123
+ client.lists.retrieve(lst_id: "id")
124
+ client.lists.archive(lst_id: "id")
125
+ client.lists.create_browser_fingerprint_list({})
126
+ client.lists.create_country_list({})
127
+ client.lists.create_email_address_list({})
128
+ client.lists.create_face_list({})
129
+ client.lists.create_geolocation_list({})
130
+ client.lists.create_government_id_number_list({})
131
+ client.lists.create_ip_address_list({})
132
+ client.lists.create_name_list({})
133
+ client.lists.create_phone_number_list({})
134
+ ```
135
+
136
+ ### Reports
137
+
138
+ ```ruby
139
+ client.reports.list
140
+ client.reports.create({})
141
+ client.reports.retrieve(rep_id: "id")
142
+ client.reports.redact(rep_id: "id")
143
+ client.reports.add_tag(rep_id: "id", {})
144
+ client.reports.remove_tag(rep_id: "id", {})
145
+ client.reports.set_all_tags(rep_id: "id", {})
146
+ ```
147
+
148
+ ### User Audit Logs
149
+
150
+ ```ruby
151
+ client.user_audit_logs.list
152
+ client.user_audit_logs.retrieve(ual_id: "id")
153
+ ```
154
+
155
+ ### Verifications
156
+
157
+ ```ruby
158
+ client.verifications.retrieve(ver_id: "id")
159
+ ```
160
+
161
+ ## Development
162
+
163
+ 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. This will create a `@client` for you to use, assuming you have assigned an API key to `ENV["PERSONA_API_KEY"]`.
164
+
165
+ ## Contributing
166
+
167
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mattgriffith0/persona_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/mattgriffith0/persona_api/blob/master/CODE_OF_CONDUCT.md).
168
+
169
+ ## Code of Conduct
170
+
171
+ Everyone interacting in the PersonaApi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mattgriffith0/persona_api/blob/master/CODE_OF_CONDUCT.md).
172
+
173
+
174
+ ## Thanks
175
+ Massive thanks to [Chris Oliver](https://github.com/excid3), whose Vultr gem served as inspiration.
176
+
177
+ ## License
178
+
179
+ [The MIT License (MIT)](https://github.com/mattgriffith0/persona_api/blob/main/LICENSE.txt)
data/Rakefile ADDED
@@ -0,0 +1,8 @@
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
+ task default: :spec
@@ -0,0 +1,70 @@
1
+ require "faraday"
2
+ require "faraday_middleware"
3
+
4
+ module PersonaApi
5
+ class Client
6
+ BASE_URL = 'https://withpersona.com/api/v1/'
7
+
8
+ attr_reader :api_key, :adapter
9
+
10
+ def initialize(api_key:, adapter: Faraday.default_adapter)
11
+ @api_key = api_key
12
+ @adapter = adapter
13
+ end
14
+
15
+ def accounts
16
+ AccountsResource.new(self)
17
+ end
18
+
19
+ def api_logs
20
+ ApiLogsResource.new(self)
21
+ end
22
+
23
+ def cases
24
+ CasesResource.new(self)
25
+ end
26
+
27
+ def documents
28
+ DocumentsResource.new(self)
29
+ end
30
+
31
+ def events
32
+ EventsResource.new(self)
33
+ end
34
+
35
+ def inquiries
36
+ InquiriesResource.new(self)
37
+ end
38
+
39
+ def lists
40
+ ListsResource.new(self)
41
+ end
42
+
43
+ def list_items
44
+ ListItemsResource.new(self)
45
+ end
46
+
47
+ def reports
48
+ ReportsResource.new(self)
49
+ end
50
+
51
+ def user_audit_logs
52
+ UserAuditLogsResource.new(self)
53
+ end
54
+
55
+ def verifications
56
+ VerificationsResource.new(self)
57
+ end
58
+
59
+ def connection
60
+ @connection ||= Faraday.new do |connection|
61
+ connection.url_prefix = BASE_URL
62
+ connection.request :authorization, :Bearer, api_key
63
+ connection.headers['Key-Inflection'] = "snake"
64
+ connection.request :json
65
+ connection.response :json, content_type: "application/json"
66
+ connection.adapter adapter
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,20 @@
1
+ module PersonaApi
2
+ class Collection
3
+ attr_reader :data, :next_page, :prev_page
4
+
5
+ def self.from_response(response, key:, type:)
6
+ body = response.body
7
+ new(
8
+ data: body[key].map{ |attrs| type.new(attrs) },
9
+ next_page: body.dig("links", "next"),
10
+ prev_page: body.dig("links", "prev")
11
+ )
12
+ end
13
+
14
+ def initialize(data:, next_page:, prev_page:)
15
+ @data = data
16
+ @next_page = next_page.nil? ? nil : data.last.id
17
+ @prev_page = prev_page.nil? ? nil : data.first.id
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module PersonaApi
2
+ class Error < StandardError; end
3
+ end
@@ -0,0 +1,18 @@
1
+ require "ostruct"
2
+
3
+ module PersonaApi
4
+ class Object
5
+ def initialize(attributes)
6
+ @attributes = OpenStruct.new(attributes)
7
+ end
8
+
9
+ def method_missing(method, *args, &block)
10
+ attribute = @attributes.send(method, *args, &block)
11
+ attribute.is_a?(Hash) ? Object.new(attribute) : attribute
12
+ end
13
+
14
+ def respond_to_missing?(method, include_private = false)
15
+ true
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ module PersonaApi
2
+ class Account < Object
3
+ def reference_id
4
+ attributes.reference_id
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ module PersonaApi
2
+ class ApiLog < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module PersonaApi
2
+ class Case < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module PersonaApi
2
+ class Document < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module PersonaApi
2
+ class Event < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module PersonaApi
2
+ class File < Object
3
+ end
4
+ end
@@ -0,0 +1,28 @@
1
+ module PersonaApi
2
+ class Inquiry < Object
3
+ def account
4
+ # return the account id token associated with this inquiry
5
+ relationships.account.data.id
6
+ end
7
+
8
+ def completed?
9
+ attributes.completed_at.nil? ? false : true
10
+ end
11
+
12
+ def expired?
13
+ attributes.expired_at.nil? ? false : true
14
+ end
15
+
16
+ def failed?
17
+ attributes.failed_at.nil? ? false : true
18
+ end
19
+
20
+ def redacted?
21
+ attributes.redacted_at.nil? ? false : true
22
+ end
23
+
24
+ def started?
25
+ attributes.started_at.nil? ? false: true
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,4 @@
1
+ module PersonaApi
2
+ class List < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module PersonaApi
2
+ class ListItem < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module PersonaApi
2
+ class Report < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module PersonaApi
2
+ class UserAuditLog < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module PersonaApi
2
+ class Verification < Object
3
+ end
4
+ end
@@ -0,0 +1,49 @@
1
+ module PersonaApi
2
+ class Resource
3
+ attr_reader :client
4
+
5
+ def initialize(client)
6
+ @client = client
7
+ end
8
+
9
+ def get_request(url, params: {}, headers: {})
10
+ handle_response client.connection.get(url, params, headers)
11
+ end
12
+
13
+ def post_request(url, body:, headers: {})
14
+ handle_response client.connection.post(url, body, headers)
15
+ end
16
+
17
+ def patch(url, body:, headers: {})
18
+ handle_response client.connection.patch(url, body, headers)
19
+ end
20
+
21
+ def put(url, body:, headers: {})
22
+ handle_response client.connection.put(url, body, headers)
23
+ end
24
+
25
+ def delete_request(url, params: {}, headers: {})
26
+ handle_response client.connection.delete(url, params, headers)
27
+ end
28
+
29
+ def handle_response(response)
30
+
31
+ case response.status
32
+ when 400
33
+ raise Error, "The request was unacceptable, often due to invalid parameters."
34
+ when 401
35
+ raise Error, "Not authenticated - check your API key"
36
+ when 403
37
+ raise Error, "The given API key doesn't have permissions to perform the request or a quota has been exceeded."
38
+ when 404
39
+ raise Error, "The requested resource doesn't exist."
40
+ when 429
41
+ raise Error, "Your organization's rate limit has been exceeded. We recommend an exponential backoff on requests."
42
+ when 500
43
+ raise Error, "Something went wrong on Persona's end."
44
+ end
45
+
46
+ response
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,42 @@
1
+ module PersonaApi
2
+ class AccountsResource < Resource
3
+ def add_tag(act_id:, **attributes)
4
+ post_request("accounts/#{act_id}/add-tag", body: attributes)
5
+ true
6
+ end
7
+
8
+ def consolidate_accounts(act_id:, **attributes)
9
+ post_request("accounts/#{act_id}/consolidate", body: attributes).body.dig("data")
10
+ end
11
+
12
+ def create(**attributes)
13
+ Account.new post_request("inquiries", body: attributes).body.dig("data")
14
+ end
15
+
16
+ def list(**params)
17
+ Collection.from_response get_request("accounts", params: params), key: "data", type: Account
18
+ end
19
+
20
+ def retrieve(act_id:)
21
+ Account.new get_request("accounts/#{act_id}").body.dig("data")
22
+ end
23
+
24
+ def redact(act_id:)
25
+ delete_request("accounts/#{act_id}")
26
+ end
27
+
28
+ def remove_tag(act_id:, **attributes)
29
+ post_request("accounts/#{act_id}/remove-tag", body: attributes)
30
+ true
31
+ end
32
+
33
+ def set_all_tags(act_id:, **attributes)
34
+ post_request("accounts/#{act_id}/set-tags", body: attributes)
35
+ true
36
+ end
37
+
38
+ def update(act_id:, **attributes)
39
+ patch_request("accounts/#{act_id}", body: attributes).body.dig("data")
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,11 @@
1
+ module PersonaApi
2
+ class ApiLogsResource < Resource
3
+ def list(**params)
4
+ Collection.from_response get_request("api-logs", params: params), key: "data", type: ApiLog
5
+ end
6
+
7
+ def retrieve(req_id:)
8
+ ApiLog.new get_request("api-logs/#{req_id}").body.dig("data")
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,28 @@
1
+ module PersonaApi
2
+ class CasesResource < Resource
3
+ def add_persona_objects(case_id:, **attributes)
4
+ Case.new post_request("cases/#{case_id}/add-objects", body: attributes).body.dig("data")
5
+ end
6
+
7
+ def assign(case_id:, **attributes)
8
+ Case.new post_request("cases/#{case_id}/assign", body: attributes).body.dig("data")
9
+ end
10
+
11
+ def create(**attributes)
12
+ # cases attributes must include the 'case-template-id'
13
+ Case.new post_request("cases", body: attributes).body
14
+ end
15
+
16
+ def list(**params)
17
+ Collection.from_response get_request("cases", params: params), key: "data", type: Case
18
+ end
19
+
20
+ def retrieve(case_id:)
21
+ Case.new get_request("cases/#{case_id}").body
22
+ end
23
+
24
+ def set_status(case_id:, **attributes)
25
+ Case.new post_request("cases/#{case_id}/set-status", body: attributes).body.dig("data")
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,7 @@
1
+ module PersonaApi
2
+ class DocumentsResource < Resource
3
+ def retrieve(doc_id:)
4
+ Document.new get_request("documents/#{doc_id}").body.dig("data")
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ module PersonaApi
2
+ class EventsResource < Resource
3
+ def list(**params)
4
+ Collection.from_response get_request("events", params: params), key: "data", type: Event
5
+ end
6
+
7
+ def retrieve(evt_id:)
8
+ Event.new get_request("events/#{evt_id}").body.dig("data")
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ module PersonaApi
2
+ class FilesResource < Resource
3
+ def download(file_id:, file_name:)
4
+ get_request("files/#{file_id}/#{file_name}").body.dig("data")
5
+ true
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,52 @@
1
+ module PersonaApi
2
+ class InquiriesResource < Resource
3
+ def add_tag(inq_id:, **attributes)
4
+ post_request("inquiries/#{inq_id}/add-tag", body: attributes)
5
+ true
6
+ end
7
+
8
+ def approve(inq_id:, **attributes)
9
+ post_request("inquiries/#{inq_id}/approve", body: attributes)
10
+ end
11
+
12
+ def create(**attributes)
13
+ # inquiry attributes must include one of 'template-id' or 'inquiry-template-id'
14
+ Inquiry.new post_request("inquiries", body: attributes).body.dig("data")
15
+ end
16
+
17
+ def decline(inq_id:, **attributes)
18
+ post_request("inquiries/#{inq_id}/decline", body: attributes)
19
+ end
20
+
21
+ def list(**params)
22
+ Collection.from_response get_request("inquiries", params: params), key: "data", type: Inquiry
23
+ end
24
+
25
+ def retrieve(inq_id:)
26
+ Inquiry.new get_request("inquiries/#{inq_id}").body.dig("data")
27
+ end
28
+
29
+ def redact(inq_id:)
30
+ delete_request("inquiries/#{inq_id}")
31
+ end
32
+
33
+ def remove_tag(inq_id:, **attributes)
34
+ post_request("inquiries/#{inq_id}/remove-tag", body: attributes)
35
+ true
36
+ end
37
+
38
+ def resume(inq_id:, **attributes)
39
+ # this request will return only the session_token
40
+ post_request("inquiries/#{inq_id}/resume", body: attributes).body.dig("meta", "session_token")
41
+ end
42
+
43
+ def set_all_tags(inq_id:, **attributes)
44
+ post_request("inquiries/#{inq_id}/set-tags", body: attributes)
45
+ true
46
+ end
47
+
48
+ def update(inq_id:, **attributes)
49
+ Inquiry.new patch_request("inquiries/#{inq_id}", body: attributes).body.dig("data")
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,79 @@
1
+ module PersonaApi
2
+ class ListItemsResource < Resource
3
+ # These archive requests will return the body of the response. This is slightly different
4
+ # from other endpoints with redact/archive requests, as the List Items endpoint doesn't
5
+ # contain a `retrieve` method.
6
+
7
+ def archive_browser_fingerprint_list_item(libf_id:)
8
+ delete_request("list-item/browser-fingerprints/#{libf_id}").body.dig("data")
9
+ end
10
+
11
+ def archive_country_list_item(libf_id:)
12
+ delete_request("list-item/countries/#{libf_id}").body.dig("data")
13
+ end
14
+
15
+ def archive_email_address_list_item(libf_id:)
16
+ delete_request("list-item/email-addresses/#{libf_id}").body.dig("data")
17
+ end
18
+
19
+ def archive_face_list_item(libf_id:)
20
+ delete_request("list-item/faces/#{libf_id}").body.dig("data")
21
+ end
22
+
23
+ def archive_geolocation_list_item(libf_id:)
24
+ delete_request("list-item/geolocations#{libf_id}").body.dig("data")
25
+ end
26
+
27
+ def archive_government_id_number_list_item(libf_id:)
28
+ delete_request("list-item/government-id-numbers#{libf_id}").body.dig("data")
29
+ end
30
+
31
+ def archive_ip_address_list_item(libf_id:)
32
+ delete_request("list-item/ip-addresses#{libf_id}").body.dig("data")
33
+ end
34
+
35
+ def archive_name_list_item(libf_id:)
36
+ delete_request("list-item/names#{libf_id}").body.dig("data")
37
+ end
38
+
39
+ def archive_phone_number_list_item(libf_id:)
40
+ delete_request("list-item/phone-numbers#{libf_id}").body.dig("data")
41
+ end
42
+
43
+ def create_browser_fingerprint_list_item(**attributes)
44
+ ListItem.new post_request("list-item/browser-fingerprints", body: attributes).body.dig("data")
45
+ end
46
+
47
+ def create_country_list_item(**attributes)
48
+ ListItem.new post_request("list-item/countries", body: attributes).body.dig("data")
49
+ end
50
+
51
+ def create_email_address_list_item(**attributes)
52
+ ListItem.new post_request("list-item/email-addresses", body: attributes).body.dig("data")
53
+ end
54
+
55
+ def create_face_list_item(**attributes)
56
+ ListItem.new post_request("list-item/faces", body: attributes).body.dig("data")
57
+ end
58
+
59
+ def create_geolocation_list_item(**attributes)
60
+ ListItem.new post_request("list-item/geolocations", body: attributes).body.dig("data")
61
+ end
62
+
63
+ def create_government_id_number_list_item(**attributes)
64
+ ListItem.new post_request("list-item/government-id-numbers", body: attributes).body.dig("data")
65
+ end
66
+
67
+ def create_ip_address_list_item(**attributes)
68
+ ListItem.new post_request("list-item/ip-addresses", body: attributes).body.dig("data")
69
+ end
70
+
71
+ def create_name_list_item(**attributes)
72
+ ListItem.new post_request("list-item/names", body: attributes).body.dig("data")
73
+ end
74
+
75
+ def create_phone_number_list_item(**attributes)
76
+ ListItem.new post_request("list-item/phone-numbers", body: attributes).body.dig("data")
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,51 @@
1
+ module PersonaApi
2
+ class ListsResource < Resource
3
+ def list(**params)
4
+ Collection.from_response get_request("lists", params: params), key: "data", type: List
5
+ end
6
+
7
+ def retrieve(lst_id:)
8
+ List.new get_request("lists/#{lst_id}").body.dig("data")
9
+ end
10
+
11
+ def archive(lst_id:)
12
+ delete_request("lists/#{lst_id}")
13
+ end
14
+
15
+ def create_browser_fingerprint_list(**attributes)
16
+ List.new post_request("lists/browser-fingerprints", body: attributes).body.dig("data")
17
+ end
18
+
19
+ def create_country_list(**attributes)
20
+ List.new post_request("lists/countries", body: attributes).body.dig("data")
21
+ end
22
+
23
+ def create_email_address_list(**attributes)
24
+ List.new post_request("lists/email-addresses", body: attributes).body.dig("data")
25
+ end
26
+
27
+ def create_face_list(**attributes)
28
+ List.new post_request("lists/faces", body: attributes).body.dig("data")
29
+ end
30
+
31
+ def create_geolocation_list(**attributes)
32
+ List.new post_request("lists/geolocations", body: attributes).body.dig("data")
33
+ end
34
+
35
+ def create_government_id_number_list(**attributes)
36
+ List.new post_request("lists/government-id-numbers", body: attributes).body.dig("data")
37
+ end
38
+
39
+ def create_ip_address_list(**attributes)
40
+ List.new post_request("lists/ip-addresses", body: attributes).body.dig("data")
41
+ end
42
+
43
+ def create_name_list(**attributes)
44
+ List.new post_request("lists/names", body: attributes).body.dig("data")
45
+ end
46
+
47
+ def create_phone_number_list(**attributes)
48
+ List.new post_request("lists/phone-numbers", body: attributes).body.dig("data")
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,37 @@
1
+ module PersonaApi
2
+ class ReportsResource < Resource
3
+ def add_tag(rep_id:, **attributes)
4
+ post_request("reports/#{rep_id}/add-tag", body: attributes)
5
+ true
6
+ end
7
+
8
+ def create(**attributes)
9
+ # report attributes must include a 'report-template-id' as well as other fields as laid out
10
+ # in the documentation https://docs.withpersona.com/reference/supported-report-types-and-examples
11
+
12
+ Report.new post_request("reports", body: attributes).body.dig("data")
13
+ end
14
+
15
+ def list(**params)
16
+ Collection.from_response get_request("reports", params: params), key: "data", type: Report
17
+ end
18
+
19
+ def retrieve(rep_id:)
20
+ Report.new get_request("reports/#{rep_id}").body.dig("data")
21
+ end
22
+
23
+ def redact(rep_id:)
24
+ delete_request("reports/#{rep_id}")
25
+ end
26
+
27
+ def remove_tag(rep_id:, **attributes)
28
+ post_request("reports/#{rep_id}/remove-tag", body: attributes)
29
+ true
30
+ end
31
+
32
+ def set_all_tags(rep_id:, **attributes)
33
+ post_request("reports/#{rep_id}/set-tags", body: attributes)
34
+ true
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,11 @@
1
+ module PersonaApi
2
+ class UserAuditLogsResource < Resource
3
+ def list(**params)
4
+ Collection.from_response get_request("user-audit-logs", params: params), key: "data", type: UserAuditLog
5
+ end
6
+
7
+ def retrieve(ual_id:)
8
+ ApiLog.new get_request("user-audit-logs/#{ual_id}").body.dig("data")
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ module PersonaApi
2
+ class VerificationsResource < Resource
3
+ def retrieve(ver_id:)
4
+ Verification.new get_request("verifications/#{ver_id}").body.dig("data")
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PersonaApi
4
+ VERSION = "0.1.6"
5
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "persona_api/version"
4
+
5
+ module PersonaApi
6
+ autoload :Client, "persona_api/client"
7
+ autoload :Collection, "persona_api/collection"
8
+ autoload :Error, "persona_api/error"
9
+ autoload :Object, "persona_api/object"
10
+ autoload :Resource, "persona_api/resource"
11
+
12
+ # objects
13
+ autoload :Account, "persona_api/objects/account"
14
+ autoload :Inquiry, "persona_api/objects/inquiry"
15
+ autoload :Verification, "persona_api/objects/verification"
16
+ autoload :Case, "persona_api/objects/case"
17
+ autoload :Document, "persona_api/objects/document"
18
+ autoload :Report, "persona_api/objects/report"
19
+ autoload :File, "persona_api/objects/file"
20
+ autoload :Event, "persona_api/objects/event"
21
+ autoload :List, "persona_api/objects/list"
22
+ autoload :ApiLog, "persona_api/objects/api_log"
23
+ autoload :UserAuditLog, "persona_api/objects/user_audit_log"
24
+ autoload :ListItem, "persona_api/objects/list_item"
25
+
26
+ # resources
27
+ autoload :AccountsResource, "persona_api/resources/accounts"
28
+ autoload :InquiriesResource, "persona_api/resources/inquiries"
29
+ autoload :VerificationsResource, "persona_api/resources/verifications"
30
+ autoload :CasesResource, "persona_api/resources/cases"
31
+ autoload :DocumentsResource, "persona_api/resources/documents"
32
+ autoload :ReportsResource, "persona_api/resources/reports"
33
+ autoload :FilesResource, "persona_api/resources/files"
34
+ autoload :EventsResource, "persona_api/resources/events"
35
+ autoload :ListsResource, "persona_api/resources/lists"
36
+ autoload :ApiLogsResource, "persona_api/resources/api_logs"
37
+ autoload :UserAuditLogsResource, "persona_api/resources/user_audit_logs"
38
+ autoload :ListItemsResource, "persona_api/resoruces/list_items"
39
+ end
@@ -0,0 +1,4 @@
1
+ module PersonaApi
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: persona_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.6
5
+ platform: ruby
6
+ authors:
7
+ - Matt Griffith
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-07-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ description: Write more in here later.
42
+ email:
43
+ - mattgriffith0@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".rspec"
49
+ - CHANGELOG.md
50
+ - CODE_OF_CONDUCT.md
51
+ - Gemfile
52
+ - Gemfile.lock
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - lib/persona_api.rb
57
+ - lib/persona_api/client.rb
58
+ - lib/persona_api/collection.rb
59
+ - lib/persona_api/error.rb
60
+ - lib/persona_api/object.rb
61
+ - lib/persona_api/objects/account.rb
62
+ - lib/persona_api/objects/api_log.rb
63
+ - lib/persona_api/objects/case.rb
64
+ - lib/persona_api/objects/document.rb
65
+ - lib/persona_api/objects/event.rb
66
+ - lib/persona_api/objects/file.rb
67
+ - lib/persona_api/objects/inquiry.rb
68
+ - lib/persona_api/objects/list.rb
69
+ - lib/persona_api/objects/list_item.rb
70
+ - lib/persona_api/objects/report.rb
71
+ - lib/persona_api/objects/user_audit_log.rb
72
+ - lib/persona_api/objects/verification.rb
73
+ - lib/persona_api/resource.rb
74
+ - lib/persona_api/resources/accounts.rb
75
+ - lib/persona_api/resources/api_logs.rb
76
+ - lib/persona_api/resources/cases.rb
77
+ - lib/persona_api/resources/documents.rb
78
+ - lib/persona_api/resources/events.rb
79
+ - lib/persona_api/resources/files.rb
80
+ - lib/persona_api/resources/inquiries.rb
81
+ - lib/persona_api/resources/list_items.rb
82
+ - lib/persona_api/resources/lists.rb
83
+ - lib/persona_api/resources/reports.rb
84
+ - lib/persona_api/resources/user_audit_logs.rb
85
+ - lib/persona_api/resources/verifications.rb
86
+ - lib/persona_api/version.rb
87
+ - sig/persona_api.rbs
88
+ homepage: https://github.com/mattgriffith0/persona_api
89
+ licenses:
90
+ - MIT
91
+ metadata:
92
+ homepage_uri: https://github.com/mattgriffith0/persona_api
93
+ source_code_uri: https://github.com/mattgriffith0/persona_api
94
+ changelog_uri: https://github.com/mattgriffith0/persona_api/blob/main/CHANGELOG.md
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 2.6.0
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubygems_version: 3.3.7
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: An API wrapper for the public Persona API.
114
+ test_files: []