Completed
Push — master ( b7f3f7...84b41c )
by Mads
01:18
created

ContractTier::deleteContractTier()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Fenerum\API;
6
7
class ContractTier extends Base
8
{
9
    /**
10
     * @param string $accountCode
11
     * @param string $contract
12
     * @return array|null
13
     * @throws \GuzzleHttp\Exception\GuzzleException
14
     */
15
    public function listContractTiers(string $accountCode, string $contract): ?array
16
    {
17
        return $this->client->get('accounts/'.$accountCode.'/contracts/'.$contract.'/tiers/');
18
    }
19
20
    /**
21
     * @param string $accountCode
22
     * @param string $contract
23
     * @param string $id
24
     * @return array|null
25
     * @throws \GuzzleHttp\Exception\GuzzleException
26
     */
27
    public function getContract(string $accountCode, string $contract, string $id): ?array
28
    {
29
        return $this->client->get('accounts/'.$accountCode.'/contracts/'.$contract.'/tiers/'.$id.'/');
30
    }
31
32
    /**
33
     * @param array $data
34
     * @param string $accountCode
35
     * @param string $contract
36
     * @return array|null
37
     * @throws \GuzzleHttp\Exception\GuzzleException
38
     * @throws \Illuminate\Validation\ValidationException
39
     */
40
    public function createContractTier(array $data, string $accountCode, string $contract): ?array
41
    {
42
        $this->validate($data, [
43
            'minimum_quantity' => 'required|integer',
44
            'maximum_quantity' => 'integer',
45
            'discount' => 'string',
46
            'discount_type' => 'required|string',
47
            'overall_flat_discount' => 'string',
48
            'only_apply_to_quantity_above_minimal' => 'boolean',
49
        ]);
50
51
        return $this->client->post('accounts/'.$accountCode.'/contracts/'.$contract.'/tiers/', $data);
52
    }
53
54
    /**
55
     * @param array $data
56
     * @param string $accountCode
57
     * @param string $contract
58
     * @param string $id
59
     * @return array|null
60
     * @throws \GuzzleHttp\Exception\GuzzleException
61
     * @throws \Illuminate\Validation\ValidationException
62
     */
63
    public function updateContractTier(array $data, string $accountCode, string $contract, string $id): ?array
64
    {
65
        $this->validate($data, [
66
            'minimum_quantity' => 'required|integer',
67
            'maximum_quantity' => 'integer',
68
            'discount' => 'string',
69
            'discount_type' => 'required|string',
70
            'overall_flat_discount' => 'string',
71
            'only_apply_to_quantity_above_minimal' => 'boolean',
72
        ]);
73
74
        return $this->client->put('accounts/'.$accountCode.'/contracts/'.$contract.'/tiers/'.$id.'/', $data);
75
    }
76
77
    /**
78
     * @param string $accountCode
79
     * @param string $uuid
0 ignored issues
show
Bug introduced by
There is no parameter named $uuid. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
80
     * @return array|null
81
     * @throws \GuzzleHttp\Exception\GuzzleException
82
     */
83
    public function deleteContractTier(string $accountCode, string $contract, string $id): ?array
84
    {
85
        return $this->client->delete('accounts/'.$accountCode.'/contracts/'.$contract.'/tiers/'.$id.'/');
86
    }
87
}
88