Skip to content

Commit

Permalink
update: updated bootprint docs & made /product reusable with params
Browse files Browse the repository at this point in the history
  • Loading branch information
vickywane committed Jun 18, 2021
1 parent 6f40ab2 commit 11d303f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
6 changes: 3 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h2 id="swagger--summary-no-tags">Summary</h2>
<a href="#operation--product-get">GET</a>
</td>
<td>
<p>Retrieve notification product</p>
<p>Retrieve product and pricing information associated with a premium customer subscription.</p>

</td>
</tr>
Expand Down Expand Up @@ -199,12 +199,12 @@ <h3 class="panel-title"><span class="operation-name">POST</span> <strong>/notifi
<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>
<div class="operation-summary">Retrieve product and pricing information associated with a premium customer subscription.</div>
<h3 class="panel-title"><span class="operation-name">GET</span> <strong>/product</strong></h3>
</div>
<div class="panel-body">
<section class="sw-operation-description">
<p>An endpoint to retrieve details about the Ambianic notifications product.</p>
<p>An endpoint to retrieve details about Ambianic product.</p>

</section>

Expand Down
17 changes: 13 additions & 4 deletions netlify/functions/product.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,28 @@ const headers = {
"Content-Type": "application/json",
};

exports.handler = async (event, context, callback) => {
exports.handler = async ({ httpMethod, queryStringParameters }, context, callback) => {
const { productId } = queryStringParameters

if (event.httpMethod === "OPTIONS") {
if (!productId) {
callback(null, {
statusCode: 422,
headers,
body: JSON.stringify({ message: "Provide productId param to retrieve product details" }),
});
}

if (httpMethod === "OPTIONS") {
// for preflight check
callback(null, {
statusCode: 200,
headers,
body: JSON.stringify({ status: "OK" }),
});
} else if (event.httpMethod === "GET") {
} else if (httpMethod === "GET") {

try {
const product = await stripe.products.retrieve(process.env.EMAIL_PRODUCT_ID);
const product = await stripe.products.retrieve(productId);

callback(null, {
statusCode: 200,
Expand Down
2 changes: 1 addition & 1 deletion openapi-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ paths:
/product:
get:
summary: Retrieve product and pricing information associated with a premium customer subscription.
description: An endpoint to retrieve details about the Ambianic notifications product.
description: An endpoint to retrieve details about Ambianic product.
operationId: get-product-information
parameters:
- name: Access-Control-Allow-Origin
Expand Down

0 comments on commit 11d303f

Please sign in to comment.