Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release: 4.0.0 #9

Merged
merged 12 commits into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Release Notes

## [Unreleased]
## [4.0.0] - 2021-04-19
### Added
- Support new Soldo 2.0 APIs

## [3.0.0] - 2020-07-17
### Changed
- Update company name
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ $soldo = new \Soldo\Soldo([

- **Retrieve collections**
- [Obtaining the Employees list](./examples/collections.md#obtaining-the-employees-list)
- [Obtaining the Expense Centres list](./examples/collections.md#obtaining-the-expense-centres-list)
- [Obtaining the Groups list](./examples/collections.md#obtaining-the-groups-list)
- [Obtaining the Wallets list](./examples/collections.md#obtaining-the-wallets-list)
- [Obtaining the Cards list](./examples/collections.md#obtaining-the-cards-list)
- [Obtaining the Transactions list](./examples/collections.md#obtaining-the-transactions-list)
Expand All @@ -42,8 +42,7 @@ $soldo = new \Soldo\Soldo([
- [Obtaining the Company resource](./examples/resources.md#obtaining-the-company-resource)
- [Obtaining an Employee resource](./examples/resources.md#obtaining-an-employee-resource)
- [Updating an Employee resource](./examples/resources.md#updating-an-employee-resource)
- [Obtaining an Expense Centre resource](./examples/resources.md#obtaining-an-expense-centre-resource)
- [Updating an Expense Centre resource](./examples/resources.md#updating-an--expense-centre-resource)
- [Obtaining a Group resource](./examples/resources.md#obtaining-a-group-resource)
- [Obtaining a Wallet resource](./examples/resources.md#obtaining-a-wallet-resource)
- [Obtaining a Card resource](./examples/resources.md#obtaining-a-card-resource)
- [Obtaining a Transaction resource](./examples/resources.md#obtaining-a-transaction-resource)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "everli/soldo-php-sdk",
"version": "3.0.0",
"version": "4.0.0",
"description": "Unofficial PHP SDK to work with Soldo API",
"keywords": ["everli", "soldo", "api"],
"license": "Apache-2.0",
Expand Down
6 changes: 3 additions & 3 deletions examples/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ var_dump($collection);
Accessing the other collections is pretty similar. Below you can find an example for each collection provided by the API.


## Obtaining the Expense Centres list
## Obtaining the Groups list

```php
try {
$collection = $soldo->getExpenseCentres();
$collection = $soldo->getGroups();
} catch (\Soldo\Exceptions\SoldoException $e) {
echo 'Soldo returned an error: ' . $e->getMessage();
}

// each item of $collection is of type \Soldo\Resource\ExpenseCentre
// each item of $collection is of type \Soldo\Resource\Group
var_dump($collection);
```

Expand Down
27 changes: 2 additions & 25 deletions examples/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,40 +68,17 @@ Any key different from the supported ones will be ignored. If no supported keys

Printing out `$employee->department` will show `Department name` and the value of `custom_reference_id` will be `a-random-string`.

## Obtaining an Expense Centre resource
## Obtaining a Group resource

```php
try {
$resource = $soldo->getExpenseCentre('SDMD7784-000002');
$resource = $soldo->getGroup('SDMD7784-000002');
} catch (\Soldo\Exceptions\SoldoException $e) {
echo 'Soldo returned an error: ' . $e->getMessage();
}
```


## Updating an Expense Centre resource

You can update the following Expense Centre properties:
- `custom_reference_id`: the employee reference id into the calling system
- `assignee`: the assignee of the expense centre

doing as follows:

```php
try {
$expenseCentre = $soldo->updateExpenseCentre('SDMD7784-000001', [
'department' => 'Department name',
'assignee' => 'An Assignee',
]);
} catch (\Soldo\Exceptions\SoldoException $e) {
echo 'Soldo returned an error: ' . $e->getMessage();
}
```

Any key different from the supported ones will be ignored. If no supported keys are provided an `InvalidArgumentException` will be thrown.

Printing out `$expenseCentre->department` will show `Department name` and the value of `assignee` will be `An Assignee`.

## Obtaining a Wallet resource

```php
Expand Down
2 changes: 1 addition & 1 deletion examples/transfer.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Array
[currency_code] => EUR
[available_amount] => 4623
[blocked_amount] => 0
[primary_user_type] => expensecentre
[primary_user_type] => company
[primary_user_public_id] => SDMD7784-000002
[visible] => 1
)
Expand Down
6 changes: 3 additions & 3 deletions examples/webhooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ The endpoint you expose will receive a JSON Payload similar to:
],
"card_id":"f275d49c-1526-11e7-9287-0a89c8769141",
"masked_pan":"999999******3706",
"owner_id":"SDMD7784-000002",
"group_id":"SDMD7784-000002",
"custom_reference_id":"sdfgsfgsdfg",
"owner_type":"expensecentre"
"owner_type":"company"
}
}
```
Expand Down Expand Up @@ -158,7 +158,7 @@ Array
[masked_pan] => 999999******3706
[owner_id] => SDMD7784-000002
[custom_reference_id] => sdfgsfgsdfg
[owner_type] => expensecentre
[owner_type] => COMPANY
)

```
Expand Down
35 changes: 0 additions & 35 deletions src/Soldo/Resources/ExpenseCentre.php

This file was deleted.

30 changes: 30 additions & 0 deletions src/Soldo/Resources/Group.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Soldo\Resources;

/**
* Class Group
* @package Soldo\Resources
*
* @property string id
* @property string name
* @property string custom_reference_id
* @property string type
* @property string note
* @property string creation_time
* @property array members
* @property array wallets
* @property array cards
*/
class Group extends Resource
{
/**
* @inheritDoc
*/
protected static $basePath = '/groups';

/**
* @inheritDoc
*/
protected $path = '/{id}';
}
2 changes: 1 addition & 1 deletion src/Soldo/Resources/InternalTransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Soldo\Exceptions\SoldoInternalTransferException;

/**
* Class ExpenseCentre
* Class InternalTransfer
* @package Soldo\Resources
*
* @property string fromWalletId
Expand Down
5 changes: 2 additions & 3 deletions src/Soldo/Resources/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@
* @property array tags
* @property string card_id
* @property string masked_pan
* @property string owner_id
* @property string group_id
* @property string owner_type
* @property string owner_name
* @property string owner_surname
* @property string trx_owner_id
* @property string custom_reference_id
* @property array details
*/
Expand Down
74 changes: 30 additions & 44 deletions src/Soldo/Soldo.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
use Psr\Log\LoggerInterface;
use Soldo\Authentication\OAuthCredential;
use Soldo\Exceptions\SoldoException;
use Soldo\Resources\Group;
use Soldo\Resources\InternalTransfer;
use Soldo\Resources\Transaction;
use Soldo\Utils\Paginator;
use Soldo\Resources\Card;
use Soldo\Resources\Company;
use Soldo\Resources\Employee;
use Soldo\Resources\ExpenseCentre;
use Soldo\Resources\Wallet;

/**
Expand Down Expand Up @@ -85,49 +85,6 @@ public function getWallet($id)
return $wallet;
}

/**
* Return an array containing a list of ExpenseCentre
*
* @param int $page
* @param int $perPage
* @param array $searchFields
* @return array
*/
public function getExpenseCentres($page = 0, $perPage = Paginator::MAX_ALLOWED_ITEMS_PER_PAGE, $searchFields = [])
{
$paginator = new Paginator($page, $perPage);
$collection = $this->client->getCollection(ExpenseCentre::class, $paginator, $searchFields);

return $collection->get();
}

/**
* Return a single ExpenseCentre resource
*
* @param mixed $id
* @return \Soldo\Resources\Resource
*/
public function getExpenseCentre($id)
{
$expense_center = $this->client->getItem(ExpenseCentre::class, $id);

return $expense_center;
}

/**
* Update the ExpenseCentre by id and return the resource up to date
*
* @param mixed $id
* @param array $data
* @return \Soldo\Resources\Resource
*/
public function updateExpenseCentre($id, $data)
{
$expense_center = $this->client->updateItem(ExpenseCentre::class, $id, $data);

return $expense_center;
}

/**
* Return an array containing a list of Employee
*
Expand Down Expand Up @@ -205,6 +162,35 @@ public function getTransaction($id, $withDetails = false)
return $transaction;
}

/**
* Return an array containing a list of Groups
*
* @param int $page
* @param int $perPage
* @param array $searchFields
* @return array
*/
public function getGroups($page = 0, $perPage = Paginator::MAX_ALLOWED_ITEMS_PER_PAGE, $searchFields = [])
{
$paginator = new Paginator($page, $perPage);
$collection = $this->client->getCollection(Group::class, $paginator, $searchFields);

return $collection->get();
}

/**
* Return a single Group resource
*
* @param mixed $id
* @return \Soldo\Resources\Resource
*/
public function getGroup($id)
{
$group = $this->client->getItem(Group::class, $id);

return $group;
}

/**
* Return an array containing a list of Card
*
Expand Down
2 changes: 0 additions & 2 deletions src/Soldo/SoldoEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class SoldoEvent
const EVENT_TYPE_CARD = 'Card';
const EVENT_TYPE_TRANSACTION = 'Transaction';
const EVENT_TYPE_EMPLOYEE = 'Employee';
const EVENT_TYPE_EXPENSE_CENTRE = 'ExpenseCentre';

/**
* An identifier for the event
Expand Down Expand Up @@ -113,7 +112,6 @@ public static function types()
self::EVENT_TYPE_CARD,
self::EVENT_TYPE_TRANSACTION,
self::EVENT_TYPE_EMPLOYEE,
self::EVENT_TYPE_EXPENSE_CENTRE,
];
}
}
2 changes: 0 additions & 2 deletions src/Soldo/Utils/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ public function __construct($page, $perPage, $orderDirection = null, $orderedPro
);
}

// TODO: handle orderDirection and orderedProperties

// set page param
$this->page = $page < 0 ?
0 :
Expand Down
Loading