-
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.
Merge branch 'main' into kelvinwari/ext-251-create-gorgias-ticket
- Loading branch information
Showing
29 changed files
with
963 additions
and
10 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
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
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 @@ | ||
../ramp/actions |
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 @@ | ||
../ramp/nango.yaml |
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 @@ | ||
../ramp/schema.zod.ts |
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 @@ | ||
../ramp/syncs |
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 @@ | ||
../ramp/types.ts |
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,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; | ||
} |
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,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 | ||
}; | ||
} |
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,5 @@ | ||
{ | ||
"firstName": "Johny", | ||
"lastName": "Does", | ||
"email": "john1@doe.com" | ||
} |
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,3 @@ | ||
{ | ||
"id": "969017636421645" | ||
} |
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,3 @@ | ||
{ | ||
"id": "0193bab1-c269-7257-9749-5749b3ce6729" | ||
} |
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,3 @@ | ||
{ | ||
"success": true | ||
} |
Oops, something went wrong.