Skip to content

Commit

Permalink
Add Daily Closure, closes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
EmanueleCoppola committed Oct 17, 2024
1 parent 7fc1e20 commit aac4078
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
17 changes: 17 additions & 0 deletions examples/get-daily-closure.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

require_once __DIR__ . '/../vendor/autoload.php';

\SatispayGBusiness\Api::setSandbox(true);

$authData = json_decode(file_get_contents(__DIR__ . '/authentication.json'));

\SatispayGBusiness\Api::setPublicKey($authData->public_key);
\SatispayGBusiness\Api::setPrivateKey($authData->private_key);
\SatispayGBusiness\Api::setKeyId($authData->key_id);

$dailyClosure = \SatispayGBusiness\DailyClosure::get(null, [
'generate_pdf' => 'true'
]);

var_dump($dailyClosure);
37 changes: 37 additions & 0 deletions src/DailyClosure.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace SatispayGBusiness;

class DailyClosure
{
private static $apiPath = "/g_business/v1/daily_closure";

/**
* Get daily clousure.
* @see https://developers.satispay.com/reference/retrieve-daily-closure
*
* @param string $date
* @param array $options
*/
public static function get($date = null, $query = [], $headers = [])
{
if (!$date) {
$date = date('Ymd');
}

$path = self::$apiPath . '/' . $date;

if (!empty($query)) {
$path .= '?' . http_build_query($query);
}

return
Request::get(
$path,
[
'headers' => $headers,
'sign' => true
]
);
}
}

0 comments on commit aac4078

Please sign in to comment.