<?php
/**
 * This code was generated by
 * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
 *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
 *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
 *
 * Twilio Memory API
 * APIs for managing memory stores, profiles, events, and conversational intelligence capabilities.
 *
 * NOTE: This class is auto generated by OpenAPI Generator.
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace Twilio\Rest\Memory\V1;

use Twilio\Values;
abstract class IdentityResolutionSettingModels
{
    /**
     * @property string $idType Name of the identifier type. Usual values are email, phone, external_id etc.
     * @property string $matchingAlgo The algorithm to use for matching identifier values.    - `exact`, exact string match.   - `fuzzy`, low precision match allowing for some variations.
     * @property int $matchingThreshold The `fuzzy` matching threshold percentage.
     * @property int $limit Maximum number of historical values to retain.
     * @property string $limitPolicy Removal policy to apply when the number of values exceeds the limit and is based on the timestamp of the request when the identifier was added. - `fifo`: First In First Out, removes the oldest values first. - `lifo`: Last In First Out, removes the most recent values first.
     * @property bool $enforceUnique When enabled, more than one profile may not share the same identifier value. Adding a shared identifier to a second profile may trigger a merge. Disabling creates a compound identifier where merges are only triggered if two or more identifiers satisfy a matching rule.
     * @property string $normalization Normalization to apply to the identifier value before storing and matching. - `phone`: Normalize phone numbers to E.164 format. - `email`: Normalize email addresses by coverting to lowercase and removing spaces. - `trim`: Removes spaces from both ends of the string. - `none`: No normalization.  **Important Note for Phone Number Normalization:** When using the `phone` normalization option, please adhere to the following guidelines to ensure proper formatting: - All US numbers must be at least valid 10 digit phone numbers with area code. They may also include or omit the \"+1\" prefix. - Non-US numbers must include a 1-3 digit country code (a \"+\" prefix is optional). Non-US national formats are not supported and will be interpreted as US numbers.
    */
    public static function createIdentifierConfig(array $payload = []): IdentifierConfig
    {
        return new IdentifierConfig($payload);
    }

    /**
     * @property IdentifierConfig[] $identifierConfigs List of identifier types and their resolution settings.
     * @property string[] $matchingRules Priority list of identifiers to locate profiles to apply new data to, or for  determining if two existing profiles should merge. Rules are evaluated in order. - If no rule matches against existing profiles, a new profile will be created.  - If a rule matches to a single existing profile, the profile will be updated.  - If a rule matches to multiple existing profiles, those existing profiles will be merged.
    */
    public static function createIdentityResolutionSettingsCore(array $payload = []): IdentityResolutionSettingsCore
    {
        return new IdentityResolutionSettingsCore($payload);
    }

}

class IdentifierConfig implements \JsonSerializable
{
    /**
     * @property string $idType Name of the identifier type. Usual values are email, phone, external_id etc.
     * @property string $matchingAlgo The algorithm to use for matching identifier values.    - `exact`, exact string match.   - `fuzzy`, low precision match allowing for some variations.
     * @property int $matchingThreshold The `fuzzy` matching threshold percentage.
     * @property int $limit Maximum number of historical values to retain.
     * @property string $limitPolicy Removal policy to apply when the number of values exceeds the limit and is based on the timestamp of the request when the identifier was added. - `fifo`: First In First Out, removes the oldest values first. - `lifo`: Last In First Out, removes the most recent values first.
     * @property bool $enforceUnique When enabled, more than one profile may not share the same identifier value. Adding a shared identifier to a second profile may trigger a merge. Disabling creates a compound identifier where merges are only triggered if two or more identifiers satisfy a matching rule.
     * @property string $normalization Normalization to apply to the identifier value before storing and matching. - `phone`: Normalize phone numbers to E.164 format. - `email`: Normalize email addresses by coverting to lowercase and removing spaces. - `trim`: Removes spaces from both ends of the string. - `none`: No normalization.  **Important Note for Phone Number Normalization:** When using the `phone` normalization option, please adhere to the following guidelines to ensure proper formatting: - All US numbers must be at least valid 10 digit phone numbers with area code. They may also include or omit the \"+1\" prefix. - Non-US numbers must include a 1-3 digit country code (a \"+\" prefix is optional). Non-US national formats are not supported and will be interpreted as US numbers.
    */
        protected $idType;
        protected $matchingAlgo;
        protected $matchingThreshold;
        protected $limit;
        protected $limitPolicy;
        protected $enforceUnique;
        protected $normalization;
    public function __construct(array $payload = []) {
        $this->idType = Values::array_get($payload, 'idType');
        $this->matchingAlgo = Values::array_get($payload, 'matchingAlgo');
        $this->matchingThreshold = Values::array_get($payload, 'matchingThreshold');
        $this->limit = Values::array_get($payload, 'limit');
        $this->limitPolicy = Values::array_get($payload, 'limitPolicy');
        $this->enforceUnique = Values::array_get($payload, 'enforceUnique');
        $this->normalization = Values::array_get($payload, 'normalization');
    }

    public function toArray(): array
    {
        return $this->jsonSerialize();
    }

    public function jsonSerialize(): array
    {
        $jsonString = [
            'idType' => $this->idType
        ];
        if (isset($this->matchingAlgo)) {
            $jsonString['matchingAlgo'] = $this->matchingAlgo;
        }
        if (isset($this->matchingThreshold)) {
            $jsonString['matchingThreshold'] = $this->matchingThreshold;
        }
        if (isset($this->limit)) {
            $jsonString['limit'] = $this->limit;
        }
        if (isset($this->limitPolicy)) {
            $jsonString['limitPolicy'] = $this->limitPolicy;
        }
        if (isset($this->enforceUnique)) {
            $jsonString['enforceUnique'] = $this->enforceUnique;
        }
        if (isset($this->normalization)) {
            $jsonString['normalization'] = $this->normalization;
        }
        return $jsonString;
    }
}

class IdentityResolutionSettingsCore implements \JsonSerializable
{
    /**
     * @property IdentifierConfig[] $identifierConfigs List of identifier types and their resolution settings.
     * @property string[] $matchingRules Priority list of identifiers to locate profiles to apply new data to, or for  determining if two existing profiles should merge. Rules are evaluated in order. - If no rule matches against existing profiles, a new profile will be created.  - If a rule matches to a single existing profile, the profile will be updated.  - If a rule matches to multiple existing profiles, those existing profiles will be merged.
    */
        protected $identifierConfigs;
        protected $matchingRules;
    public function __construct(array $payload = []) {
        $this->identifierConfigs = Values::array_get($payload, 'identifierConfigs');
        $this->matchingRules = Values::array_get($payload, 'matchingRules');
    }

    public function toArray(): array
    {
        return $this->jsonSerialize();
    }

    public function jsonSerialize(): array
    {
        $jsonString = [
        ];
        if (isset($this->identifierConfigs)) {
            $jsonString['identifierConfigs'] = $this->identifierConfigs;
        }
        if (isset($this->matchingRules)) {
            $jsonString['matchingRules'] = $this->matchingRules;
        }
        return $jsonString;
    }
}

