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

feat(sc-57429): Support Opportunities API #98

Conversation

kamilpavlicko
Copy link
Contributor

closes ticket: https://app.shortcut.com/chartmogul/story/57429/support-opportunities-resource-node-client

API Specs: https://www.notion.so/chartmogul/API-endpoints-for-Opportunities-a92323514bf44f89ad2f97ae30cee7f0#6f09cc7a71bc40e69ef65d8d0342d230

Background

There were added following methods to the library

Customers

ChartMogul.Customer.opportunities(config, customerUuid, { per_page: 10, cursor: 'cursor==' })
ChartMogul.Customer.createOpportunity(config, customerUuid, data)

Opportunities

ChartMogul.Opportunity.create(config, data)
ChartMogul.Opportunity.retrieve(config, opportunityUuid)
ChartMogul.Opportunity.patch(config, opportunityUuid, data)
ChartMogul.Opportunity.destroy(config, opportunityUuid)
ChartMogul.Opportunity.all(config, { per_page: 10, cursor: 'cursor==', customer_uuid: customerUuid})

Tests

Regarding the tests, you will be probably suprised about the other approach of tests, but I found out that all existing tests are incorrect for all the resources. Iwrote the tests for the opportunity in good way, but fixing all the others will take some time, so needs to be addressed independently. Will ping about it to the engineering channnel.

The issue is that we assert value in promise block with no return. This way the test will pass even though the assertion is false.

 Customer.createContact(config, customerUuid, postBody)
      .then(res => {
        expect(res).to.have.property('uuid');
      });

Copy link

This pull request has been linked to Shortcut Story #57429: Support Opportunities resource - Node client.

Copy link

@keith-chartmogul keith-chartmogul left a comment

Choose a reason for hiding this comment

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

LGTM in general 👍

There is just one non-blocking suggestion for correcting a typo in two of the updated files

test/chartmogul/customer.js Outdated Show resolved Hide resolved
test/chartmogul/opportunity.js Outdated Show resolved Hide resolved
Copy link

@keith-chartmogul keith-chartmogul left a comment

Choose a reason for hiding this comment

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

👍

@kamilpavlicko kamilpavlicko merged commit 4c53578 into main Mar 25, 2024
4 checks passed
@kamilpavlicko kamilpavlicko deleted the kamilpavlicko/feat/sc-57429/support-opportunities-resource-node-client branch March 25, 2024 12:30
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.

3 participants