Passed
Push — master ( 28b0ab...accbfe )
by Andrey
03:54
created

Counterparty::getCounterpartyAddresses()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 8
rs 10
1
<?php
2
3
namespace Daaner\NovaPoshta\Models;
4
5
use Daaner\NovaPoshta\NovaPoshta;
6
use Daaner\NovaPoshta\Traits\CounterpartyProperty;
7
use Daaner\NovaPoshta\Traits\Limit;
8
9
class Counterparty extends NovaPoshta
10
{
11
    use Limit, CounterpartyProperty;
12
13
    protected $model = 'Counterparty';
14
    protected $calledMethod;
15
    protected $methodProperties = [];
16
17
    public function getCounterparties($find = null)
18
    {
19
        $this->calledMethod = 'getCounterparties';
20
        $this->getPage();
21
        $this->addLimit();
22
23
        $this->getCounterpartyProperty();
24
25
        if ($find) {
26
            $this->methodProperties['FindByString'] = $find;
27
        }
28
29
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties);
30
    }
31
32
    public function getCounterpartyContactPerson($ref)
33
    {
34
        $this->calledMethod = 'getCounterpartyContactPersons';
35
        $this->getPage();
36
        $this->addLimit();
37
38
        $this->methodProperties['Ref'] = $ref;
39
40
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties);
41
    }
42
43
    public function save($firstName, $lastName = null, $middleName = null, $phone = null, $email = null)
44
    {
45
        $this->calledMethod = 'save';
46
        $this->getCounterpartyType();
47
        $this->getCounterpartyProperty();
48
        $this->getOwnershipForm();
49
        $this->getEDRPOU();
50
51
        if ($this->counterpartyProperty !== 'ThirdPerson') {
52
          $this->methodProperties['FirstName'] = $firstName;
53
        }
54
55
        if ($lastName) {
56
          $this->methodProperties['LastName'] = $lastName;
57
        }
58
        if ($middleName) {
59
          $this->methodProperties['MiddleName'] = $middleName;
60
        }
61
        if ($phone) {
62
          $this->methodProperties['Phone'] = $phone;
63
        }
64
        if ($email) {
65
          $this->methodProperties['Email'] = $email;
66
        }
67
68
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties);
69
    }
70
71
72
    public function getCounterpartyOptions($ref)
73
    {
74
        $this->calledMethod = 'getCounterpartyOptions';
75
76
        $this->methodProperties['Ref'] = $ref;
77
78
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties);
79
    }
80
81
82
    public function getCounterpartyAddresses($ref)
83
    {
84
        $this->calledMethod = 'getCounterpartyAddresses';
85
        $this->getCounterpartyProperty();
86
87
        $this->methodProperties['Ref'] = $ref;
88
89
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties);
90
    }
91
92
}
93