@@ -34,6 +34,16 @@ class Resource implements InputFilterAwareInterface
34
34
*/
35
35
protected $ httpClient ;
36
36
37
+ /**
38
+ * @var mixed
39
+ */
40
+ protected $ curl ;
41
+
42
+ /**
43
+ * @var string
44
+ */
45
+ protected $ collectionName ;
46
+
37
47
/**
38
48
* @var string
39
49
*/
@@ -54,6 +64,28 @@ public function hasErrors()
54
64
return count ($ this ->errors ) > 0 ;
55
65
}
56
66
67
+ /**
68
+ * Get the collectionName
69
+ *
70
+ * @return string
71
+ */
72
+ public function getCollectionName ()
73
+ {
74
+ return $ this ->collectionName ;
75
+ }
76
+
77
+ /**
78
+ * Set the collectionName
79
+ *
80
+ * @param string $collectionName
81
+ * @return Resource
82
+ */
83
+ public function setCollectionName ($ collectionName )
84
+ {
85
+ $ this ->collectionName = $ collectionName ;
86
+ return $ this ;
87
+ }
88
+
57
89
/**
58
90
* @return string
59
91
*/
@@ -111,23 +143,24 @@ public function setHydrator(HydratorInterface $hydrator)
111
143
/**
112
144
* Constructor
113
145
*
114
- * @param Http\Client $httpClient
146
+ * @param $curl
115
147
*/
116
- public function __construct (Http \ Client $ httpClient )
148
+ public function __construct ($ curl )
117
149
{
118
- $ this ->httpClient = $ httpClient ;
119
- $ this ->httpClient ->setUri (self ::ZOHO_API_ENDPOINT );
150
+ $ this ->curl = $ curl ;
120
151
}
121
152
122
153
/**
123
154
* @return array
124
155
*/
125
156
public function fetchAll ()
126
157
{
127
- $ this ->httpClient ->setMethod (Http \Request::METHOD_GET )
128
- ->setUri (self ::ZOHO_API_ENDPOINT . $ this ->getPath ());
129
-
130
- return $ this ->httpClient ->send ();
158
+ curl_setopt ($ this ->curl , CURLOPT_URL , self ::ZOHO_API_ENDPOINT . $ this ->getPath ());
159
+ $ result = curl_exec ($ this ->curl );
160
+ $ result = json_decode ($ result );
161
+ curl_close ($ this ->curl );
162
+ $ collectioNName = $ this ->getCollectionName ();
163
+ return $ result ->$ collectioNName ;
131
164
}
132
165
133
166
/**
0 commit comments