From 591d23c1512870b824c63492fba56b3a887e29d2 Mon Sep 17 00:00:00 2001 From: Lasse Rafn Date: Fri, 13 Sep 2019 16:02:55 +0100 Subject: [PATCH 1/3] Update Builder.php Set limit to 1000 as default, instead of 1500. Rackbeat has a max-limit of 1000 anyway, so it has no effect setting it higher --- src/Builders/Builder.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Builders/Builder.php b/src/Builders/Builder.php index 78c62a1..0fedc15 100644 --- a/src/Builders/Builder.php +++ b/src/Builders/Builder.php @@ -33,7 +33,7 @@ public function __construct(Request $request ) */ public function get($filters = [] ) { - $filters[] = [ 'limit', '=', 1500 ]; + $filters[] = [ 'limit', '=', 1000 ]; $urlFilters = $this->parseFilters( $filters ); @@ -102,7 +102,7 @@ public function all($filters = [] ) $response = function ( $filters, $page ) { - $filters[] = [ 'limit', '=', 1500 ]; + $filters[] = [ 'limit', '=', 1000 ]; $filters[] = [ 'page', '=', $page ]; $urlFilters = $this->parseFilters( $filters ); @@ -185,4 +185,4 @@ public function setEntity( $new_entity ) return $this->entity; } -} \ No newline at end of file +} From a3216996b2014d60efedc078553759edf6606e21 Mon Sep 17 00:00:00 2001 From: Lasse Rafn Date: Fri, 13 Sep 2019 16:15:51 +0100 Subject: [PATCH 2/3] Update Request.php Added User-Agent header and utf8 charset. The utf part doesn't REALLY matter, but does fix some weird edge-cases with utf8 characters being broken --- src/Utils/Request.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Utils/Request.php b/src/Utils/Request.php index 37b8346..4e009b4 100644 --- a/src/Utils/Request.php +++ b/src/Utils/Request.php @@ -33,9 +33,10 @@ public function __construct( $token = null, $options = [], $headers = [] ) { $token = $token ?? config( 'rackbeat.token' ); $headers = array_merge( $headers, [ - - 'Accept' => 'application/json', - 'Content-Type' => 'application/json', + + 'User-Agent' => config('rackbeat.user_agent'), + 'Accept' => 'application/json; charset=utf8', + 'Content-Type' => 'application/json; charset=utf8', 'Authorization' => 'Bearer ' . $token, ] ); $options = array_merge( $options, [ @@ -92,4 +93,4 @@ public function handleWithExceptions( $callback ) throw new RackbeatClientException( $message, $code ); } } -} \ No newline at end of file +} From 4bbcb1f7022b7f836dad47eee66b72e6524d5f44 Mon Sep 17 00:00:00 2001 From: Lasse Rafn Date: Fri, 13 Sep 2019 16:17:04 +0100 Subject: [PATCH 3/3] Update rackbeat.php Add support for user agent header --- src/config/rackbeat.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/config/rackbeat.php b/src/config/rackbeat.php index 968f7c9..2f22aa7 100644 --- a/src/config/rackbeat.php +++ b/src/config/rackbeat.php @@ -9,6 +9,7 @@ return [ 'token' => env( 'RACKBEAT_API_TOKEN' ), + 'user_agent' => env('RACKBEAT_USER_AGENT', 'kg-bot/laravel-rackbeat') 'supplier' => [ 'fields' => [ @@ -20,4 +21,4 @@ ], ], 'base_uri' => env( 'RACKBEAT_BASE_URL', 'https://app.rackbeat.com/api/' ), -]; \ No newline at end of file +];