generated from adobe/aio-lib-template
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update registration methods to use V2 API #30
Merged
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8847137
Update registration methods to use V2 API
sangeetha5491 c57dbdc
remove from registration method names and add unit tests
sangeetha5491 00a36f4
Update typings and README files
sangeetha5491 3fc8d2a
address review comments
sangeetha5491 abfca52
update registration to use PUT method
sangeetha5491 7b949aa
Make events base url const in test
sangeetha5491 fdc7bf9
add registration create and update model typedefs
sangeetha5491 82ff1ed
add typedefs for Provider and EventMetadata input models
sangeetha5491 6cc5908
Update README.md
sangeetha5491 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -311,61 +311,104 @@ class EventsCoreAPI { | |
* Create a webhook or journal registration | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} integrationId integration Id from the console | ||
* @param {string} projectId Project Id from the console | ||
* @param {string} workspaceId Workspace Id from the console | ||
* @param {object} body Json data contains details of the registration | ||
* @returns {Promise<object>} Details of the webhook/journal registration created | ||
*/ | ||
createWebhookRegistration (consumerOrgId, integrationId, body) { | ||
createRegistration (consumerOrgId, projectId, workspaceId, body) { | ||
const headers = {} | ||
const requestOptions = this.__createRequest('POST', headers, JSON.stringify(body)) | ||
const url = this.__getUrl(`/events/organizations/${consumerOrgId}/integrations/${integrationId}/registrations`) | ||
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/registrations`) | ||
const sdkDetails = { requestOptions: requestOptions, url: url } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_CREATE_REGISTRATION) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why we pass the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i fixed it. thanks! |
||
} | ||
|
||
/** | ||
* Update a webhook or journal registration | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} projectId Project Id from the console | ||
* @param {string} workspaceId Workspace Id from the console | ||
* @param {string} registrationId Registration id whose details are to be fetched | ||
* @param {object} body Json data contains details of the registration | ||
* @returns {Promise<object>} Details of the webhook/journal registration to be updated | ||
*/ | ||
updateRegistration (consumerOrgId, projectId, workspaceId, registrationId, body) { | ||
const headers = {} | ||
shikhartanwar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const requestOptions = this.__createRequest('POST', headers, JSON.stringify(body)) | ||
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/registrations/${registrationId}`) | ||
const sdkDetails = { requestOptions: requestOptions, url: url } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_UPDATE_REGISTRATION) | ||
} | ||
|
||
/** | ||
* Get registration details for a given registration | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} integrationId Integration Id from the console | ||
* @param {string} projectId Project Id from the console | ||
* @param {string} workspaceId Workspace Id from the console | ||
* @param {string} registrationId Registration id whose details are to be fetched | ||
* @returns {Promise<object>} Details of the webhook/journal registration | ||
*/ | ||
getWebhookRegistration (consumerOrgId, integrationId, registrationId) { | ||
getRegistration (consumerOrgId, projectId, workspaceId, registrationId) { | ||
const headers = {} | ||
const requestOptions = this.__createRequest('GET', headers) | ||
const url = this.__getUrl(`/events/organizations/${consumerOrgId}/integrations/${integrationId}/registrations/${registrationId}`) | ||
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/registrations/${registrationId}`) | ||
const sdkDetails = { requestOptions: requestOptions, url: url } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_GET_REGISTRATION) | ||
} | ||
|
||
/** | ||
* Get all registration details for a given integration | ||
* Get all registration details for a workspace | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} integrationId Integration Id from the console | ||
* @param {string} projectId Project Id from the console | ||
* @param {string} workspaceId Workspace Id from the console | ||
* @returns {Promise<object>} List of all webhook/journal registrations | ||
*/ | ||
getAllWebhookRegistrations (consumerOrgId, integrationId) { | ||
getAllRegistrationsForWorkspace (consumerOrgId, projectId, workspaceId) { | ||
const headers = {} | ||
const requestOptions = this.__createRequest('GET', headers) | ||
const url = this.__getUrl(`/events/organizations/${consumerOrgId}/integrations/${integrationId}/registrations`) | ||
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/registrations`) | ||
const sdkDetails = { requestOptions: requestOptions, url: url } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_GET_ALL_REGISTRATION) | ||
} | ||
|
||
/** | ||
* @typedef {object} Page | ||
* @property {number} [page] page number to be fetched. Default 0 (optional) | ||
* @property {number} [size] size of each page. Default 10 (optional) | ||
*/ | ||
shikhartanwar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/** | ||
* Get all registration details for an org | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {Page} [page] page size and page number | ||
* @returns {Promise<object>} Paginated response of all webhook/journal registrations for an org | ||
*/ | ||
getAllRegistrationsForOrg (consumerOrgId, page) { | ||
const headers = {} | ||
const requestOptions = this.__createRequest('GET', headers) | ||
const url = this.__getUrl(`/events/${consumerOrgId}/registrations`) | ||
const urlWithQueryParams = helpers.appendQueryParams(url, page) | ||
const sdkDetails = { requestOptions: requestOptions, url: urlWithQueryParams } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_GET_ALL_REGISTRATION_FOR_ORG) | ||
} | ||
|
||
/** | ||
* Delete webhook registration | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} integrationId Integration Id from the console | ||
* @param {string} projectId Project Id from the console | ||
* @param {string} workspaceId Workspace Id from the console | ||
* @param {string} registrationId Id of the registration to be deleted | ||
* @returns {Promise<object>} Empty object if deletion was successful | ||
*/ | ||
deleteWebhookRegistration (consumerOrgId, integrationId, registrationId) { | ||
deleteRegistration (consumerOrgId, projectId, workspaceId, registrationId) { | ||
const headers = {} | ||
const requestOptions = this.__createRequest('DELETE', headers) | ||
const url = this.__getUrl(`/events/organizations/${consumerOrgId}/integrations/${integrationId}/registrations/${registrationId}`) | ||
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/registrations/${registrationId}`) | ||
const sdkDetails = { requestOptions: requestOptions, url: url } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_DELETE_REGISTRATION) | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: change 'ERROR_GET_ALL_REGISTRATION_FOR_ORG' to 'ERROR_GET_ALL_REGISTRATIONS_FOR_ORG .
Same for 'ERROR_GET_ALL_REGISTRATION' above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done