##
#    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 TollfreeVerificationList < ListResource
                
                    ##
                    # Initialize the TollfreeVerificationList
                    # @param [Version] version Version that contains the resource
                    # @return [TollfreeVerificationList] TollfreeVerificationList
                    def initialize(version)
                        super(version)
                        # Path Solution
                        @solution = {  }
                        @uri = "/Tollfree/Verifications"
                        
                    end
                    ##
                    # Create the TollfreeVerificationInstance
                    # @param [String] business_name The name of the business or organization using the Tollfree number.
                    # @param [String] business_website The website of the business or organization using the Tollfree number.
                    # @param [String] notification_email The email address to receive the notification about the verification result. .
                    # @param [Array[String]] use_case_categories The category of the use case for the Tollfree Number. List as many are applicable..
                    # @param [String] use_case_summary Use this to further explain how messaging is used by the business or organization.
                    # @param [String] production_message_sample An example of message content, i.e. a sample message.
                    # @param [Array[String]] opt_in_image_urls Link to an image that shows the opt-in workflow. Multiple images allowed and must be a publicly hosted URL.
                    # @param [OptInType] opt_in_type 
                    # @param [String] message_volume Estimate monthly volume of messages from the Tollfree Number.
                    # @param [String] tollfree_phone_number_sid The SID of the Phone Number associated with the Tollfree Verification.
                    # @param [String] customer_profile_sid Customer's Profile Bundle BundleSid.
                    # @param [String] business_street_address The address of the business or organization using the Tollfree number.
                    # @param [String] business_street_address2 The address of the business or organization using the Tollfree number.
                    # @param [String] business_city The city of the business or organization using the Tollfree number.
                    # @param [String] business_state_province_region The state/province/region of the business or organization using the Tollfree number.
                    # @param [String] business_postal_code The postal code of the business or organization using the Tollfree number.
                    # @param [String] business_country The country of the business or organization using the Tollfree number.
                    # @param [String] additional_information Additional information to be provided for verification.
                    # @param [String] business_contact_first_name The first name of the contact for the business or organization using the Tollfree number.
                    # @param [String] business_contact_last_name The last name of the contact for the business or organization using the Tollfree number.
                    # @param [String] business_contact_email The email address of the contact for the business or organization using the Tollfree number.
                    # @param [String] business_contact_phone The E.164 formatted phone number of the contact for the business or organization using the Tollfree number.
                    # @param [String] external_reference_id An optional external reference ID supplied by customer and echoed back on status retrieval.
                    # @param [String] business_registration_number A legally recognized business registration number
                    # @param [String] business_registration_authority The organizational authority for business registrations
                    # @param [String] business_registration_country Country business is registered in
                    # @param [String] business_type The type of business, valid values are PRIVATE_PROFIT, PUBLIC_PROFIT, NON_PROFIT, SOLE_PROPRIETOR, GOVERNMENT
                    # @param [String] business_registration_phone_number The E.164 formatted number associated with the business.
                    # @param [String] doing_business_as Trade name, sub entity, or downstream business name of business being submitted for verification
                    # @param [String] opt_in_confirmation_message The confirmation message sent to users when they opt in to receive messages.
                    # @param [String] help_message_sample A sample help message provided to users.
                    # @param [String] privacy_policy_url The URL to the privacy policy for the business or organization.
                    # @param [String] terms_and_conditions_url The URL to the terms and conditions for the business or organization.
                    # @param [Boolean] age_gated_content Indicates if the content is age gated.
                    # @param [Array[String]] opt_in_keywords List of keywords that users can text in to opt in to receive messages.
                    # @return [TollfreeVerificationInstance] Created TollfreeVerificationInstance
                    def create(
                        business_name: nil, 
                        business_website: nil, 
                        notification_email: nil, 
                        use_case_categories: nil, 
                        use_case_summary: nil, 
                        production_message_sample: nil, 
                        opt_in_image_urls: nil, 
                        opt_in_type: nil, 
                        message_volume: nil, 
                        tollfree_phone_number_sid: nil, 
                        customer_profile_sid: :unset, 
                        business_street_address: :unset, 
                        business_street_address2: :unset, 
                        business_city: :unset, 
                        business_state_province_region: :unset, 
                        business_postal_code: :unset, 
                        business_country: :unset, 
                        additional_information: :unset, 
                        business_contact_first_name: :unset, 
                        business_contact_last_name: :unset, 
                        business_contact_email: :unset, 
                        business_contact_phone: :unset, 
                        external_reference_id: :unset, 
                        business_registration_number: :unset, 
                        business_registration_authority: :unset, 
                        business_registration_country: :unset, 
                        business_type: :unset, 
                        business_registration_phone_number: :unset, 
                        doing_business_as: :unset, 
                        opt_in_confirmation_message: :unset, 
                        help_message_sample: :unset, 
                        privacy_policy_url: :unset, 
                        terms_and_conditions_url: :unset, 
                        age_gated_content: :unset, 
                        opt_in_keywords: :unset
                    )

                        data = Twilio::Values.of({
                            'BusinessName' => business_name,
                            'BusinessWebsite' => business_website,
                            'NotificationEmail' => notification_email,
                            'UseCaseCategories' => Twilio.serialize_list(use_case_categories) { |e| e },
                            'UseCaseSummary' => use_case_summary,
                            'ProductionMessageSample' => production_message_sample,
                            'OptInImageUrls' => Twilio.serialize_list(opt_in_image_urls) { |e| e },
                            'OptInType' => opt_in_type,
                            'MessageVolume' => message_volume,
                            'TollfreePhoneNumberSid' => tollfree_phone_number_sid,
                            'CustomerProfileSid' => customer_profile_sid,
                            'BusinessStreetAddress' => business_street_address,
                            'BusinessStreetAddress2' => business_street_address2,
                            'BusinessCity' => business_city,
                            'BusinessStateProvinceRegion' => business_state_province_region,
                            'BusinessPostalCode' => business_postal_code,
                            'BusinessCountry' => business_country,
                            'AdditionalInformation' => additional_information,
                            'BusinessContactFirstName' => business_contact_first_name,
                            'BusinessContactLastName' => business_contact_last_name,
                            'BusinessContactEmail' => business_contact_email,
                            'BusinessContactPhone' => business_contact_phone,
                            'ExternalReferenceId' => external_reference_id,
                            'BusinessRegistrationNumber' => business_registration_number,
                            'BusinessRegistrationAuthority' => business_registration_authority,
                            'BusinessRegistrationCountry' => business_registration_country,
                            'BusinessType' => business_type,
                            'BusinessRegistrationPhoneNumber' => business_registration_phone_number,
                            'DoingBusinessAs' => doing_business_as,
                            'OptInConfirmationMessage' => opt_in_confirmation_message,
                            'HelpMessageSample' => help_message_sample,
                            'PrivacyPolicyUrl' => privacy_policy_url,
                            'TermsAndConditionsUrl' => terms_and_conditions_url,
                            'AgeGatedContent' => age_gated_content,
                            'OptInKeywords' => Twilio.serialize_list(opt_in_keywords) { |e| e },
                        })

                        headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
                        
                        
                        
                        
                        
                        payload = @version.create('POST', @uri, data: data, headers: headers)
                        TollfreeVerificationInstance.new(
                            @version,
                            payload,
                        )
                    end

                
                    ##
                    # Lists TollfreeVerificationInstance records from the API as a list.
                    # Unlike stream(), this operation is eager and will load `limit` records into
                    # memory before returning.
                    # @param [String] tollfree_phone_number_sid The SID of the Phone Number associated with the Tollfree Verification.
                    # @param [Status] status The compliance status of the Tollfree Verification record.
                    # @param [String] external_reference_id Customer supplied reference id for the Tollfree Verification record.
                    # @param [Boolean] include_sub_accounts Whether to include Tollfree Verifications from sub accounts in list response.
                    # @param [Integer] limit Upper limit for the number of records to return. stream()
                    #    guarantees to never return more than limit.  Default is no limit
                    # @param [Integer] page_size Number of records to fetch per request, when
                    #    not set will use the default value of 50 records.  If no page_size is defined
                    #    but a limit is defined, stream() will attempt to read the limit with the most
                    #    efficient page size, i.e. min(limit, 1000)
                    # @return [Array] Array of up to limit results
                    def list(tollfree_phone_number_sid: :unset, status: :unset, external_reference_id: :unset, include_sub_accounts: :unset, limit: nil, page_size: nil)
                        self.stream(
                            tollfree_phone_number_sid: tollfree_phone_number_sid,
                            status: status,
                            external_reference_id: external_reference_id,
                            include_sub_accounts: include_sub_accounts,
                            limit: limit,
                            page_size: page_size
                        ).entries
                    end

                    ##
                    # Streams Instance records from the API as an Enumerable.
                    # This operation lazily loads records as efficiently as possible until the limit
                    # is reached.
                    # @param [String] tollfree_phone_number_sid The SID of the Phone Number associated with the Tollfree Verification.
                    # @param [Status] status The compliance status of the Tollfree Verification record.
                    # @param [String] external_reference_id Customer supplied reference id for the Tollfree Verification record.
                    # @param [Boolean] include_sub_accounts Whether to include Tollfree Verifications from sub accounts in list response.
                    # @param [Integer] limit Upper limit for the number of records to return. stream()
                    #    guarantees to never return more than limit.  Default is no limit
                    # @param [Integer] page_size Number of records to fetch per request, when
                    #    not set will use the default value of 50 records.  If no page_size is defined
                    #    but a limit is defined, stream() will attempt to read the limit with the most
                    #    efficient page size, i.e. min(limit, 1000)
                    # @return [Enumerable] Enumerable that will yield up to limit results
                    def stream(tollfree_phone_number_sid: :unset, status: :unset, external_reference_id: :unset, include_sub_accounts: :unset, limit: nil, page_size: nil)
                        limits = @version.read_limits(limit, page_size)

                        page = self.page(
                            tollfree_phone_number_sid: tollfree_phone_number_sid,
                            status: status,
                            external_reference_id: external_reference_id,
                            include_sub_accounts: include_sub_accounts,
                            page_size: limits[:page_size], )

                        @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
                    end

                    ##
                    # When passed a block, yields TollfreeVerificationInstance records from the API.
                    # This operation lazily loads records as efficiently as possible until the limit
                    # is reached.
                    def each
                        limits = @version.read_limits

                        page = self.page(page_size: limits[:page_size], )

                        @version.stream(page,
                            limit: limits[:limit],
                            page_limit: limits[:page_limit]).each {|x| yield x}
                    end

                    ##
                    # Retrieve a single page of TollfreeVerificationInstance records from the API.
                    # Request is executed immediately.
                    # @param [String] tollfree_phone_number_sid The SID of the Phone Number associated with the Tollfree Verification.
                    # @param [Status] status The compliance status of the Tollfree Verification record.
                    # @param [String] external_reference_id Customer supplied reference id for the Tollfree Verification record.
                    # @param [Boolean] include_sub_accounts Whether to include Tollfree Verifications from sub accounts in list response.
                    # @param [String] page_token PageToken provided by the API
                    # @param [Integer] page_number Page Number, this value is simply for client state
                    # @param [Integer] page_size Number of records to return, defaults to 50
                    # @return [Page] Page of TollfreeVerificationInstance
                    def page(tollfree_phone_number_sid: :unset, status: :unset, external_reference_id: :unset, include_sub_accounts: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
                        params = Twilio::Values.of({
                            'TollfreePhoneNumberSid' => tollfree_phone_number_sid,
                            'Status' => status,
                            'ExternalReferenceId' => external_reference_id,
                            'IncludeSubAccounts' => include_sub_accounts,
                            'PageToken' => page_token,
                            'Page' => page_number,
                            'PageSize' => page_size,
                        })
                        headers = Twilio::Values.of({})
                        
                        

                        response = @version.page('GET', @uri, params: params, headers: headers)

                        TollfreeVerificationPage.new(@version, response, @solution)
                    end

                    ##
                    # Retrieve a single page of TollfreeVerificationInstance records from the API.
                    # Request is executed immediately.
                    # @param [String] target_url API-generated URL for the requested results page
                    # @return [Page] Page of TollfreeVerificationInstance
                    def get_page(target_url)
                        response = @version.domain.request(
                            'GET',
                            target_url
                        )
                    TollfreeVerificationPage.new(@version, response, @solution)
                    end
                    


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


                class TollfreeVerificationContext < InstanceContext
                    ##
                    # Initialize the TollfreeVerificationContext
                    # @param [Version] version Version that contains the resource
                    # @param [String] sid The unique string to identify Tollfree Verification.
                    # @return [TollfreeVerificationContext] TollfreeVerificationContext
                    def initialize(version, sid)
                        super(version)

                        # Path Solution
                        @solution = { sid: sid,  }
                        @uri = "/Tollfree/Verifications/#{@solution[:sid]}"

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

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

                    ##
                    # Update the TollfreeVerificationInstance
                    # @param [String] business_name The name of the business or organization using the Tollfree number.
                    # @param [String] business_website The website of the business or organization using the Tollfree number.
                    # @param [String] notification_email The email address to receive the notification about the verification result. .
                    # @param [Array[String]] use_case_categories The category of the use case for the Tollfree Number. List as many are applicable..
                    # @param [String] use_case_summary Use this to further explain how messaging is used by the business or organization.
                    # @param [String] production_message_sample An example of message content, i.e. a sample message.
                    # @param [Array[String]] opt_in_image_urls Link to an image that shows the opt-in workflow. Multiple images allowed and must be a publicly hosted URL.
                    # @param [OptInType] opt_in_type 
                    # @param [String] message_volume Estimate monthly volume of messages from the Tollfree Number.
                    # @param [String] business_street_address The address of the business or organization using the Tollfree number.
                    # @param [String] business_street_address2 The address of the business or organization using the Tollfree number.
                    # @param [String] business_city The city of the business or organization using the Tollfree number.
                    # @param [String] business_state_province_region The state/province/region of the business or organization using the Tollfree number.
                    # @param [String] business_postal_code The postal code of the business or organization using the Tollfree number.
                    # @param [String] business_country The country of the business or organization using the Tollfree number.
                    # @param [String] additional_information Additional information to be provided for verification.
                    # @param [String] business_contact_first_name The first name of the contact for the business or organization using the Tollfree number.
                    # @param [String] business_contact_last_name The last name of the contact for the business or organization using the Tollfree number.
                    # @param [String] business_contact_email The email address of the contact for the business or organization using the Tollfree number.
                    # @param [String] business_contact_phone The E.164 formatted phone number of the contact for the business or organization using the Tollfree number.
                    # @param [String] edit_reason Describe why the verification is being edited. If the verification was rejected because of a technical issue, such as the website being down, and the issue has been resolved this parameter should be set to something similar to 'Website fixed'.
                    # @param [String] business_registration_number A legaly recognized business registration number
                    # @param [String] business_registration_authority The organizational authority for business registrations
                    # @param [String] business_registration_country Country business is registered in
                    # @param [String] business_type The type of business, valid values are PRIVATE_PROFIT, PUBLIC_PROFIT, NON_PROFIT, SOLE_PROPRIETOR, GOVERNMENT
                    # @param [String] business_registration_phone_number The E.164 formatted number associated with the business.
                    # @param [String] doing_business_as Trade name, sub entity, or downstream business name of business being submitted for verification
                    # @param [String] opt_in_confirmation_message The confirmation message sent to users when they opt in to receive messages.
                    # @param [String] help_message_sample A sample help message provided to users.
                    # @param [String] privacy_policy_url The URL to the privacy policy for the business or organization.
                    # @param [String] terms_and_conditions_url The URL to the terms and conditions for the business or organization.
                    # @param [Boolean] age_gated_content Indicates if the content is age gated.
                    # @param [Array[String]] opt_in_keywords List of keywords that users can text in to opt in to receive messages.
                    # @return [TollfreeVerificationInstance] Updated TollfreeVerificationInstance
                    def update(
                        business_name: :unset, 
                        business_website: :unset, 
                        notification_email: :unset, 
                        use_case_categories: :unset, 
                        use_case_summary: :unset, 
                        production_message_sample: :unset, 
                        opt_in_image_urls: :unset, 
                        opt_in_type: :unset, 
                        message_volume: :unset, 
                        business_street_address: :unset, 
                        business_street_address2: :unset, 
                        business_city: :unset, 
                        business_state_province_region: :unset, 
                        business_postal_code: :unset, 
                        business_country: :unset, 
                        additional_information: :unset, 
                        business_contact_first_name: :unset, 
                        business_contact_last_name: :unset, 
                        business_contact_email: :unset, 
                        business_contact_phone: :unset, 
                        edit_reason: :unset, 
                        business_registration_number: :unset, 
                        business_registration_authority: :unset, 
                        business_registration_country: :unset, 
                        business_type: :unset, 
                        business_registration_phone_number: :unset, 
                        doing_business_as: :unset, 
                        opt_in_confirmation_message: :unset, 
                        help_message_sample: :unset, 
                        privacy_policy_url: :unset, 
                        terms_and_conditions_url: :unset, 
                        age_gated_content: :unset, 
                        opt_in_keywords: :unset
                    )

                        data = Twilio::Values.of({
                            'BusinessName' => business_name,
                            'BusinessWebsite' => business_website,
                            'NotificationEmail' => notification_email,
                            'UseCaseCategories' => Twilio.serialize_list(use_case_categories) { |e| e },
                            'UseCaseSummary' => use_case_summary,
                            'ProductionMessageSample' => production_message_sample,
                            'OptInImageUrls' => Twilio.serialize_list(opt_in_image_urls) { |e| e },
                            'OptInType' => opt_in_type,
                            'MessageVolume' => message_volume,
                            'BusinessStreetAddress' => business_street_address,
                            'BusinessStreetAddress2' => business_street_address2,
                            'BusinessCity' => business_city,
                            'BusinessStateProvinceRegion' => business_state_province_region,
                            'BusinessPostalCode' => business_postal_code,
                            'BusinessCountry' => business_country,
                            'AdditionalInformation' => additional_information,
                            'BusinessContactFirstName' => business_contact_first_name,
                            'BusinessContactLastName' => business_contact_last_name,
                            'BusinessContactEmail' => business_contact_email,
                            'BusinessContactPhone' => business_contact_phone,
                            'EditReason' => edit_reason,
                            'BusinessRegistrationNumber' => business_registration_number,
                            'BusinessRegistrationAuthority' => business_registration_authority,
                            'BusinessRegistrationCountry' => business_registration_country,
                            'BusinessType' => business_type,
                            'BusinessRegistrationPhoneNumber' => business_registration_phone_number,
                            'DoingBusinessAs' => doing_business_as,
                            'OptInConfirmationMessage' => opt_in_confirmation_message,
                            'HelpMessageSample' => help_message_sample,
                            'PrivacyPolicyUrl' => privacy_policy_url,
                            'TermsAndConditionsUrl' => terms_and_conditions_url,
                            'AgeGatedContent' => age_gated_content,
                            'OptInKeywords' => Twilio.serialize_list(opt_in_keywords) { |e| e },
                        })

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


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

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

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

                        # Path Solution
                        @solution = solution
                    end

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

                    ##
                    # Provide a user friendly representation
                    def to_s
                        '<Twilio.Messaging.V1.TollfreeVerificationPage>'
                    end
                end
                class TollfreeVerificationInstance < InstanceResource
                    ##
                    # Initialize the TollfreeVerificationInstance
                    # @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 TollfreeVerification
                    #   resource.
                    # @param [String] sid The SID of the Call resource to fetch.
                    # @return [TollfreeVerificationInstance] TollfreeVerificationInstance
                    def initialize(version, payload , sid: nil)
                        super(version)
                        
                        # Marshaled Properties
                        @properties = { 
                            'sid' => payload['sid'],
                            'account_sid' => payload['account_sid'],
                            'customer_profile_sid' => payload['customer_profile_sid'],
                            'trust_product_sid' => payload['trust_product_sid'],
                            'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
                            'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
                            'regulated_item_sid' => payload['regulated_item_sid'],
                            'business_name' => payload['business_name'],
                            'business_street_address' => payload['business_street_address'],
                            'business_street_address2' => payload['business_street_address2'],
                            'business_city' => payload['business_city'],
                            'business_state_province_region' => payload['business_state_province_region'],
                            'business_postal_code' => payload['business_postal_code'],
                            'business_country' => payload['business_country'],
                            'business_website' => payload['business_website'],
                            'business_contact_first_name' => payload['business_contact_first_name'],
                            'business_contact_last_name' => payload['business_contact_last_name'],
                            'business_contact_email' => payload['business_contact_email'],
                            'business_contact_phone' => payload['business_contact_phone'],
                            'notification_email' => payload['notification_email'],
                            'use_case_categories' => payload['use_case_categories'],
                            'use_case_summary' => payload['use_case_summary'],
                            'production_message_sample' => payload['production_message_sample'],
                            'opt_in_image_urls' => payload['opt_in_image_urls'],
                            'opt_in_type' => payload['opt_in_type'],
                            'message_volume' => payload['message_volume'],
                            'additional_information' => payload['additional_information'],
                            'tollfree_phone_number_sid' => payload['tollfree_phone_number_sid'],
                            'tollfree_phone_number' => payload['tollfree_phone_number'],
                            'status' => payload['status'],
                            'url' => payload['url'],
                            'rejection_reason' => payload['rejection_reason'],
                            'error_code' => payload['error_code'] == nil ? payload['error_code'] : payload['error_code'].to_i,
                            'edit_expiration' => Twilio.deserialize_iso8601_datetime(payload['edit_expiration']),
                            'edit_allowed' => payload['edit_allowed'],
                            'business_registration_number' => payload['business_registration_number'],
                            'business_registration_authority' => payload['business_registration_authority'],
                            'business_registration_country' => payload['business_registration_country'],
                            'business_type' => payload['business_type'],
                            'business_registration_phone_number' => payload['business_registration_phone_number'],
                            'doing_business_as' => payload['doing_business_as'],
                            'opt_in_confirmation_message' => payload['opt_in_confirmation_message'],
                            'help_message_sample' => payload['help_message_sample'],
                            'privacy_policy_url' => payload['privacy_policy_url'],
                            'terms_and_conditions_url' => payload['terms_and_conditions_url'],
                            'age_gated_content' => payload['age_gated_content'],
                            'opt_in_keywords' => payload['opt_in_keywords'],
                            'rejection_reasons' => payload['rejection_reasons'],
                            'resource_links' => payload['resource_links'],
                            'external_reference_id' => payload['external_reference_id'],
                        }

                        # Context
                        @instance_context = nil
                        @params = { 'sid' => sid  || @properties['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 [TollfreeVerificationContext] CallContext for this CallInstance
                    def context
                        unless @instance_context
                            @instance_context = TollfreeVerificationContext.new(@version , @params['sid'])
                        end
                        @instance_context
                    end
                    
                    ##
                    # @return [String] The unique string to identify Tollfree Verification.
                    def sid
                        @properties['sid']
                    end
                    
                    ##
                    # @return [String] The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Tollfree Verification resource.
                    def account_sid
                        @properties['account_sid']
                    end
                    
                    ##
                    # @return [String] Customer's Profile Bundle BundleSid.
                    def customer_profile_sid
                        @properties['customer_profile_sid']
                    end
                    
                    ##
                    # @return [String] Tollfree TrustProduct Bundle BundleSid.
                    def trust_product_sid
                        @properties['trust_product_sid']
                    end
                    
                    ##
                    # @return [Time] The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
                    def date_created
                        @properties['date_created']
                    end
                    
                    ##
                    # @return [Time] The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
                    def date_updated
                        @properties['date_updated']
                    end
                    
                    ##
                    # @return [String] The SID of the Regulated Item.
                    def regulated_item_sid
                        @properties['regulated_item_sid']
                    end
                    
                    ##
                    # @return [String] The name of the business or organization using the Tollfree number.
                    def business_name
                        @properties['business_name']
                    end
                    
                    ##
                    # @return [String] The address of the business or organization using the Tollfree number.
                    def business_street_address
                        @properties['business_street_address']
                    end
                    
                    ##
                    # @return [String] The address of the business or organization using the Tollfree number.
                    def business_street_address2
                        @properties['business_street_address2']
                    end
                    
                    ##
                    # @return [String] The city of the business or organization using the Tollfree number.
                    def business_city
                        @properties['business_city']
                    end
                    
                    ##
                    # @return [String] The state/province/region of the business or organization using the Tollfree number.
                    def business_state_province_region
                        @properties['business_state_province_region']
                    end
                    
                    ##
                    # @return [String] The postal code of the business or organization using the Tollfree number.
                    def business_postal_code
                        @properties['business_postal_code']
                    end
                    
                    ##
                    # @return [String] The country of the business or organization using the Tollfree number.
                    def business_country
                        @properties['business_country']
                    end
                    
                    ##
                    # @return [String] The website of the business or organization using the Tollfree number.
                    def business_website
                        @properties['business_website']
                    end
                    
                    ##
                    # @return [String] The first name of the contact for the business or organization using the Tollfree number.
                    def business_contact_first_name
                        @properties['business_contact_first_name']
                    end
                    
                    ##
                    # @return [String] The last name of the contact for the business or organization using the Tollfree number.
                    def business_contact_last_name
                        @properties['business_contact_last_name']
                    end
                    
                    ##
                    # @return [String] The email address of the contact for the business or organization using the Tollfree number.
                    def business_contact_email
                        @properties['business_contact_email']
                    end
                    
                    ##
                    # @return [String] The E.164 formatted phone number of the contact for the business or organization using the Tollfree number.
                    def business_contact_phone
                        @properties['business_contact_phone']
                    end
                    
                    ##
                    # @return [String] The email address to receive the notification about the verification result. .
                    def notification_email
                        @properties['notification_email']
                    end
                    
                    ##
                    # @return [Array<String>] The category of the use case for the Tollfree Number. List as many are applicable..
                    def use_case_categories
                        @properties['use_case_categories']
                    end
                    
                    ##
                    # @return [String] Use this to further explain how messaging is used by the business or organization.
                    def use_case_summary
                        @properties['use_case_summary']
                    end
                    
                    ##
                    # @return [String] An example of message content, i.e. a sample message.
                    def production_message_sample
                        @properties['production_message_sample']
                    end
                    
                    ##
                    # @return [Array<String>] Link to an image that shows the opt-in workflow. Multiple images allowed and must be a publicly hosted URL.
                    def opt_in_image_urls
                        @properties['opt_in_image_urls']
                    end
                    
                    ##
                    # @return [OptInType] 
                    def opt_in_type
                        @properties['opt_in_type']
                    end
                    
                    ##
                    # @return [String] Estimate monthly volume of messages from the Tollfree Number.
                    def message_volume
                        @properties['message_volume']
                    end
                    
                    ##
                    # @return [String] Additional information to be provided for verification.
                    def additional_information
                        @properties['additional_information']
                    end
                    
                    ##
                    # @return [String] The SID of the Phone Number associated with the Tollfree Verification.
                    def tollfree_phone_number_sid
                        @properties['tollfree_phone_number_sid']
                    end
                    
                    ##
                    # @return [String] The E.164 formatted toll-free phone number associated with the verification.
                    def tollfree_phone_number
                        @properties['tollfree_phone_number']
                    end
                    
                    ##
                    # @return [Status] 
                    def status
                        @properties['status']
                    end
                    
                    ##
                    # @return [String] The absolute URL of the Tollfree Verification resource.
                    def url
                        @properties['url']
                    end
                    
                    ##
                    # @return [String] The rejection reason given when a Tollfree Verification has been rejected.
                    def rejection_reason
                        @properties['rejection_reason']
                    end
                    
                    ##
                    # @return [String] The error code given when a Tollfree Verification has been rejected.
                    def error_code
                        @properties['error_code']
                    end
                    
                    ##
                    # @return [Time] The date and time when the ability to edit a rejected verification expires.
                    def edit_expiration
                        @properties['edit_expiration']
                    end
                    
                    ##
                    # @return [Boolean] If a rejected verification is allowed to be edited/resubmitted. Some rejection reasons allow editing and some do not.
                    def edit_allowed
                        @properties['edit_allowed']
                    end
                    
                    ##
                    # @return [String] A legally recognized business registration number
                    def business_registration_number
                        @properties['business_registration_number']
                    end
                    
                    ##
                    # @return [String] The organizational authority for business registrations
                    def business_registration_authority
                        @properties['business_registration_authority']
                    end
                    
                    ##
                    # @return [String] Country business is registered in
                    def business_registration_country
                        @properties['business_registration_country']
                    end
                    
                    ##
                    # @return [String] The type of business, valid values are PRIVATE_PROFIT, PUBLIC_PROFIT, NON_PROFIT, SOLE_PROPRIETOR, GOVERNMENT
                    def business_type
                        @properties['business_type']
                    end
                    
                    ##
                    # @return [String] The E.164 formatted number associated with the business.
                    def business_registration_phone_number
                        @properties['business_registration_phone_number']
                    end
                    
                    ##
                    # @return [String] Trade name, sub entity, or downstream business name of business being submitted for verification
                    def doing_business_as
                        @properties['doing_business_as']
                    end
                    
                    ##
                    # @return [String] The confirmation message sent to users when they opt in to receive messages.
                    def opt_in_confirmation_message
                        @properties['opt_in_confirmation_message']
                    end
                    
                    ##
                    # @return [String] A sample help message provided to users.
                    def help_message_sample
                        @properties['help_message_sample']
                    end
                    
                    ##
                    # @return [String] The URL to the privacy policy for the business or organization.
                    def privacy_policy_url
                        @properties['privacy_policy_url']
                    end
                    
                    ##
                    # @return [String] The URL of the terms and conditions for the business or organization.
                    def terms_and_conditions_url
                        @properties['terms_and_conditions_url']
                    end
                    
                    ##
                    # @return [Boolean] Indicates if the content is age gated.
                    def age_gated_content
                        @properties['age_gated_content']
                    end
                    
                    ##
                    # @return [Array<String>] List of keywords that users can send to opt in or out of messages.
                    def opt_in_keywords
                        @properties['opt_in_keywords']
                    end
                    
                    ##
                    # @return [Array<Hash>] A list of rejection reasons and codes describing why a Tollfree Verification has been rejected.
                    def rejection_reasons
                        @properties['rejection_reasons']
                    end
                    
                    ##
                    # @return [Hash] The URLs of the documents associated with the Tollfree Verification resource.
                    def resource_links
                        @properties['resource_links']
                    end
                    
                    ##
                    # @return [String] An optional external reference ID supplied by customer and echoed back on status retrieval.
                    def external_reference_id
                        @properties['external_reference_id']
                    end
                    
                    ##
                    # Delete the TollfreeVerificationInstance
                    # @return [Boolean] True if delete succeeds, false otherwise
                    def delete

                        context.delete
                    end

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

                        context.fetch
                    end

                    ##
                    # Update the TollfreeVerificationInstance
                    # @param [String] business_name The name of the business or organization using the Tollfree number.
                    # @param [String] business_website The website of the business or organization using the Tollfree number.
                    # @param [String] notification_email The email address to receive the notification about the verification result. .
                    # @param [Array[String]] use_case_categories The category of the use case for the Tollfree Number. List as many are applicable..
                    # @param [String] use_case_summary Use this to further explain how messaging is used by the business or organization.
                    # @param [String] production_message_sample An example of message content, i.e. a sample message.
                    # @param [Array[String]] opt_in_image_urls Link to an image that shows the opt-in workflow. Multiple images allowed and must be a publicly hosted URL.
                    # @param [OptInType] opt_in_type 
                    # @param [String] message_volume Estimate monthly volume of messages from the Tollfree Number.
                    # @param [String] business_street_address The address of the business or organization using the Tollfree number.
                    # @param [String] business_street_address2 The address of the business or organization using the Tollfree number.
                    # @param [String] business_city The city of the business or organization using the Tollfree number.
                    # @param [String] business_state_province_region The state/province/region of the business or organization using the Tollfree number.
                    # @param [String] business_postal_code The postal code of the business or organization using the Tollfree number.
                    # @param [String] business_country The country of the business or organization using the Tollfree number.
                    # @param [String] additional_information Additional information to be provided for verification.
                    # @param [String] business_contact_first_name The first name of the contact for the business or organization using the Tollfree number.
                    # @param [String] business_contact_last_name The last name of the contact for the business or organization using the Tollfree number.
                    # @param [String] business_contact_email The email address of the contact for the business or organization using the Tollfree number.
                    # @param [String] business_contact_phone The E.164 formatted phone number of the contact for the business or organization using the Tollfree number.
                    # @param [String] edit_reason Describe why the verification is being edited. If the verification was rejected because of a technical issue, such as the website being down, and the issue has been resolved this parameter should be set to something similar to 'Website fixed'.
                    # @param [String] business_registration_number A legaly recognized business registration number
                    # @param [String] business_registration_authority The organizational authority for business registrations
                    # @param [String] business_registration_country Country business is registered in
                    # @param [String] business_type The type of business, valid values are PRIVATE_PROFIT, PUBLIC_PROFIT, NON_PROFIT, SOLE_PROPRIETOR, GOVERNMENT
                    # @param [String] business_registration_phone_number The E.164 formatted number associated with the business.
                    # @param [String] doing_business_as Trade name, sub entity, or downstream business name of business being submitted for verification
                    # @param [String] opt_in_confirmation_message The confirmation message sent to users when they opt in to receive messages.
                    # @param [String] help_message_sample A sample help message provided to users.
                    # @param [String] privacy_policy_url The URL to the privacy policy for the business or organization.
                    # @param [String] terms_and_conditions_url The URL to the terms and conditions for the business or organization.
                    # @param [Boolean] age_gated_content Indicates if the content is age gated.
                    # @param [Array[String]] opt_in_keywords List of keywords that users can text in to opt in to receive messages.
                    # @return [TollfreeVerificationInstance] Updated TollfreeVerificationInstance
                    def update(
                        business_name: :unset, 
                        business_website: :unset, 
                        notification_email: :unset, 
                        use_case_categories: :unset, 
                        use_case_summary: :unset, 
                        production_message_sample: :unset, 
                        opt_in_image_urls: :unset, 
                        opt_in_type: :unset, 
                        message_volume: :unset, 
                        business_street_address: :unset, 
                        business_street_address2: :unset, 
                        business_city: :unset, 
                        business_state_province_region: :unset, 
                        business_postal_code: :unset, 
                        business_country: :unset, 
                        additional_information: :unset, 
                        business_contact_first_name: :unset, 
                        business_contact_last_name: :unset, 
                        business_contact_email: :unset, 
                        business_contact_phone: :unset, 
                        edit_reason: :unset, 
                        business_registration_number: :unset, 
                        business_registration_authority: :unset, 
                        business_registration_country: :unset, 
                        business_type: :unset, 
                        business_registration_phone_number: :unset, 
                        doing_business_as: :unset, 
                        opt_in_confirmation_message: :unset, 
                        help_message_sample: :unset, 
                        privacy_policy_url: :unset, 
                        terms_and_conditions_url: :unset, 
                        age_gated_content: :unset, 
                        opt_in_keywords: :unset
                    )

                        context.update(
                            business_name: business_name, 
                            business_website: business_website, 
                            notification_email: notification_email, 
                            use_case_categories: use_case_categories, 
                            use_case_summary: use_case_summary, 
                            production_message_sample: production_message_sample, 
                            opt_in_image_urls: opt_in_image_urls, 
                            opt_in_type: opt_in_type, 
                            message_volume: message_volume, 
                            business_street_address: business_street_address, 
                            business_street_address2: business_street_address2, 
                            business_city: business_city, 
                            business_state_province_region: business_state_province_region, 
                            business_postal_code: business_postal_code, 
                            business_country: business_country, 
                            additional_information: additional_information, 
                            business_contact_first_name: business_contact_first_name, 
                            business_contact_last_name: business_contact_last_name, 
                            business_contact_email: business_contact_email, 
                            business_contact_phone: business_contact_phone, 
                            edit_reason: edit_reason, 
                            business_registration_number: business_registration_number, 
                            business_registration_authority: business_registration_authority, 
                            business_registration_country: business_registration_country, 
                            business_type: business_type, 
                            business_registration_phone_number: business_registration_phone_number, 
                            doing_business_as: doing_business_as, 
                            opt_in_confirmation_message: opt_in_confirmation_message, 
                            help_message_sample: help_message_sample, 
                            privacy_policy_url: privacy_policy_url, 
                            terms_and_conditions_url: terms_and_conditions_url, 
                            age_gated_content: age_gated_content, 
                            opt_in_keywords: opt_in_keywords, 
                        )
                    end

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

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

            end
        end
    end
end
