@@ -130,7 +130,7 @@ |
||
| 130 | 130 | { |
| 131 | 131 | return !is_null($this->expiration) && |
| 132 | 132 | Carbon::now() |
| 133 | - ->gte($this->expiration); |
|
| 133 | + ->gte($this->expiration); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | protected function endpoint() |
| 60 | 60 | { |
| 61 | - return 'system/members/' . $this->member_id . '/tokens'; |
|
| 61 | + return 'system/members/'.$this->member_id.'/tokens'; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function getUsername() |
| 120 | 120 | { |
| 121 | - return $this->company_id . '+' . $this->username; |
|
| 121 | + return $this->company_id.'+'.$this->username; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -83,9 +83,9 @@ |
||
| 83 | 83 | $app->make(Token::class), $app->make(Guzzle::class), |
| 84 | 84 | $app->make(ModelResolver::class) |
| 85 | 85 | ))->setIntegrator($app->config->get('services.connectwise.integrator')) |
| 86 | - ->setPassword($app->config->get('services.connectwise.password')) |
|
| 87 | - ->setUrl($app->config->get('services.connectwise.url')) |
|
| 88 | - ->setVersion($app->config->get('services.connectwise.version')); |
|
| 86 | + ->setPassword($app->config->get('services.connectwise.password')) |
|
| 87 | + ->setUrl($app->config->get('services.connectwise.url')) |
|
| 88 | + ->setVersion($app->config->get('services.connectwise.version')); |
|
| 89 | 89 | } |
| 90 | 90 | ); |
| 91 | 91 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | $this->app->singleton( |
| 80 | 80 | Client::class, |
| 81 | - function (Application $app) { |
|
| 81 | + function(Application $app) { |
|
| 82 | 82 | return (new Client( |
| 83 | 83 | $app->make(Token::class), $app->make(Guzzle::class), |
| 84 | 84 | $app->make(ModelResolver::class) |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | { |
| 114 | 114 | $this->app->singleton( |
| 115 | 115 | Token::class, |
| 116 | - function (Application $app) { |
|
| 116 | + function(Application $app) { |
|
| 117 | 117 | return (new Token())->setCompanyId($app->config->get('services.connectwise.company_id')) |
| 118 | 118 | ->setMemberId($this->determineMemberId()); |
| 119 | 119 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - trigger_error('Call to undefined method ' . __CLASS__ . '::' . $method . '()', E_USER_ERROR); |
|
| 95 | + trigger_error('Call to undefined method '.__CLASS__.'::'.$method.'()', E_USER_ERROR); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | return $value; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - $class = 'Spinen\ConnectWise\\' . $cast; |
|
| 157 | + $class = 'Spinen\ConnectWise\\'.$cast; |
|
| 158 | 158 | |
| 159 | 159 | if (class_exists($class)) { |
| 160 | 160 | return new $class($value); |
@@ -165,11 +165,11 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | if (strcasecmp('json', $cast) == 0) { |
| 168 | - return json_encode((array)$value); |
|
| 168 | + return json_encode((array) $value); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | if (strcasecmp('collection', $cast) == 0) { |
| 172 | - return new Collection((array)$value); |
|
| 172 | + return new Collection((array) $value); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | if (in_array($cast, ['bool', 'boolean'])) { |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | return $this->attributes[$attribute]; |
| 275 | 275 | }; |
| 276 | 276 | |
| 277 | - trigger_error('Undefined property:'. __CLASS__ . '::$' . $attribute); |
|
| 277 | + trigger_error('Undefined property:'.__CLASS__.'::$'.$attribute); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | */ |
| 303 | 303 | protected function getterMethodName($attribute) |
| 304 | 304 | { |
| 305 | - return 'get' . Str::studly($attribute) . 'Attribute'; |
|
| 305 | + return 'get'.Str::studly($attribute).'Attribute'; |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | */ |
| 398 | 398 | protected function setterMethodName($attribute) |
| 399 | 399 | { |
| 400 | - return 'set' . Str::studly($attribute) . 'Attribute'; |
|
| 400 | + return 'set'.Str::studly($attribute).'Attribute'; |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | /** |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | $pattern = preg_replace('|(/)\\d+(/?)|u', '$1{id}$2', $pattern); |
| 46 | 46 | |
| 47 | 47 | // Make regex |
| 48 | - $pattern = '|^/' . $pattern . '$|ui'; |
|
| 48 | + $pattern = '|^/'.$pattern.'$|ui'; |
|
| 49 | 49 | |
| 50 | 50 | // Search the map for the uri that matches |
| 51 | 51 | return ($uri = $this->maps[$version]->search( |
| 52 | - function ($model, $uri) use ($pattern) { |
|
| 52 | + function($model, $uri) use ($pattern) { |
|
| 53 | 53 | return preg_match($pattern, $uri); |
| 54 | 54 | } |
| 55 | 55 | )) ? $this->maps[$version][$uri] : null; |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | if (!array_key_exists($version, $this->maps)) { |
| 66 | 66 | $this->maps[$version] = collect( |
| 67 | 67 | json_decode( |
| 68 | - @file_get_contents(__DIR__ . '/../Models/v' . str_replace('.', '_', $version) . '/map.json'), |
|
| 68 | + @file_get_contents(__DIR__.'/../Models/v'.str_replace('.', '_', $version).'/map.json'), |
|
| 69 | 69 | true |
| 70 | 70 | ) |
| 71 | 71 | ); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * "Generated" that you can move to src/Models/ |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -require __DIR__ . '/../vendor/autoload.php'; |
|
| 14 | +require __DIR__.'/../vendor/autoload.php'; |
|
| 15 | 15 | |
| 16 | 16 | use Illuminate\Support\Str; |
| 17 | 17 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | function mapResourceToClass($uri, $namespace, $class) |
| 71 | 71 | { |
| 72 | - echo "'${uri}' => '" . $namespace . "\\" . $class . "',\n"; |
|
| 72 | + echo "'${uri}' => '".$namespace."\\".$class."',\n"; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | function parseResponse($response, $uri) |
@@ -97,18 +97,18 @@ discard block |
||
| 97 | 97 | function processPaths() |
| 98 | 98 | { |
| 99 | 99 | $namespace = Str::studly($GLOBALS['api']); |
| 100 | - $path = __DIR__ . '/Generated/' . $GLOBALS['version'] . '/'; |
|
| 100 | + $path = __DIR__.'/Generated/'.$GLOBALS['version'].'/'; |
|
| 101 | 101 | |
| 102 | - mkdir($path . $namespace, 0755, true); |
|
| 102 | + mkdir($path.$namespace, 0755, true); |
|
| 103 | 103 | |
| 104 | 104 | foreach ($GLOBALS['swagger']['paths'] as $uri => $actions) { |
| 105 | 105 | if (array_key_exists('get', $actions)) { |
| 106 | 106 | $docs = $actions['get']; |
| 107 | 107 | $class = Str::singular($docs['tags'][0]); |
| 108 | - $file = $path . '/' . $namespace . '/' . $class . '.php'; |
|
| 108 | + $file = $path.'/'.$namespace.'/'.$class.'.php'; |
|
| 109 | 109 | |
| 110 | 110 | if (!file_exists($file)) { |
| 111 | - $GLOBALS['map'][$uri] = $GLOBALS['version'] . '\\' . $namespace . '\\' . $class; |
|
| 111 | + $GLOBALS['map'][$uri] = $GLOBALS['version'].'\\'.$namespace.'\\'.$class; |
|
| 112 | 112 | |
| 113 | 113 | $attributes = parseResponse(getResponse($docs['responses']), $uri); |
| 114 | 114 | |
@@ -159,8 +159,8 @@ discard block |
||
| 159 | 159 | $properties = null; |
| 160 | 160 | |
| 161 | 161 | foreach ($attributes as $attribute => $type) { |
| 162 | - $casts .= "\n '" . $attribute . "' => '" . $type . "',"; |
|
| 163 | - $properties .= "\n * @property " . $type . ' $' . $attribute; |
|
| 162 | + $casts .= "\n '".$attribute."' => '".$type."',"; |
|
| 163 | + $properties .= "\n * @property ".$type.' $'.$attribute; |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | $file = preg_replace('|{{ Namespace }}|u', $namespace, $template); |
@@ -172,18 +172,18 @@ discard block |
||
| 172 | 172 | file_put_contents($file_path, $file); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | -foreach (glob(__DIR__ . "/swagger/*") as $version) { |
|
| 175 | +foreach (glob(__DIR__."/swagger/*") as $version) { |
|
| 176 | 176 | $GLOBALS['version'] = basename($version); |
| 177 | 177 | $GLOBALS['map'] = null; |
| 178 | 178 | |
| 179 | - foreach (glob(__DIR__ . "/swagger/" . $GLOBALS['version'] . "/*.json") as $swaggerfile) { |
|
| 179 | + foreach (glob(__DIR__."/swagger/".$GLOBALS['version']."/*.json") as $swaggerfile) { |
|
| 180 | 180 | $GLOBALS['api'] = explode('.', basename($swaggerfile))[0]; |
| 181 | 181 | $GLOBALS['swagger'] = readSwagger($swaggerfile); |
| 182 | 182 | |
| 183 | 183 | processPaths(); |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - file_put_contents(__DIR__ . '/Generated/' . $GLOBALS['version'] . '/map.json', json_encode($GLOBALS['map'])); |
|
| 186 | + file_put_contents(__DIR__.'/Generated/'.$GLOBALS['version'].'/map.json', json_encode($GLOBALS['map'])); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | public function buildUri($resource) |
| 200 | 200 | { |
| 201 | - $uri = $this->getUrl() . ltrim($resource, '/'); |
|
| 201 | + $uri = $this->getUrl().ltrim($resource, '/'); |
|
| 202 | 202 | |
| 203 | 203 | var_dump($uri); |
| 204 | 204 | |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | return array_merge( |
| 242 | 242 | [ |
| 243 | - 'Accept' => 'application/vnd.connectwise.com+json; version=' . $this->version, |
|
| 243 | + 'Accept' => 'application/vnd.connectwise.com+json; version='.$this->version, |
|
| 244 | 244 | ], |
| 245 | 245 | $this->headers |
| 246 | 246 | ); |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | */ |
| 274 | 274 | public function getUrl() |
| 275 | 275 | { |
| 276 | - return $this->url . '/v4_6_release/apis/3.0/'; |
|
| 276 | + return $this->url.'/v4_6_release/apis/3.0/'; |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -302,14 +302,14 @@ discard block |
||
| 302 | 302 | */ |
| 303 | 303 | protected function processResponse($resource, Response $response) |
| 304 | 304 | { |
| 305 | - $response = (array)json_decode($response->getBody(), true); |
|
| 305 | + $response = (array) json_decode($response->getBody(), true); |
|
| 306 | 306 | |
| 307 | 307 | if ($model = $this->resolver->find($resource, $this->version)) { |
| 308 | - $model = 'Spinen\ConnectWise\Models\\' . $model; |
|
| 308 | + $model = 'Spinen\ConnectWise\Models\\'.$model; |
|
| 309 | 309 | |
| 310 | 310 | if ($this->isCollection($response)) { |
| 311 | 311 | $response = array_map( |
| 312 | - function ($item) use ($model) { |
|
| 312 | + function($item) use ($model) { |
|
| 313 | 313 | $item = new $model($item, $this); |
| 314 | 314 | |
| 315 | 315 | return $item; |