Giter Club home page Giter Club logo

bpm-online's Introduction

API BPM ONLINE

Build Status Twitter Scrutinizer Code Quality Code Coverage License

RU | EN

Что это такое?

Пакет предоставляет удобный интерфейс для работы с API Bpm’online через протокол OData.

Установка

Для установки необходимо выполнить команду из composer

composer require agoalofalife/bpm-online

Настройка конфигураций

Для установки ваших конфигурационных данных есть несколько способов :

  • Через class File
 //Инициализируем ядро
 $kernel = new KernelBpm();
 $file = new File();
 
 // указываем путь до файла с  конфигурациями
 $file->setSource(__DIR__ . '/config/apiBpm.php');
 // Загружаем их
 $kernel->loadConfiguration($file);

Файл должен возвращать массив с конфигурационными данными

return [
	// url для аутентификации
    'UrlLogin' => '',
    //ваш url для запросов по api       
    'UrlHome'  => '',
    'Login'    => '',
    'Password' => ''
    ]
  • Через метод setConfigManually в KernelBpm
$kernel = new KernelBpm();
// первым параметром передается префикс для конфигурации
$$kernel->setConfigManually('apiBpm', [
        'UrlLogin' => '',
        'Login'    => '',
        'Password' => '',
        'UrlHome'  => ''
]);

Аутенфикация

Для аутенфикация в BPM API необходимо получить cookie по URL https://ikratkoe.bpmonline.com/ServiceModel/AuthService.svc/Login Для этого необходимо вызвать метод authentication

$kernel->authentication();

Можно не вызывать его и пакет автоматически обновит куки сделав дополнительный запрос.

Установка коллекции

В BPM все таблицы из базы данных именуются как коллекции ( Collections ) Для взаимодействия необходимо установить коллекцию.

$kernel->setCollection('CaseCollection');

Данный подход имеет минус в дополнительном вызове метода setCollection , но позволяет переиспользывать установку коллекции. Имеется в виду что мы можем один раз установить коллекцию и производить операции по ней.

Select

Все методы принимают первым параметром строку типа операции и тип данных, вторым параметром callback внутрь которого передается тип операции, внутри callback происходит выполнение всех пред - настроек в конце вызывается метод get. Возращается обьект типа Handler который обрабатывает ответ от BPM.

$handler = $kernel->action('read:json', function ($read){
    $read->amount(1)->skip(100);

})->get();

Всего два типа данных xml и json. Четыре вида операции read, create, update, delete.

Методы Select

filterConstructor Позволяет фильтровать выборку с помощью функции $filter в запросе

filterConstructor('Id eq guid\'00000000-0000-0000-0000-000000000000\'');

orderBy Получать данные в отсортированном виде Первым параметром название поля, вторым параметром тип сортировки : по возрастанию (asc) по убыванию (desc)

->orderby('Number', 'desc')

skip Если необходимо пропустить заданное кол - во записей

->skip(10)

amount Задать максимальное кол - во записей

->amount(100)

Имейте в виду что вы можете комбинировать методы согласно документации Bpm’online

Create

Синтаксис для создания записи такой же как и Select. Внутри callback необходимо вызвать метод setData и передать ему массив параметров для создания записи в таблице BPM.

$handler = $kernel->action('create:xml', function ($creator){
    $creator->setData([
        // array key => value
    ]);
})->get();

Update

Для обновления данных в записи в BPM необходимо знать guid записи. Здесь устанавливается guid и новые параметры для обновления.

$handler = $kernel->action('update:json', function ($creator){
    $creator->guid('')->setData([
       'Number' => ''
    ]);
})->get();

Delete

Для удаление записи из бд достаточно знать guid

$handler = $kernel->action('delete:xml', function ($creator){
    $creator->guid('');
})->get();

Обработчики ответов

Вне зависимости от операции всегда возращается тип Handler, который иммеет несколько методов для преобразования данных.

toArray Преобразовывает данные в массив

toJson Преобразовывает данные в json

getData Получить данные как есть

Логирование

На данный момент пакет сохраняет внутри себя детализацию всех запросов с сортировкой по дате. Их можно найти в src/resource/logs/...

Интеграция с Laravel

Для интеграции с фреймворком Laravel необходимо скопировать конфигурации и заполнить их

 php artisan vendor:publish --tag=bpm --force

Вставить сервис провайдер в файл config/app.php

 \agoalofalife\bpm\ServiceProviders\BpmBaseServiceProvider::class

Далее можно пользоваться извлекая обьект из контейнера

$bpm =  app('bpm');
$bpm->setCollection('CaseCollection');

 $handler = $bpm->action('read:xml', function ($read){
    $read->amount(1);
})->get();

Либо используя фасад , предварительно зарегистрировав его в файле config/app.php:

   'aliases' => [
 Illuminate\Support\Facades\Facade\Bpm
  ... 
  ]

Клиентский код


    Bpm::setCollection('CaseCollection');
     $handler = Bpm::action('read:xml', function ($read){
        $read->amount(1);
    })->get();

Инструмент

Вам необходимо запустить сервер выполнив команду

vendor/bin/panel-server

Когда перейдете по адресу то увидите перед собой , статистику продолжительности ваших запросов в Bpm. Это программа парсит ваш лог файл который находиться по адресу src/resource/logs

alt text

What is it ?

The package provides a convenient interface to work with API Bpm’online through the Protocol

Install

For installation, you must run the command from composer

composer require agoalofalife/bpm-online

Configurations

To install your configuration data there are several ways :

  • class File
 //Init  kernel
 $kernel = new KernelBpm();
 $file = new File();
 
 // specify the path to the file with the configurations
 $file->setSource(__DIR__ . '/config/apiBpm.php');
 // loading...
 $kernel->loadConfiguration($file);

The file must return an array with the data

return [
	// url for auth
    'UrlLogin' => '',
    //our url for request api       
    'UrlHome'  => '',
    'Login'    => '',
    'Password' => ''
    ]
  • through method setConfigManually in KernelBpm
$kernel = new KernelBpm();
// the first parameter is passed a prefix for configuration
$kernel->setConfigManually('apiBpm', [
        'UrlLogin' => '',
        'Login'    => '',
        'Password' => '',
        'UrlHome'  => ''
]);

Authentication

For authentication in BPM API , it is necessary to get cookie in URL

https://ikratkoe.bpmonline.com/ServiceModel/AuthService.svc/Login It is necessary to call the method authentication

$kernel->authentication();

You can not call it and the package will automatically update the cookies by making an additional query.

Set Collection

In BPM all tables of the database are referred to as collections ( Collections ) To communicate, you must install the collection.

$kernel->setCollection('CaseCollection');

This approach has an additional disadvantage in the method call setCollection, but reuse installation of the collection. Meaning that we can install a collection and perform operations on it.

Select

All methods take the first parameter of the string type and the data type, the second parameter callback inside of which is passed the type of operation, inside callback executed all pre - settings at the end method is called get.

Returns the object type Handler which handler response from BPM.

$handler = $kernel->action('read:json', function ($read){
    $read->amount(1)->skip(100);

})->get();

Only two types of data xml and json. Four types of operations read, create, update, delete.

Methods Select

filterConstructor

Allows you to filter the selection using the function $filter in request

filterConstructor('Id eq guid\'00000000-0000-0000-0000-000000000000\'');

orderBy To retrieve data in sorted form The first parameter the field name, the second argument to sort : ascending (asc) descending (desc)

->orderby('Number', 'desc')

skip

If you want to skip the specified number of records

->skip(10)

amount To set the maximum number of records

->amount(100)

Keep in mind that you can combine the methods according to the documentation Bpm’online

Create

The syntax for creating a record is the same as Select. Inside callback you must call setData and pass his array parameters for creating record in table BPM.

$handler = $kernel->action('create:xml', function ($creator){
    $creator->setData([
        // array key => value
    ]);
})->get();

Update

To update the data in the record BPM you need to know guid record. This set guid and new parameters for updates.

$handler = $kernel->action('update:json', function ($creator){
    $creator->guid('')->setData([
       'Number' => ''
    ]);
})->get();

Delete

For deleting a record from DB enough to know guid and only guid

$handler = $kernel->action('delete:xml', function ($creator){
    $creator->guid('');
})->get();

Handler Response

Regardless of the operation always returns a typeп Handler, which has several methods to convert the data.

toArray Converts the data into an array

toJson Converts the data to json

getData Just Return the data

Log

At the moment, the package keeps a detail of all queries sorted by date. You can find them in src/resource/logs/...

Integration with Laravel

For integration with the framework Laravel you must copy the configuration and fill them

 php artisan vendor:publish --tag=bpm --force

Insert the service provider to a file config/app.php

 \agoalofalife\bpm\ServiceProviders\BpmBaseServiceProvider::class,

Then you can use extract the object from the container.

    $bpm =  app('bpm');
    $bpm->setCollection('CaseCollection');

     $handler = $bpm->action('read:xml', function ($read){
        $read->amount(1);
    })->get();

Or by using the Facade , registering it in a fileconfig/app.php:

   'aliases' => [
 Illuminate\Support\Facades\Facade\Bpm
  ... 
  ]

Client code

    Bpm::setCollection('CaseCollection');
     $handler = Bpm::action('read:xml', function ($read){
        $read->amount(1);
    })->get();

Tool

You need to start the server by running the command :

vendor/bin/panel-server

When you click on the address you will see a statistics of the duration of your queries in Bpm. This program parses your log file which is located at the address src/resource/logs

alt text

bpm-online's People

Contributors

agoalofalife avatar bunke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

bpm-online's Issues

Conflict with Laravel 6.x

Problem 1
- Installation request for agoalofalife/bpm-online ^2.2 -> satisfiable by agoalofalife/bpm-online[2.2.1].
- Conclusion: remove laravel/framework v6.15.1
- Conclusion: don't install laravel/framework v6.15.1
- agoalofalife/bpm-online 2.2.1 requires illuminate/config ~5.4 -> satisfiable by illuminate/config[5.4.x-dev, 5.5.x-dev, 5.6.x-dev, 5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, 5.8.x-dev, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.5.44, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9, v5.7.0, v5.7.1, v5.7.10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.36, v5.8.4, v5.8.8, v5.8.9].

Composer.json is too inclusive

Hi,

I've noticed, that composer requires next packages

"symfony/var-dumper": "^3.2",
"monolog/monolog": "1.*",
"slim/slim": "^3.0"

That's stuff should be in require-dev and I don't think, that slim or monolog should be required at all. It's up to library user to inject logger or choose web framework.

How to get Error from response after update

When I'm execute update action with error, I've got handler:

object(agoalofalife\bpm\Handlers\XmlHandler)#43 (6) {
["response":"agoalofalife\bpm\Handlers\XmlHandler":private]=>
object(SimpleXMLElement)#46 (3) {
["code"]=>
string(1) "1"
["message"]=>
string(45) "Элемент UsrDiagnosis не найден"
["innererror"]=>
object(SimpleXMLElement)#41 (3) {
["message"]=>
string(45) "Элемент UsrDiagnosis не найден"
["type"]=>
string(38) "Terrasoft.Common.ItemNotFoundException"
....

method ->toArray() do not return response in this case

How can I parse response->message ? this field is private, can I write some getter?

Conflict with Laravel 5.8.x

$ composer require agoalofalife/bpm-online
Using version ^2.2 for agoalofalife/bpm-online
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for agoalofalife/bpm-online ^2.2 -> satisfiable by agoalofalife/bpm-online[2.2.1].
- Conclusion: remove symfony/http-kernel v4.2.4
- Conclusion: don't install symfony/http-kernel v4.2.4
- agoalofalife/bpm-online 2.2.1 requires symfony/var-dumper ^3.2 -> satisfiable by symfony/var-dumper[3.2.x-dev, 3.3.x-dev, 3.4.x-dev, v3.2.0, v3.2.0-BETA1, v3.2.0-RC1, v3.2.0-RC2, v3.2.1, v3.2.10, v3.2.11, v3.2.12, v3.2.13, v3.2.14, v3.2.2, v3.2.3, v3.2.4, v3.2.5, v3.2.6, v3.2.7, v3.2.8, v3.2.9, v3.3.0, v3.3.0-BETA1, v3.3.0-RC1, v3.3.1, v3.3.10, v3.3.11, v3.3.12, v3.3.13, v3.3.14, v3.3.15, v3.3.16, v3.3.17, v3.3.18, v3.3.2, v3.3.3, v3.3.4, v3.3.5, v3.3.6, v3.3.7, v3.3.8, v3.3.9, v3.4.0, v3.4.0-BETA1, v3.4.0-BETA2, v3.4.0-BETA3, v3.4.0-BETA4, v3.4.0-RC1, v3.4.0-RC2, v3.4.1, v3.4.10, v3.4.11, v3.4.12, v3.4.13, v3.4.14, v3.4.15, v3.4.16, v3.4.17, v3.4.18, v3.4.19, v3.4.2, v3.4.20, v3.4.21, v3.4.22, v3.4.23, v3.4.3, v3.4.4, v3.4.5, v3.4.6, v3.4.7, v3.4.8, v3.4.9].
- symfony/var-dumper 3.2.x-dev conflicts with symfony/http-kernel[v4.2.4].
...

Please, update dependencies.

I can`t install package.

When I write:
composer require agoalofalife/bpm-online
I get:
Problem 1
- Installation request for agoalofalife/bpm-online ^2.1 -> satisfiable by agoalofalife/bpm-online[2.1.0].
- Conclusion: remove laravel/framework v5.5.39
- Conclusion: don't install laravel/framework v5.5.39
- agoalofalife/bpm-online 2.1.0 requires illuminate/config 5.4.* -> satisfiable by illuminate/config[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9].
- don't install illuminate/config v5.4.0|don't install laravel/framework v5.5.39
- don't install illuminate/config v5.4.13|don't install laravel/framework v5.5.39
- don't install illuminate/config v5.4.17|don't install laravel/framework v5.5.39
- don't install illuminate/config v5.4.19|don't install laravel/framework v5.5.39
- don't install illuminate/config v5.4.27|don't install laravel/framework v5.5.39
- don't install illuminate/config v5.4.36|don't install laravel/framework v5.5.39
- don't install illuminate/config v5.4.9|don't install laravel/framework v5.5.39
- Installation request for laravel/framework (locked at v5.5.39, required as 5.5.*) -> satisfiable by laravel/framework[v5.5.39].

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.