|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Wcomnisky\Flagship\Api; |
|
6
|
|
|
|
|
7
|
|
|
class RequestParameters |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* Decision Group |
|
11
|
|
|
* |
|
12
|
|
|
* If specified, visitors that matches targeting will be |
|
13
|
|
|
* affected to a unique variation ID per decision group |
|
14
|
|
|
* |
|
15
|
|
|
* @var string |
|
16
|
|
|
* @see http://developers.flagship.io/api/v1/#decision-group |
|
17
|
|
|
*/ |
|
18
|
|
|
private $decisionGroup; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Trigger Hit |
|
22
|
|
|
* |
|
23
|
|
|
* Should the visitor be affected to targeted campaigns |
|
24
|
|
|
* |
|
25
|
|
|
* @var bool |
|
26
|
|
|
* @see http://developers.flagship.io/api/v1/#trigger-hit |
|
27
|
|
|
*/ |
|
28
|
|
|
private $triggerHit = true; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Mode |
|
32
|
|
|
* |
|
33
|
|
|
* The mode of the response body you want to receive |
|
34
|
|
|
* |
|
35
|
|
|
* @var string Mode |
|
36
|
|
|
* @see http://developers.flagship.io/api/v1/#mode |
|
37
|
|
|
*/ |
|
38
|
|
|
private $mode = 'normal'; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Format Response |
|
42
|
|
|
* |
|
43
|
|
|
* If set to true, the response of the API call will be formatted according to your modification |
|
44
|
|
|
* |
|
45
|
|
|
* @var bool |
|
46
|
|
|
* @see http://developers.flagship.io/api/v1/#run-a-single-campaign-assignment |
|
47
|
|
|
* @see http://developers.flagship.io/api/v1/#formatted-campaign |
|
48
|
|
|
*/ |
|
49
|
|
|
private $formatResponse = false; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Enables the Format Response |
|
53
|
|
|
*/ |
|
54
|
1 |
|
public function enableFormatResponse(): void |
|
55
|
|
|
{ |
|
56
|
1 |
|
$this->formatResponse = true; |
|
57
|
1 |
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Disables the Format Response |
|
61
|
|
|
*/ |
|
62
|
1 |
|
public function disableFormatResponse(): void |
|
63
|
|
|
{ |
|
64
|
1 |
|
$this->formatResponse = false; |
|
65
|
1 |
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Returns a bool if Format Response parameter is enabled/disabled |
|
69
|
|
|
* |
|
70
|
|
|
* @return bool |
|
71
|
|
|
*/ |
|
72
|
1 |
|
public function isFormatResponseEnabled(): bool |
|
73
|
|
|
{ |
|
74
|
1 |
|
return $this->formatResponse; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @param string $decisionGroup |
|
79
|
|
|
*/ |
|
80
|
1 |
|
public function setDecisionGroup(string $decisionGroup): void |
|
81
|
|
|
{ |
|
82
|
1 |
|
$this->decisionGroup = $decisionGroup; |
|
83
|
1 |
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @return string|null |
|
87
|
|
|
*/ |
|
88
|
2 |
|
public function getDecisionGroup(): ?string |
|
89
|
|
|
{ |
|
90
|
2 |
|
return $this->decisionGroup; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Enables the Trigger Hit parameter |
|
95
|
|
|
*/ |
|
96
|
1 |
|
public function enableTriggerHit(): void |
|
97
|
|
|
{ |
|
98
|
1 |
|
$this->triggerHit = true; |
|
99
|
1 |
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Disables the Trigger Hit parameter |
|
103
|
|
|
*/ |
|
104
|
1 |
|
public function disableTriggerHit(): void |
|
105
|
|
|
{ |
|
106
|
1 |
|
$this->triggerHit = false; |
|
107
|
1 |
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Returns a bool if Trigger Hit parameter is enabled/disabled |
|
111
|
|
|
*/ |
|
112
|
2 |
|
public function isTriggerHitEnabled(): bool |
|
113
|
|
|
{ |
|
114
|
2 |
|
return $this->triggerHit; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* Defines the mode parameter to normal |
|
120
|
|
|
*/ |
|
121
|
1 |
|
public function enableModeNormal(): void |
|
122
|
|
|
{ |
|
123
|
1 |
|
$this->mode = 'normal'; |
|
124
|
1 |
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* Defines the mode parameter to simple |
|
128
|
|
|
*/ |
|
129
|
1 |
|
public function enableModeSimple(): void |
|
130
|
|
|
{ |
|
131
|
1 |
|
$this->mode = 'simple'; |
|
132
|
1 |
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* Defines the mode parameter to full |
|
136
|
|
|
*/ |
|
137
|
2 |
|
public function enableModeFull(): void |
|
138
|
|
|
{ |
|
139
|
2 |
|
$this->mode = 'full'; |
|
140
|
2 |
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* Returns the mode parameter value |
|
144
|
|
|
* |
|
145
|
|
|
* @return string |
|
146
|
|
|
*/ |
|
147
|
4 |
|
public function getMode(): string |
|
148
|
|
|
{ |
|
149
|
4 |
|
return $this->mode; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* Returns a bool if the Mode is currently set to its default value (normal) or not |
|
154
|
|
|
* |
|
155
|
|
|
* @return bool |
|
156
|
|
|
*/ |
|
157
|
1 |
|
public function isDefaultMode(): bool |
|
158
|
|
|
{ |
|
159
|
1 |
|
return $this->mode === 'normal'; |
|
160
|
|
|
} |
|
161
|
|
|
} |
|
162
|
|
|
|