| @@ -0,0 +1,43 @@ | ||
| <?hh // strict | ||
|
|
||
| class FetchOrderPricePolicyQuery { | ||
|
|
||
| public function __construct( | ||
| private FetchQuery<OrderPricePolicy> $fetchQuery, | ||
| private OrderPricePolicyTable $orderPricePolicyTable, | ||
| private TimestampSerializer $timestampSerializer | ||
| ) {} | ||
|
|
||
| public async function fetch(Timestamp $timestamp): Awaitable<OrderPricePolicy> { | ||
| $fetch_params_builder = new FetchParamsBuilder(); | ||
|
|
||
| // Build where clause: select all records | ||
| $where_clause_vector_builder = new WhereClauseVectorBuilder(); | ||
| $fetch_params_builder->setWhereClause( | ||
| $where_clause_vector_builder->setFirstClause( | ||
| new LessThanWhereClause( | ||
| $this->orderPricePolicyTable->getTimeEnactedKey(), | ||
| $this->timestampSerializer->serialize($timestamp) | ||
| ) | ||
| ) | ||
| ->build() | ||
| ); | ||
|
|
||
| // Build order-by clause: sort by 'time-enacted' | ||
| $order_by_clause_builder = new OrderByClauseBuilder(); | ||
| $fetch_params_builder->setOrderByClause( | ||
| $order_by_clause_builder->asc( | ||
| $this->orderPricePolicyTable->getTimeEnactedKey() | ||
| ) | ||
| ->build() | ||
| ); | ||
|
|
||
| $policy_list = await $this->fetchQuery->fetch( | ||
| $fetch_params_builder | ||
| ->setTable($this->orderPricePolicyTable) | ||
| ->build() | ||
| ); | ||
|
|
||
| return $policy_list[0]; | ||
| } | ||
| } |
| @@ -0,0 +1,43 @@ | ||
| <?hh // strict | ||
|
|
||
| class FetchVideoEditingPricePolicyQuery { | ||
|
|
||
| public function __construct( | ||
| private FetchQuery<VideoEditingPricePolicy> $fetchQuery, | ||
| private VideoEditingPricePolicyTable $videoEditingPricePolicyTable, | ||
| private TimestampSerializer $timestampSerializer | ||
| ) {} | ||
|
|
||
| public async function fetch(Timestamp $timestamp): Awaitable<VideoEditingPricePolicy> { | ||
| $fetch_params_builder = new FetchParamsBuilder(); | ||
|
|
||
| // Build where clause: select all records | ||
| $where_clause_vector_builder = new WhereClauseVectorBuilder(); | ||
| $fetch_params_builder->setWhereClause( | ||
| $where_clause_vector_builder->setFirstClause( | ||
| new LessThanWhereClause( | ||
| $this->videoEditingPricePolicyTable->getTimeEnactedKey(), | ||
| $this->timestampSerializer->serialize($timestamp) | ||
| ) | ||
| ) | ||
| ->build() | ||
| ); | ||
|
|
||
| // Build order-by clause: sort by 'time-enacted' | ||
| $order_by_clause_builder = new OrderByClauseBuilder(); | ||
| $fetch_params_builder->setOrderByClause( | ||
| $order_by_clause_builder->asc( | ||
| $this->videoEditingPricePolicyTable->getTimeEnactedKey() | ||
| ) | ||
| ->build() | ||
| ); | ||
|
|
||
| $policy_list = await $this->fetchQuery->fetch( | ||
| $fetch_params_builder | ||
| ->setTable($this->videoEditingPricePolicyTable) | ||
| ->build() | ||
| ); | ||
|
|
||
| return $policy_list[0]; | ||
| } | ||
| } |
| @@ -0,0 +1,43 @@ | ||
| <?hh // strict | ||
|
|
||
| class FetchVideoStoragePricePolicyQuery { | ||
|
|
||
| public function __construct( | ||
| private FetchQuery<VideoStoragePricePolicy> $fetchQuery, | ||
| private VideoStoragePricePolicyTable $videoStoragePricePolicyTable, | ||
| private TimestampSerializer $timestampSerializer | ||
| ) {} | ||
|
|
||
| public async function fetch(Timestamp $timestamp): Awaitable<VideoStoragePricePolicy> { | ||
| $fetch_params_builder = new FetchParamsBuilder(); | ||
|
|
||
| // Build where clause: select all records | ||
| $where_clause_vector_builder = new WhereClauseVectorBuilder(); | ||
| $fetch_params_builder->setWhereClause( | ||
| $where_clause_vector_builder->setFirstClause( | ||
| new LessThanWhereClause( | ||
| $this->videoStoragePricePolicyTable->getTimeEnactedKey(), | ||
| $this->timestampSerializer->serialize($timestamp) | ||
| ) | ||
| ) | ||
| ->build() | ||
| ); | ||
|
|
||
| // Build order-by clause: sort by 'time-enacted' | ||
| $order_by_clause_builder = new OrderByClauseBuilder(); | ||
| $fetch_params_builder->setOrderByClause( | ||
| $order_by_clause_builder->asc( | ||
| $this->videoStoragePricePolicyTable->getTimeEnactedKey() | ||
| ) | ||
| ->build() | ||
| ); | ||
|
|
||
| $policy_list = await $this->fetchQuery->fetch( | ||
| $fetch_params_builder | ||
| ->setTable($this->videoStoragePricePolicyTable) | ||
| ->build() | ||
| ); | ||
|
|
||
| return $policy_list[0]; | ||
| } | ||
| } |
| @@ -0,0 +1,21 @@ | ||
| <?hh // strict | ||
|
|
||
| class InsertEditedVideoOrderQuery { | ||
|
|
||
| public function __construct( | ||
| private InsertQuery<EditedVideoOrder> $insertQuery, | ||
| private EditedVideoOrderTable $editedVideoOrdersTable | ||
| ) {} | ||
|
|
||
| public async function insert( | ||
| UnsignedInt $confirmed_order, | ||
| UnsignedInt $recording_duration_minutes | ||
| ): Awaitable<EditedVideoOrder> { | ||
| return await $this->insertQuery->insert( | ||
| ImmMap{ | ||
| $this->editedVideoOrdersTable->getConfirmedOrderIdKey() => $confirmed_order->getNumber(), | ||
| $this->editedVideoOrdersTable->getRecordingDurationMinutesKey() => $recording_duration_minutes->getNumber(), | ||
| } | ||
| ); | ||
| } | ||
| } |
| @@ -0,0 +1,22 @@ | ||
| <?hh // strict | ||
|
|
||
| class InsertOrderPricePolicyQuery { | ||
|
|
||
| public function __construct( | ||
| private InsertQuery<OrderPricePolicy> $insertQuery, | ||
| private OrderPricePolicyTable $orderPricePolicyTable, | ||
| private HRTimestampSerializer $hrTimestampSerializer | ||
| ) {} | ||
|
|
||
| public async function insert( | ||
| UnsignedFloat $price, | ||
| Timestamp $time_enacted | ||
| ): Awaitable<OrderPricePolicy> { | ||
| return await $this->insertQuery->insert( | ||
| ImmMap{ | ||
| $this->orderPricePolicyTable->getPriceKey() => $price->getNumber(), | ||
| $this->orderPricePolicyTable->getTimeEnactedKey() => $this->hrTimestampSerializer->serialize($time_enacted), | ||
| } | ||
| ); | ||
| } | ||
| } |
| @@ -0,0 +1,25 @@ | ||
| <?hh // strict | ||
|
|
||
| class BasicVideosTable extends Table { | ||
|
|
||
| const string TABLE_NAME = "BasicVideos"; | ||
| const string CONFIRMED_ORDER_ID_KEY = "confirmedOrderId"; | ||
| const string SCOPE_INDEX_KEY = "scopeIndex"; | ||
| const string EXPIRATION_TIME_KEY = "expirationTime"; | ||
|
|
||
| public function getName(): string { | ||
| return self::TABLE_NAME; | ||
| } | ||
|
|
||
| public function getConfirmedOrderIdKey(): string { | ||
| return self::CONFIRMED_ORDER_ID_KEY; | ||
| } | ||
|
|
||
| public function getScopeIndexKey(): string { | ||
| return self::SCOPE_INDEX_KEY; | ||
| } | ||
|
|
||
| public function getExpirationTimeKey(): string { | ||
| return self::EXPIRATION_TIME_KEY; | ||
| } | ||
| } |
| @@ -0,0 +1,20 @@ | ||
| <?hh // strict | ||
|
|
||
| class CompositeVideoTable extends Table { | ||
|
|
||
| const string TABLE_NAME = "CompositeVideos"; | ||
| const string CONFIRMED_ORDER_ID_KEY = "confirmedOrderId"; | ||
| const string EXPIRATION_TIME_KEY = "expirationTime"; | ||
|
|
||
| public function getName(): string { | ||
| return self::TABLE_NAME; | ||
| } | ||
|
|
||
| public function getConfirmedOrderIdKey(): string { | ||
| return self::CONFIRMED_ORDER_ID_KEY; | ||
| } | ||
|
|
||
| public function getExpirationTimeKey(): string { | ||
| return self::EXPIRATION_TIME_KEY; | ||
| } | ||
| } |
| @@ -0,0 +1,20 @@ | ||
| <?hh // strict | ||
|
|
||
| class EditedVideoOrderTable extends Table { | ||
|
|
||
| const string TABLE_NAME = "EditedVideoOrders"; | ||
| const string CONFIRMED_ORDER_ID_KEY = "confirmedOrderId"; | ||
| const string RECORDING_DURATION_MINUTES_KEY = "recordingDurationMinutes"; | ||
|
|
||
| public function getName(): string { | ||
| return self::TABLE_NAME; | ||
| } | ||
|
|
||
| public function getConfirmedOrderIdKey(): string { | ||
| return self::CONFIRMED_ORDER_ID_KEY; | ||
| } | ||
|
|
||
| public function getRecordingDurationMinutesKey(): string { | ||
| return self::RECORDING_DURATION_MINUTES_KEY; | ||
| } | ||
| } |
| @@ -0,0 +1,20 @@ | ||
| <?hh // strict | ||
|
|
||
| class OrderPricePolicyTable extends Table { | ||
|
|
||
| const string TABLE_NAME = "OrderPricePolicy"; | ||
| const string PRICE_KEY = "price"; | ||
| const string TIME_ENACTED_KEY = "timeEnacted"; | ||
|
|
||
| public function getName(): string { | ||
| return self::TABLE_NAME; | ||
| } | ||
|
|
||
| public function getPriceKey(): string { | ||
| return self::PRICE_KEY; | ||
| } | ||
|
|
||
| public function getTimeEnactedKey(): string { | ||
| return self::TIME_ENACTED_KEY; | ||
| } | ||
| } |
| @@ -0,0 +1,20 @@ | ||
| <?hh // strict | ||
|
|
||
| class VideoEditingPricePolicyTable extends Table { | ||
|
|
||
| const string TABLE_NAME = "VideoEditingPricePolicy"; | ||
| const string PRICE_KEY = "price"; | ||
| const string TIME_ENACTED_KEY = "timeEnacted"; | ||
|
|
||
| public function getName(): string { | ||
| return self::TABLE_NAME; | ||
| } | ||
|
|
||
| public function getPriceKey(): string { | ||
| return self::PRICE_KEY; | ||
| } | ||
|
|
||
| public function getTimeEnactedKey(): string { | ||
| return self::TIME_ENACTED_KEY; | ||
| } | ||
| } |
| @@ -0,0 +1,25 @@ | ||
| <?hh // strict | ||
|
|
||
| class VideoStoragePricePolicyTable extends Table { | ||
|
|
||
| const string TABLE_NAME = "VideoStoragePricePolicy"; | ||
| const string PRICE_KEY = "price"; | ||
| const string NUMBER_FREE_DAYS_KEY = "numberFreeDays"; | ||
| const string TIME_ENACTED_KEY = "timeEnacted"; | ||
|
|
||
| public function getName(): string { | ||
| return self::TABLE_NAME; | ||
| } | ||
|
|
||
| public function getPriceKey(): string { | ||
| return self::PRICE_KEY; | ||
| } | ||
|
|
||
| public function getNumberFreeDaysKey(): string { | ||
| return self::NUMBER_FREE_DAYS_KEY; | ||
| } | ||
|
|
||
| public function getTimeEnactedKey(): string { | ||
| return self::TIME_ENACTED_KEY; | ||
| } | ||
| } |
| @@ -1,8 +1,8 @@ | ||
| <?hh // strict | ||
|
|
||
| class ConfirmOrderApiRequestFactoryLazyLoader extends LazyLoader<ConfirmOrderApiRequestFactory> { | ||
|
|
||
| protected function make(): ConfirmOrderApiRequestFactory { | ||
| return new ConfirmOrderApiRequestFactory(); | ||
| } | ||
| } |
| @@ -0,0 +1,14 @@ | ||
| <?hh // strict | ||
|
|
||
| class EditedVideoOrderModelFactoryLazyLoader extends LazyLoader<ConcreteModelFactory<EditedVideoOrder>> { | ||
|
|
||
| public function __construct( | ||
| private EditedVideoOrderTableLazyLoader $editedVideoOrderTableLazyLoader, | ||
| ) {} | ||
|
|
||
| protected function make(): ConcreteModelFactory<EditedVideoOrder> { | ||
| return new EditedVideoOrderFactory( | ||
| $this->editedVideoOrderTableLazyLoader->load() | ||
| ); | ||
| } | ||
| } |
| @@ -0,0 +1,8 @@ | ||
| <?hh // strict | ||
|
|
||
| class EditedVideoOrderTableLazyLoader extends LazyLoader<EditedVideoOrderTable> { | ||
|
|
||
| protected function make(): EditedVideoOrderTable { | ||
| return new EditedVideoOrderTable(); | ||
| } | ||
| } |
| @@ -0,0 +1,21 @@ | ||
| <?hh // strict | ||
|
|
||
| class ComputePriceOfConfirmedOrderMethod { | ||
|
|
||
| public function __construct( | ||
| private FetchOrderPricePolicyQuery $fetchOrderPricePolicyQuery, | ||
| private FetchVideoEditingPricePolicyQuery $fetchVideoEditingPricePolicyQuery, | ||
| private FetchVideoStoragePricePolicyQuery $fetchVideoStoragePricePolicyQuery | ||
| ) {} | ||
|
|
||
| public function computePrice( | ||
| CreateConfirmOrderRequest $create_confirm_order_request | ||
| ): UnsignedFloat { | ||
| $price = 0; | ||
|
|
||
| // Fetch policies applicable to all common orders | ||
| $fetch_order_policy_handle = $this->fetchOrderPricePolicyQuery->fetch( | ||
|
|
||
| ); | ||
| } | ||
| } |
| @@ -0,0 +1,12 @@ | ||
| <?hh // strict | ||
|
|
||
| class CreateCellLabelRequest { | ||
|
|
||
| public function __construct( | ||
| private string $label | ||
| ) {} | ||
|
|
||
| public function getLabel(): string { | ||
| return $this->label; | ||
| } | ||
| } |
| @@ -0,0 +1,37 @@ | ||
| <?hh // strict | ||
|
|
||
| class CreateConfirmOrderRequest { | ||
|
|
||
| public function __construct( | ||
| private UnsignedInt $reservedOrderId, | ||
| private Timestamp $timeOrderMade, | ||
| private string $title, | ||
| private string $description, | ||
| private UnsignedInt $shortCodeId, | ||
| private ?CreateEditedVideoOrderRequest $editedVideoOrder | ||
| ) {} | ||
|
|
||
| public function getReserveOrderId(): UnsignedInt { | ||
| return $this->reservedOrderId; | ||
| } | ||
|
|
||
| public function getTimeOrderMade(): Timestamp { | ||
| return $this->timeOrderMade; | ||
| } | ||
|
|
||
| public function getTitle(): string { | ||
| return $this->title; | ||
| } | ||
|
|
||
| public function getDescription(): string { | ||
| return $this->description; | ||
| } | ||
|
|
||
| public function getShortCodeId(): UnsignedInt { | ||
| return $this->shortCodeId; | ||
| } | ||
|
|
||
| public function getCreateEditedVideoOrderRequest(): ?CreateEditedVideoOrderRequest { | ||
| return $this->editedVideoOrder; | ||
| } | ||
| } |
| @@ -0,0 +1,17 @@ | ||
| <?hh // strict | ||
|
|
||
| class CreateEditedVideoOrderRequest { | ||
|
|
||
| public function __construct( | ||
| private UnsignedInt $recordingDurationMinutes, | ||
| private ImmVector<CreateCellLabelRequest> $cellLabels | ||
| ) {} | ||
|
|
||
| public function getRecordingDurationMinutes(): UnsignedInt { | ||
| return $this->recordingDurationMinutes; | ||
| } | ||
|
|
||
| public function getCellLabels(): ImmVector<CreateCellLabelRequest> { | ||
| return $this->cellLabels; | ||
| } | ||
| } |
| @@ -1,6 +1,6 @@ | ||
| <?hh // strict | ||
|
|
||
| class ObjectVectorApiRequestField<Ttype> { | ||
|
|
||
| public function __construct( | ||
| private string $key, | ||
| @@ -0,0 +1,8 @@ | ||
| <?hh // strict | ||
|
|
||
| class CellLabelVectorApiRequestFieldFactoryBuilder extends ObjectVectorApiRequestFieldFactoryBuilder<CreateCellLabelApiRequest> { | ||
|
|
||
| public function __construct() { | ||
| parent::__construct(new CreateCellLabelApiRequestFactory()); | ||
| } | ||
| } |
| @@ -1,8 +1,8 @@ | ||
| <?hh // strict | ||
|
|
||
| class CreateCellLabelVectorApiRequestFieldFactoryBuilder extends ObjectVectorApiRequestFieldFactoryBuilder<CreateCellLabelApiRequest> { | ||
|
|
||
| public function __construct() { | ||
| parent::__construct(new CreateCellLabelApiRequestFactory()); | ||
| } | ||
| } |
| @@ -0,0 +1,40 @@ | ||
| <?hh // strict | ||
|
|
||
| class EditedVideoOrderApiRequestFactory implements RequestFactory<EditedVideoOrderApiRequest> { | ||
|
|
||
| private RequestFieldFactory<UnsignedInt> $recordingDurationFieldFactory; | ||
| private ObjectVectorApiRequestFieldFactory<CreateCellLabelApiRequest> $cellLabelsRequestFieldFactory; | ||
|
|
||
| public function __construct() { | ||
| $uint_field_factory_builder = new UnsignedIntRequestFieldFactoryBuilder(); | ||
|
|
||
| // Create recording duration field factory | ||
| $this->recordingDurationFieldFactory = $uint_field_factory_builder->build(); | ||
|
|
||
| // Create cell label request | ||
| $cell_label_vector_factory_builder = new CreateCellLabelVectorApiRequestFieldFactoryBuilder(); | ||
| $this->cellLabelsRequestFieldFactory = $cell_label_vector_factory_builder->build(); | ||
| } | ||
|
|
||
| public function make(ImmMap<string, mixed> $raw_field_map): EditedVideoOrderApiRequest { | ||
| $edited_order_request_builder = new EditedVideoOrderApiRequestBuilder(); | ||
| foreach ($raw_field_map as $key => $value) { | ||
| switch ($key) { | ||
| case EditedVideoOrderApiRequest::RECORDING_DURATION_KEY: | ||
| $edited_order_request_builder->setRecordingDurationMinutes( | ||
| $this->recordingDurationFieldFactory->make($key, $value) | ||
| ); | ||
| break; | ||
| case EditedVideoOrderApiRequest::CELL_LABEL_KEY: | ||
| $edited_order_request_builder->setCellLabels( | ||
| $this->cellLabelsRequestFieldFactory->make($key, $value) | ||
| ); | ||
| break; | ||
| default: | ||
| throw new UnexpectedRequestFieldKeyException(__CLASS__, $key); | ||
| break; | ||
| } | ||
| } | ||
| return $edited_order_request_builder->build(); | ||
| } | ||
| } |
| @@ -0,0 +1,90 @@ | ||
| <?hh // strict | ||
|
|
||
| class ConfirmOrderApiRequest { | ||
|
|
||
| const string REQUEST_OBJECT_NAME = "ConfirmOrderApiRequest"; | ||
|
|
||
| const string RSVD_ORDER_ID_KEY = 'rid'; | ||
| const string TITLE_KEY = 'title'; | ||
| const string DESCRIPTION_KEY = 'desc'; | ||
| const string SHORT_CODE_KEY = 'code-id'; | ||
| const string EDITED_VIDEO_ORDER_REQUEST = 'edited-video'; | ||
|
|
||
| public function __construct( | ||
| private RequestField<UnsignedInt> $rsvdOrderId, | ||
| private RequestField<string> $title, | ||
| private RequestField<string> $description, | ||
| private RequestField<UnsignedInt> $shortCodeId, | ||
| private ?EditedVideoOrderApiRequest $editedVideoOrder | ||
| ) {} | ||
|
|
||
| public function getRsvdOrderId(): RequestField<UnsignedInt> { | ||
| return $this->rsvdOrderId; | ||
| } | ||
|
|
||
| public function getTitle(): RequestField<string> { | ||
| return $this->title; | ||
| } | ||
|
|
||
| public function getDescription(): RequestField<string> { | ||
| return $this->description; | ||
| } | ||
|
|
||
| public function getShortCodeId(): RequestField<UnsignedInt> { | ||
| return $this->shortCodeId; | ||
| } | ||
|
|
||
| public function getEditedVideoOrderApiRequest(): ?EditedVideoOrderApiRequest { | ||
| return $this->editedVideoOrder; | ||
| } | ||
| } | ||
|
|
||
| class ConfirmOrderApiRequestBuilder { | ||
|
|
||
| private ?RequestField<UnsignedInt> $rsvdOrderId; | ||
| private ?RequestField<string> $title; | ||
| private ?RequestField<string> $description; | ||
| private ?RequestField<UnsignedInt> $shortCodeId; | ||
| private ?EditedVideoOrderApiRequest $editedVideoOrder; | ||
|
|
||
| public function setRsvdOrderId(RequestField<UnsignedInt> $rsvd_order_id): this { | ||
| $this->rsvdOrderId = $rsvd_order_id; | ||
| return $this; | ||
| } | ||
|
|
||
| public function setTitle(RequestField<string> $title): this { | ||
| $this->title = $title; | ||
| return $this; | ||
| } | ||
|
|
||
| public function setDescription(RequestField<string> $description): this { | ||
| $this->description = $description; | ||
| return $this; | ||
| } | ||
|
|
||
| public function setShortCodeId(RequestField<UnsignedInt> $short_code_id): this { | ||
| $this->shortCodeId = $short_code_id; | ||
| return $this; | ||
| } | ||
|
|
||
| private function checkNotNull<T>(?T $field, string $key): T { | ||
| if ($field === null) { | ||
| throw new UnsetRequestFieldException( | ||
| ConfirmOrderApiRequest::REQUEST_OBJECT_NAME, | ||
| $key | ||
| ); | ||
| } | ||
| return $field; | ||
| } | ||
|
|
||
| public function build(): ConfirmOrderApiRequest { | ||
| // Extrude request object and ensure fields are not null | ||
| return new ConfirmOrderApiRequest( | ||
| $this->checkNotNull($this->rsvdOrderId, ConfirmOrderApiRequest::RSVD_ORDER_ID_KEY), | ||
| $this->checkNotNull($this->title, ConfirmOrderApiRequest::TITLE_KEY), | ||
| $this->checkNotNull($this->description, ConfirmOrderApiRequest::DESCRIPTION_KEY), | ||
| $this->checkNotNull($this->shortCodeId, ConfirmOrderApiRequest::SHORT_CODE_KEY), | ||
| $this->editedVideoOrder | ||
| ); | ||
| } | ||
| } |
| @@ -0,0 +1,64 @@ | ||
| <?hh // strict | ||
|
|
||
| class EditedVideoOrderApiRequest { | ||
|
|
||
| const string REQUEST_OBJECT_NAME = "EditedVideoOrderApiRequest"; | ||
| const string RECORDING_DURATION_KEY = "recordingDurationMinutes"; | ||
| const string CELL_LABEL_KEY = "labels"; | ||
|
|
||
| public function __construct( | ||
| private RequestField<UnsignedInt> $recordingDurationMinutes, | ||
| private ObjectVectorApiRequestField<CreateCellLabelApiRequest> $cellLabels | ||
| ) {} | ||
|
|
||
| public function getRecordingDurationMinutes(): RequestField<UnsignedInt> { | ||
| return $this->recordingDurationMinutes; | ||
| } | ||
|
|
||
| public function getCellLabels(): ObjectVectorApiRequestField<CreateCellLabelApiRequest> { | ||
| return $this->cellLabels; | ||
| } | ||
| } | ||
|
|
||
| class EditedVideoOrderApiRequestBuilder { | ||
|
|
||
| private ?RequestField<UnsignedInt> $recordingDurationMinutes; | ||
| private ?ObjectVectorApiRequestField<CreateCellLabelApiRequest> $cellLabels; | ||
|
|
||
| public function setRecordingDurationMinutes( | ||
| RequestField<UnsignedInt> $recording_duration | ||
| ): this { | ||
| $this->recordingDurationMinutes = $recording_duration; | ||
| return $this; | ||
| } | ||
|
|
||
| public function setCellLabels( | ||
| ObjectVectorApiRequestField<CreateCellLabelApiRequest> $cell_labels | ||
| ): this { | ||
| $this->cellLabels = $cell_labels; | ||
| return $this; | ||
| } | ||
|
|
||
| private function checkNotNull<T>(?T $field, string $key): T { | ||
| if ($field === null) { | ||
| throw new UnsetRequestFieldException( | ||
| EditedVideoOrderApiRequest::REQUEST_OBJECT_NAME, | ||
| $key | ||
| ); | ||
| } | ||
| return $field; | ||
| } | ||
|
|
||
| public function build(): EditedVideoOrderApiRequest { | ||
| return new EditedVideoOrderApiRequest( | ||
| $this->checkNotNull( | ||
| $this->recordingDurationMinutes, | ||
| EditedVideoOrderApiRequest::RECORDING_DURATION_KEY | ||
| ), | ||
| $this->checkNotNull( | ||
| $this->cellLabels, | ||
| EditedVideoOrderApiRequest::CELL_LABEL_KEY | ||
| ) | ||
| ); | ||
| } | ||
| } |
| @@ -0,0 +1,14 @@ | ||
| <?hh // strict | ||
|
|
||
| class UnsignedFloat { | ||
|
|
||
| public function __construct( | ||
| private float $number | ||
| ) { | ||
| invariant($this->number >= 0, "Must be non-negative!"); | ||
| } | ||
|
|
||
| public function getNumber(): float { | ||
| return $this->number; | ||
| } | ||
| } |
| @@ -0,0 +1,6 @@ | ||
| /** | ||
| * Order configuration table creation | ||
| */ | ||
| CREATE TABLE OrderConfiguration ( | ||
| scopesCount INT UNSIGNED NOT NULL | ||
| ); |
| @@ -0,0 +1,8 @@ | ||
| /** | ||
| * OrderPricePolicy table creation | ||
| * - price: price per group of 4 scopes per hour | ||
| */ | ||
| CREATE TABLE OrderPricePolicy ( | ||
| price FLOAT UNSIGNED NOT NULL, | ||
| timeEnacted TIMESTAMP NOT NULL | ||
| ); |
| @@ -19,4 +19,3 @@ CREATE TABLE BasicVideos ( | ||
| UNIQUE KEY(confirmedOrderId, scopeIndex), | ||
| expirationTime TIMESTAMP NOT NULL | ||
| ); | ||
| @@ -0,0 +1,8 @@ | ||
| /** | ||
| * VideoEditingPricePolicy table creation | ||
| * - TODO: decide how to price this... | ||
| */ | ||
| CREATE TABLE VideoEditingPricePolicy ( | ||
| price FLOAT UNSIGNED NOT NULL, | ||
| timeEnacted TIMESTAMP NOT NULL | ||
| ); |
| @@ -0,0 +1,9 @@ | ||
| /** | ||
| * VideoStoragePricePolicy table creation | ||
| * - price: price per Gb per day | ||
| */ | ||
| CREATE TABLE VideoStoragePricePolicy ( | ||
| price FLOAT UNSIGNED NOT NULL, | ||
| numberFreeDays INT UNSIGNED NOT NULL, | ||
| timeEnacted TIMESTAMP NOT NULL | ||
| ); |