AbstractNetgsmIys::send()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 11
c 1
b 0
f 1
dl 0
loc 19
rs 9.9
cc 1
nc 1
nop 0
1
<?php
2
3
namespace TarfinLabs\Netgsm\Iys;
4
5
use TarfinLabs\Netgsm\NetgsmApiClient;
6
7
abstract class AbstractNetgsmIys extends NetgsmApiClient
8
{
9
    protected string $url = '';
10
11
    protected string $method = 'GET';
12
13
    protected array $body = [];
14
15
    /**
16
     * Send request.
17
     *
18
     * @return string
19
     */
20
    public function send(): string
21
    {
22
        $response = $this->client->request($this->method, $this->url, [
23
            'headers'       => [
24
                'Content-Type'  => 'application/json',
25
            ],
26
            'json' => [
27
                'header'    => [
28
                    'username'  => $this->credentials['user_code'],
29
                    'password'  => $this->credentials['secret'],
30
                    'brandCode' => $this->credentials['brand_code'],
31
                ],
32
                'body'      => [
33
                    'data'      => $this->body,
34
                ],
35
            ],
36
        ]);
37
38
        return $response->getBody()->getContents();
39
    }
40
}
41