Passed
Push — v2.0 ( d916ef...282229 )
by Raza
02:10
created

DisputesActions   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A acceptDisputeClaim() 0 13 1
A acceptDisputeOfferResolution() 0 12 1
A acknowledgeItemReturned() 0 13 1
1
<?php
2
3
namespace Srmklive\PayPal\Traits\PayPalAPI;
4
5
trait DisputesActions
6
{
7
    /**
8
     * Accept customer dispute claim.
9
     *
10
     * @param string $dispute_id
11
     * @param string $dispute_note
12
     * @param array $data
13
     *
14
     * @throws \Throwable
15
     *
16
     * @return array|\Psr\Http\Message\StreamInterface|string
17
     *
18
     * @see https://developer.paypal.com/docs/api/customer-disputes/v1/#disputes-actions_accept-claim
19
     */
20
    public function acceptDisputeClaim($dispute_id, $dispute_note, array $data = [])
21
    {
22
        $this->apiEndPoint = "v1/customer/disputes/{$dispute_id}/accept-claim";
1 ignored issue
show
Bug Best Practice introduced by
The property apiEndPoint does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
23
        $this->apiUrl = collect([$this->apiUrl, $this->apiEndPoint])->implode('/');
1 ignored issue
show
Bug Best Practice introduced by
The property apiUrl does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
24
25
        $data["note"] = $dispute_note;
26
        $data["accept_claim_type"] = "REFUND";
27
28
        $this->options['json'] = $data;
1 ignored issue
show
Bug Best Practice introduced by
The property options does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
29
30
        $this->verb = 'post';
1 ignored issue
show
Bug Best Practice introduced by
The property verb does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
31
32
        return $this->doPayPalRequest();
1 ignored issue
show
Bug introduced by
It seems like doPayPalRequest() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
        return $this->/** @scrutinizer ignore-call */ doPayPalRequest();
Loading history...
33
    }
34
35
    /**
36
     * Accept offer to resolve dispute.
37
     *
38
     * @param string $dispute_id
39
     * @param string $dispute_note
40
     *
41
     * @throws \Throwable
42
     *
43
     * @return array|\Psr\Http\Message\StreamInterface|string
44
     *
45
     * @see https://developer.paypal.com/docs/api/customer-disputes/v1/#disputes-actions_accept-offer
46
     */
47
    public function acceptDisputeOfferResolution($dispute_id, $dispute_note)
48
    {
49
        $this->apiEndPoint = "v1/customer/disputes/{$dispute_id}/accept-offer";
1 ignored issue
show
Bug Best Practice introduced by
The property apiEndPoint does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
50
        $this->apiUrl = collect([$this->apiUrl, $this->apiEndPoint])->implode('/');
1 ignored issue
show
Bug Best Practice introduced by
The property apiUrl does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
51
52
        $this->options['json'] = [
1 ignored issue
show
Bug Best Practice introduced by
The property options does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
53
            "note"  => $dispute_note,
54
        ];
55
56
        $this->verb = 'post';
1 ignored issue
show
Bug Best Practice introduced by
The property verb does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
57
58
        return $this->doPayPalRequest();
59
    }
60
61
    /**
62
     * Acknowledge item has been returned.
63
     *
64
     * @param string $dispute_id
65
     * @param string $dispute_note
66
     * @param string $acknowledgement_type
67
     *
68
     * @throws \Throwable
69
     *
70
     * @return array|\Psr\Http\Message\StreamInterface|string
71
     *
72
     * @see https://developer.paypal.com/docs/api/customer-disputes/v1/#disputes-actions_acknowledge-return-item
73
     */
74
    public function acknowledgeItemReturned($dispute_id, $dispute_note, $acknowledgement_type)
75
    {
76
        $this->apiEndPoint = "v1/customer/disputes/{$dispute_id}/acknowledge-return-item";
1 ignored issue
show
Bug Best Practice introduced by
The property apiEndPoint does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
77
        $this->apiUrl = collect([$this->apiUrl, $this->apiEndPoint])->implode('/');
1 ignored issue
show
Bug Best Practice introduced by
The property apiUrl does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
78
79
        $this->options['json'] = [
1 ignored issue
show
Bug Best Practice introduced by
The property options does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
80
            "note"                  => $dispute_note,
81
            "acknowledgement_type"  => $acknowledgement_type
82
        ];
83
84
        $this->verb = 'post';
1 ignored issue
show
Bug Best Practice introduced by
The property verb does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
85
86
        return $this->doPayPalRequest();
87
    }
88
}
89