Completed
Push — master ( e3ed33...61d114 )
by
unknown
04:23
created

PartnerClient::confirmPaymentForVenture()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 2

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 16
ccs 12
cts 12
cp 1
rs 9.4286
cc 2
eloc 11
nc 2
nop 2
crap 2
1
<?php
2
3
namespace Iris\Api;
4
5
class PartnerClient extends BaseClient
6
{
7
    /**
8
     * Partner Create Order on venture
9
     *
10
     * @param array $orderData
11
     * @param string $ventureCode
12
     * @return bool
13
     */
14 2
    public function createOrderOnVenture($orderData, $ventureCode)
15
    {
16
        try {
17 2
            $this->doRequest(
18 2
                'post',
19 2
                $this->buildRequestUrl('/fulfillment/order/create', $ventureCode),
20 2
                array('body' => json_encode($orderData))
21 2
            );
22 2
        } catch (\Exception $e) {
23 1
            $this->throwException(
24 1
                $e,
25 1
                'Unable to create order on venture',
26 1
                ['VentureCode' => $ventureCode, 'OrderData' => $orderData]
27 1
            );
28
        }
29 2
        return true;
30
    }
31
32
33
    /**
34
     * Partner Confirm Paid Order on venture
35
     *
36
     * @param string $ventureCode
37
     * @param int    $orderNr
38
     * @return bool
39
     */
40 2
    public function confirmPaymentOnVenture($ventureCode, $orderNr)
41
    {
42
        try {
43 2
            $this->doRequest(
44 2
                'put',
45 2
                $this->buildRequestUrl(sprintf('/fulfillment/order/confirm/%s', $orderNr), $ventureCode)
46 2
            );
47 2
        } catch (\Exception $e) {
48 1
            $this->throwException(
49 1
                $e,
50 1
                'Unable to confirm payment on venture',
51 1
                ['VentureCode' => $ventureCode, 'OrderNr' => $orderNr]
52 1
            );
53
        }
54 2
        return true;
55
    }
56
57
    /**
58
     * Partner Cancel Order on venture
59
     *
60
     * @param string $ventureCode
61
     * @param int    $orderNr
62
     * @return bool
63
     */
64 2
    public function cancelOrderOnVenture($ventureCode, $orderNr)
65
    {
66
        try {
67 2
            $this->doRequest(
68 2
                'put',
69 2
                $this->buildRequestUrl(sprintf('/fulfillment/order/cancel/%s', $orderNr), $ventureCode)
70 2
            );
71 2
        } catch (\Exception $e) {
72 1
            $this->throwException(
73 1
                $e,
74 1
                'Unable to cancel order on venture',
75 1
                ['VentureCode' => $ventureCode, 'OrderNr' => $orderNr]
76 1
            );
77
        }
78 2
        return true;
79
    }
80
81
    //products
82
    /**
83
     * Sends product creation status to venture
84
     *
85
     * @param array $productsData
86
     * @param string $ventureCode
87
     * @return void
88
     */
89 2
    public function sendProductCreationConfirmationToVenture(
90
        array $productsData,
91
        $ventureCode
92
    ) {
93
        try {
94 2
            $this->doRequest(
95 2
                'post',
96 2
                $this->buildRequestUrl('/products/create/confirm', $ventureCode),
97 2
                array('body' => json_encode($productsData))
98 2
            );
99 2
        } catch (\Exception $e) {
100 1
            $this->throwException(
101 1
                $e,
102 1
                'Unable to send product creation status to venture',
103 1
                ['VentureCode' => $ventureCode, 'ProductsData' => $productsData]
104 1
            );
105
        }
106 2
        return true;
107
    }
108
}
109