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

[SDK release] Generated SDK code based on data-link 0.4.4-alpha.3 API changes #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 22 additions & 47 deletions src/README.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,46 @@
## Databox
## [email protected]

This package is designed to consume the Databox Push API functionality via TypeScript/JavaScript client that utilizes [Fetch API](https://fetch.spec.whatwg.org/). The package is compatible with the following environments:
This generator creates TypeScript/JavaScript client that utilizes [Fetch API](https://fetch.spec.whatwg.org/). The generated Node module can be used in the following environments:

Environment
* Node.js
* Webpack
* Browserify

Language level
* ES5 - You must have a Promises/A+ library installed
* ES5 - you must have a Promises/A+ library installed
* ES6

Module system
* CommonJS
* ES6 module system

The package can be used with both TypeScript and JavaScript. In TypeScript, the definitions will be automatically resolved via `package.json`. ([Reference](https://www.typescriptlang.org/docs/handbook/declaration-files/consumption.html)).
It can be used in both TypeScript and JavaScript. In TypeScript, the definition will be automatically resolved via `package.json`. ([Reference](https://www.typescriptlang.org/docs/handbook/declaration-files/consumption.html))

### Installing
### Building

To build and compile the typescript sources to javascript use:
```
npm install databox --save
npm install
npm run build
```

### Prerequisites
In use the Databox Push API functionality, please refer to [Databox Developers Page](https://developers.databox.com/), specifically the **Quick Guide** section, where you will learn how to create a **Databox Push API token** which is required for pushing your data.
### Publishing

### Example
The basic example of pushing data to Databox is provided below:
```TypeScript
import {
ApiResponse,
Configuration,
DataPostRequest,
DefaultApi,
} from "databox";
First build the package then run `npm publish`

const config: Configuration = new Configuration({
basePath: "https://push.databox.com",
username: "<Your_Databox_API_Token>",
headers: {
Accept: "application/vnd.databox.v2+json",
},
});
### Consuming

const dataPostRequest: DataPostRequest = {
pushData: [
{
key: "<Metric_name>",
value: 123,
date: "<Date_in_ISO8601>",
unit: "<Unit>", // Optional
attributes: [{ key: "<Dimension_name>", value: "<Dimension_value>" }], // Optional
},
],
};
navigate to the folder of your consuming project and run one of the following commands.

const api = new DefaultApi(config);
_published:_

try {
api
.dataPostRaw(dataPostRequest)
.then((response: ApiResponse<void>) => response.raw.json())
.then((responseBody) => {
console.log("Response data", responseBody);
});
} catch (error) {
console.log("Error: ", error);
}
```
```
npm install [email protected] --save
```

_unPublished (not recommended):_

```
npm install PATH_TO_GENERATED_PACKAGE --save
```
5 changes: 4 additions & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "OpenAPI-Generator",
"repository": {
"type": "git",
"url": "https://github.com/databox/databox-js.git"
"url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git"
},
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
Expand All @@ -15,5 +15,8 @@
},
"devDependencies": {
"typescript": "^4.0 || ^5.0"
},
"publishConfig": {
"registry": "https://github.com/databox/databox-js.git"
}
}
2 changes: 1 addition & 1 deletion src/src/apis/DefaultApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Static OpenAPI document of Push API resource
* Push API resources Open API documentation
*
* The version of the OpenAPI document: 0.4.3
* The version of the OpenAPI document: 0.4.4-alpha.3
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion src/src/models/ModelApiResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Static OpenAPI document of Push API resource
* Push API resources Open API documentation
*
* The version of the OpenAPI document: 0.4.3
* The version of the OpenAPI document: 0.4.4-alpha.3
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion src/src/models/PushData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Static OpenAPI document of Push API resource
* Push API resources Open API documentation
*
* The version of the OpenAPI document: 0.4.3
* The version of the OpenAPI document: 0.4.4-alpha.3
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion src/src/models/PushDataAttribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Static OpenAPI document of Push API resource
* Push API resources Open API documentation
*
* The version of the OpenAPI document: 0.4.3
* The version of the OpenAPI document: 0.4.4-alpha.3
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion src/src/models/State.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Static OpenAPI document of Push API resource
* Push API resources Open API documentation
*
* The version of the OpenAPI document: 0.4.3
* The version of the OpenAPI document: 0.4.4-alpha.3
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion src/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Static OpenAPI document of Push API resource
* Push API resources Open API documentation
*
* The version of the OpenAPI document: 0.4.3
* The version of the OpenAPI document: 0.4.4-alpha.3
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down