Skip to content

codebar-ag/laravel-microsoft-planner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

35 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Latest Version on Packagist GitHub-Tests GitHub Code Style Total Downloads

This package was developed to interface with Microsoft Planner.

πŸ’‘ What is Laravel Microsoft Planner?

/ Laravel Microsoft Planner is an opinionated way to interface with Microsoft Planner.

πŸ›  Requirements

<= v1.0

  • PHP: ^8.2
  • Laravel: ^10.*

βš™οΈ Installation

You can install the package via composer:

composer require codebar-ag/laravel-microsoft-planner

Add the following environment variables to your .env file:

MICROSOFT_PLANNER_CLIENT_ID=your-client-id
MICROSOFT_PLANNER_TENANT_ID=your-tenant-id
MICROSOFT_PLANNER_CLIENT_SECRET=your-client-secret

πŸ”§ Configuration file

You can publish the config file with:

php artisan vendor:publish --tag=microsoft-planner-config

This is the contents of the published config file:

<?php

// config for CodebarAg/LaravelMicrosoftPlanner

return [
    'auth' => [
        'client_id' => env('LARAVEL_MICROSOFT_PLANNER_CLIENT_ID'),
        'client_secret' => env('LARAVEL_MICROSOFT_PLANNER_CLIENT_SECRET'),
        'tenant_id' => env('LARAVEL_MICROSOFT_PLANNER_TENANT_ID'),
    ]
];

πŸ— Usage

use CodebarAg\LaravelMicrosoftPlanner\Http\Connectors\MicrosoftPlannerConnector;
use CodebarAg\LaravelMicrosoftPlanner\Http\Requests\Bucket\GetBucketTasksRequest;
use CodebarAg\LaravelMicrosoftPlanner\Http\Requests\Tasks\GetTaskRequest;
use CodebarAg\LaravelMicrosoftPlanner\Http\Requests\Tasks\GetTaskDetailsRequest;
use CodebarAg\LaravelMicrosoftPlanner\Http\Requests\Tasks\PatchTaskRequest;
use CodebarAg\LaravelMicrosoftPlanner\Http\Requests\Tasks\PatchTaskDetialsRequest;

$connector = new MicrosoftPlannerConnector();
$authenticator = $connector->getAccessToken();
$connector->authenticate($authenticator);
// Get all tasks from a bucket

$tasksResponse = $connector->send(new GetBucketTasksRequest(bucketId: 'bucket-id'));
$tasks = $tasksResponse->dto();
// Get a single task

$taskResponse = $connector->send(new GetTaskRequest(taskId: 'task-id'));
$task = $taskResponse->dto();
// Get a tasks details

$taskDetailsResponse = $connector->send(new GetTaskDetailsRequest(taskId: 'task-id'));
$taskDetails = $taskDetailsResponse->dto();
// Update a task

$updateTaskRequest = new PatchTaskRequest(taskId: 'task-id', etag: $task->eTag);
$updateTaskRequest->body()->add('somedetail', 'somevalue');

$updateTaskResponse = $connector->send($updateTaskRequest);

if ($updatedTask->successful()) {
    // Do something
}
// Update a tasks details

$updateTaskDetailsRequest = new PatchTaskDetialsRequest(taskId: 'task-id', etag: $taskDetails->eTag);
$updateTaskDetailsRequest->body()->add('somedetail', 'somevalue');

$updateTaskDetailsResponse = $connector->send($updateTaskDetailsRequest);

if ($updatedTaskDetails->successful()) {
    // Do something
}

πŸ‹οΈ DTO showcase

CodebarAg\LaravelMicrosoftPlanner\Data\Checklist {
    +id: "2f071481-095d-4363-abd9-29ef845a8b05"                     // string
    +isChecked: true,                                               // bool
    +title: "sometask"                                              // string
    +orderHint: "858",                                              // string
    +lastModifiedDateTime: "2021-08-31T13:00:00Z"                   // string
    +lastModifiedByUserId: "1234456"                                // string|null
}
CodebarAg\LaravelMicrosoftPlanner\Data\Note {
    +contentType: 'html'                                            // string
    +content: '<p>Some content</p>'                                 // string
}
CodebarAg\LaravelMicrosoftPlanner\Data\Reference {
    +alias: "test.pdf"                                              // string
    +url: "https://something.here/in-this-file/test.pdf"            // string
    +type: "pdf"                                                    // string
    +previewPriority: "858"                                         // string
    +lastModifiedDateTime: "2021-08-31T13:00:00Z"                   // string
    +lastModifiedByUserId: "1234456"                                // string
}
CodebarAg\LaravelMicrosoftPlanner\Data\TaskDetails {
    +eTag: "W/"1238934jbdf89bfdkkjbr34g98hh98vhhcc=""               // string
    +description: "Some Description"                                // string
    +previewType: "noPreview"                                       // string
    +id: "EZAPnP4uBkGAMqyd2dneWJcAOGbk"                             // string
    +notes: CodebarAg\LaravelMicrosoftPlanner\Data\Note             // Note
    +references: Illuminate\Support\Collection                      // Collection
    +checklist: Illuminate\Support\Collection                       // Collection
}
CodebarAg\LaravelMicrosoftPlanner\Data\Task {
    +eTag: "W/"JzEtVGFzsdfsdEBAQEBAQEBAQEBAQEBJcCc=""               // string
    +planId: "aL8rSpzb_0-0IGcHql4P0ZcAG3_B"                         // string
    +bucketId: "09AEzJXp0E6zY5LEE2Wsv5cAOdQd"                       // string
    +title: "Task Title"                                            // string
    +orderHint: "8585037232077788756Pe"                             // string
    +assigneePriority: ""                                           // string
    +percentComplete: 100                                           // int
    +completed: true                                                // bool
    +startDateTime: Carbon                                          // Carbon\Carbon|null
    +createdDateTime: Carbon                                        // Carbon\Carbon
    +dueDateTime: Carbon                                            // Carbon\Carbon|null
    +recurrence: null                                               // array|null
    +hasDescription: true                                           // bool
    +specifiedCompletionRequirements: "none"                        // string
    +previewType: "noPreview"                                       // string
    +completedDateTime: Carbon                                      // Carbon\Carbon|null
    +completedBy: array                                             // array
    +referenceCount: 2                                              // int
    +checklistItemCount: 3                                          // int
    +activeChecklistItemCount: 2                                    // int
    +conversationThreadId: "AAQkADk1ZG"                             // string|null
    +priority: 1                                                    // int
    +creationSource: null                                           // string|null
    +id: "EZAPnP4uBkGAMqyd2dneWJcAOGbk"                             // string
    +createdBy: array                                               // array
    +appliedCategories: array                                       // array
    +assignments: array                                             // array

🚧 Testing

Copy your own phpunit.xml-file.

cp phpunit.xml.dist phpunit.xml

Run the tests:

./vendor/bin/pest

πŸ“ Changelog

Please see CHANGELOG for more information on what has changed recently.

✏️ Contributing

Please see CONTRIBUTING for details.

πŸ§‘β€πŸ’» Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

πŸ™ Credits

🎭 License

The MIT License (MIT). Please see License File for more information.