File tree Expand file tree Collapse file tree 2 files changed +16
-11
lines changed
Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -30,8 +30,6 @@ class Service extends PersistentResource
3030 protected static $ url_resource = 'services ' ;
3131 protected static $ json_name = 'service ' ;
3232
33- const UPDATE_METHOD = 'PATCH ' ;
34-
3533 protected $ id ;
3634 protected $ name ;
3735 protected $ domains ;
@@ -99,4 +97,19 @@ protected function createJson()
9997 $ createJson = parent ::createJson ();
10098 return $ createJson ->{self ::$ json_name };
10199 }
100+
101+ /**
102+ * Update this resource
103+ *
104+ * @param array $params
105+ * @return \Guzzle\Http\Message\Response
106+ */
107+ public function update ($ params = array ())
108+ {
109+ $ json = $ this ->generateJsonPatch ($ params );
110+
111+ return $ this ->getClient ()
112+ ->patch ($ this ->getUrl (), $ this ->getPatchHeaders (), $ json )
113+ ->send ();
114+ }
102115}
Original file line number Diff line number Diff line change 2929
3030abstract class PersistentResource extends BaseResource
3131{
32- const UPDATE_METHOD = 'PUT ' ;
33-
3432 /**
3533 * Create a new resource
3634 *
@@ -82,13 +80,7 @@ public function update($params = array())
8280 $ this ->checkJsonError ();
8381
8482 // send the request
85- return $ this ->makeUpdateRequest ($ json );
86- }
87-
88- protected function makeUpdateRequest ($ json )
89- {
90- $ updateMethod = ('PATCH ' === static ::UPDATE_METHOD ) ? 'patch ' : 'post ' ;
91- return $ this ->getClient ()->$ updateMethod ($ this ->getUrl (), self ::getJsonHeader (), $ json )->send ();
83+ return $ this ->getClient ()->put ($ this ->getUrl (), self ::getJsonHeader (), $ json )->send ();
9284 }
9385
9486 /**
You can’t perform that action at this time.
0 commit comments