Skip to content

Commit

Permalink
Updated readme + ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
bwiz committed Sep 6, 2024
1 parent a2f8ece commit 69330a5
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 23 deletions.
1 change: 0 additions & 1 deletion .github/workflows/generate_sdk_code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ jobs:
run: |
java --version
java -jar ${{ runner.temp }}/openapi-generator-cli.jar generate -i ${{ runner.temp }}/openapispec/openapi.yml -g typescript-fetch -o ./src -c ${{ runner.temp }}/${{ env.CONFIG_FILE }} --skip-validate-spec
cp ./src/README.md ./README.md
- name: Create Pull Request
id: cpr
Expand Down
69 changes: 47 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,71 @@
## [email protected]
## Databox

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:
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:

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

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))
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)).

### Building
### Installing

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

### Publishing
### 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.

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

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

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

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

```
npm install [email protected] --save
```

_unPublished (not recommended):_

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

0 comments on commit 69330a5

Please sign in to comment.