Completed
Pull Request — master (#7)
by Rafael
09:00
created

PartnerClient::partnerConfirmPaymentForVenture()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
ccs 0
cts 0
cp 0
rs 9.4286
cc 2
eloc 8
nc 2
nop 2
crap 6
1
<?php
2
3
namespace Iris\Api;
4
5
class PartnerClient extends BaseClient
6
{
7
    /**
8
     * Partner Create Order on External Shop
9
     *
10
     * @param string $ventureCode
11
     * @param array $orderData
12
     * @return bool
13
     */
14 2
    public function createOrderOnVenture($ventureCode, $orderData)
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 Externalshop',
26 1
                ['VentureCode' => $ventureCode, 'OrderData' => $orderData]
27 1
            );
28
        }
29 2
        return true;
30
    }
31
32
33
    /**
34
     * Partner Confirm Paid Order on External Shop
35
     *
36
     * @param string $ventureCode
37
     * @param int    $orderNr
38
     * @return bool
39 2
     */
40
    public function confirmPaymentOnVenture($ventureCode, $orderNr)
41
    {
42 2
        try {
43 2
            $this->doRequest(
44 2
                'put',
45 2
                $this->buildRequestUrl(sprintf('/fulfillment/order/confirm/%s', $orderNr), $ventureCode)
46 2
            );
47 1
        } catch (\Exception $e) {
48 1
            $this->throwException(
49 1
                $e,
50 1
                'Unable to confirm payment for venture on Externalshop',
51 1
                ['VentureCode' => $ventureCode, 'OrderNr' => $orderNr]
52
            );
53 2
        }
54
        return true;
55
    }
56
57
    /**
58
     * Partner Cancel Order on External Shop
59
     *
60
     * @param string $ventureCode
61
     * @param int    $orderNr
62
     * @return bool
63 2
     */
64
    public function cancelOrderOnVenture($ventureCode, $orderNr)
65
    {
66 2
        try {
67 2
            $this->doRequest(
68 2
                'put',
69 2
                $this->buildRequestUrl(sprintf('/fulfillment/order/cancel/%s', $orderNr), $ventureCode)
70 2
            );
71 1
        } catch (\Exception $e) {
72 1
            $this->throwException(
73 1
                $e,
74 1
                'Unable to cancel order on Externalshop',
75 1
                ['VentureCode' => $ventureCode, 'OrderNr' => $orderNr]
76
            );
77 2
        }
78
        return true;
79
    }
80
81
    /**
82
     * Partner Confirm Paid Order on External Shop
83
     * @param string $ventureCode
84
     * @param int $orderNr
85
     * @return bool
86
     */
87
    public function partnerConfirmPaymentForVenture($ventureCode, $orderNr)
88
    {
89
        try {
90
            $this->doRequest(
91
                'put',
92
                $this->buildRequestUrl(sprintf('/fulfillment/order/confirm/%s', $orderNr), $ventureCode)
93
            );
94
        } catch (RequestException $e) {
0 ignored issues
show
Bug introduced by
The class Iris\Api\RequestException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
95
            $this->throwException($e);
0 ignored issues
show
Bug introduced by
The call to throwException() misses a required argument $message.

This check looks for function calls that miss required arguments.

Loading history...
96
        }
97
        return true;
98
    }
99
100
    /**
101
     * Partner Cancel Order on External Shop
102
     * @param string $ventureCode
103
     * @param int $orderNr
104
     * @return bool
105
     */
106
    public function partnerCancelOrderOnVenture($ventureCode, $orderNr)
107
    {
108
        try {
109
            $this->doRequest(
110
                'put',
111
                $this->buildRequestUrl(sprintf('/fulfillment/order/cancel/%s', $orderNr), $ventureCode)
112
            );
113
        } catch (RequestException $e) {
0 ignored issues
show
Bug introduced by
The class Iris\Api\RequestException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
114
            $this->throwException($e);
0 ignored issues
show
Bug introduced by
The call to throwException() misses a required argument $message.

This check looks for function calls that miss required arguments.

Loading history...
115
        }
116
        return true;
117
    }
118
119
    //products
120
121
    /**
122
     * Sends product creation status to venture
123
     *
124
     * @param array $productsData
125
     * @param string $venture
0 ignored issues
show
Documentation introduced by
There is no parameter named $venture. Did you maybe mean $ventureCode?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

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

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

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

Loading history...
126
     * @return void
127
     */
128
    public function sendProductCreationConfirmationToVenture(
129
        array $productsData,
130
        $ventureCode
131
    ) {
132
133
        try {
134
            $this->doRequest(
135
                'post',
136
                $this->buildRequestUrl('/products/create/confirm', $ventureCode),
137
                array('body' => json_encode($productsData))
138
            );
139
        } catch (\Exception $e) {
140
            $this->throwException(
141
                $e,
142
                'Unable to send product creation status to venture',
143
                ['VentureCode' => $ventureCode, 'ConfigData' => $productsData]
144
            );
145
        }
146
        return true;
147
    }
148
}
149