# channel-client

> This is a Node.js bindings for Channel API https://api.channel.io/docs/open

Latest version **0.1.1** (published 2017-10-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install channel-client
pnpm add channel-client
yarn add channel-client
bun add channel-client
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2017-10-10 |
| First published | 2016-12-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | blaswan |

## Links

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

## Dependencies (2)

- [request](https://npm.io/package/request.md) ^2.79.0
- [request-promise](https://npm.io/package/request-promise.md) ^4.1.1

## Recent versions

- 0.1.1 (latest) — 2017-10-10
- 0.1.0 — 2016-12-24

## README

# channel-api-node

This is a Node.js bindings for Channel API https://api.channel.io/docs/open

## Installation

```
npm install channel-client
```

## Testing
Put values in test_sample.yaml
```
access:
  accessKey: YOUR_ACCESS_KEY
  accessSecret: YOUR_ACCESS_SECRET

id:
  groupId: YOUR_GROUP_ID
  userChatId: YOUR_USER_CHAT_ID  
  userId: YOUR_USER_ID
  veilId: YOUR_VEIL_ID

path:
  file: YOUR_FILE_PATH
```

Run commands below.
```
$ mv test_sample.yaml test.yaml
$ npm test
```

## Building

```
$ npm run build
```

## Usage

### Require Channel

```
var Channel = require('channel-client');
```

### Using Personal Access Key and Access Secret
Create a client.
```
var client = new Channel.Client({
  accessKey: 'your_access_key',
  accessSecret: 'your_access_secret'
})
```

## Bot
```
// Create a bot with avatar ('avatar_url can be undefined')
client.bots.create('bot_name', 'avatar_url').then((body) => {
  console.log(body)
}).catch((err) => {
  console.log(err)
})
```

## Manager
```
// List of managers
client.managers.get().then((body) => {
  console.log(body)
}).catch((err) => {
  console.log(err)
})
```

## User
```
// List userChats of a user
client.users.userChats.get('user_id').then((body) => {
  console.log(body)
}).catch((err) => {
  console.log(err)
})

// Create userChat of a user
client.users.userChats.create('user_id').then((body) => {
  console.log(body)
}).catch((err) => {
  console.log(err)
})

// Get a user
client.users.get('user_id').then((body) => {
  console.log(body)
}).catch((err) => {
  console.log(err)
})
```

## Veil
```
// List userChats of a veil
client.veils.userChats.get('veil_id').then((body) => {
  console.log(body)
}).catch((err) => {
  console.log(err)
})

// Create userChat of a veil
client.veils.userChats.create('veil_id').then((body) => {
  console.log(body)
}).catch((err) => {
  console.log(err)
})

// Get a veil
client.users.get('veil_id').then((body) => {
  console.log(body)
}).catch((err) => {
  console.log(err)
})
```

## Group
### Messages

```
// Send a message to group from bot
var message = {
  message: 'Hi! I'm bot!'
}

client.groups.messages.create('group_id', 'bot_name', message).then((body) => {
  console.log(body)
}).catch((err) => {
  console.log(err)
})

// Send a file to group from bot
var file = fs.readFileSync('file_path')

client.groups.files.create('group_id', 'bot_name', file).then((body) => {
  console.log(body)
}).catch((err) => {
  console.log(err)
})
```

## UserChat
### Message
```
// Send a message to user chat from bot
var message = {
  message: 'Hi! I'm bot!'
}

client.userChats.messages.create('user_chat_id', 'bot_name', message)
  .then((body) => {
    console.log(body)
  }).catch((err) => {
    console.log(err)
  })

// Send a file to user chat from bot
var file = fs.readFileSync('file_path')

client.userChats.files.create('user_chat_id', 'bot_name', file).then((body) => {
  console.log(body)
}).catch((err) => {
  console.log(err)
})
```
### Invite
```
// Invite a manager
client.userChats.invite('user_chat_id', 'bot_name', 'manager_id')
  .then((body) => {
    console.log(body)
  }).catch((err) => {
    console.log(err)
  })
```

## License

MIT

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