Skip to content

Commit f86da94

Browse files
committed
Merge pull request #16 from Vitafy/programs
Programs and enrolments
2 parents 75fa39c + 580de2c commit f86da94

File tree

8 files changed

+295
-0
lines changed

8 files changed

+295
-0
lines changed

src/DataTypes/ApiProgram.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
*
4+
* @author Roman Piták <[email protected]>
5+
* @author Alexander Turiak <[email protected]>
6+
*
7+
*/
8+
9+
10+
namespace DotMailer\Api\DataTypes;
11+
12+
13+
/**
14+
* Class ApiProgram
15+
*
16+
* @property XsInt ID
17+
* @property XsString Name
18+
* @property ApiProgramStatus Status
19+
* @property XsDateTime DateCreated
20+
*/
21+
final class ApiProgram extends JsonObject
22+
{
23+
protected function getProperties()
24+
{
25+
return array(
26+
'ID' => 'XsInt',
27+
'Name' => 'XsString',
28+
'Status' => 'ApiProgramStatus',
29+
'DateCreated' => 'XsDateTime',
30+
);
31+
}
32+
33+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
*
4+
* @author Roman Piták <[email protected]>
5+
* @author Alexander Turiak <[email protected]>
6+
*
7+
*/
8+
9+
10+
namespace DotMailer\Api\DataTypes;
11+
12+
13+
/**
14+
* Class ApiProgramEnrolment
15+
*
16+
* @property Guid ID
17+
* @property XsInt ProgramId
18+
* @property ApiProgramEnrolmentStatus Status
19+
* @property XsDateTime DateCreated
20+
* @property Int32List Contacts
21+
* @property Int32List AddressBooks
22+
*/
23+
final class ApiProgramEnrolment extends JsonObject
24+
{
25+
protected function getProperties()
26+
{
27+
return array(
28+
'ID' => 'Guid',
29+
'ProgramId' => 'XsInt',
30+
'Status' => 'ApiProgramEnrolmentStatus',
31+
'DateCreated' => 'XsDateTime',
32+
'Contacts' => 'Int32List',
33+
'AddressBooks' => 'Int32List'
34+
);
35+
}
36+
37+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
*
4+
* @author Roman Piták <[email protected]>
5+
* @author Alexander Turiak <[email protected]>
6+
*
7+
*/
8+
9+
10+
namespace DotMailer\Api\DataTypes;
11+
12+
13+
final class ApiProgramEnrolmentList extends JsonArray
14+
{
15+
16+
protected function getDataClass()
17+
{
18+
return 'ApiProgramEnrolment';
19+
}
20+
21+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
*
4+
* @author Roman Piták <[email protected]>
5+
* @author Alexander Turiak <[email protected]>
6+
*
7+
*/
8+
9+
10+
namespace DotMailer\Api\DataTypes;
11+
12+
13+
final class ApiProgramEnrolmentStatus extends Enum
14+
{
15+
16+
const PROCESSING = 'Processing';
17+
const FINISHED = 'Finished';
18+
const NOT_AVAILABLE_IN_THIS_VERSION = 'NotAvailableInThisVersion';
19+
20+
21+
/*
22+
* ========== Enum ==========
23+
*/
24+
25+
protected function getDataClass()
26+
{
27+
return 'XsString';
28+
}
29+
30+
protected function getPossibleValues()
31+
{
32+
return array(
33+
self::PROCESSING,
34+
self::FINISHED,
35+
self::NOT_AVAILABLE_IN_THIS_VERSION
36+
);
37+
}
38+
39+
}

src/DataTypes/ApiProgramList.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
*
4+
* @author Roman Piták <[email protected]>
5+
* @author Alexander Turiak <[email protected]>
6+
*
7+
*/
8+
9+
10+
namespace DotMailer\Api\DataTypes;
11+
12+
13+
final class ApiProgramList extends JsonArray
14+
{
15+
16+
protected function getDataClass()
17+
{
18+
return 'ApiProgram';
19+
}
20+
21+
}

src/DataTypes/ApiProgramStatus.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
*
4+
* @author Roman Piták <[email protected]>
5+
* @author Alexander Turiak <[email protected]>
6+
*
7+
*/
8+
9+
10+
namespace DotMailer\Api\DataTypes;
11+
12+
13+
final class ApiProgramStatus extends Enum
14+
{
15+
16+
const DRAFT = 'Draft';
17+
const DEACTIVATED = 'Deactivated';
18+
const ACTIVE = 'Active';
19+
const READONLY = 'ReadOnly';
20+
const NOT_AVAILABLE_IN_THIS_VERSION = 'NotAvailableInThisVersion';
21+
22+
23+
/*
24+
* ========== Enum ==========
25+
*/
26+
27+
protected function getDataClass()
28+
{
29+
return 'XsString';
30+
}
31+
32+
protected function getPossibleValues()
33+
{
34+
return array(
35+
self::DRAFT,
36+
self::DEACTIVATED,
37+
self::ACTIVE,
38+
self::READONLY,
39+
self::NOT_AVAILABLE_IN_THIS_VERSION
40+
);
41+
}
42+
43+
}

src/Resources/IResources.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
use DotMailer\Api\DataTypes\ApiImage;
4545
use DotMailer\Api\DataTypes\ApiImageFolder;
4646
use DotMailer\Api\DataTypes\ApiImageFolderList;
47+
use DotMailer\Api\DataTypes\ApiProgram;
48+
use DotMailer\Api\DataTypes\ApiProgramList;
49+
use DotMailer\Api\DataTypes\ApiProgramEnrolment;
50+
use DotMailer\Api\DataTypes\ApiProgramEnrolmentList;
4751
use DotMailer\Api\DataTypes\ApiResubscribeResult;
4852
use DotMailer\Api\DataTypes\ApiSegmentList;
4953
use DotMailer\Api\DataTypes\ApiSegmentRefresh;
@@ -865,6 +869,60 @@ public function GetImageFolderById(XsInt $folderId);
865869
*/
866870
public function PostImageFolder(XsInt $folderId, ApiImageFolder $apiImageFolder);
867871

872+
/*
873+
* ========== programs and enrolments ==========
874+
*/
875+
876+
/**
877+
* Gets a program by id.
878+
*
879+
* @param int|XsInt $programId
880+
* @return ApiProgram
881+
*/
882+
public function GetProgramById(XsInt $programId);
883+
884+
/**
885+
* Creates a new program enrolment.
886+
*
887+
* @param ApiProgramEnrolment $apiProgramEnrolment
888+
*/
889+
public function PostProgramsEnrolments(ApiProgramEnrolment $apiProgramEnrolment);
890+
891+
/**
892+
* Gets an enrolment by id.
893+
*
894+
* @param string|Guid $enrolmentId
895+
* @return ApiProgramEnrolment
896+
*/
897+
public function GetProgramsEnrolmentByEnrolmentId($enrolmentId);
898+
899+
/**
900+
* Gets faults by an enrolment id.
901+
*
902+
* @param string|Guid $enrolmentId
903+
* @return ApiProgramEnrolment
904+
*/
905+
public function GetProgramsEnrolmentReportFaults($enrolmentId);
906+
907+
/**
908+
* Gets enrolments by status.
909+
*
910+
* @param string|XsString $status
911+
* @param int $select
912+
* @param int $skip
913+
* @return ApiProgramEnrolmentList
914+
*/
915+
public function GetProgramsEnrolmentByStatus($status, $select = 1000, $skip = 0);
916+
917+
/**
918+
* Gets all programs.
919+
*
920+
* @param int $select
921+
* @param int $skip
922+
* @return ApiProgramList
923+
*/
924+
public function GetPrograms($select = 1000, $skip = 0);
925+
868926
/*
869927
* ========== segments ==========
870928
*/

src/Resources/Resources.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
use DotMailer\Api\DataTypes\ApiImage;
4444
use DotMailer\Api\DataTypes\ApiImageFolder;
4545
use DotMailer\Api\DataTypes\ApiImageFolderList;
46+
use DotMailer\Api\DataTypes\ApiProgram;
47+
use DotMailer\Api\DataTypes\ApiProgramList;
48+
use DotMailer\Api\DataTypes\ApiProgramEnrolment;
49+
use DotMailer\Api\DataTypes\ApiProgramEnrolmentList;
4650
use DotMailer\Api\DataTypes\ApiResubscribeResult;
4751
use DotMailer\Api\DataTypes\ApiSegmentList;
4852
use DotMailer\Api\DataTypes\ApiSegmentRefresh;
@@ -603,6 +607,45 @@ public function PostImageFolder(XsInt $folderId, ApiImageFolder $apiImageFolder)
603607
return new ApiImageFolder($this->execute($url, 'POST', $apiImageFolder->toJson()));
604608
}
605609

610+
/*
611+
* ========== programs and enrolments ==========
612+
*/
613+
614+
public function GetProgramById(XsInt $programId)
615+
{
616+
$url = sprintf("programs/%s", $programId);
617+
return new ApiProgram($this->execute($url));
618+
}
619+
620+
public function PostProgramsEnrolments(ApiProgramEnrolment $apiProgramEnrolment)
621+
{
622+
$this->execute('programs/enrolments', 'POST', $apiProgramEnrolment->toJson());
623+
}
624+
625+
public function GetProgramsEnrolmentByEnrolmentId($enrolmentId)
626+
{
627+
$url = sprintf("programs/enrolments/%s", $enrolmentId);
628+
return new ApiProgramEnrolment($this->execute($url));
629+
}
630+
631+
public function GetProgramsEnrolmentReportFaults($enrolmentId)
632+
{
633+
$url = sprintf("programs/enrolments/%s/report-faults", $enrolmentId);
634+
return new ApiProgramEnrolment($this->execute($url));
635+
}
636+
637+
public function GetProgramsEnrolmentByStatus($status, $select = 1000, $skip = 0)
638+
{
639+
$url = sprintf("programs/enrolments/%s/?select=%s&skip=%s", $status, $select, $skip);
640+
return new ApiProgramEnrolmentList($this->execute($url));
641+
}
642+
643+
public function GetPrograms($select = 1000, $skip = 0)
644+
{
645+
$url = sprintf("programs/?select=%s&skip=%s", $select, $skip);
646+
return new ApiProgramList($this->execute($url));
647+
}
648+
606649
/*
607650
* ========== segments ==========
608651
*/

0 commit comments

Comments
 (0)