PHP code example of codebar-ag / laravel-beekeeper

1. Go to this page and download the library: Download codebar-ag/laravel-beekeeper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

codebar-ag / laravel-beekeeper example snippets




return [
    'api_token' => env('BEEKEEPER_API_TOKEN'),
    'endpoint_prefix' => env('BEEKEEPER_ENDPOINT_PREFIX'),
    'cache_store' => env('BEEKEEPER_CACHE_STORE')
];

use CodebarAg\LaravelBeekeeper\Connectors\BeekeeperConnector;

// Using the env variables
$connector = new BeekeeperConnector;

// Passing the credentials manually
$connector = new BeekeeperConnector(
    apiToken: $yourApiToken,
    endpointPrefix: 'foobar.us',
);

use CodebarAg\LaravelBeekeeper\Requests\GetStatusOfAuthenticatedUserRequest;

$response = $connector->send(new GetStatusOfAuthenticatedUserRequest);

use CodebarAg\LaravelBeekeeper\Requests\ListArtifacts;

$response = $connector->send(new ListArtifacts(
    type: Type::FOLDER,
    sort: Sort::NAME_ASC,
    limit: 20,
));

use CodebarAg\LaravelBeekeeper\Requests\UploadAFileRequest;

$fileContent = file_get_contents('path-to/foobar.pdf');
$fileName = 'foobar.pdf';

$response = $connector->send(new UploadAFileRequest(
    fileContent: $fileContent,
    fileName: $fileName,
    usageType: 'attachment_file',
));

use CodebarAg\LaravelBeekeeper\Requests\CreateAChildToAnArtifact;
use CodebarAg\LaravelBeekeeper\Enums\Artifacts\Type;

$response = $connector->send(new CreateAChildToAnArtifact(
    artifactId: '12345678-abcd-efgh-9012-de00edbf7b0b',
    name: 'foobar.pdf',
    type: Type::FILE,
    parentId: '12345678-abcd-efgh-9012-de00edbf7b0b',
    metadata: [
        'mimeType' => 'image/png',
        'url' => 'https://foobar.us.beekeeper.io/api/2/files/key/12345678-abcd-efgh-9012-de00edbf7b0b',
        'userId' => '12345678-abcd-efgh-9012-de00edbf7b0b',
        'key' => '12345678-abcd-efgh-9012-de00edbf7b0b',
        'id' => 12345678,
        'size' => 123456,
    ],
    adjustArtifactName: false,
    expand: []
));

use CodebarAg\LaravelBeekeeper\Requests\DeleteAnArtifact;

$response = $connector->send(new DeleteAnArtifact(
    artifactId: '12345678-abcd-efgh-9012-de00edbf7b0b'
));

// Returns a 204 No Content response on success

use CodebarAg\LaravelBeekeeper\Requests\CreateAPostInAGivenStream;

// Basic post creation
$response = $connector->send(new CreateAPostInAGivenStream(
    streamId: '6002',
    text: 'Please indicate your preferred dates for next team event in the poll below. Thanks!'
));

// Advanced post with all options
$fileData = [
    'updated' => '2016-10-07T12:49:21',
    'name' => 'fair_play_rules.pdf',
    'created' => '2016-10-07T12:49:21',
    'url' => 'https://mytenant.beekeeper.io/file/665987/original/fair_play_rules.pdf',
    'userid' => '5cb9v45d-8i78-4v65-b5fd-81cgfac3ef17',
    'height' => 619,
    'width' => 700,
    'duration' => 315,
    'key' => 'f4fdaab0-d198-49b4-b1cc-dd85572d72f1',
    'media_type' => 'image/png',
    'usage_type' => 'attachment_image',
    'id' => 66598,
    'size' => 85
];

$response = $connector->send(new CreateAPostInAGivenStream(
    streamId: '6002',
    text: 'Please indicate your preferred dates for next team event in the poll below. Thanks!',
    html: '<p>Please <b>indicate</b> your preferred dates below.</p><p>Thanks!</p>',
    title: 'Hello guys!',
    labels: ['food', 'poll', 'events'],
    sticky: true,
    locked: true,
    reactionsDisabled: true,
    scheduledAt: '2019-08-24T14:15:22',
    files: [$fileData],
    media: [$fileData],
    options: [
        ['text' => 'This Friday'],
        ['text' => 'Monday next week']
    ],
    expand: ['user', 'stream']
));

$post = $response->dto(); // Returns a Post DTO

CodebarAg\LaravelBeekeeper\Data\Artifacts\Artifact {
    +id: "12345678-abcd-efgh-9012-de00edbf7b0b"                         // string
    +tenantId: "12345"                                                  // string
    +name: "Documents"                                                  // string
    +type: CodebarAg\LaravelBeekeeper\Enums\Artifacts\Type              // Type
    +parentId: null                                                     // string|null
    +metadata: Illuminate\Support\Collection                            // Collection
    +createdAt: Carbon\CarbonImmutable                                  // CarbonImmutable
    +updatedAt: Carbon\CarbonImmutable                                  // CarbonImmutable
    +breadcrumbs: Illuminate\Support\Collection                         // Collection
    +children: Illuminate\Support\Collection                            // Collection
    +acl: Illuminate\Support\Collection                                 // Collection
    +filterData: Illuminate\Support\Collection                          // Collection
}

CodebarAg\LaravelBeekeeper\Data\Configs\AuthenticatedUserStatus {
    +maxFileSize: 262144000                                             // int|null
    +maxFilesOnPost: 8                                                  // int|null
    +maxPhotoSize: 15728640                                             // int|null
    +maxMediaOnPost: 50                                                 // int|null
    +maxVideoSize: 524288000                                            // int|null
    +maxVideoSizeForAdmins: 2147483648                                  // int|null
    +maxVoiceRecordingLength: 900                                       // int|null
    +maxUsersInGroupChat: 200                                           // int|null
    +featureFlags: Illuminate\Support\Collection                        // Collection|null
    +integrations: Illuminate\Support\Collection                        // Collection|null
    +styling: Illuminate\Support\Collection                             // Collection|null
    +tracking: Illuminate\Support\Collection                            // Collection|null   
    +general: CodebarAg\LaravelBeekeeper\Data\Configs\General           // General|null
}

CodebarAg\LaravelBeekeeper\Data\Configs\General {
    +id: 12345                                                          // int
    +companyAccount: "12345678-abcd-efgh-9012-de00edbf7b0b"             // string
    +name: "foobar"                                                     // string
    +language: "en"                                                     // string
    +created: Carbon\CarbonImmutable                                    // CarbonImmutable
    +url: "https://foobar.us.beekeeper.io/"                             // string
    +tagline: "Welcome to Beekeeper!"                                   // string
    +fqdn: "foobar.us.beekeeper.io"                                     // string
    +supportEmail: ""                                                   // string
    +isDataSecurityContactSet: false                                    // bool
    +timezone: "Europe/London"                                          // string    
    +subdomain: "foobar"                                                // string
}

CodebarAg\LaravelBeekeeper\Data\Files\File {
    +name: "test-1.pdf"                                                                               // string
    +status: CodebarAg\LaravelBeekeeper\Enums\Files\Status                                            // Status|null
    +created: Carbon\CarbonImmutable                                                                  // CarbonImmutable
    +updated: Carbon\CarbonImmutable                                                                  // CarbonImmutable
    +url: "https://foobar.us.beekeeper.io/api/2/files/key/12345678-abcd-efgh-9012-de00edbf7b0b"       // string
    +userId: "12345678-abcd-efgh-9012-de00edbf7b0b"                                                   // string
    +height: null                                                                                     // int|null
    +width: null                                                                                      // int|null
    +key: "12345678-abcd-efgh-9012-de00edbf7b0b"                                                      // string
    +duration: null                                                                                   // int|null
    +mediaType: "application/pdf"                                                                     // string
    +usageType: CodebarAg\LaravelBeekeeper\Enums\Files\UsageType                                      // UsageType
    +id: 22268153                                                                                     // int                                 
    +size: 8570                                                                                       // int
    +versions: Illuminate\Support\Collection                                                          // Collection
}

CodebarAg\LaravelBeekeeper\Data\Files\FileVersion {
    +name: "test-1.pdf"                                                                               // string
    +url: "https://foobar.us.beekeeper.io/api/2/files/key/12345678-abcd-efgh-9012-de00edbf7b0b"      // string
    +height: null                                                                                     // int|null
    +width: null                                                                                      // int|null
}

CodebarAg\LaravelBeekeeper\Data\Streams\Post {
    +id: 2234                                                                                         // int
    +text: "Please indicate your preferred dates for next team event in the poll below. Thanks!"     // string|null
    +html: "<p>Please <b>indicate</b> your preferred dates below.</p><p>Thanks!</p>"                  // string|null
    +title: "Hello guys!"                                                                             // string|null
    +labels: Illuminate\Support\Collection                                                            // Collection
    +sticky: true                                                                                     // bool
    +likeCount: 42                                                                                    // int
    +streamId: 6002                                                                                   // int
    +digest: 1                                                                                        // int
    +userId: "5cb9v45d-8i78-4v65-b5fd-81cgfac3ef17"                                                  // string
    +uuid: "731b28bc-7f10-4b68-a089-fc672abc9955"                                                    // string
    +commentCount: 2                                                                                  // int
    +reportCount: 0                                                                                   // int
    +source: "beekeeper"                                                                              // string
    +voteCount: 12                                                                                    // int
    +moderated: true                                                                                  // bool
    +photo: "https://d6698txzbomp3.cloudfront.net/72e3b7d4-c6a4-47e9-8f81-7b7d10bdd84a"              // string|null
    +languageConfidence: 0.86                                                                         // float|null
    +type: "post"                                                                                     // string
    +metadata: "string"                                                                               // string|null
    +profile: "peter_smith"                                                                           // string|null
    +edited: true                                                                                     // bool
    +displayNameExtension: "General Manager"                                                          // string|null
    +subscribedByUser: true                                                                           // bool
    +reportable: true                                                                                 // bool
    +anonymous: true                                                                                  // bool
    +displayName: "John Smith"                                                                        // string|null
    +unread: true                                                                                     // bool
    +locked: true                                                                                     // bool
    +reactionsDisabled: true                                                                          // bool
    +name: "Peter Smith"                                                                              // string|null
    +language: "en"                                                                                   // string|null
    +languageInformation: array                                                                       // array|null
    +created: Carbon\CarbonImmutable                                                                  // CarbonImmutable|null
    +postedByUser: true                                                                               // bool
    +avatar: "https://dz343oy86h947.cloudfront.net/business/neutral/normal/05.png"                    // string|null
    +reportedByUser: true                                                                             // bool
    +likedByUser: true                                                                                // bool
    +mentions: Illuminate\Support\Collection                                                          // Collection
    +mentionsDetails: array                                                                           // array|null
    +scheduledAt: Carbon\CarbonImmutable                                                              // CarbonImmutable|null
    +status: "published"                                                                              // string|null
    +files: Illuminate\Support\Collection                                                             // Collection
    +photos: Illuminate\Support\Collection                                                            // Collection
    +videos: Illuminate\Support\Collection                                                            // Collection
    +media: Illuminate\Support\Collection                                                             // Collection
    +options: Illuminate\Support\Collection                                                           // Collection
    +stateId: "2017-06-19T08:49:53"                                                                  // string|null
}

CodebarAg\LaravelBeekeeper\Data\Streams\Stream {
    +id: "12345678-abcd-efgh-9012-de00edbf7b0b"                                                      // string
    +tenantId: "12345"                                                                                // string
    +name: "General Discussion"                                                                       // string
    +description: "General discussion stream for all team members"                                    // string|null
    +type: CodebarAg\LaravelBeekeeper\Enums\Streams\Type                                             // Type|null
    +isPublic: true                                                                                   // bool
    +isArchived: false                                                                                // bool
    +createdAt: Carbon\CarbonImmutable                                                                // CarbonImmutable|null
    +updatedAt: Carbon\CarbonImmutable                                                                // CarbonImmutable|null
    +createdBy: "12345678-abcd-efgh-9012-de00edbf7b0b"                                               // string|null
    +updatedBy: "12345678-abcd-efgh-9012-de00edbf7b0b"                                               // string|null
    +posts: Illuminate\Support\Collection                                                             // Collection
    +subscribers: Illuminate\Support\Collection                                                       // Collection
    +permissions: Illuminate\Support\Collection                                                       // Collection
    +metadata: Illuminate\Support\Collection                                                          // Collection
}

use CodebarAg\LaravelBeekeeper\Enums\Artifacts\Type;
use CodebarAg\LaravelBeekeeper\Enums\Artifacts\Sort;

// Artifact types
Type::FOLDER
Type::FILE

// Sorting options
Sort::NAME_ASC
Sort::NAME_DESC
Sort::CREATED_ASC
Sort::CREATED_DESC

use CodebarAg\LaravelBeekeeper\Enums\Files\Status;
use CodebarAg\LaravelBeekeeper\Enums\Files\UsageType;

// File status
Status::PROCESSING
Status::READY
Status::ERROR

// Usage types
UsageType::ATTACHMENT_IMAGE
UsageType::ATTACHMENT_FILE
UsageType::ATTACHMENT_VIDEO
UsageType::AVATAR
UsageType::COVER_IMAGE
UsageType::LOGO
// ... and more

use CodebarAg\LaravelBeekeeper\Enums\Streams\Type;

// Stream types
Type::PUBLIC
Type::PRIVATE
Type::ANNOUNCEMENT
Type::DISCUSSION
Type::PROJECT
Type::DEPARTMENT
Type::TEAM
bash
php artisan beekeeper:install
bash
php artisan vendor:publish --tag="beekeeper-config"