-
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.
feat(whoami): add whoami endpoint for intercom (#206)
## Describe your changes ## Issue ticket number and link ## Checklist before requesting a review (skip if just adding/editing APIs & templates) - [ ] I added tests, otherwise the reason is: - [ ] External API requests have `retries` - [ ] Pagination is used where appropriate - [ ] The built in `nango.paginate` call is used instead of a `while (true)` loop - [ ] Third party requests are NOT parallelized (this can cause issues with rate limits) - [ ] If a sync requires metadata the `nango.yaml` has `auto_start: false` - [ ] If the sync is a `full` sync then `track_deletes: true` is set - [ ] I followed the best practices and guidelines from the [Writing Integration Scripts](/NangoHQ/integration-templates/blob/main/WRITING_INTEGRATION_SCRIPTS.md) doc
- Loading branch information
1 parent
bbb59c9
commit 02abedc
Showing
5 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
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,43 @@ | ||
<!-- BEGIN GENERATED CONTENT --> | ||
# Whoami | ||
|
||
## General Information | ||
|
||
- **Description:** Fetch current user information | ||
- **Version:** 0.0.1 | ||
- **Group:** Users | ||
- **Scopes:** `Read admins` | ||
- **Endpoint Type:** Action | ||
- **Code:** [github.com](https://github.com/NangoHQ/integration-templates/tree/main/integrations/intercom/actions/whoami.ts) | ||
|
||
|
||
## Endpoint Reference | ||
|
||
### Request Endpoint | ||
|
||
`GET /whoami` | ||
|
||
### Request Query Parameters | ||
|
||
_No request parameters_ | ||
|
||
### Request Body | ||
|
||
_No request body_ | ||
|
||
### Request Response | ||
|
||
```json | ||
{ | ||
"id": "<string>", | ||
"email": "<string>" | ||
} | ||
``` | ||
|
||
## Changelog | ||
|
||
- [Script History](https://github.com/NangoHQ/integration-templates/commits/main/integrations/intercom/actions/whoami.ts) | ||
- [Documentation History](https://github.com/NangoHQ/integration-templates/commits/main/integrations/intercom/actions/whoami.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,19 @@ | ||
import type { NangoAction, ProxyConfiguration, UserInformation } from '../../models'; | ||
import type { WhoAmIResponse } from '../types'; | ||
|
||
export default async function runAction(nango: NangoAction): Promise<UserInformation> { | ||
const config: ProxyConfiguration = { | ||
// https://developers.intercom.com/docs/references/1.1/rest-api/admins/viewing-the-current-admin | ||
endpoint: 'me', | ||
retries: 10 | ||
}; | ||
|
||
const { data } = await nango.get<WhoAmIResponse>(config); | ||
|
||
const user: UserInformation = { | ||
id: data.id, | ||
email: data.email | ||
}; | ||
|
||
return user; | ||
} |
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