-
Notifications
You must be signed in to change notification settings - Fork 192
/
Copy pathProfileMethodEndpoint.php
129 lines (114 loc) · 3.49 KB
/
ProfileMethodEndpoint.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
namespace Mollie\Api\Endpoints;
use Mollie\Api\Resources\Method;
use Mollie\Api\Resources\MethodCollection;
use Mollie\Api\Resources\Profile;
use Mollie\Api\Resources\ResourceFactory;
class ProfileMethodEndpoint extends CollectionEndpointAbstract
{
protected $resourcePath = "profiles_methods";
/**
* Get the object that is used by this API endpoint. Every API endpoint uses one type of object.
*
* @return Method
*/
protected function getResourceObject()
{
return new Method($this->client);
}
/**
* Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
*
* @param int $count
* @param \stdClass $_links
*
* @return MethodCollection()
*/
protected function getResourceCollectionObject($count, $_links)
{
return new MethodCollection($count, $_links);
}
/**
* Enable a method for the provided Profile ID.
*
* @param string $profileId
* @param string $methodId
* @param array $data
* @return \Mollie\Api\Resources\Method
* @throws \Mollie\Api\Exceptions\ApiException
*/
public function createForId($profileId, $methodId, array $data = [])
{
$this->parentId = $profileId;
$resource = $this->getResourcePath() . '/' . urlencode($methodId);
$body = null;
if (count($data) > 0) {
$body = json_encode($data);
}
$result = $this->client->performHttpCall(self::REST_CREATE, $resource, $body);
return ResourceFactory::createFromApiResult($result, new Method($this->client));
}
/**
* Enable a method for the provided Profile object.
*
* @param Profile $profile
* @param string $methodId
* @param array $data
* @return Method
* @throws \Mollie\Api\Exceptions\ApiException
*/
public function createFor($profile, $methodId, array $data = [])
{
return $this->createForId($profile->id, $methodId, $data);
}
/**
* Enable a method for the current profile.
*
* @param string $methodId
* @param array $data
* @return \Mollie\Api\Resources\Method
* @throws \Mollie\Api\Exceptions\ApiException
*/
public function createForCurrentProfile($methodId, array $data = [])
{
return $this->createForId('me', $methodId, $data);
}
/**
* Disable a method for the provided Profile ID.
*
* @param string $profileId
* @param string $methodId
* @param array $data
* @return mixed
* @throws \Mollie\Api\Exceptions\ApiException
*/
public function deleteForId($profileId, $methodId, array $data = [])
{
$this->parentId = $profileId;
return $this->rest_delete($methodId, $data);
}
/**
* Disable a method for the provided Profile object.
*
* @param Profile $profile
* @param string $methodId
* @param array $data
* @throws \Mollie\Api\Exceptions\ApiException
*/
public function deleteFor($profile, $methodId, array $data = [])
{
return $this->deleteForId($profile->id, $methodId, $data);
}
/**
* Disable a method for the current profile.
*
* @param string $methodId
* @param array $data
* @return \Mollie\Api\Resources\Method
* @throws \Mollie\Api\Exceptions\ApiException
*/
public function deleteForCurrentProfile($methodId, array $data)
{
return $this->deleteForId('me', $methodId, $data);
}
}