Skip to content

Commit 7af8856

Browse files
committed
SetBrandOptInStatus changes to handle response codes
1 parent 45204ea commit 7af8856

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/Services/CyclopsService.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Gcd\Cyclops\Entities\CustomerEntity;
66
use Gcd\Cyclops\Entities\CyclopsIdentityEntity;
7+
use Gcd\Cyclops\Exceptions\ConflictException;
78
use Gcd\Cyclops\Exceptions\CustomerNotFoundException;
89
use Gcd\Cyclops\Exceptions\CyclopsException;
910
use Gcd\Cyclops\Exceptions\UserForbiddenException;
@@ -195,7 +196,23 @@ public function setBrandOptInStatus(CustomerEntity $customerEntity, bool $optIn)
195196
$request = new HttpRequest($url, 'post', $brands);
196197
$request->addHeader('Authorization', 'Basic ' . $this->authorization);
197198
$request->addHeader('Content-Type', 'application/json');
198-
$response = $this->httpClient->getResponse($request);
199+
$response = $this->doCyclopsRequest($request);
200+
201+
switch ($response->getResponseCode()) {
202+
case 200:
203+
break;
204+
case 403:
205+
throw new UserForbiddenException();
206+
break;
207+
case 404:
208+
throw new CustomerNotFoundException();
209+
break;
210+
case 409:
211+
throw new ConflictException();
212+
default:
213+
throw new CyclopsException();
214+
}
215+
199216
return $response;
200217
}
201218
}

0 commit comments

Comments
 (0)