{"_id":"@adam_park/onesignal-node","_rev":"1-bbe68c7abeffb681d7cd24279daa2f5e","name":"@adam_park/onesignal-node","dist-tags":{"latest":"3.4.1"},"versions":{"3.4.0":{"name":"@adam_park/onesignal-node","version":"3.4.0","description":"A Node.js Library for OneSignal push notification service","engines":{"node":">=8.13.0"},"main":"./lib/index.js","types":"./lib/index.d.ts","scripts":{"lint":"eslint src test --ext .js,.ts","build":"tsc","test":"mocha -r ts-node/register 'test/unit/**/*.spec.ts'","test-integration":"mocha -r ts-node/register 'test/integration/**/*.spec.ts'","coverage":"nyc --reporter=lcov npm run test","update-codecov":"codecov"},"repository":{"type":"git","url":"git+https://github.com/zeyneloz/onesignal-node.git"},"keywords":["onesignal","one-signal","gcm","signal","notification"],"author":{"name":"Zeynel","email":"ozdemir.zynl@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/zeyneloz/onesignal-node.git/issues"},"homepage":"https://github.com/zeyneloz/onesignal-node.git#readme","devDependencies":{"@types/chai":"^4.3.1","@types/chai-as-promised":"^7.1.5","@types/chai-string":"^1.4.2","@types/mocha":"^5.2.7","@types/nock":"^11.1.0","@types/node":"^12.20.55","@types/request":"^2.48.8","@types/request-promise":"^4.1.48","@types/sinon":"^7.5.2","@types/sinon-chai":"^3.2.8","@typescript-eslint/eslint-plugin":"^2.34.0","@typescript-eslint/parser":"^2.34.0","chai":"^4.3.6","chai-as-promised":"^7.1.1","chai-string":"^1.5.0","codecov":"^3.8.3","eslint":"^6.8.0","eslint-config-airbnb":"^18.2.1","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.7.1","eslint-plugin-import":"^2.26.0","eslint-plugin-json":"^2.1.2","eslint-plugin-prettier":"^3.4.1","eslint-plugin-react":"^7.30.1","mocha":"^6.2.3","nock":"^11.9.1","nyc":"^14.1.1","prettier":"^1.19.1","sinon":"^7.5.0","sinon-chai":"^3.7.0","source-map-support":"^0.5.21","ts-node":"^8.10.2","typedoc":"^0.23.2","typescript":"^3.9.10"},"dependencies":{"request":"^2.88.2","request-promise":"^4.2.6"},"gitHead":"33d3b632ef975411c42f90f538cb4b822c6492ad","_id":"@adam_park/onesignal-node@3.4.0","_nodeVersion":"19.8.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-8ZXqN9e6sRadp2Fcsk9Im+JnYiCiZTfPiorM9u8bpzaufOc7ztj2Jo/dzwecf16QKYcIen0B44lE9HNqqbXdvA==","shasum":"7270b28911b317b10712f8dd9a9dd9afc99085b2","tarball":"https://registry.npmjs.org/@adam_park/onesignal-node/-/onesignal-node-3.4.0.tgz","fileCount":3,"unpackedSize":15452,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDSpHnioaKAF0ipyS0nGmpIoP4bJ60kIXNd/KxpVyWF8QIhAM1uy8I6lu2KnVRsSiX96t3jZ3cJ7tAvlS19v3GtEqDt"}]},"_npmUser":{"name":"adam_park","email":"run.eunsong@gmail.com"},"directories":{},"maintainers":[{"name":"adam_park","email":"run.eunsong@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/onesignal-node_3.4.0_1687915088729_0.3600494477427636"},"_hasShrinkwrap":false},"3.4.1":{"name":"@adam_park/onesignal-node","version":"3.4.1","description":"A Node.js Library for OneSignal push notification service","engines":{"node":">=8.13.0"},"main":"./lib/index.js","types":"./lib/index.d.ts","scripts":{"lint":"eslint src test --ext .js,.ts","build":"tsc","test":"mocha -r ts-node/register 'test/unit/**/*.spec.ts'","test-integration":"mocha -r ts-node/register 'test/integration/**/*.spec.ts'","coverage":"nyc --reporter=lcov npm run test","update-codecov":"codecov"},"repository":{"type":"git","url":"git+https://github.com/zeyneloz/onesignal-node.git"},"keywords":["onesignal","one-signal","gcm","signal","notification"],"author":{"name":"Zeynel","email":"ozdemir.zynl@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/zeyneloz/onesignal-node.git/issues"},"homepage":"https://github.com/zeyneloz/onesignal-node.git#readme","devDependencies":{"@types/chai":"^4.3.1","@types/chai-as-promised":"^7.1.5","@types/chai-string":"^1.4.2","@types/mocha":"^5.2.7","@types/nock":"^11.1.0","@types/node":"^12.20.55","@types/request":"^2.48.8","@types/request-promise":"^4.1.48","@types/sinon":"^7.5.2","@types/sinon-chai":"^3.2.8","@typescript-eslint/eslint-plugin":"^2.34.0","@typescript-eslint/parser":"^2.34.0","chai":"^4.3.6","chai-as-promised":"^7.1.1","chai-string":"^1.5.0","codecov":"^3.8.3","eslint":"^6.8.0","eslint-config-airbnb":"^18.2.1","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.7.1","eslint-plugin-import":"^2.26.0","eslint-plugin-json":"^2.1.2","eslint-plugin-prettier":"^3.4.1","eslint-plugin-react":"^7.30.1","mocha":"^6.2.3","nock":"^11.9.1","nyc":"^14.1.1","prettier":"^1.19.1","sinon":"^7.5.0","sinon-chai":"^3.7.0","source-map-support":"^0.5.21","ts-node":"^8.10.2","typedoc":"^0.23.2","typescript":"^3.9.10"},"dependencies":{"request":"^2.88.2","request-promise":"^4.2.6"},"gitHead":"33d3b632ef975411c42f90f538cb4b822c6492ad","_id":"@adam_park/onesignal-node@3.4.1","_nodeVersion":"19.8.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-i8l54sLIOOw4ob/m575kOOLejuAwObuLr78qJkfRB8E5BMiM2hNUzhJIMXQ/hkj2/hEmedCwl6EWuJy96y+wgw==","shasum":"bd010319be5d3e6cba996cb7ce7062e7daea6e6b","tarball":"https://registry.npmjs.org/@adam_park/onesignal-node/-/onesignal-node-3.4.1.tgz","fileCount":31,"unpackedSize":73316,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC5fHqvwKvI1WYODFr2IvSzZ9sEmQLy8TZ8TzEkbPTlGQIgJvxe/OPmmXc2bURKXw9jqLDkor7OYFptVIj2KicClk8="}]},"_npmUser":{"name":"adam_park","email":"run.eunsong@gmail.com"},"directories":{},"maintainers":[{"name":"adam_park","email":"run.eunsong@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/onesignal-node_3.4.1_1687917670588_0.2703801319708439"},"_hasShrinkwrap":false}},"time":{"created":"2023-06-28T01:18:08.672Z","3.4.0":"2023-06-28T01:18:08.963Z","modified":"2023-06-28T02:01:10.947Z","3.4.1":"2023-06-28T02:01:10.839Z"},"maintainers":[{"name":"adam_park","email":"run.eunsong@gmail.com"}],"description":"A Node.js Library for OneSignal push notification service","homepage":"https://github.com/zeyneloz/onesignal-node.git#readme","keywords":["onesignal","one-signal","gcm","signal","notification"],"repository":{"type":"git","url":"git+https://github.com/zeyneloz/onesignal-node.git"},"author":{"name":"Zeynel","email":"ozdemir.zynl@gmail.com"},"bugs":{"url":"https://github.com/zeyneloz/onesignal-node.git/issues"},"license":"MIT","readme":"# onesignal-node      \n\n<p align=\"center\">\n  <a href=\"https://www.npmjs.com/package/onesignal-node\">\n    <img src=\"https://img.shields.io/npm/v/onesignal-node.svg\" alt=\"Dependency Status\" />\n  </a>\n  <a href=\"https://www.npmjs.com/package/onesignal-node\">\n    <img src=\"https://img.shields.io/npm/dm/onesignal-node.svg\" alt=\"Download Count\" />\n  </a>\n  <a href=\"https://circleci.com/gh/zeyneloz/onesignal-node\">\n    <img src=\"https://circleci.com/gh/zeyneloz/onesignal-node/tree/v3.x.svg?style=shield\" alt=\"Build Status\" />\n  </a>\n  <a href=\"https://snyk.io/test/github/zeyneloz/onesignal-node?targetFile=package.json\">\n    <img src=\"https://snyk.io/test/github/zeyneloz/onesignal-node/badge.svg?targetFile=package.json\" alt=\"Known Vulnerabilities\" data-canonical-src=\"https://snyk.io/test/github/zeyneloz/onesignal-node?targetFile=package.json\" style=\"max-width:100%;\">\n  </a>\n  <a href=\"https://codecov.io/gh/zeyneloz/onesignal-node\">\n    <img src=\"https://codecov.io/gh/zeyneloz/onesignal-node/branch/master/graph/badge.svg\" />\n  </a>\n</p>\n<br>\n\nA Node.js client library for [OneSignal](https://onesignal.com/) API.  \n      \n## Table of Contents      \n* [Overview](#overview)\n* [Installation](#installation)      \n* [Usage](#usage)        \n  * [Client Types](#client-types)\n  * [Creating Client](#creating-client)      \n  * [Create notification](#create-notification)      \n  * [Cancel notification](#cancel-notification)      \n  * [View notifications](#view-notifications)      \n  * [View notification](#view-notification)      \n  * [View apps](#view-apps)      \n  * [Create an app](#create-an-app)      \n  * [Update an app](#update-an-app)      \n  * [View devices](#view-devices)      \n  * [View device](#view-device)      \n  * [Add a device](#add-a-device)      \n  * [Edit a device](#edit-a-device)\n  * [Edit tags with external user id](#edit-tags-with-external-user-id)\n  * [New session](#new-session)  \n  * [New purchase](#new-purchase)  \n  * [Increment Session Length](#increment-session-length)  \n  * [CSV Export](#csv-export)        \n  * [Identity verification](#identity-verification)      \n* [Tests](#tests)\n* [Contributing](#contributing)\n      \n\n## Overview  \n\nThis is a wrapper library over [OneSignal REST API](https://documentation.onesignal.com/reference). You can create notifications,\nview apps, edit a device and all other actions you can take on OneSignal REST API.\n\n## Installation      \n      \n```      \nnpm install onesignal-node --save      \n```      \n\n## Usage\n      \n``` js      \nconst OneSignal = require('onesignal-node');    \n```      \nOR\n``` js      \nimport * as OneSignal from 'onesignal-node';  \n```\n\n### Client Types:\n\nFor all the actions that require your OneSignal app id and app api key, you should use `OneSignal.Client`.\nSample actions: create notification, add device, csv export, create segment...\n\n``` js      \nconst client = new OneSignal.Client('appId', 'apiKey');\n``` \n\nFor all the actions that require your User Auth Key you should use `OneSignal.UserClient`.\nSample actions: view apps, update an app, create an app...\n\n``` js      \nconst userClient = new OneSignal.UserClient('userAuthKey');\n```      \n      \n### Creating client      \n\nYou can create a `Client` object as shown below. It requires two parameters: `appId` and `apiKey`, which you can find them on\nyour applications page on OneSignal dashboard.  \n\nThere is also an optional parameter called `options`. You can set OneSignal rest api endpoint if you wish to using options.\nBy default the library uses `https://onesignal.com/api/v1` for api endpoint.\n  \n```js      \n// With default options\nconst client = new OneSignal.Client('appId', 'apiKey');\n\n// With custom API endpoint\nconst client = new OneSignal.Client('appId', 'apiKey', { apiRoot: 'https://onesignal.com/api/v2'});\n```      \n\n### Creating UserClient      \n\nYou can create a `UserClient` object as shown below. It requires one parameter: `userAuthKey`, which you can find it on\nyour OneSignal dashboard.\n\nThere is also an optional parameter called `options`. You can set OneSignal rest api endpoint if you wish to using options.\nBy default the library uses `https://onesignal.com/api/v1` for api endpoint.\n  \n```js      \n// With default options\nconst userClient = new OneSignal.UserClient('userAuthKey');\n\n// With custom API endpoint\nconst userClient = new OneSignal.UserClient('userAuthKey', { apiRoot: 'https://onesignal.com/api/v2'});\n```     \n\n### Create notification      \n\nhttps://documentation.onesignal.com/reference/create-notification \n\n```ts\n.createNotification(body: CreateNotificationBody): Promise<ClientResponse>\n```\n\nPlease read the sections above to learn how to create a `Client` object.\n\n```js      \n// See all fields: https://documentation.onesignal.com/reference/create-notification\nconst notification = {\n  contents: {\n    'tr': 'Yeni bildirim',\n    'en': 'New notification',\n  },\n  included_segments: ['Subscribed Users'],\n  filters: [\n    { field: 'tag', key: 'level', relation: '>', value: 10 }\n  ]\n};\n\n// using async/await\ntry {\n  const response = await client.createNotification(notification);\n  console.log(response.body.id);\n} catch (e) {\n  if (e instanceof OneSignal.HTTPError) {\n    // When status code of HTTP response is not 2xx, HTTPError is thrown.\n    console.log(e.statusCode);\n    console.log(e.body);\n  }\n}\n\n// or you can use promise style:\nclient.createNotification(notification)\n  .then(response => {})\n  .catch(e => {});\n```      \n    \n### Cancel notification   \n\nhttps://documentation.onesignal.com/reference/cancel-notification\n\n```ts\n.cancelNotification(notificationId: string): Promise<ClientResponse>\n```  \n \n```js      \nconst response = await client.cancelNotification('notification-id');\nconsole.log(response.body);\nconsole.log(response.headers);\nconsole.log(response.statusCode);    \n```      \n      \n### View notifications      \n\nhttps://documentation.onesignal.com/reference/view-notifications\n\n```ts\n.viewNotifications(query?: ViewNotificationsQuery): Promise<ClientResponse>\n```  \n \n```js      \n// without query\nconst response = await client.viewNotifications();\nconsole.log(response.body);\n\n// with query\nconst response = await client.viewNotifications({ limit:10, kind: 2, offset: 2 });\n```      \n      \n### View notification      \n\nhttps://documentation.onesignal.com/reference/view-notification\n\n```ts\n.viewNotification(notificationId: string): Promise<ClientResponse>\n```  \n \n```js      \nconst response = await client.viewNotification('notification-id');\nconsole.log(response.body);  \n```       \n      \n### View apps   \n\nhttps://documentation.onesignal.com/reference/view-apps-apps \n\nYou should use `UserClient` for view apps since it requires User Auth Key  \n   \n```ts\n.viewApps(): Promise<ClientResponse>\n```  \n \n```js      \nconst response = await userClient.viewApps();\nconsole.log(response.body);\n```      \n      \n### Create an app      \n\nhttps://documentation.onesignal.com/reference/create-an-app\n\nYou should use `UserClient` for view apps since it requires User Auth Key  \n   \n```ts\n.createApp(body: CreateAppBody): Promise<ClientResponse>\n```  \n \n```js      \nconst response = await userClient.createApp( { name: 'APP 1' });\nconsole.log(response.body);\n```      \n      \n### Update an app      \n\nhttps://documentation.onesignal.com/reference/update-an-app\n\nYou should use `UserClient` for view apps since it requires User Auth Key  \n   \n```ts\n.updateApp(appId: string, body: UpdateAppBody): Promise<ClientResponse>\n```  \n \n```js      \nconst response = await userClient.updateApp( 'app-id',{ site_name: 'test' });\nconsole.log(response.body);\n```         \n      \n### View devices      \n\nhttps://documentation.onesignal.com/reference/view-devices\n\n```ts\n.viewDevices(query?: LimitOffsetQuery): Promise<ClientResponse>\n```  \n \n```js      \nconst response = await client.viewDevices({ limit: 200, offset: 0 });\nconsole.log(response.body);\n```       \n         \n      \n### View device   \n   \nhttps://documentation.onesignal.com/reference/view-device\n\n```ts\n.viewDevice(identifier: string): Promise<ClientResponse>\n```  \n \n```js      \nconst response = await client.viewDevice('device-id');\nconsole.log(response.body);\n```         \n      \n### Add a device      \n   \nhttps://documentation.onesignal.com/reference/add-a-device \n\n```ts\n.addDevice(body: AddDeviceBody): Promise<ClientResponse>\n```  \n \n```js      \nconst response = await client.addDevice({\n  device_type: 'ios',\n  identifier: 'id1',\n});\nconsole.log(response.body);\n```         \n      \n### Edit a device      \n   \nhttps://documentation.onesignal.com/reference/edit-device\n\n```ts\n.editDevice(deviceId: string, body: EditDeviceBody): Promise<ClientResponse>\n```  \n \n```js      \nconst response = await client.editDevice('device-id',{\n  identifier: 'id2',\n});\nconsole.log(response.body);\n```     \n\n### Edit tags with external user id\n   \nhttps://documentation.onesignal.com/reference/edit-tags-with-external-user-id\n\n```ts\n.editTagsWithExternalUserIdDevice(externalUserId: string, body: EditTagsBody): Promise<ClientResponse>\n```  \n \n```js      \nconst response = await client.editTagsWithExternalUserIdDevice('external-user-id', {\n  tags: {\n    customTag: \"customValue\"\n  },\n});\nconsole.log(response.body);\n```     \n\n### New Session     \n   \nhttps://documentation.onesignal.com/reference/new-session\n\n```ts\n.newSession(deviceId: string, body: NewSessionBody): Promise<ClientResponse>\n```  \n \n```js      \nconst response = await client.newSession('device-id',{\n  language: 'tr',\n});\nconsole.log(response.body);\n```     \n  \n### New Purchase  \n   \nhttps://documentation.onesignal.com/reference/new-purchase\n\n```ts\n.newPurchase(deviceId: string, body: NewPurchaseBody): Promise<ClientResponse>\n```  \n \n```js      \nconst response = await client.newPurchase('device-id',{\n  purchases: [...],\n});\nconsole.log(response.body);\n```     \n  \n### Increment Session Length  \n   \nhttps://documentation.onesignal.com/reference#increment-session-length\n\n```ts\n.incrementSessionLength(deviceId: string, body: IncrementSessionLengthBody): Promise<ClientResponse>\n```  \n \n```js      \nconst response = await client.incrementSessionLength('device-id',{\n  state: '',\n  active_time: 11,\n});\nconsole.log(response.body);\n```     \n  \n### CSV Export      \n   \nhttps://documentation.onesignal.com/reference/csv-export\n\n```ts\n.exportCSV(body: ExportCSVBody): Promise<ClientResponse>\n```  \n \n```js      \nconst response = await client.exportCSV({});\nconsole.log(response.body);\n```      \n      \n### Create Segment   \n   \nhttps://documentation.onesignal.com/reference/create-segments\n\n```ts\n.createSegment(body: CreateSegmentBody): Promise<ClientResponse>\n```  \n \n```js      \nconst response = await client.createSegment({\n  name: 'new-segment',\n  filters: [..]\n});\nconsole.log(response.body);\n```         \n\n### Delete Segment   \n   \nhttps://documentation.onesignal.com/reference/delete-segments\n\n```ts\n.deleteSegment(segmentId: string): Promise<ClientResponse>\n```  \n \n```js      \nconst response = await client.deleteSegment('segment-id1');\nconsole.log(response.body);\n```   \n\n### Identity Verification\n\nhttps://documentation.onesignal.com/docs/identity-verification\n\nYou can use these simple helpers to sign user id or email to be used in client-side code.\n\n```ts\n.signUserExternalId(id: string | number): string\n.signUserEmail(email: string): string\n```  \n \nEach of these will return SHA-256 hash, that was generated using apiKey.\n      \n## Tests      \n      \nRunning all tests, coverage, build:      \n```bash      \n$ npm run test      \n$ npm run test-integration      \n$ npm run coverage      \n$ npm run build      \n```      \n## Contributing\n\n### TL;DR\n\nTo send a pull request:  \n - Fork the repo  \n - Clone the forked repo on your computer  \n - Switch to master branch  \n - Create a feature branch (`git checkout -b feature/new-feature-name`)  \n - Make your changes and add new tests if necessary  \n - Push your changes to your fork  \n - Open a pull request\n\n## License      \n      \nThis project is under the MIT license.\n","readmeFilename":"README.md"}