Skip to content

Commit

Permalink
update: renamed GET /notification to /product
Browse files Browse the repository at this point in the history
  • Loading branch information
vickywane committed Jun 14, 2021
1 parent d9ea887 commit 83c257b
Show file tree
Hide file tree
Showing 22 changed files with 584 additions and 166 deletions.
99 changes: 52 additions & 47 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,26 @@ <h2 id="swagger--summary-no-tags">Summary</h2>
</thead>
<tbody>
<tr>
<td class="swagger--summary-path" rowspan="2">
<td class="swagger--summary-path" rowspan="1">
<a href="#path--notification">/notification</a>
</td>
<td>
<a href="#operation--notification-get">GET</a>
<a href="#operation--notification-post">POST</a>
</td>
<td>
<p>Retrieve notification product</p>
<p>Send an event detection notification</p>

</td>
</tr>
<tr>
<td class="swagger--summary-path" rowspan="1">
<a href="#path--product">/product</a>
</td>
<td>
<a href="#operation--notification-post">POST</a>
<a href="#operation--product-get">GET</a>
</td>
<td>
<p>Send an event detection notification</p>
<p>Retrieve notification product</p>

</td>
</tr>
Expand Down Expand Up @@ -92,14 +95,14 @@ <h2>Paths</h2>


<span id="path--notification"></span>
<div id="operation--notification-get" class="swagger--panel-operation-get panel">
<div id="operation--notification-post" class="swagger--panel-operation-post panel">
<div class="panel-heading">
<div class="operation-summary">Retrieve notification product</div>
<h3 class="panel-title"><span class="operation-name">GET</span> <strong>/notification</strong></h3>
<div class="operation-summary">Send an event detection notification</div>
<h3 class="panel-title"><span class="operation-name">POST</span> <strong>/notification</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 send notifications about detected objects to a premium ambianic subscriber from a running edge device, delivered from the Cloud API.</p>

</section>

Expand All @@ -116,6 +119,40 @@ <h3 class="panel-title"><span class="operation-name">GET</span> <strong>/notific
</tr>
</thead>
<tbody>
<tr>
<td>
userId
</td>
<td><p>ID of the user that owns the Edge Device triggering the notification</p>
</td>
<td>query</td>
<td>
<span class="json-property-type">object</span>
<span class="json-property-range" title="Value limits"></span>

</td>
<td>
<span class="json-property-required"></span>
<span class="swagger--global"></span> <span class="json-schema--reference"><a href="#/components/parameters/userId">#/components/parameters/userId</a></span>
</td>
</tr>
<tr>
<td>
notification
</td>
<td><p>Notification object containing detected event details from running ambianic edge device</p>
</td>
<td>query</td>
<td>
<span class="json-property-type">object</span>
<span class="json-property-range" title="Value limits"></span>

</td>
<td>
<span class="json-property-required"></span>
<span class="swagger--global"></span> <span class="json-schema--reference"><a href="#/components/parameters/notification">#/components/parameters/notification</a></span>
</td>
</tr>
<tr>
<td>
Access-Control-Allow-Origin
Expand Down Expand Up @@ -158,14 +195,16 @@ <h3 class="panel-title"><span class="operation-name">GET</span> <strong>/notific
</section>
</div>
</div>
<div id="operation--notification-post" class="swagger--panel-operation-post panel">

<span id="path--product"></span>
<div id="operation--product-get" class="swagger--panel-operation-get panel">
<div class="panel-heading">
<div class="operation-summary">Send an event detection notification</div>
<h3 class="panel-title"><span class="operation-name">POST</span> <strong>/notification</strong></h3>
<div class="operation-summary">Retrieve notification 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 send notifications about detected objects to a premium ambianic subscriber from a running edge device, delivered from the Cloud API.</p>
<p>An endpoint to retrieve details about the Ambianic notifications product.</p>

</section>

Expand All @@ -182,40 +221,6 @@ <h3 class="panel-title"><span class="operation-name">POST</span> <strong>/notifi
</tr>
</thead>
<tbody>
<tr>
<td>
userId
</td>
<td><p>ID of the user that owns the Edge Device triggering the notification</p>
</td>
<td>query</td>
<td>
<span class="json-property-type">object</span>
<span class="json-property-range" title="Value limits"></span>

</td>
<td>
<span class="json-property-required"></span>
<span class="swagger--global"></span> <span class="json-schema--reference"><a href="#/components/parameters/userId">#/components/parameters/userId</a></span>
</td>
</tr>
<tr>
<td>
notification
</td>
<td><p>Notification object containing detected event details from running ambianic edge device</p>
</td>
<td>query</td>
<td>
<span class="json-property-type">object</span>
<span class="json-property-range" title="Value limits"></span>

</td>
<td>
<span class="json-property-required"></span>
<span class="swagger--global"></span> <span class="json-schema--reference"><a href="#/components/parameters/notification">#/components/parameters/notification</a></span>
</td>
</tr>
<tr>
<td>
Access-Control-Allow-Origin
Expand Down
2 changes: 1 addition & 1 deletion docs/main.css.map

Large diffs are not rendered by default.

32 changes: 0 additions & 32 deletions netlify/functions/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,6 @@ const transport = nodemailer.createTransport({
const sender = process.env.SMTP_SENDER;

exports.handler = async (event, context, callback) => {

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

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

console.log(product)

callback(null, {
statusCode: 200,
headers,
body: JSON.stringify({ product }),
});
} catch (error) {
callback(null, {
statusCode: 500,
headers,
body: JSON.stringify({ error }),
});
}


} else if (event.httpMethod === "POST") {
const { userId, notification } = JSON.parse(`${event.body}`);

try {
Expand Down Expand Up @@ -113,6 +83,4 @@ exports.handler = async (event, context, callback) => {
body: JSON.stringify({ error: error.message }),
});
}
}

};
37 changes: 37 additions & 0 deletions netlify/functions/product.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
require("dotenv").config();
const stripe = require("stripe")(process.env.STRIPE_KEY);

const headers = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "Content-Type",
"Content-Type": "application/json",
};

exports.handler = async (event, context, callback) => {

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

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

callback(null, {
statusCode: 200,
headers,
body: JSON.stringify({ product }),
});
} catch (error) {
callback(null, {
statusCode: 500,
headers,
body: JSON.stringify({ error }),
});
}
}
};
8 changes: 3 additions & 5 deletions openapi-docs/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ docs/InlineResponse200.md
docs/InlineResponse2001.md
docs/InlineResponse2002.md
docs/InlineResponse2003.md
docs/InlineResponse2003Product.md
docs/InlineResponse2004.md
docs/InlineResponse2004Product.md
src/ApiClient.js
src/api/DefaultApi.js
src/index.js
Expand All @@ -19,8 +19,6 @@ src/model/InlineResponse200.js
src/model/InlineResponse2001.js
src/model/InlineResponse2002.js
src/model/InlineResponse2003.js
src/model/InlineResponse2003Product.js
src/model/InlineResponse2004.js
test/model/InlineObject1.spec.js
test/model/InlineResponse2003Product.spec.js
test/model/InlineResponse2004.spec.js
src/model/InlineResponse2004Product.js
test/model/InlineResponse2004Product.spec.js
4 changes: 2 additions & 2 deletions openapi-docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ 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** /notification | Retrieve notification product
*AmbianicCloudApiCollection.DefaultApi* | [**getNotificationProduct**](docs/DefaultApi.md#getNotificationProduct) | **GET** /product | Retrieve notification 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

Expand All @@ -140,8 +140,8 @@ Class | Method | HTTP request | Description
- [AmbianicCloudApiCollection.InlineResponse2001](docs/InlineResponse2001.md)
- [AmbianicCloudApiCollection.InlineResponse2002](docs/InlineResponse2002.md)
- [AmbianicCloudApiCollection.InlineResponse2003](docs/InlineResponse2003.md)
- [AmbianicCloudApiCollection.InlineResponse2003Product](docs/InlineResponse2003Product.md)
- [AmbianicCloudApiCollection.InlineResponse2004](docs/InlineResponse2004.md)
- [AmbianicCloudApiCollection.InlineResponse2004Product](docs/InlineResponse2004Product.md)


## Documentation for Authorization
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** /notification | Retrieve notification product
[**getNotificationProduct**](DefaultApi.md#getNotificationProduct) | **GET** /product | Retrieve notification 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 @@ -120,7 +120,7 @@ No authorization required

## getNotificationProduct

> InlineResponse2003 getNotificationProduct(accessControlAllowOrigin, opts)
> InlineResponse2004 getNotificationProduct(accessControlAllowOrigin, opts)
Retrieve notification product

Expand All @@ -134,7 +134,7 @@ import AmbianicCloudApiCollection from 'ambianic_cloud_api_collection';
let apiInstance = new AmbianicCloudApiCollection.DefaultApi();
let accessControlAllowOrigin = *; // String |
let opts = {
'inlineObject': new AmbianicCloudApiCollection.InlineObject() // InlineObject |
'inlineObject1': new AmbianicCloudApiCollection.InlineObject1() // InlineObject1 |
};
apiInstance.getNotificationProduct(accessControlAllowOrigin, opts, (error, data, response) => {
if (error) {
Expand All @@ -151,11 +151,11 @@ apiInstance.getNotificationProduct(accessControlAllowOrigin, opts, (error, data,
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**accessControlAllowOrigin** | **String**| |
**inlineObject** | [**InlineObject**](InlineObject.md)| | [optional]
**inlineObject1** | [**InlineObject1**](InlineObject1.md)| | [optional]

### Return type

[**InlineResponse2003**](InlineResponse2003.md)
[**InlineResponse2004**](InlineResponse2004.md)

### Authorization

Expand Down Expand Up @@ -222,7 +222,7 @@ No authorization required

## sendNotification

> InlineResponse2004 sendNotification(userId, notification, accessControlAllowOrigin, opts)
> InlineResponse2003 sendNotification(userId, notification, accessControlAllowOrigin, opts)
Send an event detection notification

Expand All @@ -238,7 +238,7 @@ let userId = AUTHO_USER_ID ; // String | ID of the user that owns the Edge Devic
let notification = {dateTime: "monday"}; // String | Notification object containing detected event details from running ambianic edge device
let accessControlAllowOrigin = *; // String |
let opts = {
'inlineObject1': new AmbianicCloudApiCollection.InlineObject1() // InlineObject1 |
'inlineObject': new AmbianicCloudApiCollection.InlineObject() // InlineObject |
};
apiInstance.sendNotification(userId, notification, accessControlAllowOrigin, opts, (error, data, response) => {
if (error) {
Expand All @@ -257,11 +257,11 @@ Name | Type | Description | Notes
**userId** | **String**| ID of the user that owns the Edge Device triggering the notification |
**notification** | **String**| Notification object containing detected event details from running ambianic edge device |
**accessControlAllowOrigin** | **String**| |
**inlineObject1** | [**InlineObject1**](InlineObject1.md)| | [optional]
**inlineObject** | [**InlineObject**](InlineObject.md)| | [optional]

### Return type

[**InlineResponse2004**](InlineResponse2004.md)
[**InlineResponse2003**](InlineResponse2003.md)

### Authorization

Expand Down
2 changes: 1 addition & 1 deletion openapi-docs/docs/InlineObject.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**message** | **String** | | [optional]
**message** | **String** | |


2 changes: 1 addition & 1 deletion openapi-docs/docs/InlineObject1.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**message** | **String** | |
**message** | **String** | | [optional]


2 changes: 1 addition & 1 deletion openapi-docs/docs/InlineResponse2003.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**product** | [**InlineResponse2003Product**](InlineResponse2003Product.md) | |
**message** | **String** | |


2 changes: 1 addition & 1 deletion openapi-docs/docs/InlineResponse2004.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**message** | **String** | |
**product** | [**InlineResponse2004Product**](InlineResponse2004Product.md) | |


Loading

0 comments on commit 83c257b

Please sign in to comment.