Skip to content
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 9 commits into from
Oct 6, 2022

Conversation

sangeetha5491
Copy link
Contributor

@sangeetha5491 sangeetha5491 commented Sep 26, 2022

Description

Uses the registration V2 API to create , delete, get a registration.

Adds additional features:

  • update registration
  • get all registrations for a workspace
  • get all registrations for an org ( with pagination )

References: https://developer.adobe.com/events/docs/api/#tag/Registrations

Motivation and Context

All APIs were using the V2 model of projects and workspaces except for registrations. This PR migrates the registrations to use the V2 version.

How Has This Been Tested?

E2E and unit tests

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov
Copy link

codecov bot commented Sep 26, 2022

Codecov Report

Merging #30 (6cc5908) into master (2983e2d) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master       #30   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            5         5           
  Lines          393       408   +15     
  Branches        51        51           
=========================================
+ Hits           393       408   +15     
Impacted Files Coverage Δ
src/SDKErrors.js 100.00% <100.00%> (ø)
src/index.js 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link

@francoisledroff francoisledroff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A Question :

src/index.js Outdated
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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we pass the url and requestOptions to this method, these are already contained in the sdkDetails ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i fixed it. thanks!

src/SDKErrors.js Outdated
E('ERROR_GET_REGISTRATION', '%s')
E('ERROR_GET_ALL_REGISTRATION', '%s')
E('ERROR_GET_ALL_REGISTRATION_FOR_ORG', '%s')
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@sandeep-paliwal
Copy link
Contributor

@sangeetha5491 changes look good. Just one concern, these look like breaking changes to aio-lib-events as methods are getting renamed etc.
Will this impact usage of the lib here - https://github.com/adobe/aio-cli-plugin-events ?
Also for the same reason this will have to be a major release for the lib so users don't update to this latest change when they install the lib as npm dependency.

@sangeetha5491
Copy link
Contributor Author

@sandeep-paliwal yes these are breaking changes and will impact its use in the CLI.

README.md Outdated Show resolved Hide resolved
Comment on lines -146 to -149
* [.createWebhookRegistration(consumerOrgId, integrationId, body)](#EventsCoreAPI+createWebhookRegistration) ⇒ <code>Promise.&lt;object&gt;</code>
* [.getWebhookRegistration(consumerOrgId, integrationId, registrationId)](#EventsCoreAPI+getWebhookRegistration) ⇒ <code>Promise.&lt;object&gt;</code>
* [.getAllWebhookRegistrations(consumerOrgId, integrationId)](#EventsCoreAPI+getAllWebhookRegistrations) ⇒ <code>Promise.&lt;object&gt;</code>
* [.deleteWebhookRegistration(consumerOrgId, integrationId, registrationId)](#EventsCoreAPI+deleteWebhookRegistration) ⇒ <code>Promise.&lt;object&gt;</code>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering since these are breaking changes, shouldn't we mark these as deprecated first and only then remove them completely.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if they want to use the older methods, they can use the previous version. WDYT? @sandeep-paliwal is that the right way to go?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree.
A version update should not be reason enough for clients to update their integrations.
Even with the digital signature verification feature, we first added support (on 20th Jan), and after the complete deprecation of the old signature verification, we removed the HMAC signature verification from SDK (on 16th July).
So clients atleast had a 6 month window for updating their integrations.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would favor removing the v1 and updating the version number accordingly and putting a warning in the release note

src/index.js Show resolved Hide resolved
src/index.js Show resolved Hide resolved
test/index.test.js Outdated Show resolved Hide resolved
test/mock.js Show resolved Hide resolved
shikhartanwar
shikhartanwar previously approved these changes Sep 29, 2022
Fix delivery type options Registration create and update models in the Readme file.
@sangeetha5491 sangeetha5491 merged commit c49990a into adobe:master Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants