Completed
Push — master ( c0438a...d84f32 )
by Mauro
02:27
created

MercadoLibreClient::showUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/*
3
 * This file is part of the Mercado Libre API client package.
4
 *
5
 * (c) Mauro Moreno <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Zephia\MercadoLibre\Client;
12
13
use GuzzleHttp\Client as GuzzleClient;
14
15
/**
16
 * Class MercadoLibreClient
17
 *
18
 * @package Zephia\MercadoLibre\Client
19
 * @author  Mauro Moreno <[email protected]>
20
 */
21
class MercadoLibreClient
22
{
23
    // Mercado Libre API URI.
24
    const BASE_URI = 'https://api.mercadolibre.com';
25
26
    /**
27
     * Guzzle Client
28
     *
29
     * @var GuzzleClient
30
     */
31
    private $guzzleClient;
32
33
    /**
34
     * MercadoLibreClient constructor.
35
     *
36
     * @param array $config
37
     */
38 4
    public function __construct(array $config = [])
39
    {
40 4
        $defaults = ['base_uri' => self::BASE_URI];
41
42 4
        $config = array_merge($defaults, $config);
43
44 4
        $this->guzzleClient = new GuzzleClient($config);
45 4
    }
46
47
    /**
48
     * Get Guzzle client
49
     *
50
     * @return GuzzleClient
51
     */
52 4
    public function getGuzzleClient()
53
    {
54 4
        return $this->guzzleClient;
55
    }
56
57
    /**
58
     * Show User resource
59
     *
60
     * @param $customer_id
61
     *
62
     * @return \Psr\Http\Message\ResponseInterface
63
     */
64 3
    public function showUser($customer_id)
65 1
    {
66 3
        return $this->getGuzzleClient()->get('/users/' . $customer_id);
67
    }
68
}
69