bundlesocial 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bundlesocial",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "Node.js library for the bundle.social API",
5
5
  "keywords": [
6
6
  "bundle.social",
package/readme.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # bundle.social SDK
2
2
  Node.js SDK for [bundle.social](https://bundle.social) API.
3
3
 
4
+ Check out our detailed docs here [https://info.bundle.social/api-reference/sdk](https://info.bundle.social/api-reference/sdk)
5
+
4
6
  ## Installation
5
7
 
6
8
  ```bash
@@ -9,7 +11,7 @@ yarn add bundlesocial
9
11
  pnpm add bundlesocial
10
12
  ```
11
13
 
12
- > !!! Make sure you have created a team on [bundle.social](https://bundle.social) and have an generated API key. !!!
14
+ > !!! Make sure you have generated an API key on [bundle.social](https://bundle.social). !!!
13
15
 
14
16
  ## Setup
15
17
  ```ts
@@ -20,90 +22,6 @@ const bundleSocial = new BundleSocial('YOUR_API_KEY');
20
22
  ```
21
23
 
22
24
  ## Usage
23
- ### Get the organization information
24
- ```ts
25
- const organization = await bundlesocial.organization.organizationGetOrganization();
26
- ```
27
-
28
- ### Create a team
29
- ```ts
30
- const createdTeam = await bundlesocial.team.teamCreateTeam({
31
- requestBody: {
32
- name: 'Test Team',
33
- tier: 'FREE',
34
- },
35
- });
36
- ```
37
-
38
- ### Get the team information
39
- ```ts
40
- const team = await bundlesocial.team.teamGetTeam({
41
- id: createdTeam?.id,
42
- });
43
- ```
44
-
45
- ### Manage social accounts (needed for product integration only)
46
- If you can connect social accounts directly through our web app, you can skip this step.
47
-
48
- For more info check out our docs: [https://info.bundle.social/api-reference](https://info.bundle.social/api-reference)
49
-
50
- #### Connect social account
51
- ```ts
52
- const response = await bundlesocial.socialAccount.socialAccountConnect({
53
- requestBody: {
54
- type: 'TIKTOK',
55
- teamId: team.id,
56
- redirectUrl: 'https://your-redirect-url.com',
57
- }
58
- });
59
-
60
- // Redirect the user to the response.url
61
- // After the user has connected the account, the user will be redirected to the redirectUrl
62
- ```
63
-
64
- #### Select page, account or channel (required for FACEBOOK, INSTAGRAM, YOUTUBE, LINKEDIN, DISCORD AND SLACK)
65
- After the user has connected the account and was redirected to your page, you can let the user select the page, account or channel. We unified the data for all platforms. Each social account has a `channels` field, that is an array of their channels (pages, accounts, channels depending on the platform).
66
-
67
- ```ts
68
- const team = await bundlesocial.team.teamGetTeam({
69
- id: team.id,
70
- });
71
-
72
- const socialAccount = team?.socialAccounts?.find((account) => account.type === 'TIKTOK');
73
- const socialAccountChannelId = socialAccount?.channels?.[0]?.id;
74
-
75
- if (socialAccountChannelId) {
76
- await bundlesocial.socialAccount.socialAccountSetChannel({
77
- requestBody: {
78
- type,
79
- teamId: team.id,
80
- channelId: socialAccountChannelId,
81
- }
82
- });
83
- }
84
- ```
85
-
86
-
87
- ### Upload a file
88
- ```ts
89
- const video = await fs.readFile('./video.mp4');
90
- const videoUpload = await bundlesocial.upload.uploadCreate({
91
- formData: {
92
- teamId: team.id,
93
- file: new Blob([video], { type: 'video/mp4' }),
94
- }
95
- });
96
-
97
- const jpgImage = await fs.readFile('./image.jpg');
98
- const jpgUpload = await bundlesocial.upload.uploadCreate({
99
- formData: {
100
- teamId: team.id,
101
- file: new Blob([jpgImage], { type: 'image/jpeg' }),
102
- }
103
- });
104
- ```
105
-
106
- ### Create a post
107
25
  ```ts
108
26
  // Make sure you have uploaded the file before creating a post.
109
27
  // Make sure you have connected a social account to the team.
@@ -150,52 +68,5 @@ const createdPost = await bundlesocial.post.postCreate({
150
68
  });
151
69
  ```
152
70
 
153
- ### Get the post information
154
- ```ts
155
- const post = await bundlesocial.post.postGet({
156
- id: createdPost.id,
157
- });
158
- ```
159
-
160
- ## Handling errors
161
- ```ts
162
- try {
163
- const organization = await bundlesocial.organization.organizationGetOrganization();
164
- } catch (error) {
165
- if (error instanceof ApiError) {
166
- // Handle the error
167
- console.log(error?.status, error?.statusText, error?.body);
168
- } else {
169
- throw error;
170
- }
171
- }
172
- ```
173
-
174
- ## Handling webhook events
175
- ```ts
176
- // this is a simple example using express
177
- app.post('/webhook', express.json({ type: 'application/json' }), (req, res) => {
178
- const bundlesocial = new Bundlesocial(apiKey);
179
- const signature = req.headers['x-signature'];
180
-
181
- let event: WebhookEvent;
182
-
183
- try {
184
- // Verify the webhook signature and return a typed event
185
- event = bundlesocial.webhooks.constructEvent(
186
- req.body,
187
- signature as string,
188
- secret,
189
- );
190
- // Do something with the event
191
- } catch (err) {
192
- console.log(`Webhook signature verification failed.`, err);
193
- return res.sendStatus(400);
194
- }
195
-
196
- return res.send();
197
- });
198
- ```
199
-
200
71
  ## License
201
- MIT
72
+ MIT