##
#    This code was generated by
#    ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
#     |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
#     |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
#
#    Twilio - Lookups
#    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 Lookups < LookupsBase
            class V2 < Version
                class LookupOverrideList < ListResource
                
                    class OverridesRequest
                            # @param [line_type]: [String] The new line type to override the original line type
                            # @param [reason]: [String] The reason for the override
                        attr_accessor :line_type, :reason
                        def initialize(payload)
                                @line_type = payload["line_type"]
                                @reason = payload["reason"]
                        end
                        def to_json(options = {})
                        {
                                "line_type": @line_type,
                                "reason": @reason,
                        }.to_json(options)
                        end
                    end


                    ##
                    # Initialize the LookupOverrideList
                    # @param [Version] version Version that contains the resource
                    # @return [LookupOverrideList] LookupOverrideList
                    def initialize(version)
                        super(version)
                        # Path Solution
                        @solution = {  }
                        
                        
                    end
                


                    # Provide a user friendly representation
                    def to_s
                        '#<Twilio.Lookups.V2.LookupOverrideList>'
                    end
                end


                class LookupOverrideContext < InstanceContext
                    ##
                    # Initialize the LookupOverrideContext
                    # @param [Version] version Version that contains the resource
                    # @param [String] field 
                    # @param [String] phone_number 
                    # @return [LookupOverrideContext] LookupOverrideContext
                    def initialize(version, field, phone_number)
                        super(version)

                        # Path Solution
                        @solution = { field: field, phone_number: phone_number,  }
                        @uri = "/PhoneNumbers/#{@solution[:phone_number]}/Overrides/#{@solution[:field]}"

                        
                    end
                    ##
                    # Create the LookupOverrideInstance
                    # @param [OverridesRequest] overrides_request 
                    # @return [LookupOverrideInstance] Created LookupOverrideInstance
                    def create(overrides_request: :unset
                    )

                        headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
                        headers['Content-Type'] = 'application/json'
                        
                        
                        
                        
                        payload = @version.create('POST', @uri, headers: headers, data: overrides_request.to_json)
                        LookupOverrideInstance.new(
                            @version,
                            payload,
                            field: @solution[:field],
                            phone_number: @solution[:phone_number],
                        )
                    end

                    ##
                    # Delete the LookupOverrideInstance
                    # @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 LookupOverrideInstance
                    # @return [LookupOverrideInstance] Fetched LookupOverrideInstance
                    def fetch

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

                    ##
                    # Update the LookupOverrideInstance
                    # @param [OverridesRequest] overrides_request 
                    # @return [LookupOverrideInstance] Updated LookupOverrideInstance
                    def update(overrides_request: :unset
                    )

                        headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
                        headers['Content-Type'] = 'application/json'
                        
                        
                        
                        
                        payload = @version.update('PUT', @uri, headers: headers, data: overrides_request.to_json)
                        LookupOverrideInstance.new(
                            @version,
                            payload,
                            field: @solution[:field],
                            phone_number: @solution[:phone_number],
                        )
                    end


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

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

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

                        # Path Solution
                        @solution = solution
                    end

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

                    ##
                    # Provide a user friendly representation
                    def to_s
                        '<Twilio.Lookups.V2.LookupOverridePage>'
                    end
                end
                class LookupOverrideInstance < InstanceResource
                    ##
                    # Initialize the LookupOverrideInstance
                    # @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 LookupOverride
                    #   resource.
                    # @param [String] sid The SID of the Call resource to fetch.
                    # @return [LookupOverrideInstance] LookupOverrideInstance
                    def initialize(version, payload , field: nil, phone_number: nil)
                        super(version)
                        
                        # Marshaled Properties
                        @properties = { 
                            'phone_number' => payload['phone_number'],
                            'original_line_type' => payload['original_line_type'],
                            'overridden_line_type' => payload['overridden_line_type'],
                            'override_reason' => payload['override_reason'],
                            'override_timestamp' => Twilio.deserialize_iso8601_datetime(payload['override_timestamp']),
                            'overridden_by_account_sid' => payload['overridden_by_account_sid'],
                            'code' => payload['code'],
                            'message' => payload['message'],
                            'more_info' => payload['more_info'],
                            'status' => payload['status'],
                            'field' => payload['field'],
                            'limit' => payload['limit'],
                            'bucket' => payload['bucket'],
                            'owner' => payload['owner'],
                            'ttl' => payload['ttl'],
                        }

                        # Context
                        @instance_context = nil
                        @params = { 'field' => field  || @properties['field']  ,'phone_number' => phone_number  || @properties['phone_number']  , }
                    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 [LookupOverrideContext] CallContext for this CallInstance
                    def context
                        unless @instance_context
                            @instance_context = LookupOverrideContext.new(@version , @params['field'], @params['phone_number'])
                        end
                        @instance_context
                    end
                    
                    ##
                    # @return [String] The phone number for which the override was created
                    def phone_number
                        @properties['phone_number']
                    end
                    
                    ##
                    # @return [String] The original line type
                    def original_line_type
                        @properties['original_line_type']
                    end
                    
                    ##
                    # @return [String] The new line type after the override
                    def overridden_line_type
                        @properties['overridden_line_type']
                    end
                    
                    ##
                    # @return [String] The reason for the override
                    def override_reason
                        @properties['override_reason']
                    end
                    
                    ##
                    # @return [Time] 
                    def override_timestamp
                        @properties['override_timestamp']
                    end
                    
                    ##
                    # @return [String] The Account SID for the user who made the override
                    def overridden_by_account_sid
                        @properties['overridden_by_account_sid']
                    end
                    
                    ##
                    # @return [String] Twilio-specific error code
                    def code
                        @properties['code']
                    end
                    
                    ##
                    # @return [String] Error message
                    def message
                        @properties['message']
                    end
                    
                    ##
                    # @return [String] Link to Error Code References
                    def more_info
                        @properties['more_info']
                    end
                    
                    ##
                    # @return [String] HTTP response status code
                    def status
                        @properties['status']
                    end
                    
                    ##
                    # @return [String] Limit of requests for the bucket
                    def field
                        @properties['field']
                    end
                    
                    ##
                    # @return [String] Limit of requests for the bucket
                    def limit
                        @properties['limit']
                    end
                    
                    ##
                    # @return [String] Name of the bucket
                    def bucket
                        @properties['bucket']
                    end
                    
                    ##
                    # @return [String] Owner of the rule
                    def owner
                        @properties['owner']
                    end
                    
                    ##
                    # @return [String] Time to live of the rule
                    def ttl
                        @properties['ttl']
                    end
                    
                    ##
                    # Create the LookupOverrideInstance
                    # @param [OverridesRequest] overrides_request 
                    # @return [LookupOverrideInstance] Created LookupOverrideInstance
                    def create(overrides_request: :unset
                    )

                        context.create(
                        )
                    end

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

                        context.delete
                    end

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

                        context.fetch
                    end

                    ##
                    # Update the LookupOverrideInstance
                    # @param [OverridesRequest] overrides_request 
                    # @return [LookupOverrideInstance] Updated LookupOverrideInstance
                    def update(overrides_request: :unset
                    )

                        context.update(
                        )
                    end

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

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

            end
        end
    end
end
