Skip to content

Commit

Permalink
feat(whoami): add whoami endpoint for intercom (#206)
Browse files Browse the repository at this point in the history
## 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
khaliqgant authored Jan 29, 2025
1 parent bbb59c9 commit 02abedc
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 0 deletions.
12 changes: 12 additions & 0 deletions flows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6122,6 +6122,15 @@ integrations:
path: /contact
output: SuccessResponse
input: IdEntity
whoami:
description: Fetch current user information
output: UserInformation
endpoint:
method: GET
path: /whoami
group: Users
scopes:
- Read admins
syncs:
conversations:
runs: every 6 hours
Expand Down Expand Up @@ -6295,6 +6304,9 @@ integrations:
last_seen_at?: number
owner_id?: string
unsubscribed_from_emails?: boolean
UserInformation:
id: string
email: string
jira:
syncs:
issues:
Expand Down
43 changes: 43 additions & 0 deletions integrations/intercom/actions/whoami.md
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 -->

19 changes: 19 additions & 0 deletions integrations/intercom/actions/whoami.ts
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;
}
12 changes: 12 additions & 0 deletions integrations/intercom/nango.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ integrations:
path: /contact
output: SuccessResponse
input: IdEntity
whoami:
description: Fetch current user information
output: UserInformation
endpoint:
method: GET
path: /whoami
group: Users
scopes:
- 'Read admins'
syncs:
conversations:
runs: every 6 hours
Expand Down Expand Up @@ -195,3 +204,6 @@ models:
last_seen_at?: number
owner_id?: string
unsubscribed_from_emails?: boolean
UserInformation:
id: string
email: string
23 changes: 23 additions & 0 deletions integrations/intercom/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,3 +435,26 @@ export interface IntercomAdminUser {
team_ids: string[];
team_priority_level: unknown;
}

export interface WhoAmIResponse {
type: 'admin';
id: string;
email: string;
name: string;
email_verified: boolean;
app: {
type: 'app';
id_code: string;
name: string;
created_at: number;
secure: boolean;
identity_verification: boolean;
timezone: string;
region: string;
};
avatar: {
type: 'avatar';
image_url: string;
};
has_inbox_seat: boolean;
}

0 comments on commit 02abedc

Please sign in to comment.