-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConnector.php
113 lines (98 loc) · 2.56 KB
/
Connector.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
declare(strict_types=1);
namespace BambooHRConnector;
include 'Config.php';
include 'Logger.php';
include 'BambooHRAbsences.php';
include 'BambooHR/API/API.php';
include 'PapershiftAbsences.php';
include 'SendMail.php';
use PHPMailer\PHPMailer\PHPMailer;
require 'vendor/autoload.php';
/**
* Class Connector
*
* @version 2.1
*
* @package BambooHRConnector
* @author Georgi Damyanov <[email protected]>
*/
class Connector
{
/**
* Instance of PHPMailer
*
* @var $mailer PHPMailer
*/
private $mailer;
/**
* Instance of SendMail
*
* @var $sendmail SendMail
*/
private $sendmail;
/**
* Instance of Config
*
* @var $config Config
*/
private $config;
/**
* Instance of BambooHRAbsences
*
* @var $bamboo BambooHRAbsences
*/
private $bamboo;
/**
* Instance of BambooAPI
*
* @var $bambooAPI BambooAPI
*/
private $bambooAPI;
/**
* Instance of PapershiftAbsences
*
* @var $papershift PapershiftAbsences
*/
private $papershift;
/**
* Instance of Logger
*
* @var $logger Logger
*/
private $logger;
/**
* Connector constructor. Create all instances.
*/
public function __construct()
{
$this->logger = new Logger();
$this->config = new Config($this->logger);
$this->mailer = new PHPMailer(true);
$this->sendmail = new SendMail($this->config, $this->mailer);
$this->bambooAPI = new BambooAPI($this->config->getConfig('bamboohr', 'company'));
$this->bamboo = new BambooHRAbsences($this->config, $this->bambooAPI, $this->logger, $this->sendmail);
$this->papershift = new PapershiftAbsences($this->config, $this->logger, $this->sendmail);
}
/**
* Function addAbsencesFromBambooHRToPapershift
*
* - Cut/paste error messages from tmp_error.txt to global_error.txt
* - Get absences from BambooHR
* - Add the absences to Papershift
* - Confirm the absences
* - Send email. (either error or confirmation)
*
* @return void
*/
public function addAbsencesFromBambooHRToPapershift(): void
{
$this->logger->transferDailyLogToGlobal();
$bambooAbsencesArray = $this->bamboo->getBambooHRAbsences();
$this->papershift->addAbsencesToPapershift($bambooAbsencesArray);
$this->papershift->confirmPapershiftAbsences();
$this->sendmail->sendEmail();
}
}
$connector = new Connector();
$connector->addAbsencesFromBambooHRToPapershift();