feat: implement AI styling foundation and billing scope rework
This commit is contained in:
118
app/Services/AiEditing/AiProviderResult.php
Normal file
118
app/Services/AiEditing/AiProviderResult.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\AiEditing;
|
||||
|
||||
class AiProviderResult
|
||||
{
|
||||
/**
|
||||
* @param array<int, array<string, mixed>> $outputs
|
||||
* @param array<string, mixed> $requestPayload
|
||||
* @param array<string, mixed> $responsePayload
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly string $status,
|
||||
public readonly ?string $providerTaskId = null,
|
||||
public readonly ?string $failureCode = null,
|
||||
public readonly ?string $failureMessage = null,
|
||||
public readonly ?string $safetyState = null,
|
||||
public readonly array $safetyReasons = [],
|
||||
public readonly ?float $costUsd = null,
|
||||
public readonly array $outputs = [],
|
||||
public readonly array $requestPayload = [],
|
||||
public readonly array $responsePayload = [],
|
||||
public readonly ?int $httpStatus = null,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @param array<int, array<string, mixed>> $outputs
|
||||
* @param array<string, mixed> $requestPayload
|
||||
* @param array<string, mixed> $responsePayload
|
||||
*/
|
||||
public static function succeeded(
|
||||
array $outputs = [],
|
||||
?float $costUsd = null,
|
||||
?string $safetyState = null,
|
||||
array $safetyReasons = [],
|
||||
array $requestPayload = [],
|
||||
array $responsePayload = [],
|
||||
?int $httpStatus = null,
|
||||
): self {
|
||||
return new self(
|
||||
status: 'succeeded',
|
||||
outputs: $outputs,
|
||||
costUsd: $costUsd,
|
||||
safetyState: $safetyState,
|
||||
safetyReasons: $safetyReasons,
|
||||
requestPayload: $requestPayload,
|
||||
responsePayload: $responsePayload,
|
||||
httpStatus: $httpStatus,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $requestPayload
|
||||
* @param array<string, mixed> $responsePayload
|
||||
*/
|
||||
public static function processing(
|
||||
string $providerTaskId,
|
||||
?float $costUsd = null,
|
||||
array $requestPayload = [],
|
||||
array $responsePayload = [],
|
||||
?int $httpStatus = null,
|
||||
): self {
|
||||
return new self(
|
||||
status: 'processing',
|
||||
providerTaskId: $providerTaskId,
|
||||
costUsd: $costUsd,
|
||||
requestPayload: $requestPayload,
|
||||
responsePayload: $responsePayload,
|
||||
httpStatus: $httpStatus,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $requestPayload
|
||||
* @param array<string, mixed> $responsePayload
|
||||
*/
|
||||
public static function failed(
|
||||
string $failureCode,
|
||||
string $failureMessage,
|
||||
array $requestPayload = [],
|
||||
array $responsePayload = [],
|
||||
?int $httpStatus = null,
|
||||
): self {
|
||||
return new self(
|
||||
status: 'failed',
|
||||
failureCode: $failureCode,
|
||||
failureMessage: $failureMessage,
|
||||
requestPayload: $requestPayload,
|
||||
responsePayload: $responsePayload,
|
||||
httpStatus: $httpStatus,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $requestPayload
|
||||
* @param array<string, mixed> $responsePayload
|
||||
*/
|
||||
public static function blocked(
|
||||
string $failureCode,
|
||||
string $failureMessage,
|
||||
?string $safetyState = null,
|
||||
array $safetyReasons = [],
|
||||
array $requestPayload = [],
|
||||
array $responsePayload = [],
|
||||
?int $httpStatus = null,
|
||||
): self {
|
||||
return new self(
|
||||
status: 'blocked',
|
||||
failureCode: $failureCode,
|
||||
failureMessage: $failureMessage,
|
||||
safetyState: $safetyState,
|
||||
safetyReasons: $safetyReasons,
|
||||
requestPayload: $requestPayload,
|
||||
responsePayload: $responsePayload,
|
||||
httpStatus: $httpStatus,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user