@@ -50,12 +50,11 @@ public function __construct($config)
5050 $ this ->_client = new Client ([
5151 'base_uri ' => $ this ->_entryPoint ,
5252 'headers ' => [
53- 'Accept ' => 'application/json '
54- ]
53+ 'Accept ' => 'application/json ' ,
54+ ],
5555 ]);
5656
57- if (!empty ($ config ['login ' ]) && !empty ($ config ['password ' ]))
58- {
57+ if (!empty ($ config ['login ' ]) && !empty ($ config ['password ' ])) {
5958 $ this ->login ($ config ['login ' ], $ config ['password ' ]);
6059 }
6160 }
@@ -82,15 +81,15 @@ public function login($login, $password)
8281 $ payload = [
8382 'form_params ' => [
8483 'login ' => $ login ,
85- 'password ' => $ password
86- ]
84+ 'password ' => $ password,
85+ ],
8786 ];
8887
8988 $ data = $ this ->_doRequest ('login ' , $ payload );
9089
91- if (isset ($ data ->session_key ))
92- {
90+ if (isset ($ data ->session_key )) {
9391 $ this ->_sessionKey = $ data ->session_key ;
92+
9493 return true ;
9594 }
9695
@@ -109,18 +108,15 @@ public function __call($method, $arguments)
109108 {
110109 $ payload = ['session_key ' => $ this ->_sessionKey ];
111110
112- if (is_null ($ this ->_sessionKey ))
113- {
111+ if (is_null ($ this ->_sessionKey )) {
114112 throw new Exception ('You are not logged in ' );
115113 }
116114
117- if (!empty ($ arguments [0 ]))
118- {
115+ if (!empty ($ arguments [0 ])) {
119116 $ payload = array_merge ($ payload , $ arguments [0 ]);
120117 }
121118
122- if ($ this ->_mapMethod ($ method ) === 'GET ' )
123- {
119+ if ($ this ->_mapMethod ($ method ) === 'GET ' ) {
124120 $ payload = ['query ' => $ payload ];
125121 }
126122
@@ -137,8 +133,7 @@ public function __call($method, $arguments)
137133 */
138134 private function _doRequest ($ method , $ payload )
139135 {
140- try
141- {
136+ try {
142137 $ response = $ this ->_client ->request (
143138 $ this ->_mapMethod ($ method ),
144139 $ method . '/ ' ,
@@ -147,15 +142,12 @@ private function _doRequest($method, $payload)
147142
148143 $ responseBody = json_decode ($ response ->getBody ());
149144
150- if (!$ responseBody ->success )
151- {
145+ if (!$ responseBody ->success ) {
152146 throw new Exception ($ responseBody ->message );
153147 }
154148
155149 return $ responseBody ->data ;
156- }
157- catch (TransferException $ e )
158- {
150+ } catch (TransferException $ e ) {
159151 throw new Exception ($ e ->getMessage ());
160152 }
161153 }
@@ -168,8 +160,7 @@ private function _doRequest($method, $payload)
168160 */
169161 private function _mapMethod ($ name )
170162 {
171- switch ($ name )
172- {
163+ switch ($ name ) {
173164 case 'create_agent_customer ' :
174165 case 'create_site ' :
175166 case 'create_ac_condition_group ' :
@@ -189,4 +180,4 @@ private function _mapMethod($name)
189180 return 'GET ' ;
190181 }
191182 }
192- }
183+ }
0 commit comments