Completed
Branch master (2e0c76)
by Vincent
02:08 queued 14s
created

Request::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
1
<?php
2
/**
3
 * BongaTech SMS Client Library for PHP.
4
 *
5
 * @copyright Copyright (c) 2017
6
 * @author   Vincent Mosoti <[email protected]>
7
 * @license https://github.com/VMosoti/bongatech-sms/blob/master/LICENSE
8
 */
9
10
namespace VMosoti\BongaTech;
11
12
use Unirest\Request\Body;
13
use Unirest\Request as UniRequest;
14
15
class Request
16
{
17
    /**
18
     * the request url.
19
     *
20
     * @var string
21
     */
22
    public $endpoint;
23
    /**
24
     * request headers.
25
     *
26
     * @var array
27
     */
28
    public $headers;
29
30
    /**
31
     * request body.
32
     *
33
     * @var array
34
     */
35
    public $body;
36
37
    /**
38
     * the response is in form of a string.
39
     *
40
     * @var array
41
     */
42
    public $response;
43
44
    /**
45
     * Request constructor.
46
     *
47
     * @param  $endpoint
48
     * @param array $headers
49
     * @param array $body
50
     */
51
    public function __construct($endpoint, array $headers, array $body)
52
    {
53
        $this->endpoint = $endpoint;
54
        $this->headers = $headers;
55
        $this->body = $body;
56
    }
57
58
    public function send()
59
    {
60
        return UniRequest::post($this->endpoint, $this->headers, Body::Json($this->body));
61
    }
62
63
64
}
65