-
Notifications
You must be signed in to change notification settings - Fork 5
/
init.php
41 lines (34 loc) · 1.09 KB
/
init.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
// Require any libraries needed for the module to function.
require __DIR__ . '/vendor/autoload.php';
use \Illuminate\Database\Capsule\Manager as Capsule;
/**
* Get the Moneybird settings
*
* @param none
* @return array
*/
function getMoneybirdSettings() {
$settings = Capsule::table('tbladdonmodules');
$settings = $settings->select('setting', 'value');
$settings = $settings->where('module', '=', 'moneybird');
$module_settings = array();
foreach ($settings->get() as $setting) {
$module_settings[$setting->setting] = $setting->value;
}
return $module_settings;
}
/**
* Create a Moneybird connection
*
* @param none
* @return object \Picqer\Financials\Moneybird\Moneybird
*/
function createMoneybirdConnection() {
$module_settings = getMoneybirdSettings();
// Set up the connection with MoneyBird
$connection = new \Picqer\Financials\Moneybird\Connection();
$connection->setAccessToken($module_settings['AccessToken']);
$connection->setAdministrationId($module_settings['AdministrationId']);
return new \Picqer\Financials\Moneybird\Moneybird($connection);
}