Customer::invite()   A
last analyzed

Complexity

Conditions 2
Paths 3

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.568
c 0
b 0
f 0
cc 2
nc 3
nop 2
1
<?php
2
namespace CultureKings\Afterpay\Service\InStore;
3
4
use CultureKings\Afterpay\Exception\ApiException;
5
use CultureKings\Afterpay\Model\ErrorResponse;
6
use CultureKings\Afterpay\Model;
7
use GuzzleHttp\Exception\BadResponseException;
8
use GuzzleHttp\HandlerStack;
9
10
/**
11
 * Class Customer
12
 * @package CultureKings\Afterpay\Service\InStore
13
 */
14
class Customer extends AbstractService
15
{
16
    /**
17
     * @param Model\InStore\Invite $invite
18
     * @param HandlerStack|null    $stack
19
     *
20
     * @return bool
21
     */
22
    public function invite(Model\InStore\Invite $invite, HandlerStack $stack = null)
23
    {
24
        try {
25
            $params = $this->generateParams($invite, $stack);
26
27
            $this->getClient()->post(
28
                'invite',
29
                $params
30
            );
31
        } catch (BadResponseException $e) {
32
            throw new ApiException(
33
                $this->getSerializer()->deserialize(
34
                    (string) $e->getResponse()->getBody(),
35
                    ErrorResponse::class,
36
                    'json'
37
                ),
38
                $e
39
            );
40
        }
41
42
        return true;
43
    }
44
}
45