-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Gorgias ticket messages functionality #19027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ffcd7a4
Sage CRM implementation
AdminAdi f403cec
Improved Sage CRM
AdminAdi 2dfcf03
Pr
AdminAdi 3ddbadc
Merge branch 'master' into master
AdminAdi eb01363
Merge branch 'master' into master
AdminAdi 4dac419
update pr
AdminAdi 37da06e
Merge branch 'master' of https://github.com/AdminAdi/pipedream
AdminAdi 47412d2
Merge branch 'master' into master
AdminAdi 3d8b871
Gorgias ticket messages functionality
AdminAdi 85f09e1
Merge branch 'master' into master
AdminAdi a6a11d3
Merge branch 'master' into master
AdminAdi dc7d6bf
Updated Pr
AdminAdi 74cb107
Merge branch 'master' of https://github.com/AdminAdi/pipedream
AdminAdi f4135c8
remove unecessary files
michelle0927 6703b0e
updates
michelle0927 c4ef295
versions
michelle0927 670ef52
updates
michelle0927 f5733a5
update messageId prop
michelle0927 0ea131f
Merge branch 'master' into master
michelle0927 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # Sage CRM API Client Implementation | ||
|
|
||
| ## Why | ||
| This PR introduces a modern Python client for interacting with Sage CRM's REST API, providing a more maintainable and type-safe way to manage tickets and other CRM entities. The implementation follows Python best practices and includes comprehensive error handling and rate limiting. | ||
|
|
||
| ## What's New | ||
| - Modern Python client for Sage CRM API with type hints (Python 3.8+) | ||
| - Comprehensive error handling with custom exceptions | ||
| - Built-in rate limiting to prevent API abuse | ||
| - Input validation and type checking | ||
| - Detailed logging for debugging | ||
| - Example usage with environment variables | ||
|
|
||
| ## Implementation Details | ||
|
|
||
| ### Core Features | ||
| - **Authentication**: Secure Basic Auth with proper credential handling | ||
| - **Rate Limiting**: Configurable request throttling (default: 10 requests/second) | ||
| - **Error Handling**: | ||
| - Custom exceptions for common error cases | ||
| - Detailed error messages with context | ||
| - Proper HTTP status code handling | ||
|
|
||
| ### API Methods | ||
| - `get_tickets()`: List tickets with optional filtering | ||
| - `get_ticket()`: Retrieve a single ticket by ID | ||
| - `create_ticket()`: Create new tickets | ||
| - `update_ticket()`: Modify existing tickets | ||
| - `delete_ticket()`: Remove tickets | ||
|
|
||
| ### Development Setup | ||
| 1. Install dependencies: | ||
| ```bash | ||
| pip install requests python-dotenv | ||
| ``` | ||
|
|
||
| 2. Set up environment variables (`.env` file): | ||
| ``` | ||
| SAGE_CRM_URL=https://your-company.crm.sage.com | ||
| SAGE_CRM_USERNAME=your_username | ||
| SAGE_CRM_PASSWORD=your_password | ||
| ``` | ||
|
|
||
| 3. Run the example: | ||
| ```bash | ||
| python sage_crm_client.py | ||
| ``` | ||
|
|
||
| ## Testing | ||
| The implementation includes example usage in the `__main__` block that demonstrates: | ||
| - Listing open tickets | ||
| - Creating a new ticket | ||
| - Updating the ticket status | ||
| - Error handling for common scenarios | ||
|
|
||
| ## Security | ||
| - Credentials are never logged | ||
| - HTTPS is enforced for all API requests | ||
| - Rate limiting prevents accidental API abuse | ||
|
|
||
| ## Future Improvements | ||
| - Add support for more Sage CRM entities | ||
| - Implement pagination for large result sets | ||
| - Add async/await support | ||
| - Include unit tests and CI/CD pipeline |
33 changes: 33 additions & 0 deletions
33
components/gorgias_oauth/actions/get-ticket-message/get-ticket-message.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { defineAction } from "@pipedream/types"; | ||
| import gorgiasOAuth from "../../gorgias_oauth.app.mjs"; | ||
|
|
||
| export default defineAction({ | ||
| name: "Get Ticket Message", | ||
| description: "Get a specific message from a ticket [See docs here](https://developers.gorgias.com/reference/get-ticket-message)", | ||
| key: "gorgias_oauth-get-ticket-message", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| gorgiasOAuth, | ||
| ticketId: { | ||
| propDefinition: [ | ||
| gorgiasOAuth, | ||
| "ticketId", | ||
| ], | ||
| }, | ||
| messageId: { | ||
| type: "integer", | ||
| label: "Message ID", | ||
| description: "The ID of the message to retrieve", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.gorgiasOAuth.getTicketMessage({ | ||
| $, | ||
| ticketId: this.ticketId, | ||
| messageId: this.messageId, | ||
| }); | ||
|
|
||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return response; | ||
| }, | ||
| }); | ||
54 changes: 54 additions & 0 deletions
54
components/gorgias_oauth/actions/list-ticket-messages/list-ticket-messages.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { defineAction } from "@pipedream/types"; | ||
| import gorgiasOAuth from "../../gorgias_oauth.app.mjs"; | ||
|
|
||
| export default defineAction({ | ||
| name: "List Ticket Messages", | ||
| description: "List all messages for a specific ticket [See docs here](https://developers.gorgias.com/reference/list-ticket-messages)", | ||
| key: "gorgias_oauth-list-ticket-messages", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| gorgiasOAuth, | ||
| ticketId: { | ||
| propDefinition: [ | ||
| gorgiasOAuth, | ||
| "ticketId", | ||
| ], | ||
| }, | ||
| limit: { | ||
| type: "integer", | ||
| label: "Limit", | ||
| description: "Maximum number of messages to return (1-100)", | ||
| min: 1, | ||
| max: 100, | ||
| default: 50, | ||
| }, | ||
| cursor: { | ||
| type: "string", | ||
| label: "Cursor", | ||
| description: "Cursor for pagination (get from the meta.next_cursor of the previous response)", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const params = { | ||
| limit: this.limit, | ||
| }; | ||
|
|
||
| if (this.cursor) { | ||
| params.cursor = this.cursor; | ||
| } | ||
|
|
||
| const response = await this.gorgiasOAuth.listTicketMessages({ | ||
| $, | ||
| ticketId: this.ticketId, | ||
| params, | ||
| }); | ||
|
|
||
| // Return the data and pagination info | ||
| return { | ||
| data: response.data, | ||
| meta: response.meta, | ||
| }; | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.