ncbp/psa-kiota-client

ConnectWise PSA API client generated using Microsoft Kiota

v1.0.1 2025-07-30 19:16 UTC

This package is not auto-updated.

Last update: 2025-07-31 17:37:18 UTC


README

A PHP client library for ConnectWise PSA API generated using Microsoft Kiota.

Description

This library provides a strongly-typed PHP client for interacting with the ConnectWise PSA API. It is generated using Microsoft's Kiota tool, which creates client libraries from OpenAPI specifications.

Installation

Install the package via Composer:

composer require ncbp/psa-kiota-client

Requirements

  • PHP 8.0 or higher
  • Composer

Dependencies

  • microsoft/kiota-abstractions: ^1.5
  • microsoft/kiota-serialization-form: ^1.5
  • microsoft/kiota-serialization-json: ^1.5
  • microsoft/kiota-serialization-multipart: ^1.5
  • microsoft/kiota-serialization-text: ^1.5
  • symfony/http-client: ^7.3

Usage

Basic Usage

<?php

require_once 'vendor/autoload.php';

use Microsoft\Kiota\Abstractions\Authentication\AnonymousAuthenticationProvider;
use Microsoft\Kiota\Http\Middleware\Options\RedirectHandlerOption;
use Microsoft\Kiota\Http\Symfony\SymfonyRequestAdapter;
use NCBP\Psa\Api\Client\Kiota\ApiClient;

// Create an authentication provider
// Note: Replace with appropriate authentication for ConnectWise PSA
$authProvider = new AnonymousAuthenticationProvider();

// Create request adapter with authentication
$requestAdapter = new SymfonyRequestAdapter($authProvider);

// Configure middleware options if needed
$requestAdapter->setMiddlewareOptions([
    RedirectHandlerOption::class => new RedirectHandlerOption(true, 5)
]);

// Create the API client
$client = new ApiClient($requestAdapter);

// Optional: Set a custom base URL if needed
// $requestAdapter->setBaseUrl('https://custom-connectwise-instance.com/v4_6_release/apis/3.0');

// Use the client to access different areas of the API
try {
    // Example: Get company information
    $companies = $client->company()->companies()->get();
    
    // Process the response
    foreach ($companies->getValue() as $company) {
        echo "Company: " . $company->getName() . PHP_EOL;
    }
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . PHP_EOL;
}

Available API Areas

The client provides access to the following ConnectWise PSA API areas:

  • Company: $client->company()
  • Configurations: $client->configurations()
  • Expense: $client->expense()
  • Finance: $client->finance()
  • Marketing: $client->marketing()
  • Procurement: $client->procurement()
  • Project: $client->project()
  • Sales: $client->sales()
  • Schedule: $client->schedule()
  • Service: $client->service()
  • System: $client->system()
  • Time: $client->time()

Each area provides specific endpoints for interacting with different aspects of the ConnectWise PSA system.

Authentication

Refer to the ConnectWise API documentation for specific authentication requirements and implement the appropriate authentication provider.

Regenerating the Client

If you need to regenerate the client from an updated OpenAPI specification:

  1. Ensure you have the Kiota CLI tool installed in the bin directory and that it is named kiota
  2. Run the provided Composer script:
composer generate-client

This will regenerate the client code based on the schema file located at schema/All.json. This file must be acquired from https://developer.connectwise.com.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

  • David Legatt (legattd@ncbpinc.com)