apility/24sevenoffice

A simple and independent connector for 24SevenOffice

v1.0.1 2019-10-09 07:44 UTC

This package is auto-updated.

Last update: 2024-03-09 17:16:20 UTC


README

A simple and independent PHP webservice connector for the ERP system 24SevenOffice.

Full documentation

Se the full documentation for all services at developer.24sevenoffice.com.

Installation

composer require apility/24sevenoffice

Basic usage

Authenticating and getting a list of companies matching a search:

<?php

use Apility\T4SevenOffice\T4SevenOffice;

T4SevenOffice::setCredentials(
  'user@company.com', // username
  'yourpassword123', // password
  '00000000-0000-0000-0000-000000000000', // applicationId
  '00000000-0000-0000-0000-000000000000' // identityId (optional)
);

// By default, this is set to false, since you most likely would 
// like to save the sessionId from 24SevenOffice some other place
T4SevenOffice::setUsePhpSession(true);

try {
  
  T4SevenOffice::authenticateService();
  
  $companyService = T4SevenOffice::companyService();
  
  $companies = $companyService->GetCompanies([
    'searchParams' => ['CompanyName' => 'Test'],
    'returnProperties' => ['Name', 'Id']
  ]);
  
  var_dump($companies);
  
} catch (Exception $e) {
  die('24SevenOffice Exception: '.$e->getMessage());
}

Preserve session

To avoid authenticating with the webservice every time (and improve performance), you can save the sessionId from 24SevenOffice and use this as long as it is valid.

You can either use PHP Session for this:

<?php

// By default, this is set to false
T4SevenOffice::setUsePhpSession(true);

Or handle the sessionId on your own:

<?php

// Saved from last auth
$sessionId = 'demosw1avyg2h4opyi0demo';

T4SevenOffice::setSessionId($sessionId);

T4SevenOffice::authenticateService();

if ($sessionId !== T4SevenOffice::getSessionId) {
  // Session from last time is no longer valid, and a new one has been created
  // TODO: Save the new sessionId for next time
}

Listing all identities

<?php

T4SevenOffice::setCredentials(
  'user@company.com', // username
  'yourpassword123', // password
  '00000000-0000-0000-0000-000000000000' // applicationId
);

$authService = T4SevenOffice::authenticateService();
  
$identities = $authService->GetIdentities();
  
var_dump($identities);