# dacwinapi

> This package makes it easy to manage information about your DacWin referral system.

Latest version **1.3.1** (published 2023-11-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install dacwinapi
pnpm add dacwinapi
yarn add dacwinapi
bun add dacwinapi
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2023-11-08 |
| First published | 2023-11-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 34.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | RidoineEl |
| Maintainers | ridoineel |

## Links

- npm: https://www.npmjs.com/package/dacwinapi
- npm.io page: https://npm.io/package/dacwinapi

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^1.6.0

## Recent versions

- 1.3.1 (latest) — 2023-11-08
- 1.3.0 — 2023-11-08
- 1.2.1 — 2023-11-07
- 1.2.0 — 2023-11-07
- 1.1.0 — 2023-11-07
- 1.0.0 — 2023-11-06

## README

# DacWin API

The JavaScript package dacwinapi makes it easy to manage information about your DacWin referral system. This package is specifically designed to interact with the DacWin API and allows you to manage information about an application's users, referral campaigns, rewards and events.

DacWin home page: https://referral-dev.dactechnologies.net

## Installation

To install `dacwinapi`, you can use npm:

```bash
npm install dacwinapi
```

Before using this package you must have the API key of the application you want to manage. If this is not the case yet,
- Go to your customer area: https://referral-devuser.dactechnologies.net
- In the `Applications` section:
	- Add an application and copy the generated API key.
	- Or, open your application's edit window and **regenerate a new API key** if you no longer have the old one.

## How to use this package

### 1. Campaigns

```javascript
import { CampaignService } from "dacwinapi"

// create an instance of CampaignService
const campaignService = new CampaignService("your_app_api_key")

// retrieve the list of campaigns of the app
console.log(await campaignService.getAll())

// retrieve one campaign data
console.log(await campaignService.getOne(18)) // 18 is the campaign id
```

> NOTE: Creating a campaign is only done on your DacWin customer interface.

### 2. App users

```javascript
import { AppUserService } from "dacwinapi"

// create an instance of AppUserService
const appUserService = new AppUserService("your_app_api_key")

// add new app user with referral information
const app_user_created = await appUserService.create({
	reference: "3ddd",
	referrer_referral_code: "AAAAA"
})

console.log(app_user_created)

// retrieve the list of app users of the app
console.log(await appUserService.getAll())

// retieve one app user by her id
console.log(await appUserService.getOneById(2)) // 2 is the app user id

// retieve one app user by her reference
console.log(await appUserService.getOneByReference("1Pxdd6tH3")) // "1Pxdd6tH3" is the app user reference
```

### 3. Events

```javascript
import { EventService } from "dacwinapi"

// create an instance of EventService
const eventService = new EventService("your_app_api_key")

// add a new event for specific app user and campaign
const event_created = await eventService.create({
	name: "ddd",
	campaign_id: 18,
	app_user_id: 14
})

console.log(event_created)

// retrieve the list of events of the app
console.log(await eventService.getAll())

// retrieve the list of app's events of specific campaign
console.log(await eventService.getAll({ campaign_id: 18 }))

// retrieve one event
console.log(await eventService.getOne(12)) // 12 is the event id
```

### 4. Rewards

```javascript
import { RewardService } from "dacwinapi"

// create an instance of RewardService
const rewardService = new RewardService("your_app_api_key")

// retrieve the list of rewards of the app
console.log(await rewardService.getAll())

// retrieve the list of app's rewards of specific campaign
console.log(await rewardService.getAll({ campaign_id: 18 }))

// retrieve one reward
console.log(await rewardService.getOne(12))
```

---
_Source: https://npm.io/package/dacwinapi · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
