7 protected $apiTokenId = 'apitoken';
8 protected $apiTokenSecret = 'password';
11 * Set the API editor role as the current user via the API driver.
13 protected function actingAsApiEditor()
15 $this->actingAs($this->getEditor(), 'api');
21 * Format the given items into a standardised error format.
23 protected function errorResponse(string $message, int $code): array
25 return ['error' => ['code' => $code, 'message' => $message]];
29 * Format the given (field_name => ["messages"]) array
30 * into a standard validation response format.
32 protected function validationResponse(array $messages): array
34 $err = $this->errorResponse('The given data was invalid.', 422);
35 $err['error']['validation'] = $messages;
41 * Get an approved API auth header.
43 protected function apiAuthHeader(): array
46 'Authorization' => "Token {$this->apiTokenId}:{$this->apiTokenSecret}",