Biller   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 11
c 1
b 0
f 0
dl 0
loc 44
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A productAmount() 0 5 1
A products() 0 5 1
A updateOrder() 0 6 1
1
<?php
2
3
namespace Digikraaft\Flutterwave;
4
5
class Biller extends ApiResource
6
{
7
    const OBJECT_NAME = 'billers';
8
9
    use ApiOperations\All;
10
    use ApiOperations\Create;
11
12
    /**
13
     * @param string $billerCode
14
     * @return array|object
15
     * @link https://developer.flutterwave.com/reference#get-products-under-a-agency
16
     */
17
    public static function products(string $billerCode)
18
    {
19
        $url = static::endPointUrl("{$billerCode}/products");
20
21
        return static::staticRequest('GET', $url);
22
    }
23
24
    /**
25
     * @param string $billerCode
26
     * @param string $productCode
27
     * @return array|object
28
     * @link https://developer.flutterwave.com/reference#get-amount-to-be-paid-for-a-product
29
     */
30
    public static function productAmount(string $billerCode, string $productCode)
31
    {
32
        $url = static::endPointUrl("{$billerCode}/products/{$productCode}/orders");
33
34
        return static::staticRequest('GET', $url);
35
    }
36
37
    /**
38
     * @param string $orderId
39
     * @param array $params
40
     * @return array|object
41
     * @link https://developer.flutterwave.com/reference#get-amount-to-be-paid-for-a-product
42
     */
43
    public static function updateOrder(string $orderId, array $params)
44
    {
45
        static::validateParams($params, true);
46
        $url = urlencode("product-orders/{$orderId}");
47
48
        return static::staticRequest('PUT', $url, $params);
49
    }
50
}
51