定制 prayno/moveon 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

prayno/moveon

最新稳定版本:2.2

Composer 安装命令:

composer require prayno/moveon

包简介

MoveON API wrapper

README 文档

README

MoveOn (https://www.qs-unisolution.com/moveon/) is an application used to manage International Mobility between universities and schools (Erasmus program for example). This package is a php wrapper for the MoveOn API.

Installation

Install the library via Composer by running the following command:

composer require prayno/moveon

Usage

Prerequisites

Prior to usage, you must contact your MoveON technical rep to activate the API in your MoveON instance.

Then, you have to generate a self-signed X509 certificate for your API client (.pem) and bind the serial number to a MoveON user (see technical doc for that)

Instantiation of the class

The MoveOn class now requires the use of the symfony/http-client component.

private $client;

public function __construct(HttpClientInterface $client)
{
    $this->client = $client->withOptions([
        'local_cert' => '/location/to/my/certificate/mycertificate.crt',
        'local_pk' => '/location/to/my/certificate/mycertificate.key',
        'passphrase' => 'myOptionalPassphraseToReadTheCertificate',
        'base_uri' => 'https://myUniversityInstance-api.moveonfr.com/restService/index.php?version=3.0'
    ]);
}

public function myFunction()
{
    $moveon = new MoveOn($this->client);
    ...
}

Retrieve information

To gather information, you need the entity to look for and the criteria you want to search on.

$data = $moveon->findBy("person",["surname"=>"Foo","first_name"=>"Bar"]);

You can use arrays as criteria to search for multiple values. Eg :

$data = $moveon->findBy("person",["surname"=>"Doe","first_name"=>["John","Jane"]]);

This will return a SimpleXMLElement object (page,records,total and rows).

You can also add more options to this method :

  • sort : array of fields / order
  • rows : number of rows per page
  • page : page of results
  • columns : filter fields being returned
  • locale : eng/fra/deu/ita/spa

Eg :

$data = $moveon->findBy("person",["surname"=>"Foo","first_name"=>"Bar"],["surname"=>"asc","first_name"=>"asc"],20,1,["email","surname","last_name"],"fra");

Due to a limit set by QS, you cannot request for more than 250 rows. However, this library allows you to request for more lines, it will send multiple requests and merge the responses into a single one. This feature is only available if you don't request for a specific page.

Save data

Create and update use the same method ; if you want to update, you just need to provide the id of the entry.

$data = $moveon->save("person",["id"=>"1","surname"=>"Foo","first_name"=>"Bar"]);

The additional parameter $retrieveData set to false allows the method to only return the queueId provided by the API for a later use (useful when you have many queries)

Note :

The following fields were excluded from their entities as they make the requests fail

person : address.type_eng,address.type_fra,address.type_deu,address.type_ita,address.type_spa

relation : parent,created_on,created_by,last_modified_by,last_modified_on

academic-year : is_active

subject-area : isced

institution : sector_id,size_id,organization_type_id

Custom query

You can also create your own custom query and send it to the API using the sendQuery method.

$data = $moveon->sendQuery("person","list",YOUR_QUERY_STRING);

Download files

You can download the binary content of a file using the downloadFile method. In order to achieve this, you need to provide the document ID of the file you want to download using the "template_document" or the "simple_document" object.

Here's an example of how to download a grant agreement document:

$grantName = $grant->{"grant.name"}->__toString();
$documents = $this->moveon->findBy("template-document",["regarding_grant_names"=>"$grantName,$grantName"]);
foreach ($documents->rows as $document)
{
    $fs = new Filesystem();
    $fileName = $document->{"template_document.fileName"}->__toString();
    $binary = $this->moveon->downloadFile($document->{"template_document.id"}->__toString());
    $fs->dumpFile("/location/to/my/file/$fileName", $binary);
}

统计信息

  • 总下载量: 236
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-04-01