Skip to content

Commit 4c59e2b

Browse files
authored
Merge pull request #8 from codebar-ag/finalize-beekeeper-api
Finalize Beekeeper API
2 parents 2d54906 + 003c1d5 commit 4c59e2b

19 files changed

+1573
-50
lines changed

README.md

Lines changed: 209 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
[![Dependency Review](https://github.com/codebar-ag/laravel-beekeeper/actions/workflows/dependency-review.yml/badge.svg)](https://github.com/codebar-ag/laravel-beekeeper/actions/workflows/dependency-review.yml)
1111

1212
This package was developed to give you a quick start to communicate with the
13-
Beekeeper Api. It is used to query the most common endpoints.
13+
Beekeeper API using token-based authentication. It provides a clean, type-safe
14+
interface to query the most common Beekeeper endpoints including artifacts,
15+
files, streams, and posts.
1416

1517
## Navigation
1618
<!-- TOC -->
@@ -23,7 +25,10 @@ Beekeeper Api. It is used to query the most common endpoints.
2325
* [List Artifacts](#list-artifacts)
2426
* [Upload A File](#upload-a-file)
2527
* [Create A Child To An Artifact](#create-a-child-to-an-artifact)
28+
* [Delete An Artifact](#delete-an-artifact)
29+
* [Create A Post In A Given Stream](#create-a-post-in-a-given-stream)
2630
* [DTO Showcase](#dto-showcase)
31+
* [Available Enums](#available-enums)
2732
* [Testing](#testing)
2833
* [Changelog](#changelog)
2934
* [Contributing](#contributing)
@@ -67,20 +72,30 @@ This is the contents of the published config file:
6772
<?php
6873

6974
return [
70-
75+
'api_token' => env('BEEKEEPER_API_TOKEN'),
76+
'endpoint_prefix' => env('BEEKEEPER_ENDPOINT_PREFIX'),
77+
'cache_store' => env('BEEKEEPER_CACHE_STORE')
7178
];
7279
```
7380

7481
You should finally add the following to your .env file:
7582

7683
```env
77-
BEEKEEPER_CLIENT_ID=your-client-id
78-
BEEKEEPER_CLIENT_SECRET=your-client-secret
79-
BEEKEEPER_CACHE_STORE=beekeeper
84+
BEEKEEPER_API_TOKEN=your-api-token
85+
BEEKEEPER_ENDPOINT_PREFIX=codebar.us
86+
BEEKEEPER_CACHE_STORE=file
8087
```
8188

8289
## Usage
8390

91+
### Authentication
92+
93+
This package uses token-based authentication with the Beekeeper API. You'll need to:
94+
95+
1. Obtain an API token from your Beekeeper admin panel
96+
2. Set the `BEEKEEPER_API_TOKEN` environment variable
97+
3. Set your Beekeeper subdomain in `BEEKEEPER_ENDPOINT_PREFIX`
98+
8499
### Get the connector
85100

86101
```php
@@ -127,6 +142,7 @@ $fileName = 'foobar.pdf';
127142
$response = $connector->send(new UploadAFileRequest(
128143
fileContent: $fileContent,
129144
fileName: $fileName,
145+
usageType: 'attachment_file',
130146
));
131147
```
132148

@@ -154,6 +170,67 @@ $response = $connector->send(new CreateAChildToAnArtifact(
154170
));
155171
```
156172

173+
### Delete An Artifact
174+
175+
```php
176+
use CodebarAg\LaravelBeekeeper\Requests\DeleteAnArtifact;
177+
178+
$response = $connector->send(new DeleteAnArtifact(
179+
artifactId: '12345678-abcd-efgh-9012-de00edbf7b0b'
180+
));
181+
182+
// Returns a 204 No Content response on success
183+
```
184+
185+
### Create A Post In A Given Stream
186+
187+
```php
188+
use CodebarAg\LaravelBeekeeper\Requests\CreateAPostInAGivenStream;
189+
190+
// Basic post creation
191+
$response = $connector->send(new CreateAPostInAGivenStream(
192+
streamId: '6002',
193+
text: 'Please indicate your preferred dates for next team event in the poll below. Thanks!'
194+
));
195+
196+
// Advanced post with all options
197+
$fileData = [
198+
'updated' => '2016-10-07T12:49:21',
199+
'name' => 'fair_play_rules.pdf',
200+
'created' => '2016-10-07T12:49:21',
201+
'url' => 'https://mytenant.beekeeper.io/file/665987/original/fair_play_rules.pdf',
202+
'userid' => '5cb9v45d-8i78-4v65-b5fd-81cgfac3ef17',
203+
'height' => 619,
204+
'width' => 700,
205+
'duration' => 315,
206+
'key' => 'f4fdaab0-d198-49b4-b1cc-dd85572d72f1',
207+
'media_type' => 'image/png',
208+
'usage_type' => 'attachment_image',
209+
'id' => 66598,
210+
'size' => 85
211+
];
212+
213+
$response = $connector->send(new CreateAPostInAGivenStream(
214+
streamId: '6002',
215+
text: 'Please indicate your preferred dates for next team event in the poll below. Thanks!',
216+
title: 'Hello guys!',
217+
labels: ['food', 'poll', 'events'],
218+
sticky: true,
219+
locked: true,
220+
reactionsDisabled: true,
221+
scheduledAt: '2019-08-24T14:15:22',
222+
files: [$fileData],
223+
media: [$fileData],
224+
options: [
225+
['text' => 'This Friday'],
226+
['text' => 'Monday next week']
227+
],
228+
expand: ['user', 'stream']
229+
));
230+
231+
$post = $response->dto(); // Returns a Post DTO
232+
```
233+
157234
## DTO Showcase
158235

159236
```php
@@ -183,7 +260,6 @@ CodebarAg\LaravelBeekeeper\Data\Configs\AuthenticatedUserStatus {
183260
+maxVideoSizeForAdmins: 2147483648 // int|null
184261
+maxVoiceRecordingLength: 900 // int|null
185262
+maxUsersInGroupChat: 200 // int|null
186-
+reactions: Illuminate\Support\Collection // Collection|null
187263
+featureFlags: Illuminate\Support\Collection // Collection|null
188264
+integrations: Illuminate\Support\Collection // Collection|null
189265
+styling: Illuminate\Support\Collection // Collection|null
@@ -209,13 +285,6 @@ CodebarAg\LaravelBeekeeper\Data\Configs\General {
209285
}
210286
```
211287

212-
```php
213-
CodebarAg\LaravelBeekeeper\Data\Configs\Reaction {
214-
+cldrShortName: "thumbs up" // string
215-
+name: "Like" // string
216-
+emoji: "👍" // string
217-
}
218-
```
219288

220289
```php
221290
CodebarAg\LaravelBeekeeper\Data\Files\File {
@@ -246,7 +315,134 @@ CodebarAg\LaravelBeekeeper\Data\Files\FileVersion {
246315
}
247316
```
248317

318+
```php
319+
CodebarAg\LaravelBeekeeper\Data\Streams\Post {
320+
+id: 2234 // int
321+
+text: "Please indicate your preferred dates for next team event in the poll below. Thanks!" // string
322+
+title: "Hello guys!" // string|null
323+
+labels: Illuminate\Support\Collection // Collection
324+
+sticky: true // bool
325+
+likeCount: 42 // int
326+
+streamId: 6002 // int
327+
+digest: 1 // int
328+
+userId: "5cb9v45d-8i78-4v65-b5fd-81cgfac3ef17" // string
329+
+uuid: "731b28bc-7f10-4b68-a089-fc672abc9955" // string
330+
+commentCount: 2 // int
331+
+reportCount: 0 // int
332+
+source: "beekeeper" // string
333+
+voteCount: 12 // int
334+
+moderated: true // bool
335+
+photo: "https://d6698txzbomp3.cloudfront.net/72e3b7d4-c6a4-47e9-8f81-7b7d10bdd84a" // string|null
336+
+languageConfidence: 0.86 // float|null
337+
+type: "post" // string
338+
+metadata: "string" // string|null
339+
+profile: "peter_smith" // string|null
340+
+edited: true // bool
341+
+displayNameExtension: "General Manager" // string|null
342+
+subscribedByUser: true // bool
343+
+reportable: true // bool
344+
+anonymous: true // bool
345+
+displayName: "John Smith" // string|null
346+
+unread: true // bool
347+
+locked: true // bool
348+
+reactionsDisabled: true // bool
349+
+name: "Peter Smith" // string|null
350+
+language: "en" // string|null
351+
+languageInformation: array // array|null
352+
+created: Carbon\CarbonImmutable // CarbonImmutable|null
353+
+postedByUser: true // bool
354+
+avatar: "https://dz343oy86h947.cloudfront.net/business/neutral/normal/05.png" // string|null
355+
+reportedByUser: true // bool
356+
+likedByUser: true // bool
357+
+mentions: Illuminate\Support\Collection // Collection
358+
+mentionsDetails: array // array|null
359+
+scheduledAt: Carbon\CarbonImmutable // CarbonImmutable|null
360+
+status: "published" // string|null
361+
+files: Illuminate\Support\Collection // Collection
362+
+photos: Illuminate\Support\Collection // Collection
363+
+videos: Illuminate\Support\Collection // Collection
364+
+media: Illuminate\Support\Collection // Collection
365+
+options: Illuminate\Support\Collection // Collection
366+
+stateId: "2017-06-19T08:49:53" // string|null
367+
}
368+
```
369+
370+
```php
371+
CodebarAg\LaravelBeekeeper\Data\Streams\Stream {
372+
+id: "12345678-abcd-efgh-9012-de00edbf7b0b" // string
373+
+tenantId: "12345" // string
374+
+name: "General Discussion" // string
375+
+description: "General discussion stream for all team members" // string|null
376+
+type: CodebarAg\LaravelBeekeeper\Enums\Streams\Type // Type|null
377+
+isPublic: true // bool
378+
+isArchived: false // bool
379+
+createdAt: Carbon\CarbonImmutable // CarbonImmutable|null
380+
+updatedAt: Carbon\CarbonImmutable // CarbonImmutable|null
381+
+createdBy: "12345678-abcd-efgh-9012-de00edbf7b0b" // string|null
382+
+updatedBy: "12345678-abcd-efgh-9012-de00edbf7b0b" // string|null
383+
+posts: Illuminate\Support\Collection // Collection
384+
+subscribers: Illuminate\Support\Collection // Collection
385+
+permissions: Illuminate\Support\Collection // Collection
386+
+metadata: Illuminate\Support\Collection // Collection
387+
}
388+
```
389+
390+
## Available Enums
391+
392+
The package provides several enums for type safety and better code organization:
393+
394+
### Artifact Enums
395+
396+
```php
397+
use CodebarAg\LaravelBeekeeper\Enums\Artifacts\Type;
398+
use CodebarAg\LaravelBeekeeper\Enums\Artifacts\Sort;
399+
400+
// Artifact types
401+
Type::FOLDER
402+
Type::FILE
403+
404+
// Sorting options
405+
Sort::NAME_ASC
406+
Sort::NAME_DESC
407+
Sort::CREATED_ASC
408+
Sort::CREATED_DESC
409+
```
410+
411+
### File Enums
249412

413+
```php
414+
use CodebarAg\LaravelBeekeeper\Enums\Files\Status;
415+
use CodebarAg\LaravelBeekeeper\Enums\Files\UsageType;
416+
417+
// File status
418+
Status::PROCESSING
419+
Status::READY
420+
Status::ERROR
421+
422+
// Usage types
423+
UsageType::ATTACHMENT_IMAGE
424+
UsageType::ATTACHMENT_FILE
425+
UsageType::ATTACHMENT_VIDEO
426+
UsageType::AVATAR
427+
UsageType::COVER_IMAGE
428+
UsageType::LOGO
429+
// ... and more
430+
```
431+
432+
### Stream Enums
433+
434+
```php
435+
use CodebarAg\LaravelBeekeeper\Enums\Streams\Type;
436+
437+
// Stream types
438+
Type::PUBLIC
439+
Type::PRIVATE
440+
Type::ANNOUNCEMENT
441+
Type::DISCUSSION
442+
Type::PROJECT
443+
Type::DEPARTMENT
444+
Type::TEAM
445+
```
250446

251447
## Testing
252448

src/Data/Configs/AuthenticatedUserStatus.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ public static function make(array $data): self
1818
maxVideoSizeForAdmins: Arr::get($data, 'max_video_size_for_admins'),
1919
maxVoiceRecordingLength: Arr::get($data, 'max_voice_recording_length'),
2020
maxUsersInGroupChat: Arr::get($data, 'max_users_in_group_chat'),
21-
reactions: Arr::has($data, 'reactions') ? collect(Arr::get($data, 'reactions'))->map(fn (array $reaction) => Reaction::make($reaction)) : null,
2221
featureFlags: collect(Arr::get($data, 'feature_flags')),
2322
integrations: collect(Arr::get($data, 'integrations')),
2423
styling: collect(Arr::get($data, 'styling')),
@@ -36,7 +35,6 @@ public function __construct(
3635
public ?int $maxVideoSizeForAdmins,
3736
public ?int $maxVoiceRecordingLength,
3837
public ?int $maxUsersInGroupChat,
39-
public ?Collection $reactions = null,
4038
public ?Collection $featureFlags = null,
4139
public ?Collection $integrations = null,
4240
public ?Collection $styling = null,

src/Data/Configs/General.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static function make(array $data): self
2727

2828
public function __construct(
2929
public int $id,
30-
public string $companyAccount,
30+
public ?string $companyAccount,
3131
public string $name,
3232
public string $language,
3333
public CarbonImmutable $created,

src/Data/Configs/Reaction.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)