diff --git a/examples/pushData/.gitignore b/examples/pushData/.gitignore new file mode 100644 index 0000000..b0d27ea --- /dev/null +++ b/examples/pushData/.gitignore @@ -0,0 +1,3 @@ +/node_modules/* +/dist/* +/package-lock.json \ No newline at end of file diff --git a/examples/pushData/package.json b/examples/pushData/package.json new file mode 100644 index 0000000..6b1ae46 --- /dev/null +++ b/examples/pushData/package.json @@ -0,0 +1,19 @@ +{ + "name": "push-data", + "version": "1.0.0", + "description": "", + "main": "dist/app.js", + "scripts": { + "start": "node dist/app.js", + "build": "tsc" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "databox": "^2.1.2" + }, + "devDependencies": { + "typescript": "^5.5.4" + } +} diff --git a/examples/pushData/src/app.ts b/examples/pushData/src/app.ts new file mode 100644 index 0000000..e4af7a7 --- /dev/null +++ b/examples/pushData/src/app.ts @@ -0,0 +1,39 @@ +import { + ApiResponse, + Configuration, + DataPostRequest, + DefaultApi, +} from "databox"; + +const config: Configuration = new Configuration({ + basePath: "https://push.databox.com", + username: "", + headers: { + Accept: "application/vnd.databox.v2+json", + }, +}); + +const dataPostRequest: DataPostRequest = { + pushData: [ + { + key: "", + value: 123, + date: "", + unit: "", + attributes: [{ key: "", value: "" }], + }, + ], +}; + +const api = new DefaultApi(config); + +try { + api + .dataPostRaw(dataPostRequest) + .then((response: ApiResponse) => response.raw.json()) + .then((responseBody) => { + console.log("Response data", responseBody); + }); +} catch (error) { + console.log("Error: ", error); +} diff --git a/examples/pushData/tsconfig.json b/examples/pushData/tsconfig.json new file mode 100644 index 0000000..642fa31 --- /dev/null +++ b/examples/pushData/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "es2016", + "module": "commonjs", + "rootDir": "./src", + "outDir": "./dist", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true + } +} \ No newline at end of file