1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Wabel\CertainAPI; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* CertainApiService |
7
|
|
|
*/ |
8
|
|
|
class CertainApiService{ |
9
|
|
|
/** |
10
|
|
|
* An instance of the CertainApiClient |
11
|
|
|
* @var CertainApiClient |
12
|
|
|
*/ |
13
|
|
|
private $certainClient; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Service constructor |
17
|
|
|
* @param CertainApiClient $certainClient |
18
|
|
|
*/ |
19
|
|
|
public function __construct(CertainApiClient $certainClient) |
20
|
|
|
{ |
21
|
|
|
$this->setCertainClient($certainClient); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function setCertainClient(CertainApiClient $certainClient) |
25
|
|
|
{ |
26
|
|
|
$this->certainClient = $certainClient; |
27
|
|
|
return $this; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Get Account Code |
32
|
|
|
* @return string |
33
|
|
|
*/ |
34
|
|
|
public function getAccountCode() |
35
|
|
|
{ |
36
|
|
|
return $this->getCertainClient()->getAccountCode(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Get the certain api client |
41
|
|
|
* @return CertainApiClient |
42
|
|
|
*/ |
43
|
|
|
public function getCertainClient(){ |
44
|
|
|
return $this->certainClient; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Send a "GET" request to get information about ressource; |
49
|
|
|
* @param string $ressourceName |
50
|
|
|
* @param string $ressourcePath |
51
|
|
|
* @param string $ressourceId |
52
|
|
|
* @param array $params |
53
|
|
|
* @param boolean $assoc |
54
|
|
|
* @param string $contentType |
55
|
|
|
* @return array |
56
|
|
|
*/ |
57
|
|
|
public function get($ressourceName, $ressourcePath =null, $ressourceId=null, $params = array(),$assoc = false,$contentType='json'){ |
58
|
|
|
return $this->getCertainClient()->get($ressourceName, $ressourcePath, $ressourceId, $params, $assoc,$contentType); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Send a "POST" request to put information to certain; |
63
|
|
|
* @param string $ressourceName |
64
|
|
|
* @param string $ressourcePath |
65
|
|
|
* @param string $ressourceId |
66
|
|
|
* @param array $bodyData |
67
|
|
|
* @param array $query |
68
|
|
|
* @param boolean $assoc |
69
|
|
|
* @param string $contentType |
70
|
|
|
* @return array |
71
|
|
|
*/ |
72
|
|
|
public function post($ressourceName, $ressourcePath =null, $ressourceId=null, $bodyData = array(),$query=array(), $assoc = false,$contentType='json'){ |
73
|
|
|
return $this->getCertainClient()->post($ressourceName, $ressourcePath, $ressourceId, $bodyData, $query, $assoc,$contentType); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Send a "PUT" request to put information to certain; |
79
|
|
|
* @param string $ressourceName |
80
|
|
|
* @param string $ressourcePath |
81
|
|
|
* @param string $ressourceId |
82
|
|
|
* @param array $bodyData |
83
|
|
|
* @param array $query |
84
|
|
|
* @param boolean $assoc |
85
|
|
|
* @param string $contentType |
86
|
|
|
* @return array |
87
|
|
|
*/ |
88
|
|
|
public function put($ressourceName, $ressourcePath =null, $ressourceId=null, $bodyData = array(),$query=array(), $assoc = false,$contentType='json'){ |
89
|
|
|
return $this->getCertainClient()->put($ressourceName, $ressourcePath, $ressourceId, $bodyData, $query, $assoc,$contentType); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Send a "DELETE" request to delete information from certain; |
94
|
|
|
* @param string $ressourceName |
95
|
|
|
* @param string $ressourcePath |
96
|
|
|
* @param string $ressourceId |
97
|
|
|
* @param boolean $assoc |
98
|
|
|
* @param string $contentType |
99
|
|
|
* @return array |
100
|
|
|
*/ |
101
|
|
|
public function delete($ressourceName, $ressourcePath =null, $ressourceId=null, $assoc = false,$contentType='json'){ |
102
|
|
|
return $this->getCertainClient()->delete($ressourceName, $ressourcePath, $ressourceId, $assoc,$contentType); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
|
106
|
|
|
} |