-
Notifications
You must be signed in to change notification settings - Fork 2
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: added endpoint for product details #20
base: main
Are you sure you want to change the base?
Conversation
Features
UpdateBug Fixes
ContributorsCommit-Lint commandsYou can trigger Commit-Lint actions by commenting on this PR:
|
✔️ Deploy Preview for hopeful-bell-0b6f9f ready! 🔨 Explore the source changes: b908eb4 🔍 Inspect the deploy log: https://app.netlify.com/sites/hopeful-bell-0b6f9f/deploys/60d07480f84f1d00070a01d9 😎 Browse the preview: https://deploy-preview-20--hopeful-bell-0b6f9f.netlify.app |
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.
@vickywane should the name of the endpoint be /product to better represent the intended use. It is confusing to think of POST /notification as a way to send an individual notification message and at the same time GET /notification fetches metadata about the notification product.
A more intuitive use for GET /notification would be to fetch the latest sent notification if we ever needed that historical data access.
@ivelin Good catch! This same thought ran through my mind while creating the endpoint today. I however wanted to know your thoughts on it also. I would make the change and push back. |
This pull request fixes 1 alert when merging 83c257b into 6067d3d - view on LGTM.com fixed alerts:
|
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.
@vickywane a few semantic naming comments.
docs/index.html
Outdated
<a href="#operation--product-get">GET</a> | ||
</td> | ||
<td> | ||
<p>Retrieve notification product</p> |
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.
@vickywane This doesn't need to be tied to notifications. Let's just say that it:
"Retrieve product and pricing information associated with a premium customer subscription."
In Stripe nomenclature, a subscription is the unique pairing of a customer account with a product entity. Products have a pricing attached to them which can be one time, recurring or some combination.
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.
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.
This text adjustment has been made.
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.
Still reads
"
Retrieve notification product
"
docs/index.html
Outdated
<span id="path--product"></span> | ||
<div id="operation--product-get" class="swagger--panel-operation-get panel"> | ||
<div class="panel-heading"> | ||
<div class="operation-summary">Retrieve notification product</div> |
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.
@vickywane similar comment here. It does not have to be tied to notifications. We may add other products in the future and this API should still return the product information given a customer subscription.
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.
An adjustment has been made to the summary
field in the openapi spec to correct this.
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.
Strange. This index.html
file still shows <div class="operation-summary">Retrieve notification product</div>
netlify/functions/product.js
Outdated
} else if (event.httpMethod === "GET") { | ||
|
||
try { | ||
const product = await stripe.products.retrieve(process.env.EMAIL_PRODUCT_ID); |
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.
@vickywane instead of hardcoding the email product id in the deployment environment, let's just retrieve all information about user's subscription options along with product and price id. For now it's only email notifications, but we plan for that list of options to expand.
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.
As explained in this comment, the renamed email-product-id
has no direct relation with end-users. The product is created by the organization either through the Stripe API or Stripe dashboard.
It is used to identify the product that a user is subscribed to. The product being retrieved is what stores the data.
To handle multiple product-IDs, they can be stored as environment variables with respective names. However, product IDs are currently not stored in a user's meta_data.
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.
Then this method should take a generic product ID argument and return product information details.
EMAIL_PRODUCT_ID should not be hardcoded in the method implementation, but instead passed in as a productId
argument from the client using this getProductInfo
method.
openapi-docs/README.md
Outdated
@@ -127,17 +127,21 @@ Class | Method | HTTP request | Description | |||
------------ | ------------- | ------------- | ------------- | |||
*AmbianicCloudApiCollection.DefaultApi* | [**createSubscription**](docs/DefaultApi.md#createSubscription) | **POST** /subscription | Subscribe a user to Ambianic's Premium Services | |||
*AmbianicCloudApiCollection.DefaultApi* | [**deleteSubscription**](docs/DefaultApi.md#deleteSubscription) | **DELETE** /subscription | Delete an Ambianic's user subscription | |||
*AmbianicCloudApiCollection.DefaultApi* | [**getNotificationProduct**](docs/DefaultApi.md#getNotificationProduct) | **GET** /product | Retrieve notification product |
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.
@vickywane in line with previous comments, this function name should be probably renamed to getProductInformation()
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.
An adjustment has been made to the operationId
field in the openapi spec to correct this.
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.
@vickywane the change has not been reflected in the README.md file.
The path still links to docs/DefaultApi.md#getNotificationProduct
instead of docs/DefaultApi.md#getProductInfo
.
This pull request fixes 1 alert when merging 6f40ab2 into a31218f - view on LGTM.com fixed alerts:
|
docs/index.html
Outdated
<a href="#operation--product-get">GET</a> | ||
</td> | ||
<td> | ||
<p>Retrieve notification product</p> |
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.
Still reads
"
Retrieve notification product
"
docs/index.html
Outdated
<span id="path--product"></span> | ||
<div id="operation--product-get" class="swagger--panel-operation-get panel"> | ||
<div class="panel-heading"> | ||
<div class="operation-summary">Retrieve notification product</div> |
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.
Strange. This index.html
file still shows <div class="operation-summary">Retrieve notification product</div>
netlify/functions/product.js
Outdated
} else if (event.httpMethod === "GET") { | ||
|
||
try { | ||
const product = await stripe.products.retrieve(process.env.EMAIL_PRODUCT_ID); |
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.
Then this method should take a generic product ID argument and return product information details.
EMAIL_PRODUCT_ID should not be hardcoded in the method implementation, but instead passed in as a productId
argument from the client using this getProductInfo
method.
@vickywane In my most recent commit, i updated the bootprint docs alongside the |
This pull request fixes 1 alert when merging 11d303f into a31218f - view on LGTM.com fixed alerts:
|
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.
Needs clean up.
@@ -23,7 +23,7 @@ STRIPE_KEY=STRIPE_KEY | |||
|
|||
# The ID of the email price product used in billing subscribers. | |||
EMAIL_PRODUCT_PRICE_ID=EMAIL_PRODUCT_PRICE_ID |
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.
@vickywane is this doc line still necessary? We do not hardcode product ID in the API.
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.
For now, yes it is.
The EMAIL_PRODUCT_PRICE_ID
that is used to retrieve only the pricing entity is different from the EMAIL_PRODUCT_ID
.
The EMAIL_PRODUCT_PRICE_ID
is used in the /subscription
function when creating a subscription. The product ID response retrieved using the /product
function does not include the ID of the pricing entity.
See subscription and price docs.
I would further rephrase the description of the EMAIL_PRODUCT_PRICE_ID
to better reflect it's use
docs/index.html
Outdated
<a href="#operation--product-get">GET</a> | ||
</td> | ||
<td> | ||
<p>Retrieve product and pricing information associated with a premium customer subscription.</p> |
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.
@vickywane this description is misleading. If the method returns information associated with a subscription, then the arguments to the method should be user id or subscription id. Needs clean up.
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.
Alright.
You however requested me to use that description here.
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.
Yes, I thought at the time that we would pass user subscription ID as an argument, but later I realized your intention is to pass product ID as an argument to this GET /product
method.
docs/index.html
Outdated
<a href="#operation--product-get">GET</a> | ||
</td> | ||
<td> | ||
<p>Retrieve product and pricing information associated with a premium customer subscription.</p> |
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.
Yes, I thought at the time that we would pass user subscription ID as an argument, but later I realized your intention is to pass product ID as an argument to this GET /product
method.
docs/index.html
Outdated
</div> | ||
<div class="panel-body"> | ||
<section class="sw-operation-description"> | ||
<p>An endpoint to retrieve details about Ambianic product.</p> |
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.
@vickywane let's clarify here:
"An endpoint to retrieve details about an Ambianic premium subscription product."
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.
Alright. I made this adjustment
openapi-docs/README.md
Outdated
@@ -127,17 +127,21 @@ Class | Method | HTTP request | Description | |||
------------ | ------------- | ------------- | ------------- | |||
*AmbianicCloudApiCollection.DefaultApi* | [**createSubscription**](docs/DefaultApi.md#createSubscription) | **POST** /subscription | Subscribe a user to Ambianic's Premium Services | |||
*AmbianicCloudApiCollection.DefaultApi* | [**deleteSubscription**](docs/DefaultApi.md#deleteSubscription) | **DELETE** /subscription | Delete an Ambianic's user subscription | |||
*AmbianicCloudApiCollection.DefaultApi* | [**getNotificationProduct**](docs/DefaultApi.md#getNotificationProduct) | **GET** /product | Retrieve notification product |
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.
@vickywane the change has not been reflected in the README.md file.
The path still links to docs/DefaultApi.md#getNotificationProduct
instead of docs/DefaultApi.md#getProductInfo
.
openapi-docs/docs/DefaultApi.md
Outdated
@@ -6,6 +6,7 @@ Method | HTTP request | Description | |||
------------- | ------------- | ------------- | |||
[**createSubscription**](DefaultApi.md#createSubscription) | **POST** /subscription | Subscribe a user to Ambianic's Premium Services | |||
[**deleteSubscription**](DefaultApi.md#deleteSubscription) | **DELETE** /subscription | Delete an Ambianic's user subscription | |||
[**getNotificationProduct**](DefaultApi.md#getNotificationProduct) | **GET** /product | Retrieve notification product |
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.
@vickywane another line that needs cleanup getNotificationProduct
.
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.
This would be reflected in the new operation-id
openapi-docs/docs/DefaultApi.md
Outdated
@@ -117,6 +118,55 @@ No authorization required | |||
- **Accept**: application/json | |||
|
|||
|
|||
## getNotificationProduct |
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.
@vickywane I see a lot of references to getNotificationProduct
. Is the intention to have a method hardwired to getting notification product information or is the goal to have a more generic getProductInfo
method?
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.
I was yet to push the new updates from my local repository at the time of your review. I only called your attention to this comment.
"Content-Type": "application/json", | ||
}; | ||
|
||
exports.handler = async ({ httpMethod, queryStringParameters }, context, callback) => { |
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.
@vickywane I see that the implementation is now generic and works for any valid Product ID. Therefore the JS function name should match that behavior and be named getProductInfo
as opposed to the more narrow getNotificationProduct
naming.
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.
Alright.
I have adjusted the operation-id
to effect this change.
openapi-docs/docs/DefaultApi.md
Outdated
@@ -6,6 +6,7 @@ Method | HTTP request | Description | |||
------------- | ------------- | ------------- | |||
[**createSubscription**](DefaultApi.md#createSubscription) | **POST** /subscription | Subscribe a user to Ambianic's Premium Services | |||
[**deleteSubscription**](DefaultApi.md#deleteSubscription) | **DELETE** /subscription | Delete an Ambianic's user subscription | |||
[**getNotificationProduct**](DefaultApi.md#getNotificationProduct) | **GET** /product | Retrieve notification product |
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.
@vickywane DefaultApi.md
still reads Retrieve notification product
for GET /product
.
11d303f
to
b908eb4
Compare
This pull request fixes 1 alert when merging b908eb4 into a31218f - view on LGTM.com fixed alerts:
|
This pull request closes this issue.
This PR introduces a
GET
operation into the/notification
endpoint to fetch the email notification product created on Stripe. This operation would be further used by the Premium services feature within the Ambianic PWA.