##
#    This code was generated by
#    ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
#     |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
#     |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
#
#    Twilio - Messaging
#    This is the public Twilio REST API.
#
#    NOTE: This class is auto generated by OpenAPI Generator.
#    https://openapi-generator.tech
#    Do not edit the class manually.
#


module Twilio
    module REST
        class Messaging < MessagingBase
            class V1 < Version
                class DomainConfigList < ListResource
                
                    ##
                    # Initialize the DomainConfigList
                    # @param [Version] version Version that contains the resource
                    # @return [DomainConfigList] DomainConfigList
                    def initialize(version)
                        super(version)
                        # Path Solution
                        @solution = {  }
                        
                        
                    end
                


                    # Provide a user friendly representation
                    def to_s
                        '#<Twilio.Messaging.V1.DomainConfigList>'
                    end
                end


                class DomainConfigContext < InstanceContext
                    ##
                    # Initialize the DomainConfigContext
                    # @param [Version] version Version that contains the resource
                    # @param [String] domain_sid Unique string used to identify the domain that this config should be associated with.
                    # @return [DomainConfigContext] DomainConfigContext
                    def initialize(version, domain_sid)
                        super(version)

                        # Path Solution
                        @solution = { domain_sid: domain_sid,  }
                        @uri = "/LinkShortening/Domains/#{@solution[:domain_sid]}/Config"

                        
                    end
                    ##
                    # Fetch the DomainConfigInstance
                    # @return [DomainConfigInstance] Fetched DomainConfigInstance
                    def fetch

                        headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
                        
                        
                        
                        
                        
                        payload = @version.fetch('GET', @uri, headers: headers)
                        DomainConfigInstance.new(
                            @version,
                            payload,
                            domain_sid: @solution[:domain_sid],
                        )
                    end

                    ##
                    # Update the DomainConfigInstance
                    # @param [String] fallback_url Any requests we receive to this domain that do not match an existing shortened message will be redirected to the fallback url. These will likely be either expired messages, random misdirected traffic, or intentional scraping.
                    # @param [String] callback_url URL to receive click events to your webhook whenever the recipients click on the shortened links
                    # @param [Boolean] continue_on_failure Boolean field to set customer delivery preference when there is a failure in linkShortening service
                    # @param [Boolean] disable_https Customer's choice to send links with/without \\\"https://\\\" attached to shortened url. If true, messages will not be sent with https:// at the beginning of the url. If false, messages will be sent with https:// at the beginning of the url. False is the default behavior if it is not specified.
                    # @return [DomainConfigInstance] Updated DomainConfigInstance
                    def update(
                        fallback_url: :unset, 
                        callback_url: :unset, 
                        continue_on_failure: :unset, 
                        disable_https: :unset
                    )

                        data = Twilio::Values.of({
                            'FallbackUrl' => fallback_url,
                            'CallbackUrl' => callback_url,
                            'ContinueOnFailure' => continue_on_failure,
                            'DisableHttps' => disable_https,
                        })

                        headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
                        
                        
                        
                        
                        
                        payload = @version.update('POST', @uri, data: data, headers: headers)
                        DomainConfigInstance.new(
                            @version,
                            payload,
                            domain_sid: @solution[:domain_sid],
                        )
                    end


                    ##
                    # Provide a user friendly representation
                    def to_s
                        context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
                        "#<Twilio.Messaging.V1.DomainConfigContext #{context}>"
                    end

                    ##
                    # Provide a detailed, user friendly representation
                    def inspect
                        context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
                        "#<Twilio.Messaging.V1.DomainConfigContext #{context}>"
                    end
                end

                class DomainConfigPage < Page
                    ##
                    # Initialize the DomainConfigPage
                    # @param [Version] version Version that contains the resource
                    # @param [Response] response Response from the API
                    # @param [Hash] solution Path solution for the resource
                    # @return [DomainConfigPage] DomainConfigPage
                    def initialize(version, response, solution)
                        super(version, response)

                        # Path Solution
                        @solution = solution
                    end

                    ##
                    # Build an instance of DomainConfigInstance
                    # @param [Hash] payload Payload response from the API
                    # @return [DomainConfigInstance] DomainConfigInstance
                    def get_instance(payload)
                        DomainConfigInstance.new(@version, payload)
                    end

                    ##
                    # Provide a user friendly representation
                    def to_s
                        '<Twilio.Messaging.V1.DomainConfigPage>'
                    end
                end
                class DomainConfigInstance < InstanceResource
                    ##
                    # Initialize the DomainConfigInstance
                    # @param [Version] version Version that contains the resource
                    # @param [Hash] payload payload that contains response from Twilio
                    # @param [String] account_sid The SID of the
                    #   {Account}[https://www.twilio.com/docs/iam/api/account] that created this DomainConfig
                    #   resource.
                    # @param [String] sid The SID of the Call resource to fetch.
                    # @return [DomainConfigInstance] DomainConfigInstance
                    def initialize(version, payload , domain_sid: nil)
                        super(version)
                        
                        # Marshaled Properties
                        @properties = { 
                            'domain_sid' => payload['domain_sid'],
                            'config_sid' => payload['config_sid'],
                            'fallback_url' => payload['fallback_url'],
                            'callback_url' => payload['callback_url'],
                            'continue_on_failure' => payload['continue_on_failure'],
                            'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
                            'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
                            'url' => payload['url'],
                            'disable_https' => payload['disable_https'],
                        }

                        # Context
                        @instance_context = nil
                        @params = { 'domain_sid' => domain_sid  || @properties['domain_sid']  , }
                    end

                    ##
                    # Generate an instance context for the instance, the context is capable of
                    # performing various actions.  All instance actions are proxied to the context
                    # @return [DomainConfigContext] CallContext for this CallInstance
                    def context
                        unless @instance_context
                            @instance_context = DomainConfigContext.new(@version , @params['domain_sid'])
                        end
                        @instance_context
                    end
                    
                    ##
                    # @return [String] The unique string that we created to identify the Domain resource.
                    def domain_sid
                        @properties['domain_sid']
                    end
                    
                    ##
                    # @return [String] The unique string that we created to identify the Domain config (prefix ZK).
                    def config_sid
                        @properties['config_sid']
                    end
                    
                    ##
                    # @return [String] Any requests we receive to this domain that do not match an existing shortened message will be redirected to the fallback url. These will likely be either expired messages, random misdirected traffic, or intentional scraping.
                    def fallback_url
                        @properties['fallback_url']
                    end
                    
                    ##
                    # @return [String] URL to receive click events to your webhook whenever the recipients click on the shortened links.
                    def callback_url
                        @properties['callback_url']
                    end
                    
                    ##
                    # @return [Boolean] Boolean field to set customer delivery preference when there is a failure in linkShortening service
                    def continue_on_failure
                        @properties['continue_on_failure']
                    end
                    
                    ##
                    # @return [Time] Date this Domain Config was created.
                    def date_created
                        @properties['date_created']
                    end
                    
                    ##
                    # @return [Time] Date that this Domain Config was last updated.
                    def date_updated
                        @properties['date_updated']
                    end
                    
                    ##
                    # @return [String] 
                    def url
                        @properties['url']
                    end
                    
                    ##
                    # @return [Boolean] Customer's choice to send links with/without \"https://\" attached to shortened url. If true, messages will not be sent with https:// at the beginning of the url. If false, messages will be sent with https:// at the beginning of the url. False is the default behavior if it is not specified.
                    def disable_https
                        @properties['disable_https']
                    end
                    
                    ##
                    # Fetch the DomainConfigInstance
                    # @return [DomainConfigInstance] Fetched DomainConfigInstance
                    def fetch

                        context.fetch
                    end

                    ##
                    # Update the DomainConfigInstance
                    # @param [String] fallback_url Any requests we receive to this domain that do not match an existing shortened message will be redirected to the fallback url. These will likely be either expired messages, random misdirected traffic, or intentional scraping.
                    # @param [String] callback_url URL to receive click events to your webhook whenever the recipients click on the shortened links
                    # @param [Boolean] continue_on_failure Boolean field to set customer delivery preference when there is a failure in linkShortening service
                    # @param [Boolean] disable_https Customer's choice to send links with/without \\\"https://\\\" attached to shortened url. If true, messages will not be sent with https:// at the beginning of the url. If false, messages will be sent with https:// at the beginning of the url. False is the default behavior if it is not specified.
                    # @return [DomainConfigInstance] Updated DomainConfigInstance
                    def update(
                        fallback_url: :unset, 
                        callback_url: :unset, 
                        continue_on_failure: :unset, 
                        disable_https: :unset
                    )

                        context.update(
                            fallback_url: fallback_url, 
                            callback_url: callback_url, 
                            continue_on_failure: continue_on_failure, 
                            disable_https: disable_https, 
                        )
                    end

                    ##
                    # Provide a user friendly representation
                    def to_s
                        values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
                        "<Twilio.Messaging.V1.DomainConfigInstance #{values}>"
                    end

                    ##
                    # Provide a detailed, user friendly representation
                    def inspect
                        values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
                        "<Twilio.Messaging.V1.DomainConfigInstance #{values}>"
                    end
                end

            end
        end
    end
end
