Skip to content

feat: v2 platform sdk #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
880 changes: 316 additions & 564 deletions .openapi-generator/FILES

Large diffs are not rendered by default.

90 changes: 90 additions & 0 deletions README.md-e
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
![Sendbird banner image](http://ww1.prweb.com/prfiles/2021/09/14/18371217/Sendbird_Logo_RGB_lg.png)

# [Sendbird JavaScript Platform SDK](https://sendbird.com/docs/chat/v3/platform-api/getting-started/prepare-to-use-api)

[![link to docs](https://img.shields.io/badge/SDK-docs-green)](/docs)

This is a Node.js package that makes talking to the [Sendbird Platform API](https://sendbird.com/docs/chat/v3/platform-api/getting-started/prepare-to-use-api) easier. With this library you can extend your Sendbird integration to include advanced features like channel automation and user management.
# Install
```npm install sendbird-platform-sdk```

# 🔥 Quick start

```javascript
import SendbirdPlatformSdk from 'sendbird-platform-sdk';

const userId = "1234";
const name = "bob";
const profileUrl = "https://picsum.photos/200";
const apiToken = "YOUR_API_TOKEN";
const appId = "YOUR_APP_ID";

const opts = {
'createUserData': new SendbirdPlatformSdk.CreateUserData(userId, name, profileUrl),
};

async function createUser() {
const userApiInstance = new SendbirdPlatformSdk.UserApi();
userApiInstance.apiClient.basePath = `https://api-${appId}.sendbird.com`;
try {
const data = await userApiInstance.createUser(apiToken, opts);
console.log(data);
} catch (e) {
console.log(e);
}
}

createUser();

```

# ⚒️ Prerequisite

In order to make requests with this SDK you will need you master API token. This can be found through the [Sendbird dashboard](https://dashboard.sendbird.com/). Each app you create in Sendbird has its own master api token. These tokens can be found in Settings > Application > General.

![how to find you api token](https://i.imgur.com/0YMKtpX.png)

# 💻 Requirements

You will need [Node.js](https://nodejs.org/en/download/) installed. This has been developed and tested with NodeJS 17+.

# 🤓 Local Development

To run locally we need to make use of the [npm link](https://docs.npmjs.com/cli/v8/commands/npm-link) command. You will require two terminal tabs.

Please follow these steps:

##### Terminal 1

1. Clone this repo to your machine ```git clone [email protected]:sendbird/sendbird-platform-sdk-javascript```
2. Move into the newly cloned repo ```cd sendbird-platform-sdk-javascript```
3. Install node modules ```npm install```
4. Build the bundled JS ```npm run build```
5. Link the package ```npm link```

##### Terminal 2

1. Create a new npm package or move into and existing one ```mkdir app-using-sendbird-chat```
```npm init -y```
2. Link package to sendbird-platform-sdk ```npm link path/to/sdk/sendbird-platform-sdk-javascript```

The linking step is demonstrated visually here.

![npm link walkthrough](https://i.imgur.com/897SxfC.gif)


# 🗃️ Documentation
All the documentation for this project lives in the /docs directory of this repo.

##### Helpful links

| | Documentation |
| ----------- | ----------- |
| Announcement | [docs/AnnouncementApi.md](docs/AnnouncementApi.md)|
| Application | [docs/ApplicationApi.md](docs/ApplicationApi.md) |
| Bot | [docs/BotApi.md](docs/BotApi.md) |
| GroupChannel | [docs/GroupChannelApi.md](docs/GroupChannelApi.md) |
| Message | [docs/MessageApi.md](docs/MessageApi.md) |
| OpenChannel | [docs/OpenChannelApi.md ](docs/OpenChannelApi.md) |
| User | [docs/UserApi.md](docs/UserApi.md) |
| Webhooks | [docs/WebhooksApi.md](docs/WebhooksApi.md) |
33 changes: 22 additions & 11 deletions dist/ApiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,27 @@ Object.defineProperty(exports, "__esModule", {
exports["default"] = void 0;
var _superagent = _interopRequireDefault(require("superagent"));
var _querystring = _interopRequireDefault(require("querystring"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /**
* Sendbird Platform SDK
* Sendbird Platform API SDK [https://sendbird.com/docs/chat/v3/platform-api/getting-started/prepare-to-use-api](https://sendbird.com/docs/chat/v3/platform-api/getting-started/prepare-to-use-api) Contact Support: Name: Sendbird Email: [[email protected]](https://mailto:[email protected])
*
* The version of the OpenAPI document: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*
*/
/**
* @module ApiClient
* @version 0.0.16
* @version 2.0.0
*/
/**
* Manages low level client-server communications, parameter marshalling, etc. There should not be any need for an
Expand Down Expand Up @@ -50,7 +63,7 @@ var ApiClient = /*#__PURE__*/function () {
* @default {}
*/
this.defaultHeaders = {
'User-Agent': 'OpenAPI-Generator/0.0.16/Javascript'
'User-Agent': 'OpenAPI-Generator/2.0.0/Javascript'
};

/**
Expand Down Expand Up @@ -99,7 +112,7 @@ var ApiClient = /*#__PURE__*/function () {
* @param param The actual parameter.
* @returns {String} The string representation of <code>param</code>.
*/
_createClass(ApiClient, [{
return _createClass(ApiClient, [{
key: "paramToString",
value: function paramToString(param) {
if (param == undefined || param == null) {
Expand Down Expand Up @@ -648,7 +661,6 @@ var ApiClient = /*#__PURE__*/function () {
}
}
}]);
return ApiClient;
}();
/**
* Enumeration of collection format separator strategies.
Expand Down Expand Up @@ -688,5 +700,4 @@ ApiClient.CollectionFormatEnum = {
* @type {module:ApiClient}
*/
ApiClient.instance = new ApiClient();
var _default = ApiClient;
exports["default"] = _default;
var _default = exports["default"] = ApiClient;
Loading