diff --git a/src/LaravelCM/BaseClient.php b/src/LaravelCM/BaseClient.php index 2d9af82..172edff 100644 --- a/src/LaravelCM/BaseClient.php +++ b/src/LaravelCM/BaseClient.php @@ -1,17 +1,21 @@ initGuzzle(); //Set options @@ -22,14 +26,16 @@ public function __construct() { 'listID' => config('laravel-cm.default_list_id') ]); } - - - public function setOptions(array $options): self { + + + public function setOptions(array $options): self + { $this->options = $options; return $this; } - - public function getOptions(): array { + + public function getOptions(): array + { return $this->options; } @@ -37,33 +43,37 @@ public function getOptions(): array { * Set the client API Key * @param string $key */ - public function setClientApiKey(string $key = null): self{ + public function setClientApiKey(string $key = null): self + { $this->options['clientApiKey'] = $key; return $this; } - + /** * Get the current client API Key */ - public function getClientApiKey(): string{ + public function getClientApiKey(): string + { return $this->options['clientApiKey']; } - + /** * Set the client ID * @param string $client_id * @return \self */ - public function setClientID(string $client_id = null): self{ + public function setClientID(string $client_id = null): self + { $this->options['clientID'] = $client_id; return $this; } - + /** * Get the current client ID * @return string */ - public function getClientID(): string { + public function getClientID(): string + { return $this->options['clientID']; } @@ -71,116 +81,130 @@ public function getClientID(): string { * Set the list ID to be used * @param string $list_id */ - public function setListID(string $list_id = null): self{ - $this->options['listID'] = $list_id?:$this->getListID(); + public function setListID(string $list_id = null): self + { + $this->options['listID'] = $list_id ?: $this->getListID(); return $this; } - + /** * Get the current List ID */ - public function getListID(): string{ + public function getListID(): string + { return $this->options['listID']; } - + /** * Set the format of the call * @param string $format json|xml */ - public function setFormat(string $format): self{ + public function setFormat(string $format): self + { $this->options['format'] = $format; return $this; } - + /** * Get the current format in use */ - public function getFormat(): string{ + public function getFormat(): string + { return $this->options['format']; } - + /** * Get a clean guzzle client object */ - public function getGuzzle(): Client{ + public function getGuzzle(): Client + { return new Client; } - + /** * Initialize guzzle with a base_uri called by the constructor * @param type $base_uri */ - public function initGuzzle($base_uri = null): self{ - if(!is_null($base_uri)){ - $this->guzzle = new Client(['base_uri'=>config('laravel-cm.base_uri')]); + public function initGuzzle($base_uri = null): self + { + if (!is_null($base_uri)) { + $this->guzzle = new Client(['base_uri' => config('laravel-cm.base_uri')]); } - $this->guzzle = new Client(['base_uri'=>config('laravel-cm.base_uri')]); + $this->guzzle = new Client(['base_uri' => config('laravel-cm.base_uri')]); return $this; } - + /** * Retrieve auth information for API Call * @return array */ - public function getAuthInformation(): array { - return [$this->getClientApiKey(),'']; + public function getAuthInformation(): array + { + return [$this->getClientApiKey(), '']; } - + /** * Retrieve basic Guzzle options for making an API call * @return array */ - public function getBaseRequestData(): array{ + public function getBaseRequestData(): array + { return [ 'stream' => true, 'auth' => $this->getAuthInformation(), 'headers' => [ - 'Accept' => 'application/json' - ] + 'Accept' => 'application/json' + ] ]; } - + /** * Merge the request data with parameters provided by calling function * @param array $request_data * @return type */ - public function mergeRequestData(array $request_data): array{ - return array_merge($request_data,$this->getBaseRequestData()); + public function mergeRequestData(array $request_data): array + { + return array_merge($request_data, $this->getBaseRequestData()); } - + /** * Check api options and skip optional values * @return Guzzle client */ - private function checkOptions(): void{ - foreach($this->options as $k=>$v){ - if(empty($v) && $this->skip_key != $k){ - throw new ConfigKeyNotSetException('No '.$k.' found. Please update your settings or generate a resource'); + private function checkOptions(): void + { + foreach ($this->options as $k => $v) { + if (empty($v) && $this->skip_key != $k) { + throw new ConfigKeyNotSetException('No ' . $k . ' found. Please update your settings or generate a resource'); } } return; } - + /** * Call the guzzle Client and provide optional validation key to skip * when validating options * @return Guzzle\Client */ - public function callApi(): \GuzzleHttp\Client{ + public function callApi(): \GuzzleHttp\Client + { $this->checkOptions(); return $this->guzzle; } - - public function makeCall($method = 'get', $url, array $request_data){ - try{ + + public function makeCall($method = 'get', $url, array $request_data) + { + try { return $this->formatResult( - $this->callApi()->{$method}($url.'.'.$this->getFormat(), - $this->mergeRequestData($request_data))); + $this->callApi()->{$method}( + $url . '.' . $this->getFormat(), + $this->mergeRequestData($request_data) + ) + ); } catch (RequestException $ex) { $response_body = $this->formatBody($ex->getResponse()->getBody()); - throw new Exception('Code '.$response_body->Code.': '.$response_body->Message); + throw new Exception('Code ' . $response_body->Code . ': ' . $response_body->Message); } } - -} \ No newline at end of file +} diff --git a/src/resources/views/bootstrap4/campaigns/schedule.blade.php b/src/resources/views/bootstrap4/campaigns/schedule.blade.php index 1b0853b..1aad1a5 100644 --- a/src/resources/views/bootstrap4/campaigns/schedule.blade.php +++ b/src/resources/views/bootstrap4/campaigns/schedule.blade.php @@ -1,58 +1,58 @@ @extends('layouts.'.config('laravel-cm.layout_file')) @section('content') -
-
-
-
- -
- {{ csrf_field() }} - -
-

{{$campaign->Name}}

- @lang('laravel-cm::campaigns.schedule_title') -
- -
- - @include('laravel-cm::notifications') - - @lang('laravel-cm::campaigns.preview'): {{$campaign->PreviewURL}}
- -
- - -
+
+
+
+
+ + + {{ csrf_field() }} -
- - +
+

{{ $campaign->Name }}

+ @lang('laravel-cm::campaigns.schedule_title')
-
+
- -
+
-
-@stop \ No newline at end of file +@stop