##
#    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 DomainCertsList < ListResource
                
                    ##
                    # Initialize the DomainCertsList
                    # @param [Version] version Version that contains the resource
                    # @return [DomainCertsList] DomainCertsList
                    def initialize(version)
                        super(version)
                        # Path Solution
                        @solution = {  }
                        
                        
                    end
                


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


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

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

                        
                    end
                    ##
                    # Delete the DomainCertsInstance
                    # @return [Boolean] True if delete succeeds, false otherwise
                    def delete

                        headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
                        
                        
                        
                        @version.delete('DELETE', @uri, headers: headers)
                    end

                    ##
                    # Fetch the DomainCertsInstance
                    # @return [DomainCertsInstance] Fetched DomainCertsInstance
                    def fetch

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

                    ##
                    # Update the DomainCertsInstance
                    # @param [String] tls_cert Contains the full TLS certificate and private for this domain in PEM format: https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail. Twilio uses this information to process HTTPS traffic sent to your domain.
                    # @return [DomainCertsInstance] Updated DomainCertsInstance
                    def update(
                        tls_cert: nil
                    )

                        data = Twilio::Values.of({
                            'TlsCert' => tls_cert,
                        })

                        headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
                        
                        
                        
                        
                        
                        payload = @version.update('POST', @uri, data: data, headers: headers)
                        DomainCertsInstance.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.DomainCertsContext #{context}>"
                    end

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

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

                        # Path Solution
                        @solution = solution
                    end

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

                    ##
                    # Provide a user friendly representation
                    def to_s
                        '<Twilio.Messaging.V1.DomainCertsPage>'
                    end
                end
                class DomainCertsInstance < InstanceResource
                    ##
                    # Initialize the DomainCertsInstance
                    # @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 DomainCerts
                    #   resource.
                    # @param [String] sid The SID of the Call resource to fetch.
                    # @return [DomainCertsInstance] DomainCertsInstance
                    def initialize(version, payload , domain_sid: nil)
                        super(version)
                        
                        # Marshaled Properties
                        @properties = { 
                            'domain_sid' => payload['domain_sid'],
                            'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
                            'date_expires' => Twilio.deserialize_iso8601_datetime(payload['date_expires']),
                            'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
                            'domain_name' => payload['domain_name'],
                            'certificate_sid' => payload['certificate_sid'],
                            'url' => payload['url'],
                            'cert_in_validation' => payload['cert_in_validation'],
                        }

                        # 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 [DomainCertsContext] CallContext for this CallInstance
                    def context
                        unless @instance_context
                            @instance_context = DomainCertsContext.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 [Time] Date that this Domain was last updated.
                    def date_updated
                        @properties['date_updated']
                    end
                    
                    ##
                    # @return [Time] Date that the private certificate associated with this domain expires. You will need to update the certificate before that date to ensure your shortened links will continue to work.
                    def date_expires
                        @properties['date_expires']
                    end
                    
                    ##
                    # @return [Time] Date that this Domain was registered to the Twilio platform to create a new Domain object.
                    def date_created
                        @properties['date_created']
                    end
                    
                    ##
                    # @return [String] Full url path for this domain.
                    def domain_name
                        @properties['domain_name']
                    end
                    
                    ##
                    # @return [String] The unique string that we created to identify this Certificate resource.
                    def certificate_sid
                        @properties['certificate_sid']
                    end
                    
                    ##
                    # @return [String] 
                    def url
                        @properties['url']
                    end
                    
                    ##
                    # @return [Hash] Optional JSON field describing the status and upload date of a new certificate in the process of validation
                    def cert_in_validation
                        @properties['cert_in_validation']
                    end
                    
                    ##
                    # Delete the DomainCertsInstance
                    # @return [Boolean] True if delete succeeds, false otherwise
                    def delete

                        context.delete
                    end

                    ##
                    # Fetch the DomainCertsInstance
                    # @return [DomainCertsInstance] Fetched DomainCertsInstance
                    def fetch

                        context.fetch
                    end

                    ##
                    # Update the DomainCertsInstance
                    # @param [String] tls_cert Contains the full TLS certificate and private for this domain in PEM format: https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail. Twilio uses this information to process HTTPS traffic sent to your domain.
                    # @return [DomainCertsInstance] Updated DomainCertsInstance
                    def update(
                        tls_cert: nil
                    )

                        context.update(
                            tls_cert: tls_cert, 
                        )
                    end

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

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

            end
        end
    end
end
