Skip to content

Commit

Permalink
Update README file
Browse files Browse the repository at this point in the history
  • Loading branch information
candanedo committed Mar 7, 2024
1 parent a2cb7c9 commit 6401348
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 46 deletions.
102 changes: 72 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@

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.

| API Method | REST Method | Supported | Gem's Class | Method |
|--------------------------------|-------------|-----------|-------------------------|---------------------------------------------------------------------------------|
| Disable Workflow | DELETE | [x] | UseParagon::Workflow | disable(workflow_id) |
| Get Integrations Metadata | GET | [x] | UseParagon::Integration | metadata |
| Get User | GET | [x] | UseParagon::User | get |
| Workflow Event (App Events) | POST | [x] | UseParagon::Workflow | event(event_name, payload = {}) |
| Proxy Request | | [x] | UseParagon::Workflow | proxy_request(request_method, integration_type, integration_path, payload = {}) |
| Set User Metadata | PATCH | [x] | UseParagon::User | metadata=(metadata) |
| Uninstall Integration | DELETE | [x] | UseParagon::Integration | uninstall(integration_id) |
| Workflow Request (Trigger) | POST | [x] | UseParagon::Workflow | request(workflow_id, payload = {}) |
| Get Project's Integrations | GET | [x] | UseParagon::Integration | list |
| Get User's Connect Credentials | GET | [x] | UseParagon::User | credentials |
| API Method | HTTP Method | Supported |
|--------------------------------|-------------|-----------|
| Disable Workflow | DELETE ||
| Get Integrations Metadata | GET ||
| Get User | GET ||
| Workflow Event (App Events) | POST ||
| Proxy Request | - ||
| Set User Metadata | PATCH ||
| Uninstall Integration | DELETE ||
| Workflow Request (Trigger) | POST ||
| Get Project's Integrations | GET ||
| Get User's Connect Credentials | GET ||
| Task History API | - ||

## Installation

Expand Down Expand Up @@ -46,46 +47,87 @@ Provide your private key and project ID:
UseParagon.configure do |config|
config.private_key = YOUR_PRIVATE_KEY
config.project_id = YOUR_PROJECT_ID
# Additional configurations available and defaults.
# config.base_url = "https://zeus.useparagon.com"
# config.logger = Logger.new(STDOUT)
# config.logger_enabled = true
end
```

### Workflow triggers
#### Request trigger
## How to use
### Disable Workflow
(Paragon Documentation)[https://docs.useparagon.com/api/api-reference#disableworkflow-workflowid-string-greater-than-promise]

The Request trigger can be used to run workflows by sending it an HTTP request. To trigger a workflow request, use the following code:
Call disable Workflow to turn off a workflow for a user by ID.

UseParagon::Workflow.new(user_id).request("workflow_id", {})
UseParagon::Workflow.new(user_id).disable("workflow_id")

Here, the first parameter is the endpoint of the workflow trigger, and the second one is the payload the workflow expects.
### Get Integrations Metadata
(Paragon Documentation)[https://docs.useparagon.com/api/api-reference#getintegrationmetadata]

#### Event trigger

App Events are custom events that are sent programmatically from your application via the Paragon SDK or API to trigger Workflows. To trigger a workflow event, use the following code:

UseParagon::Workflow.new(user_id).event("Create Contact", {})
Get the name, brandColor, and icon, for any of your active integration providers.

Here, the first parameter is the App event, and the second one is the payload the workflow expects.
UseParagon::Integration.new(user_id).metadata

### User API
### Get User
(Paragon Documentation)[https://docs.useparagon.com/api/api-reference#getuser-paragonuser]

Retrieve the currently authenticated user and their connected integration state.

UseParagon::User.new(user_id).get

### Integration API
### Workflow Event (App Events)
(Paragon Documentation)[https://docs.useparagon.com/api/api-reference#event-name-string-json-json]

Get the name, brandColor, and icon, for any of your active integration providers.
App Events can be sent from your application using the Paragon REST API.

UseParagon::Integration.new(user_id).metadata
UseParagon::Workflow.new(user_id).event(event_name, payload = {})

Returns a list of the integrations enabled for the Paragon project by the ID in the URL.
### Proxy Request
(Paragon Documentation)[https://docs.useparagon.com/api/api-reference#request-integrationtype-string-path-string-requestoptions-requestinit-promise-less-than-unknown-gre]

UseParagon::Integration.new(user_id).list
Call proxy_request to send an API request to a third-party integration on behalf of one of your users

This endpoint accepts any HTTP verb you want to use with the API:
post, get, put, patch or delete.

UseParagon::Integration.new(user_id).proxy_request(request_method, integration_type, integration_path, payload = {})

### Set User Metadata
(Paragon Documentation)[https://docs.useparagon.com/api/api-reference#setusermetadata-meta-object]

Associate the authenticated user with metadata from your application. This metadata can be accessed with "Get User"

UseParagon::User.new(user_id).metadata=({email: "[email protected]"})

Integrations can be disconnected using paragon.uninstallIntegration or with the REST API with:
### Uninstall Integration
(Paragon Documentation)[https://docs.useparagon.com/api/api-reference#workflow]

Disconnect an integration for the authenticated user

UseParagon::Integration.new(user_id).uninstall(integration_id)

### Workflow Request (Trigger)
(Paragon Documentation)[https://docs.useparagon.com/api/api-reference#workflow-1]

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.

UseParagon::Workflow.new(user_id).request(workflow_id, payload = {})

### Get Project's Integrations
(Paragon Documentation)[https://docs.useparagon.com/api/api-reference#get-projects-integrations]

Returns a list of the integrations enabled for the Paragon project by the ID in the URL.

UseParagon::Integration.new(user_id).list

### Get User's Connect Credentials
(Paragon Documentation)[https://docs.useparagon.com/api/api-reference#get-users-connect-credentials]

Returns a list of the user's Connect credentials (i.e., the accounts connected and authorized by the end user).

UseParagon::User.new(user_id).credentials

## Contributing

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).
Expand Down
9 changes: 0 additions & 9 deletions lib/use_paragon/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,14 @@ module UseParagon
class Integration < Base
VALID_HTTP_METHODS = %w[post get put patch delete].freeze

# Returns a list of the integrations enabled for the Paragon project by the ID in the URL.
def list
connection.get(path("sdk/integrations"))
end

# Get the name, brandColor, and icon, for any of your active integration providers.
def metadata
connection.get(path("sdk/metadata"))
end

# Call proxy_request to send an API request to a third-party integration on behalf of
# one of your users
# https://docs.useparagon.com/api/making-api-requests#server-side-usage
# This endpoint accepts any HTTP verb you want to use with the API:
# post, get, put, patch or delete.
# Body contents must be specified as application/json.
def proxy_request(request_method, integration_type, integration_path, payload = {})
formatted_method = request_method&.downcase

Expand All @@ -35,7 +27,6 @@ def proxy_request(request_method, integration_type, integration_path, payload =
)
end

# Integrations can be disconnected using uninstall via REST API.
def uninstall(integration_id)
connection.delete(path("sdk/integrations/#{integration_id}"))
end
Expand Down
3 changes: 0 additions & 3 deletions lib/use_paragon/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ def get
connection.get(path("sdk/me"))
end

# Call set_metadata to associate the authenticated user with metadata from
# your application
# { "meta": { "Email": "[email protected]", "apiKey": "key_Y0kBVldPFInxK" } }
def metadata=(metadata)
connection.patch(path("sdk/me"), metadata)
end
Expand Down
5 changes: 1 addition & 4 deletions lib/use_paragon/workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@
require "use_paragon/base"

module UseParagon
# https://docs.useparagon.com/workflows/triggers#request
# API calls for workflows
class Workflow < Base
# The Request trigger can be used to run workflows by sending it an HTTP request
def request(workflow_id, payload = {})
connection.post(path("sdk/triggers/#{workflow_id}"), payload)
end

# App Events can be sent from your application using the Paragon REST API.
def event(event_name, payload = {})
connection.post(path("sdk/events/trigger"), event_payload(event_name, payload))
end

# Call disable Workflow to turn off a workflow for a user by ID.
def disable(workflow_id)
connection.delete(path("sdk/workflows/#{workflow_id}"))
end
Expand Down

0 comments on commit 6401348

Please sign in to comment.