Split::fetch()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Iamolayemi\Paystack\Endpoints;
4
5
class Split extends Endpoint
6
{
7
    public const ENDPOINT = '/split';
8
9
    /**
10
     * Create a split payment on your integration
11
     *
12
     * @param  array<string, mixed>  $payload
13
     *
14
     * @link https://paystack.com/docs/api/#split-create
15
     */
16
    public function create(array $payload): self
17
    {
18
        $this->post($this->url(self::ENDPOINT), $payload);
19
20
        return $this;
21
    }
22
23
    /**
24
     * List/search for the transaction splits available on your integration.
25
     *
26
     * @param  array<string, mixed>  $query
27
     *
28
     * @link https://paystack.com/docs/api/#split-list
29
     */
30
    public function list(array $query = []): self
31
    {
32
        $this->get($this->url(self::ENDPOINT), $query);
33
34
        return $this;
35
    }
36
37
    /**
38
     * Get details of a split on your integration.
39
     *
40
     * @link https://paystack.com/docs/api/#split-fetch
41
     */
42
    public function fetch(string $split_id): self
43
    {
44
        $this->get($this->url(self::ENDPOINT).'/'.$split_id);
45
46
        return $this;
47
    }
48
49
    /**
50
     * Update a transaction split details on your integration.
51
     *
52
     * @param  array<string, mixed>  $payload
53
     *
54
     * @link https://paystack.com/docs/api/#split-update
55
     */
56
    public function update(string $split_id, array $payload = []): self
57
    {
58
        $this->put($this->url(self::ENDPOINT).'/'.$split_id, $payload);
59
60
        return $this;
61
    }
62
63
    /**
64
     * Add a Subaccount to a Transaction Split,
65
     * or update the share of an existing Subaccount in a Transaction Split
66
     *
67
     * @param  array<string, mixed>  $payload
68
     *
69
     * @link https://paystack.com/docs/api/#split-add-subaccount
70
     */
71
    public function addSubaccount(string $split_id, array $payload = []): self
72
    {
73
        $this->post($this->url(self::ENDPOINT).'/'.$split_id.'/subaccount/add', $payload);
74
75
        return $this;
76
    }
77
78
    /**
79
     * Remove a subaccount from a transaction split.
80
     *
81
     * @param  array<string, mixed>  $payload
82
     *
83
     * @link https://paystack.com/docs/api/#split-remove-subaccount
84
     */
85
    public function removeSubaccount(string $split_id, array $payload = []): self
86
    {
87
        $this->post($this->url(self::ENDPOINT).'/'.$split_id.'/subaccount/remove', $payload);
88
89
        return $this;
90
    }
91
}
92