persona-ruby 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: 1ee36ffc57f06970c8199420290d73f294e6664fa3a742420837d3d15238b6c7
4
+ data.tar.gz: 637973e9ae19df541886e97e97694ca7c62bce3108e5df6a8efacb3b1bc91864
5
+ SHA512:
6
+ metadata.gz: 85c6172d9f5b815de9cc999aa6c29e74edf95bd55b26e17c4e5c258b98c7883b155b8aecb4fb6ce926b72621f358b954b87907adf16bcf9717d33598d4de9630
7
+ data.tar.gz: 0b51f987d9e6e713f7047a5d379f7710b07e78d012256e0dbdccc99c6162d7074f051225f734e219d686ce1c3a917b4dd7bd45408a5fb6b1dad236666127b0f6
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,49 @@
1
+ require:
2
+ - rubocop-rspec
3
+
4
+ AllCops:
5
+ NewCops: enable
6
+ SuggestExtensions: false
7
+ TargetRubyVersion: 2.6
8
+
9
+ Metrics/BlockLength:
10
+ Enabled: true
11
+ Exclude:
12
+ - spec/**/*
13
+
14
+ Naming/FileName:
15
+ Enabled: true
16
+ Exclude:
17
+ - lib/persona-ruby.rb
18
+
19
+ RSpec/ExampleLength:
20
+ Enabled: false
21
+
22
+ RSpec/FilePath:
23
+ Enabled: false
24
+
25
+ RSpec/InstanceVariable:
26
+ Enabled: false
27
+
28
+ RSpec/MultipleMemoizedHelpers:
29
+ Enabled: false
30
+
31
+ RSpec/SubjectStub:
32
+ Enabled: false
33
+
34
+ RSpec/VerifiedDoubles:
35
+ Enabled: false
36
+
37
+ Style/Documentation:
38
+ Enabled: false
39
+
40
+ Style/StringLiterals:
41
+ Enabled: true
42
+ EnforcedStyle: double_quotes
43
+
44
+ Style/StringLiteralsInInterpolation:
45
+ Enabled: true
46
+ EnforcedStyle: double_quotes
47
+
48
+ Layout/LineLength:
49
+ Max: 150
data/CHANGELOG.md ADDED
@@ -0,0 +1 @@
1
+ ## [Unreleased]
@@ -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 me@jordanell.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.
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,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "faraday", ">= 2.0.1"
6
+
7
+ group :development, :test do
8
+ gem "rake", "~> 13.0.6"
9
+ gem "rspec", "~> 3.12.0"
10
+ gem "rspec_junit_formatter", "~> 0.6.0"
11
+ gem "rubocop", "~> 1.52.1"
12
+ gem "rubocop-rspec", "~> 2.22.0"
13
+ gem "webmock", "~> 3.18.1"
14
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,87 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.8.6)
5
+ public_suffix (>= 2.0.2, < 6.0)
6
+ ast (2.4.2)
7
+ bigdecimal (3.1.7)
8
+ crack (1.0.0)
9
+ bigdecimal
10
+ rexml
11
+ diff-lcs (1.5.1)
12
+ faraday (2.9.0)
13
+ faraday-net_http (>= 2.0, < 3.2)
14
+ faraday-net_http (3.1.0)
15
+ net-http
16
+ hashdiff (1.1.0)
17
+ json (2.7.2)
18
+ net-http (0.4.1)
19
+ uri
20
+ parallel (1.24.0)
21
+ parser (3.3.0.5)
22
+ ast (~> 2.4.1)
23
+ racc
24
+ public_suffix (5.0.5)
25
+ racc (1.7.3)
26
+ rainbow (3.1.1)
27
+ rake (13.0.6)
28
+ regexp_parser (2.9.0)
29
+ rexml (3.2.6)
30
+ rspec (3.12.0)
31
+ rspec-core (~> 3.12.0)
32
+ rspec-expectations (~> 3.12.0)
33
+ rspec-mocks (~> 3.12.0)
34
+ rspec-core (3.12.3)
35
+ rspec-support (~> 3.12.0)
36
+ rspec-expectations (3.12.4)
37
+ diff-lcs (>= 1.2.0, < 2.0)
38
+ rspec-support (~> 3.12.0)
39
+ rspec-mocks (3.12.7)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.12.0)
42
+ rspec-support (3.12.2)
43
+ rspec_junit_formatter (0.6.0)
44
+ rspec-core (>= 2, < 4, != 2.12.0)
45
+ rubocop (1.52.1)
46
+ json (~> 2.3)
47
+ parallel (~> 1.10)
48
+ parser (>= 3.2.2.3)
49
+ rainbow (>= 2.2.2, < 4.0)
50
+ regexp_parser (>= 1.8, < 3.0)
51
+ rexml (>= 3.2.5, < 4.0)
52
+ rubocop-ast (>= 1.28.0, < 2.0)
53
+ ruby-progressbar (~> 1.7)
54
+ unicode-display_width (>= 2.4.0, < 3.0)
55
+ rubocop-ast (1.31.2)
56
+ parser (>= 3.3.0.4)
57
+ rubocop-capybara (2.20.0)
58
+ rubocop (~> 1.41)
59
+ rubocop-factory_bot (2.25.1)
60
+ rubocop (~> 1.41)
61
+ rubocop-rspec (2.22.0)
62
+ rubocop (~> 1.33)
63
+ rubocop-capybara (~> 2.17)
64
+ rubocop-factory_bot (~> 2.22)
65
+ ruby-progressbar (1.13.0)
66
+ unicode-display_width (2.5.0)
67
+ uri (0.13.0)
68
+ webmock (3.18.1)
69
+ addressable (>= 2.8.0)
70
+ crack (>= 0.3.2)
71
+ hashdiff (>= 0.4.0, < 2.0.0)
72
+
73
+ PLATFORMS
74
+ ruby
75
+ x86_64-darwin-23
76
+
77
+ DEPENDENCIES
78
+ faraday (>= 2.0.1)
79
+ rake (~> 13.0.6)
80
+ rspec (~> 3.12.0)
81
+ rspec_junit_formatter (~> 0.6.0)
82
+ rubocop (~> 1.52.1)
83
+ rubocop-rspec (~> 2.22.0)
84
+ webmock (~> 3.18.1)
85
+
86
+ BUNDLED WITH
87
+ 2.5.3
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Riipen
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,85 @@
1
+ # persona-ruby
2
+ Persona is a service which is used to collect, verify, understand and orchestrate customer identities.
3
+ This API is designed to allow Ruby developers to interact with the Persona API programmatically.
4
+
5
+ For reference, the Persona API documentation can be found here:
6
+
7
+ https://docs.withpersona.com/docs
8
+
9
+ ## Install
10
+
11
+ Add to your `Gemfile`:
12
+
13
+ ```ruby
14
+ gem 'persona-ruby'
15
+ ```
16
+
17
+ Then `bundle install`.
18
+
19
+
20
+ ## Usage
21
+
22
+ ### API Client
23
+
24
+ The Persona API client uses an access token to authenticate API requests.
25
+
26
+ To obtain an access code you must visit the Persona Dashboard (https://app.withpersona.com/dashboard/api-keys).
27
+
28
+ Then you can create a Persona API client.
29
+
30
+ ```ruby
31
+ client = Persona::Client.new(
32
+ access_token: 'access_token', # Access token from authorization flow
33
+ )
34
+ ```
35
+
36
+ ### API Endpoints
37
+
38
+ For use of each endpoint please consult the [Persona API reference](https://docs.withpersona.com/reference/introduction).
39
+
40
+ ### List Inquiries
41
+
42
+ [API docs](https://docs.withpersona.com/reference/list-all-inquiries)
43
+
44
+ Example: `client.inquiry_list()`
45
+
46
+ ### Get Inquiry
47
+
48
+ [API docs](https://docs.withpersona.com/reference/retrieve-an-inquiry)
49
+
50
+ Example: `client.inquiry_get('abcd1234')`
51
+
52
+ ### Create Inquiry
53
+
54
+ [API docs](https://docs.withpersona.com/reference/create-an-inquiry)
55
+
56
+ Example: `client.inquiry_create(data = {"attribute1": "abc", "attribute2": "vcdf"})`
57
+
58
+ ### Update Inquiry Update
59
+
60
+ [API docs](https://docs.withpersona.com/reference/update-an-inquiry)
61
+
62
+ Example: `client.inquiry_update('abcd1234', data = {"attribute1": "abc", "attribute2": "vcdf"})`
63
+
64
+ ### Delete Inquiry
65
+
66
+ [API docs](https://docs.withpersona.com/reference/redact-an-inquiry)
67
+
68
+ Example: `client.inquiry_update('abcd1234')`
69
+
70
+ ### Errors
71
+
72
+ Any error code returned by the Persona API will result in one of the following expections
73
+
74
+ |Code|Exception|
75
+ |----|---------|
76
+ |400| Persona::BadRequest|
77
+ |401| Persona::Unauthorized|
78
+ |403| Persona::Forbidden|
79
+ |404| Persona::NotFound|
80
+ |429| Persona::TooManyRequests|
81
+ |400...499| Persona::ClientError|
82
+ |500| Persona::InternalServerError|
83
+ |502| Persona::BadGateway|
84
+ |503| Persona::ServiceUnavailable|
85
+ |500...599| Persona::ServerError|
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,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Persona
4
+ module Actions
5
+ module Inquiries
6
+ def inquiry_list
7
+ connection.get("inquiries", {})
8
+ end
9
+
10
+ def inquiry_get(id)
11
+ connection.get("inquiries/#{id}", {})
12
+ end
13
+
14
+ def inquiry_create(attributes = {})
15
+ connection.post("inquiries", {data: { attributes:}})
16
+ end
17
+
18
+ def inquiry_update(id, attributes = {})
19
+ connection.patch("inquiries/#{id}", {data: {attributes:}})
20
+ end
21
+
22
+ def inquiry_delete(id)
23
+ connection.delete("inquiries/#{id}", {})
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Persona
4
+ class Client
5
+ include Persona::Actions::Inquiries
6
+ attr_reader :url
7
+
8
+ BASE_URL = "https://withpersona.com/api/v1"
9
+
10
+ def initialize(access_token:)
11
+ @access_token = "Bearer #{access_token}"
12
+ @url = BASE_URL
13
+ end
14
+
15
+ def connection
16
+ Connection.new(@url, @access_token)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+
5
+ module Persona
6
+ class Connection
7
+ def initialize(url, auth_token)
8
+ @connection = Faraday.new(url: url) do |builder|
9
+ builder.request :json
10
+ builder.headers[:accept] = "application/json"
11
+ builder.response :json
12
+ builder.request :authorization, auth_token, ""
13
+ end
14
+ end
15
+
16
+ def delete(path, params = {})
17
+ request(:delete, path, params)
18
+ end
19
+
20
+ def get(path, params = {})
21
+ request(:get, path, params)
22
+ end
23
+
24
+ def patch(path, params = {})
25
+ request(:patch, path, params)
26
+ end
27
+
28
+ def post(path, params = {})
29
+ request(:post, path, params)
30
+ end
31
+
32
+ def request(method, path, params = {})
33
+ response = @connection.send(method, path, params)
34
+
35
+ error = Error.from_response(response)
36
+
37
+ raise error if error
38
+
39
+ response.body
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Persona
4
+ class Error < StandardError
5
+ attr_reader :response
6
+
7
+ def self.from_response(response)
8
+ klass =
9
+ case response.status
10
+ when 400 then BadRequest
11
+ when 401 then Unauthorized
12
+ when 403 then Forbidden
13
+ when 404 then NotFound
14
+ when 429 then TooManyRequests
15
+ when 400..499 then ClientError
16
+ when 500 then InternalServerError
17
+ when 502 then BadGateway
18
+ when 503 then ServiceUnavailable
19
+ when 500..599 then ServerError
20
+ end
21
+
22
+ klass&.new(response)
23
+ end
24
+
25
+ def initialize(response = nil)
26
+ @response = response
27
+ super(build_error_message)
28
+ end
29
+
30
+ private
31
+
32
+ def build_error_message
33
+ return nil if @response.nil?
34
+
35
+ @response.body
36
+ end
37
+ end
38
+
39
+ class ClientError < Error; end
40
+ class BadRequest < Error; end
41
+ class Unauthorized < Error; end
42
+ class Forbidden < Error; end
43
+ class NotFound < Error; end
44
+ class TooManyRequests < Error; end
45
+ class ServerError < Error; end
46
+ class InternalServerError < Error; end
47
+ class ServiceUnavailable < Error; end
48
+ class BadGateway < Error; end
49
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Persona
4
+ VERSION = "0.1.1"
5
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.dirname(__FILE__)
4
+
5
+ require "persona-ruby/actions/inquiries"
6
+ require "persona-ruby/client"
7
+ require "persona-ruby/connection"
8
+ require "persona-ruby/error"
9
+ require "persona-ruby/version"
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: persona-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Ravi Trivedi
8
+ - Stephen Tredger
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2024-04-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: faraday
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: 2.0.1
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: 2.0.1
28
+ description: Access the Persona REST API.
29
+ email:
30
+ - stephen.tredger@riipen.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".rspec"
36
+ - ".rubocop.yml"
37
+ - CHANGELOG.md
38
+ - CODE_OF_CONDUCT.md
39
+ - Gemfile
40
+ - Gemfile.lock
41
+ - LICENSE
42
+ - README.md
43
+ - Rakefile
44
+ - lib/persona-ruby.rb
45
+ - lib/persona-ruby/actions/inquiries.rb
46
+ - lib/persona-ruby/client.rb
47
+ - lib/persona-ruby/connection.rb
48
+ - lib/persona-ruby/error.rb
49
+ - lib/persona-ruby/version.rb
50
+ homepage: https://github.com/riipen/persona-ruby
51
+ licenses:
52
+ - MIT
53
+ metadata:
54
+ homepage_uri: https://github.com/riipen/persona-ruby
55
+ source_code_uri: https://github.com/riipen/persona-ruby
56
+ changelog_uri: https://github.com/riipen/persona-ruby/blob/master/CHANGELOG.md
57
+ rubygems_mfa_required: 'true'
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 2.6.0
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubygems_version: 3.5.3
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: An API client for Persona in ruby.
77
+ test_files: []