1 <?php
2
3 namespace PayPal\Api;
4
5 use PayPal\Common\PayPalResourceModel;
6 use PayPal\Rest\ApiContext;
7 use PayPal\Transport\PayPalRestCall;
8 use PayPal\Validation\ArgumentValidator;
9
10 /**
11 * Class WebProfile
12 *
13 * Payment web experience profile resource
14 *
15 * @package PayPal\Api
16 *
17 * @property string id
18 * @property string name
19 * @property bool temporary
20 * @property \PayPal\Api\FlowConfig flow_config
21 * @property \PayPal\Api\InputFields input_fields
22 * @property \PayPal\Api\Presentation presentation
23 */
24 class WebProfile extends PayPalResourceModel
25 {
26 /**
27 * The unique ID of the web experience profile.
28 *
29 * @param string $id
30 *
31 * @return $this
32 */
33 public function setId($id)
34 {
35 $this->id = $id;
36 return $this;
37 }
38
39 /**
40 * The unique ID of the web experience profile.
41 *
42 * @return string
43 */
44 public function getId()
45 {
46 return $this->id;
47 }
48
49 /**
50 * The web experience profile name. Unique for a specified merchant's profiles.
51 *
52 * @param string $name
53 *
54 * @return $this
55 */
56 public function setName($name)
57 {
58 $this->name = $name;
59 return $this;
60 }
61
62 /**
63 * The web experience profile name. Unique for a specified merchant's profiles.
64 *
65 * @return string
66 */
67 public function getName()
68 {
69 return $this->name;
70 }
71
72 /**
73 * Indicates whether the profile persists for three hours or permanently. Set to `false` to persist the profile permanently. Set to `true` to persist the profile for three hours.
74 *
75 * @param bool $temporary
76 *
77 * @return $this
78 */
79 public function setTemporary($temporary)
80 {
81 $this->temporary = $temporary;
82 return $this;
83 }
84
85 /**
86 * Indicates whether the profile persists for three hours or permanently. Set to `false` to persist the profile permanently. Set to `true` to persist the profile for three hours.
87 *
88 * @return bool
89 */
90 public function getTemporary()
91 {
92 return $this->temporary;
93 }
94
95 /**
96 * Parameters for flow configuration.
97 *
98 * @param \PayPal\Api\FlowConfig $flow_config
99 *
100 * @return $this
101 */
102 public function setFlowConfig($flow_config)
103 {
104 $this->flow_config = $flow_config;
105 return $this;
106 }
107
108 /**
109 * Parameters for flow configuration.
110 *
111 * @return \PayPal\Api\FlowConfig
112 */
113 public function getFlowConfig()
114 {
115 return $this->flow_config;
116 }
117
118 /**
119 * Parameters for input fields customization.
120 *
121 * @param \PayPal\Api\InputFields $input_fields
122 *
123 * @return $this
124 */
125 public function setInputFields($input_fields)
126 {
127 $this->input_fields = $input_fields;
128 return $this;
129 }
130
131 /**
132 * Parameters for input fields customization.
133 *
134 * @return \PayPal\Api\InputFields
135 */
136 public function getInputFields()
137 {
138 return $this->input_fields;
139 }
140
141 /**
142 * Parameters for style and presentation.
143 *
144 * @param \PayPal\Api\Presentation $presentation
145 *
146 * @return $this
147 */
148 public function setPresentation($presentation)
149 {
150 $this->presentation = $presentation;
151 return $this;
152 }
153
154 /**
155 * Parameters for style and presentation.
156 *
157 * @return \PayPal\Api\Presentation
158 */
159 public function getPresentation()
160 {
161 return $this->presentation;
162 }
163
164 /**
165 * Creates a web experience profile. Pass the profile name and details in the JSON request body.
166 *
167 * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
168 * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
169 * @return CreateProfileResponse
170 */
171 public function create($apiContext = null, $restCall = null)
172 {
173 $payLoad = $this->toJSON();
174 $json = self::executeCall(
175 "/v1/payment-experience/web-profiles/",
176 "POST",
177 $payLoad,
178 null,
179 $apiContext,
180 $restCall
181 );
182 $ret = new CreateProfileResponse();
183 $ret->fromJson($json);
184 return $ret;
185 }
186
187 /**
188 * Updates a web experience profile. Pass the ID of the profile to the request URI and pass the profile details in the JSON request body. If your request omits any profile detail fields, the operation removes the previously set values for those fields.
189 *
190 * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
191 * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
192 * @return bool
193 */
194 public function update($apiContext = null, $restCall = null)
195 {
196 ArgumentValidator::validate($this->getId(), "Id");
197 $payLoad = $this->toJSON();
198 self::executeCall(
199 "/v1/payment-experience/web-profiles/{$this->getId()}",
200 "PUT",
201 $payLoad,
202 null,
203 $apiContext,
204 $restCall
205 );
206 return true;
207 }
208
209 /**
210 * Partially-updates a web experience profile. Pass the profile ID to the request URI. Pass a patch object with the operation, path of the profile location to update, and, if needed, a new value to complete the operation in the JSON request body.
211 *
212 * @param Patch[] $patch
213 * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
214 * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
215 * @return bool
216 */
217 public function partial_update($patch, $apiContext = null, $restCall = null)
218 {
219 ArgumentValidator::validate($this->getId(), "Id");
220 ArgumentValidator::validate($patch, 'patch');
221 $payload = array();
222 foreach ($patch as $patchObject) {
223 $payload[] = $patchObject->toArray();
224 }
225 $payLoad = json_encode($payload);
226 self::executeCall(
227 "/v1/payment-experience/web-profiles/{$this->getId()}",
228 "PATCH",
229 $payLoad,
230 null,
231 $apiContext,
232 $restCall
233 );
234 return true;
235 }
236
237 /**
238 * Shows details for a web experience profile, by ID.
239 *
240 * @param string $profileId
241 * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
242 * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
243 * @return WebProfile
244 */
245 public static function get($profileId, $apiContext = null, $restCall = null)
246 {
247 ArgumentValidator::validate($profileId, 'profileId');
248 $payLoad = "";
249 $json = self::executeCall(
250 "/v1/payment-experience/web-profiles/$profileId",
251 "GET",
252 $payLoad,
253 null,
254 $apiContext,
255 $restCall
256 );
257 $ret = new WebProfile();
258 $ret->fromJson($json);
259 return $ret;
260 }
261
262 /**
263 * Lists all web experience profiles for a merchant or subject.
264 *
265 * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
266 * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
267 * @return WebProfile[]
268 */
269 public static function get_list($apiContext = null, $restCall = null)
270 {
271 $payLoad = "";
272 $json = self::executeCall(
273 "/v1/payment-experience/web-profiles/",
274 "GET",
275 $payLoad,
276 null,
277 $apiContext,
278 $restCall
279 );
280 return WebProfile::getList($json);
281 }
282
283 /**
284 * Deletes a web experience profile, by ID.
285 *
286 * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
287 * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
288 * @return bool
289 */
290 public function delete($apiContext = null, $restCall = null)
291 {
292 ArgumentValidator::validate($this->getId(), "Id");
293 $payLoad = "";
294 self::executeCall(
295 "/v1/payment-experience/web-profiles/{$this->getId()}",
296 "DELETE",
297 $payLoad,
298 null,
299 $apiContext,
300 $restCall
301 );
302 return true;
303 }
304
305 }
306