flexible-shipping
/
vendor_prefixed
/
octolize
/
wp-octolize-docs-chat
/
src
/
Chat
/
ConsentSettings.php
flexible-shipping
/
vendor_prefixed
/
octolize
/
wp-octolize-docs-chat
/
src
/
Chat
Last commit date
views
2 weeks ago
AjaxChatSettings.php
2 weeks ago
Assets.php
2 weeks ago
ChatContainer.php
2 weeks ago
ChatSettings.php
2 weeks ago
ChatSettingsProvider.php
2 weeks ago
ConsentSettings.php
2 weeks ago
DocsChat.php
2 weeks ago
HookableChatObjects.php
2 weeks ago
ConsentSettings.php
80 lines
| 1 | <?php |
| 2 | |
| 3 | declare (strict_types=1); |
| 4 | namespace FSVendor\Octolize\Docs\Chat; |
| 5 | |
| 6 | /** |
| 7 | * Configures the consent dialog displayed before the chat starts. |
| 8 | */ |
| 9 | final class ConsentSettings |
| 10 | { |
| 11 | private const TITLE = 'title'; |
| 12 | private const MESSAGE = 'message'; |
| 13 | private const ACCEPT = 'accept'; |
| 14 | private const DECLINE = 'decline'; |
| 15 | private const PRIVACY_POLICY_URL = 'privacy_policy_url'; |
| 16 | private const PRIVACY_LINK_LABEL = 'privacy_link_label'; |
| 17 | private const SUPPORT_URL = 'support_url'; |
| 18 | private const SUPPORT_TEXT = 'support_text'; |
| 19 | private const SUPPORT_LINK_LABEL = 'support_link_label'; |
| 20 | /** @var array<string, mixed> */ |
| 21 | private array $settings = []; |
| 22 | /** |
| 23 | * Creates consent settings from the legacy array configuration. |
| 24 | * |
| 25 | * @param array<string, mixed> $settings Consent settings. |
| 26 | */ |
| 27 | public static function from_array(array $settings): self |
| 28 | { |
| 29 | $consent_settings = new self(); |
| 30 | $consent_settings->settings = $settings; |
| 31 | return $consent_settings; |
| 32 | } |
| 33 | public function set_title(string $title): void |
| 34 | { |
| 35 | $this->settings[self::TITLE] = $title; |
| 36 | } |
| 37 | public function set_message(string $message): void |
| 38 | { |
| 39 | $this->settings[self::MESSAGE] = $message; |
| 40 | } |
| 41 | public function set_accept(string $accept): void |
| 42 | { |
| 43 | $this->settings[self::ACCEPT] = $accept; |
| 44 | } |
| 45 | public function set_decline(string $decline): void |
| 46 | { |
| 47 | $this->settings[self::DECLINE] = $decline; |
| 48 | } |
| 49 | public function set_privacy_policy_url(string $privacy_policy_url): void |
| 50 | { |
| 51 | $this->settings[self::PRIVACY_POLICY_URL] = $privacy_policy_url; |
| 52 | } |
| 53 | public function set_privacy_link_label(string $privacy_link_label): void |
| 54 | { |
| 55 | $this->settings[self::PRIVACY_LINK_LABEL] = $privacy_link_label; |
| 56 | } |
| 57 | public function set_support_url(string $support_url): void |
| 58 | { |
| 59 | $this->settings[self::SUPPORT_URL] = $support_url; |
| 60 | } |
| 61 | public function set_support_text(string $support_text): void |
| 62 | { |
| 63 | $this->settings[self::SUPPORT_TEXT] = $support_text; |
| 64 | } |
| 65 | public function set_support_link_label(string $support_link_label): void |
| 66 | { |
| 67 | $this->settings[self::SUPPORT_LINK_LABEL] = $support_link_label; |
| 68 | } |
| 69 | /** @return array<string, mixed> */ |
| 70 | public function to_array(): array |
| 71 | { |
| 72 | return array_merge($this->default_settings(), $this->settings); |
| 73 | } |
| 74 | /** @return array<string, string> */ |
| 75 | private function default_settings(): array |
| 76 | { |
| 77 | return [self::TITLE => __('Do you consent to sending data to the chat?', 'flexible-shipping'), self::MESSAGE => __('To start the chat, we need to send your inputs and technical data to the chat service. Read more in our Privacy Policy.', 'flexible-shipping'), self::ACCEPT => __('Accept', 'flexible-shipping'), self::DECLINE => __('Decline', 'flexible-shipping'), self::PRIVACY_POLICY_URL => 'https://octolize.com/terms-of-service/privacy-policy/', self::PRIVACY_LINK_LABEL => __('Privacy Policy', 'flexible-shipping'), self::SUPPORT_URL => 'https://octolize.com/support/', self::SUPPORT_TEXT => __('If you don’t want to give consent, you can contact our support using this form:', 'flexible-shipping'), self::SUPPORT_LINK_LABEL => __('Support form', 'flexible-shipping')]; |
| 78 | } |
| 79 | } |
| 80 |