bundlesocial
Advanced tools
Comparing version 2.0.0 to 2.1.0
{ | ||
"name": "bundlesocial", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Node.js library for the bundle.social API", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
137
readme.md
# bundle.social SDK | ||
Node.js SDK for [bundle.social](https://bundle.social) API. | ||
Check out our detailed docs here [https://info.bundle.social/api-reference/sdk](https://info.bundle.social/api-reference/sdk) | ||
## Installation | ||
@@ -12,3 +14,3 @@ | ||
> !!! Make sure you have created a team on [bundle.social](https://bundle.social) and have an generated API key. !!! | ||
> !!! Make sure you have generated an API key on [bundle.social](https://bundle.social). !!! | ||
@@ -24,87 +26,3 @@ ## Setup | ||
## Usage | ||
### Get the organization information | ||
```ts | ||
const organization = await bundlesocial.organization.organizationGetOrganization(); | ||
``` | ||
### Create a team | ||
```ts | ||
const createdTeam = await bundlesocial.team.teamCreateTeam({ | ||
requestBody: { | ||
name: 'Test Team', | ||
tier: 'FREE', | ||
}, | ||
}); | ||
``` | ||
### Get the team information | ||
```ts | ||
const team = await bundlesocial.team.teamGetTeam({ | ||
id: createdTeam?.id, | ||
}); | ||
``` | ||
### Manage social accounts (needed for product integration only) | ||
If you can connect social accounts directly through our web app, you can skip this step. | ||
For more info check out our docs: [https://info.bundle.social/api-reference](https://info.bundle.social/api-reference) | ||
#### Connect social account | ||
```ts | ||
const response = await bundlesocial.socialAccount.socialAccountConnect({ | ||
requestBody: { | ||
type: 'TIKTOK', | ||
teamId: team.id, | ||
redirectUrl: 'https://your-redirect-url.com', | ||
} | ||
}); | ||
// Redirect the user to the response.url | ||
// After the user has connected the account, the user will be redirected to the redirectUrl | ||
``` | ||
#### Select page, account or channel (required for FACEBOOK, INSTAGRAM, YOUTUBE, LINKEDIN, DISCORD AND SLACK) | ||
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). | ||
```ts | ||
const team = await bundlesocial.team.teamGetTeam({ | ||
id: team.id, | ||
}); | ||
const socialAccount = team?.socialAccounts?.find((account) => account.type === 'TIKTOK'); | ||
const socialAccountChannelId = socialAccount?.channels?.[0]?.id; | ||
if (socialAccountChannelId) { | ||
await bundlesocial.socialAccount.socialAccountSetChannel({ | ||
requestBody: { | ||
type, | ||
teamId: team.id, | ||
channelId: socialAccountChannelId, | ||
} | ||
}); | ||
} | ||
``` | ||
### Upload a file | ||
```ts | ||
const video = await fs.readFile('./video.mp4'); | ||
const videoUpload = await bundlesocial.upload.uploadCreate({ | ||
formData: { | ||
teamId: team.id, | ||
file: new Blob([video], { type: 'video/mp4' }), | ||
} | ||
}); | ||
const jpgImage = await fs.readFile('./image.jpg'); | ||
const jpgUpload = await bundlesocial.upload.uploadCreate({ | ||
formData: { | ||
teamId: team.id, | ||
file: new Blob([jpgImage], { type: 'image/jpeg' }), | ||
} | ||
}); | ||
``` | ||
### Create a post | ||
```ts | ||
// Make sure you have uploaded the file before creating a post. | ||
@@ -155,50 +73,3 @@ // Make sure you have connected a social account to the team. | ||
### Get the post information | ||
```ts | ||
const post = await bundlesocial.post.postGet({ | ||
id: createdPost.id, | ||
}); | ||
``` | ||
## Handling errors | ||
```ts | ||
try { | ||
const organization = await bundlesocial.organization.organizationGetOrganization(); | ||
} catch (error) { | ||
if (error instanceof ApiError) { | ||
// Handle the error | ||
console.log(error?.status, error?.statusText, error?.body); | ||
} else { | ||
throw error; | ||
} | ||
} | ||
``` | ||
## Handling webhook events | ||
```ts | ||
// this is a simple example using express | ||
app.post('/webhook', express.json({ type: 'application/json' }), (req, res) => { | ||
const bundlesocial = new Bundlesocial(apiKey); | ||
const signature = req.headers['x-signature']; | ||
let event: WebhookEvent; | ||
try { | ||
// Verify the webhook signature and return a typed event | ||
event = bundlesocial.webhooks.constructEvent( | ||
req.body, | ||
signature as string, | ||
secret, | ||
); | ||
// Do something with the event | ||
} catch (err) { | ||
console.log(`Webhook signature verification failed.`, err); | ||
return res.sendStatus(400); | ||
} | ||
return res.send(); | ||
}); | ||
``` | ||
## License | ||
MIT | ||
MIT |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
396617
5076
73