changed api_response signature
This commit is contained in:
@@ -48,7 +48,7 @@ final class Index
|
||||
$response['backends'][] = $backend;
|
||||
}
|
||||
|
||||
return api_response($response, HTTP_STATUS::HTTP_OK, []);
|
||||
return api_response(HTTP_STATUS::HTTP_OK, $response, []);
|
||||
}
|
||||
|
||||
public static function getBackends(string|null $name = null, bool $blacklist = false): array
|
||||
|
||||
@@ -35,8 +35,8 @@ final class View
|
||||
'list' => (string)$apiUrl->withPath(parseConfigValue(self::URL)),
|
||||
],
|
||||
];
|
||||
|
||||
return api_response(['backend' => $response], HTTP_STATUS::HTTP_OK, []);
|
||||
|
||||
return api_response(HTTP_STATUS::HTTP_OK, ['backend' => $response], []);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -314,6 +314,6 @@ final class Index
|
||||
$response['history'][] = $item;
|
||||
}
|
||||
|
||||
return api_response($response, HTTP_STATUS::HTTP_OK, []);
|
||||
return api_response(HTTP_STATUS::HTTP_OK, $response, []);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,6 @@ final readonly class View
|
||||
],
|
||||
];
|
||||
|
||||
return api_response(['history' => $item], HTTP_STATUS::HTTP_OK, []);
|
||||
return api_response(HTTP_STATUS::HTTP_OK, ['history' => $item], []);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,6 @@ final class Env
|
||||
];
|
||||
}
|
||||
|
||||
return api_response($response, HTTP_STATUS::HTTP_OK, []);
|
||||
return api_response(HTTP_STATUS::HTTP_OK, $response, []);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ final class Index
|
||||
$response['tasks'][] = $task;
|
||||
}
|
||||
|
||||
return api_response($response, HTTP_STATUS::HTTP_OK, []);
|
||||
return api_response(HTTP_STATUS::HTTP_OK, $response, []);
|
||||
}
|
||||
|
||||
public static function formatTask(array $task): array
|
||||
|
||||
@@ -35,6 +35,6 @@ final class View
|
||||
],
|
||||
];
|
||||
|
||||
return api_response(['task' => $response], HTTP_STATUS::HTTP_OK);
|
||||
return api_response(HTTP_STATUS::HTTP_OK, ['task' => $response]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,12 +243,12 @@ final class Initializer
|
||||
|
||||
// -- health endpoint.
|
||||
if (true === str_starts_with($requestPath, '/healthcheck')) {
|
||||
return api_response([], HTTP_STATUS::HTTP_OK);
|
||||
return api_response(HTTP_STATUS::HTTP_OK, []);
|
||||
}
|
||||
|
||||
// -- favicon endpoint.
|
||||
if (true === str_starts_with($requestPath, '/favicon.ico')) {
|
||||
return api_response([], HTTP_STATUS::HTTP_NO_CONTENT);
|
||||
return api_response(HTTP_STATUS::HTTP_NO_CONTENT, []);
|
||||
}
|
||||
|
||||
// -- Forward requests to API server.
|
||||
@@ -269,7 +269,7 @@ final class Initializer
|
||||
'headers' => $request->getHeaders(),
|
||||
'query' => $request->getQueryParams(),
|
||||
], true);
|
||||
return api_response([], HTTP_STATUS::HTTP_UNAUTHORIZED);
|
||||
return api_response(HTTP_STATUS::HTTP_UNAUTHORIZED, []);
|
||||
}
|
||||
|
||||
$validUser = $validUUid = null;
|
||||
@@ -371,7 +371,7 @@ final class Initializer
|
||||
}
|
||||
|
||||
$this->write($request, $loglevel ?? Level::Error, $message, ['messages' => $log]);
|
||||
return api_response([], HTTP_STATUS::HTTP_UNAUTHORIZED);
|
||||
return api_response(HTTP_STATUS::HTTP_UNAUTHORIZED, []);
|
||||
}
|
||||
|
||||
// -- sanity check in case user has both import.enabled and options.IMPORT_METADATA_ONLY enabled.
|
||||
@@ -388,7 +388,7 @@ final class Initializer
|
||||
'backend' => $class->getName()
|
||||
]);
|
||||
|
||||
return api_response([], HTTP_STATUS::HTTP_NOT_ACCEPTABLE);
|
||||
return api_response(HTTP_STATUS::HTTP_NOT_ACCEPTABLE, []);
|
||||
}
|
||||
|
||||
$entity = $class->parseWebhook($request);
|
||||
@@ -412,7 +412,7 @@ final class Initializer
|
||||
]
|
||||
);
|
||||
|
||||
return api_response([], HTTP_STATUS::HTTP_NOT_MODIFIED);
|
||||
return api_response(HTTP_STATUS::HTTP_NOT_MODIFIED, []);
|
||||
}
|
||||
|
||||
if ((0 === (int)$entity->episode || null === $entity->season) && $entity->isEpisode()) {
|
||||
@@ -431,7 +431,7 @@ final class Initializer
|
||||
]
|
||||
);
|
||||
|
||||
return api_response([], HTTP_STATUS::HTTP_NOT_MODIFIED);
|
||||
return api_response(HTTP_STATUS::HTTP_NOT_MODIFIED, []);
|
||||
}
|
||||
|
||||
$cache = Container::get(CacheInterface::class);
|
||||
@@ -471,7 +471,7 @@ final class Initializer
|
||||
]
|
||||
]);
|
||||
|
||||
return api_response([], HTTP_STATUS::HTTP_OK);
|
||||
return api_response(HTTP_STATUS::HTTP_OK, []);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -320,7 +320,7 @@ class HelpersTest extends TestCase
|
||||
public function test_api_response(): void
|
||||
{
|
||||
$data = ['foo' => 'bar'];
|
||||
$response = api_response($data, HTTP_STATUS::HTTP_OK);
|
||||
$response = api_response(HTTP_STATUS::HTTP_OK, $data);
|
||||
$this->assertSame(HTTP_STATUS::HTTP_OK->value, $response->getStatusCode());
|
||||
$this->assertSame('application/json', $response->getHeaderLine('Content-Type'));
|
||||
$this->assertSame(getAppVersion(), $response->getHeaderLine('X-Application-Version'));
|
||||
|
||||
Reference in New Issue
Block a user