client.php 474 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php

namespace local_asystgrade\api;

defined('MOODLE_INTERNAL') || die();

class client {
    private $endpoint;
    private $httpClient;

    public function __construct(string $endpoint, http_client $httpClient = null) {
        $this->endpoint = $endpoint;
        $this->httpClient = $httpClient ?: new http_client();
    }

    public function send_data($data) {
        $response = $this->httpClient->post($this->endpoint, $data);

        return $response;
    }
}