Add::setType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 2
c 1
b 0
f 1
dl 0
loc 5
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace TarfinLabs\Netgsm\Iys\Requests;
4
5
class Add
6
{
7
    protected string $url = 'iys/add';
8
9
    protected string $refId;
10
11
    protected string $type;
12
13
    protected string $source;
14
15
    protected string $recipient;
16
17
    protected string $status;
18
19
    protected string $consentDate;
20
21
    protected string $recipientType;
22
23
    protected ?int $retailerCode;
24
25
    protected ?int $retailerAccess;
26
27
    /**
28
     * @param string $refId
29
     * @return $this
30
     */
31
    public function setRefId(string $refId): self
32
    {
33
        $this->refId = $refId;
34
35
        return $this;
36
    }
37
38
    /**
39
     * @param string $type
40
     * @return $this
41
     */
42
    public function setType(string $type): self
43
    {
44
        $this->type = $type;
45
46
        return $this;
47
    }
48
49
    /**
50
     * @param string $source
51
     * @return $this
52
     */
53
    public function setSource(string $source): self
54
    {
55
        $this->source = $source;
56
57
        return $this;
58
    }
59
60
    /**
61
     * @param string $recipient
62
     * @return $this
63
     */
64
    public function setRecipient(string $recipient): self
65
    {
66
        $this->recipient = $recipient;
67
68
        return $this;
69
    }
70
71
    /**
72
     * @param string $status
73
     * @return $this
74
     */
75
    public function setStatus(string $status): self
76
    {
77
        $this->status = $status;
78
79
        return $this;
80
    }
81
82
    /**
83
     * @param string $consentDate
84
     * @return $this
85
     */
86
    public function setConsentDate(string $consentDate): self
87
    {
88
        $this->consentDate = $consentDate;
89
90
        return $this;
91
    }
92
93
    /**
94
     * @param string $recipientType
95
     * @return $this
96
     */
97
    public function setRecipientType(string $recipientType): self
98
    {
99
        $this->recipientType = $recipientType;
100
101
        return $this;
102
    }
103
104
    /**
105
     * @param int|null $retailerCode
106
     * @return $this
107
     */
108
    public function setRetailerCode(?int $retailerCode): self
109
    {
110
        $this->retailerCode = $retailerCode;
111
112
        return $this;
113
    }
114
115
    /**
116
     * @param int|null $retailerAccess
117
     * @return $this
118
     */
119
    public function setRetailerAccess(?int $retailerAccess): self
120
    {
121
        $this->retailerAccess = $retailerAccess;
122
123
        return $this;
124
    }
125
126
    /**
127
     * @param array $defaults
128
     * @return $this
129
     */
130
    public function setDefaults(array $defaults): self
131
    {
132
        foreach ($defaults as $key => $value) {
133
            if (method_exists($this, 'set'.ucfirst($key))) {
134
                call_user_func([$this, 'set'.ucfirst($key)], $value);
135
            }
136
        }
137
138
        return $this;
139
    }
140
141
    /**
142
     * Get request body.
143
     *
144
     * @return array
145
     */
146
    public function body(): array
147
    {
148
        return [
149
            'refid'             => $this->refId ?? null,
150
            'type'              => $this->type ?? null,
151
            'source'            => $this->source ?? null,
152
            'recipient'         => $this->recipient ?? null,
153
            'status'            => $this->status ?? null,
154
            'consentDate'       => $this->consentDate ?? null,
155
            'recipientType'     => $this->recipientType ?? null,
156
            'retailerCode'      => $this->retailerCode ?? null,
157
            'retailerAccess'    => $this->retailerAccess ?? null,
158
        ];
159
    }
160
161
    /**
162
     * Get request url.
163
     *
164
     * @return string
165
     */
166
    public function getUrl(): string
167
    {
168
        return $this->url;
169
    }
170
}
171