use_paragon 0.1.0
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 +7 -0
- data/.github/workflows/main.yml +18 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.rubocop.yml +18 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +21 -0
- data/README.md +141 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/use_paragon/base.rb +63 -0
- data/lib/use_paragon/configuration.rb +14 -0
- data/lib/use_paragon/integration.rb +44 -0
- data/lib/use_paragon/user.rb +21 -0
- data/lib/use_paragon/version.rb +5 -0
- data/lib/use_paragon/workflow.rb +29 -0
- data/lib/use_paragon.rb +25 -0
- data/use_paragon.gemspec +36 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4977ae9bf55dabf8686da9a46c7cf7bcf9fd7f162721a08b49899a9df3b08807
|
4
|
+
data.tar.gz: 790d1f453420f72bc196bbe29d4323cc04d559a0175fff436520deadf3580435
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 560649657f7ecb06819b324347183695301d733f420e257fd5beb197f10f99d997be3184b61c9122a9a0c0bb935e88d0a0d700e51c6a05a10e7b481d06af182f
|
7
|
+
data.tar.gz: 57ea9e04630f118197f49c5f9a8ec3c362f6867d994da518d117db7833cb7b7c27e887b5440d3c077746b9cc6aaf9b3278d69bc207d962fadd3fb5af686ef22c
|
@@ -0,0 +1,18 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push,pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v2
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 3.0.0
|
14
|
+
- name: Run the default task
|
15
|
+
run: |
|
16
|
+
gem install bundler -v 2.2.3
|
17
|
+
bundle install
|
18
|
+
bundle exec rake
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.6
|
3
|
+
|
4
|
+
Style/StringLiterals:
|
5
|
+
Enabled: true
|
6
|
+
EnforcedStyle: double_quotes
|
7
|
+
|
8
|
+
Style/StringLiteralsInInterpolation:
|
9
|
+
Enabled: true
|
10
|
+
EnforcedStyle: double_quotes
|
11
|
+
|
12
|
+
Layout/LineLength:
|
13
|
+
Max: 100
|
14
|
+
|
15
|
+
Metrics/BlockLength:
|
16
|
+
Enabled: true
|
17
|
+
Exclude:
|
18
|
+
- 'spec/**/*_spec.rb'
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -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 eduardo@candanedo.dev. 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
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Eduardo Candanedo
|
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,141 @@
|
|
1
|
+
# UseParagon
|
2
|
+
|
3
|
+
[](https://github.com/candanedo/use_paragon/actions?query=branch%3Amain)
|
4
|
+
[](https://github.com/testdouble/standard)
|
5
|
+
|
6
|
+
The UseParagon Ruby Gem simplifies the interaction with Paragon's service through RESTful API calls, enabling seamless integration of native features into your Ruby applications. With this gem, engineering teams can effortlessly incorporate Paragon's API to accelerate the development of native integrations.
|
7
|
+
|
8
|
+
| API Method | HTTP Method | Supported |
|
9
|
+
|--------------------------------|-------------|-----------|
|
10
|
+
| Disable Workflow | DELETE | ✅ |
|
11
|
+
| Get Integrations Metadata | GET | ✅ |
|
12
|
+
| Get User | GET | ✅ |
|
13
|
+
| Workflow Event (App Events) | POST | ✅ |
|
14
|
+
| Proxy Request | - | ✅ |
|
15
|
+
| Set User Metadata | PATCH | ✅ |
|
16
|
+
| Uninstall Integration | DELETE | ✅ |
|
17
|
+
| Workflow Request (Trigger) | POST | ✅ |
|
18
|
+
| Get Project's Integrations | GET | ✅ |
|
19
|
+
| Get User's Connect Credentials | GET | ✅ |
|
20
|
+
| Task History API | - | ❌ |
|
21
|
+
|
22
|
+
## Installation
|
23
|
+
|
24
|
+
Add the gem to your application's Gemfile by executing:
|
25
|
+
|
26
|
+
$ bundle add use_paragon
|
27
|
+
|
28
|
+
or manually add it to the Gemfile:
|
29
|
+
|
30
|
+
gem "use_paragon"
|
31
|
+
|
32
|
+
Then run:
|
33
|
+
|
34
|
+
bundle install
|
35
|
+
|
36
|
+
If Bundler is not used to manage dependencies, install the gem with:
|
37
|
+
|
38
|
+
$ gem install use_paragon
|
39
|
+
|
40
|
+
## Configuration
|
41
|
+
|
42
|
+
To use the UseParagon gem, you need to configure it with your private key and project ID. Here's an example on how to do it:
|
43
|
+
|
44
|
+
Provide your private key and project ID:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
UseParagon.configure do |config|
|
48
|
+
config.private_key = YOUR_PRIVATE_KEY
|
49
|
+
config.project_id = YOUR_PROJECT_ID
|
50
|
+
# Additional configurations available and defaults.
|
51
|
+
# config.base_url = "https://zeus.useparagon.com"
|
52
|
+
# config.logger = Logger.new(STDOUT)
|
53
|
+
# config.logger_enabled = true
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
## How to use
|
58
|
+
### Disable Workflow
|
59
|
+
(Paragon Documentation)[https://docs.useparagon.com/api/api-reference#disableworkflow-workflowid-string-greater-than-promise]
|
60
|
+
|
61
|
+
Call disable Workflow to turn off a workflow for a user by ID.
|
62
|
+
|
63
|
+
UseParagon::Workflow.new(user_id).disable("workflow_id")
|
64
|
+
|
65
|
+
### Get Integrations Metadata
|
66
|
+
(Paragon Documentation)[https://docs.useparagon.com/api/api-reference#getintegrationmetadata]
|
67
|
+
|
68
|
+
Get the name, brandColor, and icon, for any of your active integration providers.
|
69
|
+
|
70
|
+
UseParagon::Integration.new(user_id).metadata
|
71
|
+
|
72
|
+
### Get User
|
73
|
+
(Paragon Documentation)[https://docs.useparagon.com/api/api-reference#getuser-paragonuser]
|
74
|
+
|
75
|
+
Retrieve the currently authenticated user and their connected integration state.
|
76
|
+
|
77
|
+
UseParagon::User.new(user_id).get
|
78
|
+
|
79
|
+
### Workflow Event (App Events)
|
80
|
+
(Paragon Documentation)[https://docs.useparagon.com/api/api-reference#event-name-string-json-json]
|
81
|
+
|
82
|
+
App Events can be sent from your application using the Paragon REST API.
|
83
|
+
|
84
|
+
UseParagon::Workflow.new(user_id).event(event_name, payload = {})
|
85
|
+
|
86
|
+
### Proxy Request
|
87
|
+
(Paragon Documentation)[https://docs.useparagon.com/api/api-reference#request-integrationtype-string-path-string-requestoptions-requestinit-promise-less-than-unknown-gre]
|
88
|
+
|
89
|
+
Call proxy_request to send an API request to a third-party integration on behalf of one of your users
|
90
|
+
|
91
|
+
This endpoint accepts any HTTP verb you want to use with the API:
|
92
|
+
post, get, put, patch or delete.
|
93
|
+
|
94
|
+
UseParagon::Integration.new(user_id).proxy_request(request_method, integration_type, integration_path, payload = {})
|
95
|
+
|
96
|
+
### Set User Metadata
|
97
|
+
(Paragon Documentation)[https://docs.useparagon.com/api/api-reference#setusermetadata-meta-object]
|
98
|
+
|
99
|
+
Associate the authenticated user with metadata from your application. This metadata can be accessed with "Get User"
|
100
|
+
|
101
|
+
UseParagon::User.new(user_id).metadata=({email: "example@example.com"})
|
102
|
+
|
103
|
+
### Uninstall Integration
|
104
|
+
(Paragon Documentation)[https://docs.useparagon.com/api/api-reference#workflow]
|
105
|
+
|
106
|
+
Disconnect an integration for the authenticated user
|
107
|
+
|
108
|
+
UseParagon::Integration.new(user_id).uninstall(integration_id)
|
109
|
+
|
110
|
+
### Workflow Request (Trigger)
|
111
|
+
(Paragon Documentation)[https://docs.useparagon.com/api/api-reference#workflow-1]
|
112
|
+
|
113
|
+
Trigger a Paragon workflow that sends a custom response back to your app. Note: The workflow must be enabled and use a Request-type trigger.
|
114
|
+
|
115
|
+
UseParagon::Workflow.new(user_id).request(workflow_id, payload = {})
|
116
|
+
|
117
|
+
### Get Project's Integrations
|
118
|
+
(Paragon Documentation)[https://docs.useparagon.com/api/api-reference#get-projects-integrations]
|
119
|
+
|
120
|
+
Returns a list of the integrations enabled for the Paragon project by the ID in the URL.
|
121
|
+
|
122
|
+
UseParagon::Integration.new(user_id).list
|
123
|
+
|
124
|
+
### Get User's Connect Credentials
|
125
|
+
(Paragon Documentation)[https://docs.useparagon.com/api/api-reference#get-users-connect-credentials]
|
126
|
+
|
127
|
+
Returns a list of the user's Connect credentials (i.e., the accounts connected and authorized by the end user).
|
128
|
+
|
129
|
+
UseParagon::User.new(user_id).credentials
|
130
|
+
|
131
|
+
## Contributing
|
132
|
+
|
133
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/candanedo/use_paragon. 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/candanedo/use_paragon/blob/main/CODE_OF_CONDUCT.md).
|
134
|
+
|
135
|
+
## License
|
136
|
+
|
137
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
138
|
+
|
139
|
+
## Code of Conduct
|
140
|
+
|
141
|
+
Everyone interacting in the UseParagon project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/candanedo/use_paragon/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "use_paragon"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "faraday"
|
4
|
+
require "jwt"
|
5
|
+
|
6
|
+
module UseParagon
|
7
|
+
# Basic logic for interacting with UseParagon platform
|
8
|
+
# Handles authentication and requests to Paragon API base on:
|
9
|
+
# https://docs.useparagon.com/getting-started/installing-the-connect-sdk#setup-with-your-own-authentication-backend
|
10
|
+
class Base
|
11
|
+
attr_reader :token, :user_id
|
12
|
+
|
13
|
+
def initialize(user_id)
|
14
|
+
@user_id = user_id
|
15
|
+
@token = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def generate_token
|
19
|
+
# Paragon User Token for each of your authenticated user
|
20
|
+
validate_user_id!
|
21
|
+
|
22
|
+
rsa_private = OpenSSL::PKey::RSA.new(config.private_key)
|
23
|
+
created_at = Time.now.floor.to_i
|
24
|
+
|
25
|
+
payload = {
|
26
|
+
sub: user_id,
|
27
|
+
iat: created_at,
|
28
|
+
exp: created_at + 60 * 60
|
29
|
+
}
|
30
|
+
|
31
|
+
@token = JWT.encode payload, rsa_private, "RS256"
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def connection
|
37
|
+
@connection ||= Faraday.new do |conn|
|
38
|
+
conn.url_prefix = config.base_url
|
39
|
+
conn.request :authorization, "Bearer", generate_token
|
40
|
+
conn.request :json
|
41
|
+
|
42
|
+
if config.logger_enabled
|
43
|
+
conn.response :logger, config.logger, { errors: true, bodies: true }
|
44
|
+
end
|
45
|
+
|
46
|
+
conn.response :json, content_type: "application/json"
|
47
|
+
conn.response :raise_error
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def path(endpoint)
|
52
|
+
"/projects/#{config.project_id}/#{endpoint}"
|
53
|
+
end
|
54
|
+
|
55
|
+
def validate_user_id!
|
56
|
+
raise UseParagon::InvalidUserIdError if user_id.nil? || user_id.to_s.empty?
|
57
|
+
end
|
58
|
+
|
59
|
+
def config
|
60
|
+
UseParagon.configuration
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UseParagon
|
4
|
+
# Allows configuration using an initializer
|
5
|
+
class Configuration
|
6
|
+
attr_accessor :private_key, :project_id, :base_url, :logger, :logger_enabled
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@base_url = "https://zeus.useparagon.com"
|
10
|
+
@logger = Logger.new(STDOUT)
|
11
|
+
@logger_enabled = true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "use_paragon/base"
|
4
|
+
|
5
|
+
module UseParagon
|
6
|
+
# https://docs.useparagon.com/api/users#disconnecting-integrations
|
7
|
+
class Integration < Base
|
8
|
+
VALID_HTTP_METHODS = %w[post get put patch delete].freeze
|
9
|
+
|
10
|
+
def list
|
11
|
+
connection.get(path("sdk/integrations"))
|
12
|
+
end
|
13
|
+
|
14
|
+
def metadata
|
15
|
+
connection.get(path("sdk/metadata"))
|
16
|
+
end
|
17
|
+
|
18
|
+
def proxy_request(request_method, integration_type, integration_path, payload = {})
|
19
|
+
formatted_method = request_method&.downcase
|
20
|
+
|
21
|
+
validate_proxy_http_method(formatted_method)
|
22
|
+
|
23
|
+
connection.send(
|
24
|
+
formatted_method,
|
25
|
+
path("sdk/proxy/#{integration_type}/#{integration_path}"),
|
26
|
+
payload
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def uninstall(integration_id)
|
31
|
+
connection.delete(path("sdk/integrations/#{integration_id}"))
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def validate_proxy_http_method(formatted_method)
|
37
|
+
return if VALID_HTTP_METHODS.include?(formatted_method)
|
38
|
+
|
39
|
+
raise ArgumentError,
|
40
|
+
"Invalid request method: #{formatted_method}. " \
|
41
|
+
"Allowed methods: #{VALID_HTTP_METHODS.join(", ")}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "use_paragon/base"
|
4
|
+
|
5
|
+
module UseParagon
|
6
|
+
# https://docs.useparagon.com/api/api-reference#getuser-paragonuser
|
7
|
+
# Retrieve the currently authenticated user and their connected integration state
|
8
|
+
class User < Base
|
9
|
+
def get
|
10
|
+
connection.get(path("sdk/me"))
|
11
|
+
end
|
12
|
+
|
13
|
+
def metadata=(metadata)
|
14
|
+
connection.patch(path("sdk/me"), metadata)
|
15
|
+
end
|
16
|
+
|
17
|
+
def credentials
|
18
|
+
connection.get(path("sdk/credentials"))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "use_paragon/base"
|
4
|
+
|
5
|
+
module UseParagon
|
6
|
+
# API calls for workflows
|
7
|
+
class Workflow < Base
|
8
|
+
def request(workflow_id, payload = {})
|
9
|
+
connection.post(path("sdk/triggers/#{workflow_id}"), payload)
|
10
|
+
end
|
11
|
+
|
12
|
+
def event(event_name, payload = {})
|
13
|
+
connection.post(path("sdk/events/trigger"), event_payload(event_name, payload))
|
14
|
+
end
|
15
|
+
|
16
|
+
def disable(workflow_id)
|
17
|
+
connection.delete(path("sdk/workflows/#{workflow_id}"))
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def event_payload(event_name, payload)
|
23
|
+
{
|
24
|
+
name: event_name,
|
25
|
+
payload: payload
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/use_paragon.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "use_paragon/configuration"
|
4
|
+
require "use_paragon/base"
|
5
|
+
require "use_paragon/integration"
|
6
|
+
require "use_paragon/user"
|
7
|
+
require "use_paragon/version"
|
8
|
+
require "use_paragon/workflow"
|
9
|
+
|
10
|
+
# UseParagon gem base module
|
11
|
+
module UseParagon
|
12
|
+
class Error < StandardError; end
|
13
|
+
class InvalidUserIdError < StandardError; end
|
14
|
+
|
15
|
+
# Configuration from initializer
|
16
|
+
class << self
|
17
|
+
def configuration
|
18
|
+
@configuration ||= Configuration.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def configure
|
22
|
+
yield(configuration)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/use_paragon.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/use_paragon/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "use_paragon"
|
7
|
+
spec.version = UseParagon::VERSION
|
8
|
+
spec.authors = ["Eduardo Candanedo"]
|
9
|
+
spec.email = ["eduardo@candanedo.dev"]
|
10
|
+
|
11
|
+
spec.summary = "Ship every native integration your customers need."
|
12
|
+
spec.description = "Product & engineering teams use Paragon's SDK & embedded
|
13
|
+
iPaaS to ship native integrations 7x faster than building in-house. This Gem
|
14
|
+
will allow you to seamlessly connect to the Paragon platform via API"
|
15
|
+
spec.homepage = "https://github.com/candanedo/use_paragon"
|
16
|
+
spec.license = "MIT"
|
17
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
|
18
|
+
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
20
|
+
|
21
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
22
|
+
spec.metadata["source_code_uri"] = "https://github.com/candanedo/use_paragon"
|
23
|
+
spec.metadata["changelog_uri"] = "https://github.com/candanedo/use_paragon"
|
24
|
+
|
25
|
+
# Specify which files should be added to the gem when it is released.
|
26
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
27
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
28
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
29
|
+
end
|
30
|
+
spec.bindir = "exe"
|
31
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
|
34
|
+
spec.add_dependency "faraday"
|
35
|
+
spec.add_dependency "jwt"
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: use_paragon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eduardo Candanedo
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-03-13 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: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: jwt
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: |-
|
42
|
+
Product & engineering teams use Paragon's SDK & embedded
|
43
|
+
iPaaS to ship native integrations 7x faster than building in-house. This Gem
|
44
|
+
will allow you to seamlessly connect to the Paragon platform via API
|
45
|
+
email:
|
46
|
+
- eduardo@candanedo.dev
|
47
|
+
executables: []
|
48
|
+
extensions: []
|
49
|
+
extra_rdoc_files: []
|
50
|
+
files:
|
51
|
+
- ".github/workflows/main.yml"
|
52
|
+
- ".gitignore"
|
53
|
+
- ".rspec"
|
54
|
+
- ".rubocop.yml"
|
55
|
+
- CODE_OF_CONDUCT.md
|
56
|
+
- Gemfile
|
57
|
+
- LICENSE.txt
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- bin/console
|
61
|
+
- bin/setup
|
62
|
+
- lib/use_paragon.rb
|
63
|
+
- lib/use_paragon/base.rb
|
64
|
+
- lib/use_paragon/configuration.rb
|
65
|
+
- lib/use_paragon/integration.rb
|
66
|
+
- lib/use_paragon/user.rb
|
67
|
+
- lib/use_paragon/version.rb
|
68
|
+
- lib/use_paragon/workflow.rb
|
69
|
+
- use_paragon.gemspec
|
70
|
+
homepage: https://github.com/candanedo/use_paragon
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata:
|
74
|
+
allowed_push_host: https://rubygems.org
|
75
|
+
homepage_uri: https://github.com/candanedo/use_paragon
|
76
|
+
source_code_uri: https://github.com/candanedo/use_paragon
|
77
|
+
changelog_uri: https://github.com/candanedo/use_paragon
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 2.6.0
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubygems_version: 3.2.3
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Ship every native integration your customers need.
|
97
|
+
test_files: []
|