PluginProbe
AliNext – WooCommerce Dropshipping Plugin for AliExpress / trunk
AliNext – WooCommerce Dropshipping Plugin for AliExpress vtrunk
ali2woo-lite / includes / classes / object / ApiResponse.php

ApiResponse.php in AliNext – WooCommerce Dropshipping Plugin for AliExpress trunk, at includes/classes/object/ApiResponse.php

92 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Description of ExternalOrder
5 *
6 * @author Ali2Woo Team
7 */
8
9 namespace AliNext_Lite;;
10
11 class ApiResponse
12 {
13
14 public const STATE_OK = 'ok';
15 public const STATE_ERROR = 'error';
16
17 public const FIELD_MESSAGE = 'message';
18 public const FIELD_STATE = 'state';
19 public const FIELD_DATA = 'data';
20
21
22 private string $state;
23 private ?string $message;
24 private ?array $data;
25
26
27 public function getState(): string
28 {
29 return $this->state;
30 }
31
32 public function setState(string $state): self
33 {
34 $this->state = $state;
35
36 return $this;
37 }
38
39 public function isStateOk(): bool
40 {
41 return $this->state === self::STATE_OK;
42 }
43
44 public function setStateOk(): self
45 {
46 $this->state = self::STATE_OK;
47
48 return $this;
49 }
50
51 public function setStateError(string $message): self
52 {
53 $this->state = self::STATE_ERROR;
54 $this->message = $message;
55
56 return $this;
57 }
58
59 public function getMessage(): ?string
60 {
61 return $this->message;
62 }
63
64 public function setMessage(?string $message): self
65 {
66 $this->message = $message;
67
68 return $this;
69 }
70
71 public function getData(): ?array
72 {
73 return $this->data;
74 }
75
76 public function setData(?array $data): self
77 {
78 $this->data = $data;
79
80 return $this;
81 }
82
83 public function toArray(): array
84 {
85 return [
86 self::FIELD_MESSAGE => $this->message,
87 self::FIELD_STATE => $this->state,
88 self::FIELD_DATA => $this->data,
89 ];
90 }
91 }
92