-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
152 changed files
with
11,739 additions
and
620 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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,97 @@ | ||
<!-- BEGIN GENERATED CONTENT --> | ||
# Create Todo | ||
|
||
## General Information | ||
|
||
- **Description:** Create a new to-do in a specific project + list | ||
- **Version:** 0.0.1 | ||
- **Group:** Todos | ||
- **Scopes:** _None_ | ||
- **Endpoint Type:** Action | ||
- **Code:** [github.com](https://github.com/NangoHQ/integration-templates/tree/main/integrations/basecamp/actions/create-todo.ts) | ||
|
||
|
||
## Endpoint Reference | ||
|
||
### Request Endpoint | ||
|
||
`POST /todos` | ||
|
||
### Request Query Parameters | ||
|
||
_No request parameters_ | ||
|
||
### Request Body | ||
|
||
```json | ||
{ | ||
"projectId": "<number>", | ||
"todoListId": "<number>", | ||
"content": "<string>", | ||
"description?": "<string>", | ||
"due_on?": "<string>", | ||
"starts_on?": "<string>", | ||
"notify?": "<boolean>", | ||
"assigneeEmails?": [ | ||
"<string>" | ||
], | ||
"completionSubscriberEmails?": [ | ||
"<string>" | ||
] | ||
} | ||
``` | ||
|
||
### Request Response | ||
|
||
```json | ||
{ | ||
"id": "<number>", | ||
"status": "<string>", | ||
"visible_to_clients": "<boolean>", | ||
"created_at": "<string>", | ||
"updated_at": "<string>", | ||
"title": "<string>", | ||
"inherits_status": "<boolean>", | ||
"type": "<string>", | ||
"url": "<string>", | ||
"app_url": "<string>", | ||
"bookmark_url": "<string>", | ||
"subscription_url": "<string>", | ||
"comments_count": "<integer>", | ||
"comments_url": "<string>", | ||
"position": "<integer>", | ||
"parent": { | ||
"id": "<number>", | ||
"title": "<string>", | ||
"type": "<string>", | ||
"url": "<string>", | ||
"app_url": "<string>" | ||
}, | ||
"bucket": { | ||
"id": "<number>", | ||
"name": "<string>", | ||
"type": "<string>" | ||
}, | ||
"creator": "<any>", | ||
"description": "<string>", | ||
"completed": "<boolean>", | ||
"content": "<string>", | ||
"starts_on": "<string>", | ||
"due_on": "<string>", | ||
"assignees": [ | ||
"<any>" | ||
], | ||
"completion_subscribers": [ | ||
"<any>" | ||
], | ||
"completion_url": "<string>" | ||
} | ||
``` | ||
|
||
## Changelog | ||
|
||
- [Script History](https://github.com/NangoHQ/integration-templates/commits/main/integrations/basecamp/actions/create-todo.ts) | ||
- [Documentation History](https://github.com/NangoHQ/integration-templates/commits/main/integrations/basecamp/actions/create-todo.md) | ||
|
||
<!-- END GENERATED CONTENT --> | ||
|
This file contains 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,75 @@ | ||
import type { BasecampPerson, BasecampCreateTodoInput, NangoAction, ProxyConfiguration } from '../../models'; | ||
import { findUserIdByEmail } from '../helpers/find-user.js'; | ||
import { basecampCreateTodoInputSchema } from '../schema.zod.js'; | ||
/** | ||
* Action: createBasecampTodo | ||
* | ||
* 1) Parse input (which includes email arrays). | ||
* 2) Fetch the project's people (GET /projects/{projectId}/people.json). | ||
* 3) Match each email to a person, build 'assignee_ids' + 'completion_subscriber_ids'. | ||
* 4) POST /buckets/{projectId}/todolists/{todoListId}/todos.json to create the to-do. | ||
*/ | ||
export default async function runAction(nango: NangoAction, input: BasecampCreateTodoInput) { | ||
// 1) Validate input | ||
const parsed = basecampCreateTodoInputSchema.safeParse(input); | ||
if (!parsed.success) { | ||
const msg = parsed.error.errors.map((e) => e.message).join('; '); | ||
throw new nango.ActionError({ message: `Invalid Basecamp create-todo input: ${msg}` }); | ||
} | ||
|
||
const { projectId, todoListId, content, description, due_on, starts_on, notify, assigneeEmails, completionSubscriberEmails } = parsed.data; | ||
|
||
// 2) Fetch the project’s people by email -> user ID | ||
const peopleConfig: ProxyConfiguration = { | ||
// https://github.com/basecamp/bc3-api/blob/master/sections/people.md#get-people-on-a-project | ||
endpoint: `/projects/${projectId}/people.json`, | ||
retries: 10 | ||
}; | ||
const peopleResp = await nango.get<BasecampPerson[]>(peopleConfig); | ||
const projectPeople = Array.isArray(peopleResp.data) ? peopleResp.data : []; | ||
|
||
const assigneeIds: number[] = []; | ||
const completionSubscriberIds: number[] = []; | ||
|
||
if (assigneeEmails) { | ||
for (const email of assigneeEmails) { | ||
const userId = findUserIdByEmail(email, projectPeople); | ||
if (userId) { | ||
assigneeIds.push(userId); | ||
} else { | ||
throw new nango.ActionError({ message: `No user found with email: ${email}` }); | ||
} | ||
} | ||
} | ||
|
||
if (completionSubscriberEmails) { | ||
for (const email of completionSubscriberEmails) { | ||
const userId = findUserIdByEmail(email, projectPeople); | ||
if (userId) { | ||
completionSubscriberIds.push(userId); | ||
} else { | ||
throw new nango.ActionError({ message: `No user found with email: ${email}` }); | ||
} | ||
} | ||
} | ||
|
||
const dataBody: Record<string, unknown> = { | ||
content | ||
}; | ||
if (description) dataBody['description'] = description; | ||
if (due_on) dataBody['due_on'] = due_on; | ||
if (starts_on) dataBody['starts_on'] = starts_on; | ||
if (typeof notify === 'boolean') dataBody['notify'] = notify; | ||
if (assigneeIds.length > 0) dataBody['assignee_ids'] = assigneeIds; | ||
if (completionSubscriberIds.length > 0) dataBody['completion_subscriber_ids'] = completionSubscriberIds; | ||
|
||
const config: ProxyConfiguration = { | ||
// https://github.com/basecamp/bc3-api/blob/master/sections/todos.md#create-a-to-do | ||
endpoint: `/buckets/${projectId}/todolists/${todoListId}/todos.json`, | ||
data: dataBody, | ||
retries: 10 | ||
}; | ||
|
||
const response = await nango.post(config); | ||
return response.data; | ||
} |
This file contains 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,57 @@ | ||
<!-- BEGIN GENERATED CONTENT --> | ||
# Fetch Accounts | ||
|
||
## General Information | ||
|
||
- **Description:** Fetch account list and user information from Basecamp | ||
- **Version:** 0.0.1 | ||
- **Group:** Accounts | ||
- **Scopes:** _None_ | ||
- **Endpoint Type:** Action | ||
- **Code:** [github.com](https://github.com/NangoHQ/integration-templates/tree/main/integrations/basecamp/actions/fetch-accounts.ts) | ||
|
||
|
||
## Endpoint Reference | ||
|
||
### Request Endpoint | ||
|
||
`GET /accounts` | ||
|
||
### Request Query Parameters | ||
|
||
_No request parameters_ | ||
|
||
### Request Body | ||
|
||
_No request body_ | ||
|
||
### Request Response | ||
|
||
```json | ||
{ | ||
"identity": { | ||
"id": "<number>", | ||
"firstName": "<string>", | ||
"lastName": "<string>", | ||
"email": "<string>" | ||
}, | ||
"accounts": [ | ||
{ | ||
"id": "<number>", | ||
"name": "<string>", | ||
"product": "<string>", | ||
"href": "<string>", | ||
"app_href": "<string>", | ||
"hidden?": "<boolean>" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
## Changelog | ||
|
||
- [Script History](https://github.com/NangoHQ/integration-templates/commits/main/integrations/basecamp/actions/fetch-accounts.ts) | ||
- [Documentation History](https://github.com/NangoHQ/integration-templates/commits/main/integrations/basecamp/actions/fetch-accounts.md) | ||
|
||
<!-- END GENERATED CONTENT --> | ||
|
This file contains 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,24 @@ | ||
import type { UserInformation, NangoAction, ProxyConfiguration } from '../../models'; | ||
import type { BasecampAuthorizationResponse } from '../types'; | ||
|
||
export default async function runAction(nango: NangoAction): Promise<UserInformation> { | ||
const config: ProxyConfiguration = { | ||
baseUrlOverride: 'https://launchpad.37signals.com', | ||
// https://github.com/basecamp/api/blob/master/sections/authentication.md#get-authorization | ||
endpoint: '/authorization.json', | ||
retries: 10 | ||
}; | ||
|
||
const { data } = await nango.get<BasecampAuthorizationResponse>(config); | ||
const { identity, accounts } = data; | ||
|
||
return { | ||
identity: { | ||
id: identity.id, | ||
email: identity.email_address, | ||
firstName: identity.first_name, | ||
lastName: identity.last_name | ||
}, | ||
accounts | ||
}; | ||
} |
This file contains 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,73 @@ | ||
<!-- BEGIN GENERATED CONTENT --> | ||
# Fetch Projects | ||
|
||
## General Information | ||
|
||
- **Description:** Fetch all projects from Basecamp | ||
- **Version:** 0.0.1 | ||
- **Group:** Projects | ||
- **Scopes:** _None_ | ||
- **Endpoint Type:** Action | ||
- **Code:** [github.com](https://github.com/NangoHQ/integration-templates/tree/main/integrations/basecamp/actions/fetch-projects.ts) | ||
|
||
|
||
## Endpoint Reference | ||
|
||
### Request Endpoint | ||
|
||
`GET /projects` | ||
|
||
### Request Query Parameters | ||
|
||
_No request parameters_ | ||
|
||
### Request Body | ||
|
||
_No request body_ | ||
|
||
### Request Response | ||
|
||
```json | ||
{ | ||
"projects": [ | ||
{ | ||
"id": "<number>", | ||
"status": "<string>", | ||
"created_at": "<string>", | ||
"updated_at": "<string>", | ||
"name": "<string>", | ||
"description": "<string | null>", | ||
"purpose": "<string>", | ||
"clients_enabled": "<boolean>", | ||
"timesheet_enabled?": "<boolean>", | ||
"color?": "<string | null>", | ||
"last_needle_color?": "<string | null>", | ||
"last_needle_position?": "<string | null>", | ||
"previous_needle_position?": "<string | null>", | ||
"bookmark_url": "<string>", | ||
"url": "<string>", | ||
"app_url": "<string>", | ||
"dock": [ | ||
{ | ||
"id": "<number>", | ||
"title": "<string>", | ||
"name": "<string>", | ||
"enabled": "<boolean>", | ||
"position": "<number | null>", | ||
"url": "<string>", | ||
"app_url": "<string>" | ||
} | ||
], | ||
"bookmarked": "<boolean>" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
## Changelog | ||
|
||
- [Script History](https://github.com/NangoHQ/integration-templates/commits/main/integrations/basecamp/actions/fetch-projects.ts) | ||
- [Documentation History](https://github.com/NangoHQ/integration-templates/commits/main/integrations/basecamp/actions/fetch-projects.md) | ||
|
||
<!-- END GENERATED CONTENT --> | ||
|
This file contains 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,27 @@ | ||
import type { BasecampProject, BasecampProjectsResponse, NangoAction, ProxyConfiguration } from '../../models'; | ||
|
||
/** | ||
* Action: fetch-projects | ||
* Fetches *all* projects from Basecamp's /projects.json endpoint. | ||
*/ | ||
export default async function runAction(nango: NangoAction): Promise<BasecampProjectsResponse> { | ||
const allProjects: BasecampProject[] = []; | ||
|
||
const config: ProxyConfiguration = { | ||
//https://github.com/basecamp/bc3-api/blob/master/sections/projects.md#projects | ||
endpoint: '/projects.json', | ||
retries: 10, | ||
paginate: { | ||
type: 'link', | ||
link_rel_in_response_header: 'next' | ||
} | ||
}; | ||
|
||
for await (const projectsPage of nango.paginate<BasecampProject>(config)) { | ||
for (const project of projectsPage) { | ||
allProjects.push(project); | ||
} | ||
} | ||
|
||
return { projects: allProjects }; | ||
} |
Oops, something went wrong.