Passed
Push — master ( 45dbb4...99f77d )
by Raza
01:40
created

BillingPortal::customer_enable_billing_portal()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 8
rs 10
1
<?php
2
3
namespace Srmklive\Chargify\Traits\ChargifyAPI;
4
5
trait BillingPortal
6
{
7
    /**
8
     * Get billing portal details for a customer.
9
     *
10
     * @param int $customer_id
11
     *
12
     * @return array
13
     */
14
    public function customer_billing_portal_details($customer_id): array
15
    {
16
        $this->apiEndPoint = "/portal/customers/{$customer_id}/management_link.json";
17
18
        $this->verb = 'get';
19
20
        return $this->doChargifyRequest();
0 ignored issues
show
Bug introduced by
It seems like doChargifyRequest() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
        return $this->/** @scrutinizer ignore-call */ doChargifyRequest();
Loading history...
21
    }
22
23
    /**
24
     * Enable billing portal for a customer.
25
     *
26
     * @param int  $customer_id
27
     * @param bool $auto_invite
28
     *
29
     * @return string
30
     */
31
    public function customer_enable_billing_portal($customer_id, $auto_invite=false): string
32
    {
33
        $invite_param = ($auto_invite === true) ? '?auto_invite=1' : '';
34
        $this->apiEndPoint = "/portal/customers/{$customer_id}/enable.json{$invite_param}";
35
36
        $this->verb = 'post';
37
38
        return $this->doChargifyRequest(false);
39
    }
40
41
    /**
42
     * Revoke billing portal invitation for a customer.
43
     *
44
     * @param int  $customer_id
45
     *
46
     * @return array
47
     */
48
    public function customer_revoke_billing_portal($customer_id): array
49
    {
50
        $this->apiEndPoint = "/portal/customers/{$customer_id}/invitations/revoke.json";
51
52
        $this->verb = 'delete';
53
54
        return $this->doChargifyRequest();
55
    }
56
}
57