mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-18 02:05:36 +00:00
feat: ovh api conditions checkbox
This commit is contained in:
parent
5b8e4e43c4
commit
6b2beadc9c
@ -1,4 +1,4 @@
|
||||
import {Button, Form, FormInstance, Input, Select, Space, Typography} from "antd";
|
||||
import {Button, Checkbox, Form, FormInstance, Input, Select, Space, Typography} from "antd";
|
||||
import React, {useState} from "react";
|
||||
import {Connector, ConnectorProvider} from "../../utils/api/connectors";
|
||||
import {t} from "ttag";
|
||||
@ -106,6 +106,33 @@ export function ConnectorForm({form, onCreate}: { form: FormInstance, onCreate:
|
||||
>
|
||||
<Select options={ovhPricingMode} optionFilterProp="label"/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
valuePropName="checked"
|
||||
label={t`TOS`}
|
||||
name={['authData', 'acceptConditions']}
|
||||
rules={[{required: true, message: t`Required`}]}
|
||||
>
|
||||
<Checkbox
|
||||
required={true}>{t`I accept the terms of use of the OVH provider API and those of Domain Watchdog`}</Checkbox>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
valuePropName="checked"
|
||||
label={t`Legal age`}
|
||||
name={['authData', 'ownerLegalAge']}
|
||||
rules={[{required: true, message: t`Required`}]}
|
||||
>
|
||||
<Checkbox
|
||||
required={true}>{t`I certify on my honor that I am of the minimum age required to consent to these conditions`}</Checkbox>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
valuePropName="checked"
|
||||
label={t`Withdrawal period`}
|
||||
name={['authData', 'waiveRetractationPeriod']}
|
||||
rules={[{required: true, message: t`Required`}]}
|
||||
>
|
||||
<Checkbox
|
||||
required={true}>{t`I expressly waive my right of withdrawal concerning the purchase of domain names via the OVH API`}</Checkbox>
|
||||
</Form.Item>
|
||||
</>
|
||||
}
|
||||
|
||||
|
||||
@ -8,10 +8,5 @@ interface ConnectorInterface
|
||||
{
|
||||
public static function verifyAuthData(array $authData): array;
|
||||
|
||||
public function orderDomain(Domain $domain,
|
||||
bool $acceptConditions,
|
||||
bool $ownerLegalAge,
|
||||
bool $waiveRetractationPeriod,
|
||||
bool $dryRun
|
||||
): void;
|
||||
public function orderDomain(Domain $domain, bool $dryRun): void;
|
||||
}
|
||||
@ -19,11 +19,7 @@ readonly class OvhConnector implements ConnectorInterface
|
||||
* Order a domain name with the OVH API
|
||||
* @throws Exception
|
||||
*/
|
||||
public function orderDomain(Domain $domain,
|
||||
bool $acceptConditions,
|
||||
bool $ownerLegalAge,
|
||||
bool $waiveRetractationPeriod,
|
||||
bool $dryRun = false
|
||||
public function orderDomain(Domain $domain, bool $dryRun = false
|
||||
): void
|
||||
{
|
||||
if (!$domain->getDeleted()) throw new Exception('The domain name still appears in the WHOIS database');
|
||||
@ -33,22 +29,19 @@ readonly class OvhConnector implements ConnectorInterface
|
||||
|
||||
$authData = self::verifyAuthData($this->authData);
|
||||
|
||||
$appKey = $authData['appKey'];
|
||||
$appSecret = $authData['appSecret'];
|
||||
$apiEndpoint = $authData['apiEndpoint'];
|
||||
$consumerKey = $authData['consumerKey'];
|
||||
$ovhSubsidiary = $authData['ovhSubsidiary'];
|
||||
$pricingMode = $authData['pricingMode'];
|
||||
$acceptConditions = $authData['acceptConditions'];
|
||||
$ownerLegalAge = $authData['ownerLegalAge'];
|
||||
$waiveRetractationPeriod = $authData['waiveRetractationPeriod'];
|
||||
|
||||
$conn = new Api(
|
||||
$appKey,
|
||||
$appSecret,
|
||||
$apiEndpoint,
|
||||
$consumerKey
|
||||
$authData['appKey'],
|
||||
$authData['appSecret'],
|
||||
$authData['apiEndpoint'],
|
||||
$authData['consumerKey']
|
||||
);
|
||||
|
||||
$cart = $conn->post('/order/cart', [
|
||||
"ovhSubsidiary" => $ovhSubsidiary,
|
||||
"ovhSubsidiary" => $authData['ovhSubsidiary'],
|
||||
"description" => "Domain Watchdog"
|
||||
]);
|
||||
$cartId = $cart['cartId'];
|
||||
@ -58,7 +51,7 @@ readonly class OvhConnector implements ConnectorInterface
|
||||
]);
|
||||
$offer = array_filter($offers, fn($offer) => $offer['action'] === 'create' &&
|
||||
$offer['orderable'] === true &&
|
||||
$offer['pricingMode'] === $pricingMode
|
||||
$offer['pricingMode'] === $authData['pricingMode']
|
||||
);
|
||||
if (empty($offer)) {
|
||||
$conn->delete("/order/cart/{$cartId}");
|
||||
@ -109,12 +102,21 @@ readonly class OvhConnector implements ConnectorInterface
|
||||
$ovhSubsidiary = $authData['ovhSubsidiary'];
|
||||
$pricingMode = $authData['pricingMode'];
|
||||
|
||||
$acceptConditions = $authData['acceptConditions'];
|
||||
$ownerLegalAge = $authData['ownerLegalAge'];
|
||||
$waiveRetractationPeriod = $authData['waiveRetractationPeriod'];
|
||||
|
||||
if (!is_string($appKey) || empty($appKey) ||
|
||||
!is_string($appSecret) || empty($appSecret) ||
|
||||
!is_string($consumerKey) || empty($consumerKey) ||
|
||||
!is_string($apiEndpoint) || empty($apiEndpoint) ||
|
||||
!is_string($ovhSubsidiary) || empty($ovhSubsidiary) ||
|
||||
!is_string($pricingMode) || empty($pricingMode)
|
||||
!is_string($pricingMode) || empty($pricingMode) ||
|
||||
|
||||
true !== $acceptConditions ||
|
||||
true !== $ownerLegalAge ||
|
||||
true !== $waiveRetractationPeriod
|
||||
|
||||
) throw new Exception("Bad authData schema");
|
||||
|
||||
$conn = new Api(
|
||||
@ -137,7 +139,10 @@ readonly class OvhConnector implements ConnectorInterface
|
||||
"apiEndpoint" => $apiEndpoint,
|
||||
"consumerKey" => $consumerKey,
|
||||
"ovhSubsidiary" => $ovhSubsidiary,
|
||||
"pricingMode" => $pricingMode
|
||||
"pricingMode" => $pricingMode,
|
||||
"acceptConditions" => $acceptConditions,
|
||||
"ownerLegalAge" => $ownerLegalAge,
|
||||
"waiveRetractationPeriod" => $waiveRetractationPeriod
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -53,6 +53,9 @@ msgstr ""
|
||||
#: assets/components/tracking/ConnectorForm.tsx:90
|
||||
#: assets/components/tracking/ConnectorForm.tsx:97
|
||||
#: assets/components/tracking/ConnectorForm.tsx:105
|
||||
#: assets/components/tracking/ConnectorForm.tsx:113
|
||||
#: assets/components/tracking/ConnectorForm.tsx:122
|
||||
#: assets/components/tracking/ConnectorForm.tsx:131
|
||||
#: assets/components/tracking/WatchlistForm.tsx:115
|
||||
#: assets/components/tracking/WatchlistForm.tsx:174
|
||||
#: assets/components/tracking/WatchlistForm.tsx:184
|
||||
@ -196,12 +199,12 @@ msgstr ""
|
||||
msgid "Add a Trigger"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/tracking/ConnectorForm.tsx:116
|
||||
#: assets/components/tracking/ConnectorForm.tsx:143
|
||||
#: assets/components/tracking/WatchlistForm.tsx:237
|
||||
msgid "Create"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/tracking/ConnectorForm.tsx:119
|
||||
#: assets/components/tracking/ConnectorForm.tsx:146
|
||||
#: assets/components/tracking/WatchlistForm.tsx:240
|
||||
msgid "Reset"
|
||||
msgstr ""
|
||||
@ -261,6 +264,37 @@ msgstr ""
|
||||
msgid "OVH pricing mode"
|
||||
msgstr ""
|
||||
|
||||
#: assets/App.tsx:164
|
||||
#: assets/components/tracking/ConnectorForm.tsx:111
|
||||
msgid "TOS"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/tracking/ConnectorForm.tsx:116
|
||||
msgid ""
|
||||
"I accept the terms of use of the OVH provider API and those of Domain "
|
||||
"Watchdog"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/tracking/ConnectorForm.tsx:120
|
||||
msgid "Legal age"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/tracking/ConnectorForm.tsx:125
|
||||
msgid ""
|
||||
"I certify on my honor that I am of the minimum age required to consent to "
|
||||
"these conditions"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/tracking/ConnectorForm.tsx:129
|
||||
msgid "Withdrawal period"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/tracking/ConnectorForm.tsx:134
|
||||
msgid ""
|
||||
"I expressly waive my right of withdrawal concerning the purchase of domain "
|
||||
"names via the OVH API"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/tracking/WatchlistsList.tsx:14
|
||||
#, javascript-format
|
||||
msgid "Watchlist ${ watchlist.token }"
|
||||
@ -529,10 +563,6 @@ msgstr ""
|
||||
msgid "My Watchdog"
|
||||
msgstr ""
|
||||
|
||||
#: assets/App.tsx:164
|
||||
msgid "TOS"
|
||||
msgstr ""
|
||||
|
||||
#: assets/App.tsx:170
|
||||
msgid "Privacy Policy"
|
||||
msgstr ""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user