Skip to content

Commit

Permalink
Merge branch 'main' into kelvinwari/ext-251-create-gorgias-ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
hassan254-prog authored Dec 17, 2024
2 parents 6e373ca + 652ac85 commit ed27bc8
Show file tree
Hide file tree
Showing 29 changed files with 963 additions and 10 deletions.
116 changes: 116 additions & 0 deletions flows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11434,6 +11434,122 @@ integrations:
customer_ref: Reference
currency_ref?: Reference
project_ref?: Reference
ramp:
syncs:
users:
runs: every day
description: Fetches a list of users from Ramp
output: User
sync_type: full
track_deletes: true
endpoint:
method: GET
path: /users
group: Users
scopes:
- users:read
actions:
create-user:
description: Creates a user in Ramp
output: User
endpoint:
method: POST
path: /users
group: Users
input: RampCreateUser
scopes:
- users:write
disable-user:
description: Deletes a user in Ramp by id
endpoint:
method: DELETE
path: /users
group: Users
output: SuccessResponse
input: IdEntity
scopes:
- users:write
models:
IdEntity:
id: string
SuccessResponse:
success: boolean
User:
id: string
email: string
firstName: string
lastName: string
CreateUser:
firstName: string
lastName: string
email: string
RampCreateUser:
firstName: string
lastName: string
email: string
role?: string
departmentId?: string
directManagerId?: string
idempotencyKey?: string
locationId?: string
ramp-sandbox:
syncs:
users:
runs: every day
description: Fetches a list of users from Ramp
output: User
sync_type: full
track_deletes: true
endpoint:
method: GET
path: /users
group: Users
scopes:
- users:read
actions:
create-user:
description: Creates a user in Ramp
output: User
endpoint:
method: POST
path: /users
group: Users
input: RampCreateUser
scopes:
- users:write
disable-user:
description: Deletes a user in Ramp by id
endpoint:
method: DELETE
path: /users
group: Users
output: SuccessResponse
input: IdEntity
scopes:
- users:write
models:
IdEntity:
id: string
SuccessResponse:
success: boolean
User:
id: string
email: string
firstName: string
lastName: string
CreateUser:
firstName: string
lastName: string
email: string
RampCreateUser:
firstName: string
lastName: string
email: string
role?: string
departmentId?: string
directManagerId?: string
idempotencyKey?: string
locationId?: string
ring-central:
actions:
create-user:
Expand Down
2 changes: 1 addition & 1 deletion integrations/asana/actions/delete-task.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

## General Information

- **Description:** undefined
- **Description:**
- **Version:** 0.0.1
- **Group:** Others
- **Scopes:** _None_
Expand Down
2 changes: 1 addition & 1 deletion integrations/checkr-partner/actions/create-candidate.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

## General Information

- **Description:** undefined
- **Description:**
- **Version:** 0.0.1
- **Group:** Others
- **Scopes:** _None_
Expand Down
2 changes: 1 addition & 1 deletion integrations/google/syncs/workspace-org-units.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

## General Information

- **Description:** undefined
- **Description:**
- **Version:** 0.0.1
- **Group:** Others
- **Scopes:** `https://www.googleapis.com/auth/admin.directory.orgunit.readonly, https://www.googleapis.com/auth/admin.directory.user.readonly`
Expand Down
2 changes: 1 addition & 1 deletion integrations/google/syncs/workspace-user-access-tokens.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

## General Information

- **Description:** undefined
- **Description:**
- **Version:** 0.0.1
- **Group:** Others
- **Scopes:** `https://www.googleapis.com/auth/admin.directory.user.readonly, https://www.googleapis.com/auth/admin.directory.user.security`
Expand Down
2 changes: 1 addition & 1 deletion integrations/google/syncs/workspace-users.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

## General Information

- **Description:** undefined
- **Description:**
- **Version:** 0.0.1
- **Group:** Others
- **Scopes:** _None_
Expand Down
49 changes: 45 additions & 4 deletions integrations/linkedin/actions/post.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { CreateLinkedInPostWithVideoResponse, NangoAction, LinkedinVideoPost } from '../../models';
import { createPostWithVideo } from '../helpers/post-video.js';
import type { CreateLinkedInPostWithVideoResponse, LinkedinVideoPost, NangoAction, ProxyConfiguration } from '../../models.js';
import { userInfo } from '../helpers/user-info.js';
import type { LinkedinCreatePost } from '../types.js';

export default async function runAction(nango: NangoAction, input: LinkedinVideoPost): Promise<CreateLinkedInPostWithVideoResponse> {
const videoURN = input?.videoURN;
Expand All @@ -17,7 +17,48 @@ export default async function runAction(nango: NangoAction, input: LinkedinVideo
});
}

const resp = await createPostWithVideo(nango, ownerId, input.text, input.videoTitle, videoURN);
const postData: LinkedinCreatePost = {
author: `urn:li:person:${ownerId}`,
commentary: input.text,
visibility: 'PUBLIC',
distribution: {
feedDistribution: 'MAIN_FEED',
targetEntities: [],
thirdPartyDistributionChannels: []
},
lifecycleState: 'PUBLISHED',
isReshareDisabledByAuthor: false
};

return resp;
if (videoURN) {
postData.content = {
media: {
title: input.videoTitle,
// video that is already uploaded to linkedin api. this id can be video, image or document urn.
id: videoURN
}
};
}

const config: ProxyConfiguration = {
// https://learn.microsoft.com/en-us/linkedin/marketing/community-management/shares/posts-api?view=li-lms-2024-10&tabs=http
endpoint: `/rest/posts`,
retries: 10,
data: postData,
headers: {
'LinkedIn-Version': '202405'
}
};

const response = await nango.post(config);

if (response.status !== 200) {
throw new nango.ActionError({
message: `failed to create post with video urn ${videoURN}`
});
}

return {
succcess: response.status == 200
};
}
1 change: 1 addition & 0 deletions integrations/ramp-sandbox/actions
1 change: 1 addition & 0 deletions integrations/ramp-sandbox/nango.yaml
1 change: 1 addition & 0 deletions integrations/ramp-sandbox/schema.zod.ts
1 change: 1 addition & 0 deletions integrations/ramp-sandbox/syncs
1 change: 1 addition & 0 deletions integrations/ramp-sandbox/types.ts
45 changes: 45 additions & 0 deletions integrations/ramp/actions/create-user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import type { NangoAction, ProxyConfiguration, RampCreateUser, User } from '../../models';
import type { RampCreatedUser } from '../types';
import { rampCreateUserSchema } from '../schema.zod.js';

/**
* Executes the create user action by validating input, constructing the request configuration,
* and making the Ramp API call to create a new user.
*/
export default async function runAction(nango: NangoAction, input: RampCreateUser): Promise<User> {
const parsedInput = rampCreateUserSchema.safeParse(input);

if (!parsedInput.success) {
for (const error of parsedInput.error.errors) {
await nango.log(`Invalid input provided to create a user: ${error.message} at path ${error.path.join('.')}`, { level: 'error' });
}

throw new nango.ActionError({
message: 'Invalid input provided to create a user'
});
}

const config: ProxyConfiguration = {
// https://docs.ramp.com/developer-api/v1/api/users#post-developer-v1-users-deferred
endpoint: '/developer/v1/users/deferred',
data: {
first_name: parsedInput.data.firstName,
last_name: parsedInput.data.lastName,
email: parsedInput.data.email,
role: parsedInput.data.role || 'IT_ADMIN'
},
retries: 10
};

const response = await nango.post<RampCreatedUser>(config);

const newUser = response.data;
const user: User = {
id: newUser.id ? newUser.id.toString() : '',
firstName: parsedInput.data.firstName,
lastName: parsedInput.data.lastName,
email: parsedInput.data.email
};

return user;
}
28 changes: 28 additions & 0 deletions integrations/ramp/actions/disable-user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { NangoAction, ProxyConfiguration, SuccessResponse, IdEntity } from '../../models';
import { idEntitySchema } from '../schema.zod.js';

export default async function runAction(nango: NangoAction, input: IdEntity): Promise<SuccessResponse> {
const parsedInput = idEntitySchema.safeParse(input);

if (!parsedInput.success) {
for (const error of parsedInput.error.errors) {
await nango.log(`Invalid input provided to disable a user: ${error.message} at path ${error.path.join('.')}`, { level: 'error' });
}

throw new nango.ActionError({
message: 'Invalid id provided to disable a user'
});
}

const config: ProxyConfiguration = {
// https://docs.ramp.com/developer-api/v1/api/users#patch-developer-v1-users-user-id-deactivate
endpoint: `/developer/v1/users/${encodeURIComponent(parsedInput.data.id)}/deactivate`,
retries: 10
};

await nango.patch(config);

return {
success: true
};
}
5 changes: 5 additions & 0 deletions integrations/ramp/fixtures/create-user.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"firstName": "Johny",
"lastName": "Does",
"email": "john1@doe.com"
}
3 changes: 3 additions & 0 deletions integrations/ramp/fixtures/delete-user.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"id": "969017636421645"
}
3 changes: 3 additions & 0 deletions integrations/ramp/mocks/disable-user/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"id": "0193bab1-c269-7257-9749-5749b3ce6729"
}
3 changes: 3 additions & 0 deletions integrations/ramp/mocks/disable-user/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"success": true
}
Loading

0 comments on commit ed27bc8

Please sign in to comment.