Skip to content

Commit

Permalink
update: adjusted /product documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
vickywane committed Jun 21, 2021
1 parent 4e14a81 commit b908eb4
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 85 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Before executing the `netlify dev` command, create a `.env` file in the root dir
# Access key from Stripe to access your Stripe resources
STRIPE_KEY=STRIPE_KEY
# The ID of the email price product used in billing subscribers.
# The ID of the price entity attached to a product.
EMAIL_PRODUCT_PRICE_ID=EMAIL_PRODUCT_PRICE_ID
# Your Auth0 Domain
Expand Down Expand Up @@ -65,7 +65,7 @@ The following environment variables used within the serverless functions, and sh
# Access key from Stripe to access your Stripe resources
STRIPE_KEY=STRIPE_KEY
# The ID of the email price product used in billing subscribers.
# The ID of the price entity attached to a product.
EMAIL_PRODUCT_PRICE_ID=EMAIL_PRODUCT_PRICE_ID
# Your Auth0 Domain
Expand Down
21 changes: 18 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>An endpoint to retrieve details about an Ambianic premium subscription product.</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">An endpoint to retrieve details about an Ambianic premium subscription product.</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>Retrieve product and pricing information associated with an Ambianic product.</p>

</section>

Expand Down Expand Up @@ -236,6 +236,21 @@ <h3 class="panel-title"><span class="operation-name">GET</span> <strong>/product
<span class="json-property-required"></span>
</td>
</tr>
<tr>
<td>
productId
</td>
<td><p>Unique ID of product to be retrieved</p>
</td>
<td>query</td>
<td>
<span class="json-property-type">object</span>
<span class="json-property-range" title="Value limits"></span>

</td>
<td>
</td>
</tr>
</tbody>
</table>
</section>
Expand Down
2 changes: 1 addition & 1 deletion netlify/functions/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ exports.handler = async (event, context, callback) => {
statusCode: 403,
headers,
body: JSON.stringify({
message: "NO ACTIVE SUBSCRIPTION TO SEND EMAIL",
message: "Premium subscription inactive. Cannot send notification email. Please (re)activate premium subscription service.",
}),
});
}
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
3 changes: 0 additions & 3 deletions openapi-docs/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
README.md
docs/DefaultApi.md
docs/InlineObject.md
docs/InlineObject1.md
docs/InlineResponse200.md
docs/InlineResponse2001.md
docs/InlineResponse2002.md
Expand All @@ -14,11 +13,9 @@ src/ApiClient.js
src/api/DefaultApi.js
src/index.js
src/model/InlineObject.js
src/model/InlineObject1.js
src/model/InlineResponse200.js
src/model/InlineResponse2001.js
src/model/InlineResponse2002.js
src/model/InlineResponse2003.js
src/model/InlineResponse2004.js
src/model/InlineResponse2004Product.js
test/model/InlineResponse2004Product.spec.js
3 changes: 1 addition & 2 deletions openapi-docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,14 @@ Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AmbianicCloudApiCollection.DefaultApi* | [**createSubscription**](docs/DefaultApi.md#createSubscription) | **POST** /subscription | Subscribe a user to Ambianic&#39;s Premium Services
*AmbianicCloudApiCollection.DefaultApi* | [**deleteSubscription**](docs/DefaultApi.md#deleteSubscription) | **DELETE** /subscription | Delete an Ambianic&#39;s user subscription
*AmbianicCloudApiCollection.DefaultApi* | [**getNotificationProduct**](docs/DefaultApi.md#getNotificationProduct) | **GET** /product | Retrieve notification product
*AmbianicCloudApiCollection.DefaultApi* | [**getProductInfo**](docs/DefaultApi.md#getProductInfo) | **GET** /product | An endpoint to retrieve details about an Ambianic premium subscription product.
*AmbianicCloudApiCollection.DefaultApi* | [**getSubscriptionData**](docs/DefaultApi.md#getSubscriptionData) | **GET** /subscription | Get a user&#39;s subscription data
*AmbianicCloudApiCollection.DefaultApi* | [**sendNotification**](docs/DefaultApi.md#sendNotification) | **POST** /notification | Send an event detection notification


## Documentation for Models

- [AmbianicCloudApiCollection.InlineObject](docs/InlineObject.md)
- [AmbianicCloudApiCollection.InlineObject1](docs/InlineObject1.md)
- [AmbianicCloudApiCollection.InlineResponse200](docs/InlineResponse200.md)
- [AmbianicCloudApiCollection.InlineResponse2001](docs/InlineResponse2001.md)
- [AmbianicCloudApiCollection.InlineResponse2002](docs/InlineResponse2002.md)
Expand Down
18 changes: 9 additions & 9 deletions openapi-docs/docs/DefaultApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Method | HTTP request | Description
------------- | ------------- | -------------
[**createSubscription**](DefaultApi.md#createSubscription) | **POST** /subscription | Subscribe a user to Ambianic&#39;s Premium Services
[**deleteSubscription**](DefaultApi.md#deleteSubscription) | **DELETE** /subscription | Delete an Ambianic&#39;s user subscription
[**getNotificationProduct**](DefaultApi.md#getNotificationProduct) | **GET** /product | Retrieve notification product
[**getProductInfo**](DefaultApi.md#getProductInfo) | **GET** /product | An endpoint to retrieve details about an Ambianic premium subscription product.
[**getSubscriptionData**](DefaultApi.md#getSubscriptionData) | **GET** /subscription | Get a user&#39;s subscription data
[**sendNotification**](DefaultApi.md#sendNotification) | **POST** /notification | Send an event detection notification

Expand Down Expand Up @@ -118,13 +118,13 @@ No authorization required
- **Accept**: application/json


## getNotificationProduct
## getProductInfo

> InlineResponse2004 getNotificationProduct(accessControlAllowOrigin, opts)
> InlineResponse2004 getProductInfo(accessControlAllowOrigin, opts)
Retrieve notification product
An endpoint to retrieve details about an Ambianic premium subscription product.

An endpoint to retrieve details about the Ambianic notifications product.
Retrieve product and pricing information associated with an Ambianic product.

### Example

Expand All @@ -134,9 +134,9 @@ import AmbianicCloudApiCollection from 'ambianic_cloud_api_collection';
let apiInstance = new AmbianicCloudApiCollection.DefaultApi();
let accessControlAllowOrigin = *; // String |
let opts = {
'inlineObject1': new AmbianicCloudApiCollection.InlineObject1() // InlineObject1 |
'productId': "productId_example" // String | Unique ID of product to be retrieved
};
apiInstance.getNotificationProduct(accessControlAllowOrigin, opts, (error, data, response) => {
apiInstance.getProductInfo(accessControlAllowOrigin, opts, (error, data, response) => {
if (error) {
console.error(error);
} else {
Expand All @@ -151,7 +151,7 @@ apiInstance.getNotificationProduct(accessControlAllowOrigin, opts, (error, data,
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**accessControlAllowOrigin** | **String**| |
**inlineObject1** | [**InlineObject1**](InlineObject1.md)| | [optional]
**productId** | **String**| Unique ID of product to be retrieved | [optional]

### Return type

Expand All @@ -163,7 +163,7 @@ No authorization required

### HTTP request headers

- **Content-Type**: application/json
- **Content-Type**: Not defined
- **Accept**: application/json


Expand Down
22 changes: 11 additions & 11 deletions openapi-docs/src/api/DefaultApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import ApiClient from "../ApiClient";
import InlineObject from '../model/InlineObject';
import InlineObject1 from '../model/InlineObject1';
import InlineResponse200 from '../model/InlineResponse200';
import InlineResponse2001 from '../model/InlineResponse2001';
import InlineResponse2002 from '../model/InlineResponse2002';
Expand Down Expand Up @@ -175,33 +174,34 @@ export default class DefaultApi {
}

/**
* Callback function to receive the result of the getNotificationProduct operation.
* @callback module:api/DefaultApi~getNotificationProductCallback
* Callback function to receive the result of the getProductInfo operation.
* @callback module:api/DefaultApi~getProductInfoCallback
* @param {String} error Error message, if any.
* @param {module:model/InlineResponse2004} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/

/**
* Retrieve notification product
* An endpoint to retrieve details about the Ambianic notifications product.
* An endpoint to retrieve details about an Ambianic premium subscription product.
* Retrieve product and pricing information associated with an Ambianic product.
* @param {String} accessControlAllowOrigin
* @param {Object} opts Optional parameters
* @param {module:model/InlineObject1} opts.inlineObject1
* @param {module:api/DefaultApi~getNotificationProductCallback} callback The callback function, accepting three arguments: error, data, response
* @param {String} opts.productId Unique ID of product to be retrieved
* @param {module:api/DefaultApi~getProductInfoCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/InlineResponse2004}
*/
getNotificationProduct(accessControlAllowOrigin, opts, callback) {
getProductInfo(accessControlAllowOrigin, opts, callback) {
opts = opts || {};
let postBody = opts['inlineObject1'];
let postBody = null;
// verify the required parameter 'accessControlAllowOrigin' is set
if (accessControlAllowOrigin === undefined || accessControlAllowOrigin === null) {
throw new Error("Missing the required parameter 'accessControlAllowOrigin' when calling getNotificationProduct");
throw new Error("Missing the required parameter 'accessControlAllowOrigin' when calling getProductInfo");
}

let pathParams = {
};
let queryParams = {
'productId': opts['productId']
};
let headerParams = {
'Access-Control-Allow-Origin': accessControlAllowOrigin
Expand All @@ -210,7 +210,7 @@ export default class DefaultApi {
};

let authNames = [];
let contentTypes = ['application/json'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = InlineResponse2004;
return this.apiClient.callApi(
Expand Down
7 changes: 0 additions & 7 deletions openapi-docs/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import ApiClient from './ApiClient';
import InlineObject from './model/InlineObject';
import InlineObject1 from './model/InlineObject1';
import InlineResponse200 from './model/InlineResponse200';
import InlineResponse2001 from './model/InlineResponse2001';
import InlineResponse2002 from './model/InlineResponse2002';
Expand Down Expand Up @@ -68,12 +67,6 @@ export {
*/
InlineObject,

/**
* The InlineObject1 model constructor.
* @property {module:model/InlineObject1}
*/
InlineObject1,

/**
* The InlineResponse200 model constructor.
* @property {module:model/InlineResponse200}
Expand Down
Loading

0 comments on commit b908eb4

Please sign in to comment.