##
#    This code was generated by
#    ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
#     |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
#     |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
#
#    Twilio - Accounts
#    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 Accounts < AccountsBase
            class V1 < Version
                class MessagingGeopermissionsList < ListResource
                
                    ##
                    # Initialize the MessagingGeopermissionsList
                    # @param [Version] version Version that contains the resource
                    # @return [MessagingGeopermissionsList] MessagingGeopermissionsList
                    def initialize(version)
                        super(version)
                        # Path Solution
                        @solution = {  }
                        @uri = "/Messaging/GeoPermissions"
                        
                    end
                    ##
                    # Fetch the MessagingGeopermissionsInstance
                    # @param [String] country_code The country code to filter the geo permissions. If provided, only the geo permission for the specified country will be returned.
                    # @return [MessagingGeopermissionsInstance] Fetched MessagingGeopermissionsInstance
                    def fetch(
                        country_code: :unset
                    )

                        params = Twilio::Values.of({
                            'CountryCode' => country_code,
                        })
                        headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
                        
                        
                        
                        
                        
                        payload = @version.fetch('GET', @uri, params: params, headers: headers)
                        MessagingGeopermissionsInstance.new(
                            @version,
                            payload,
                        )
                    end

                    ##
                    # Update the MessagingGeopermissionsInstance
                    # @param [Array[Hash]] permissions A list of objects where each object represents the Geo Permission to be updated. Each object contains the following fields: `country_code`, unique code for each country of Geo Permission; `type`, permission type of the Geo Permission i.e. country; `enabled`, configure true for enabling the Geo Permission, false for disabling the Geo Permission.
                    # @return [MessagingGeopermissionsInstance] Updated MessagingGeopermissionsInstance
                    def update(
                        permissions: nil
                    )

                        data = Twilio::Values.of({
                            'Permissions' => Twilio.serialize_list(permissions) { |e| Twilio.serialize_object(e) },
                        })

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

                


                    # Provide a user friendly representation
                    def to_s
                        '#<Twilio.Accounts.V1.MessagingGeopermissionsList>'
                    end
                end

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

                        # Path Solution
                        @solution = solution
                    end

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

                    ##
                    # Provide a user friendly representation
                    def to_s
                        '<Twilio.Accounts.V1.MessagingGeopermissionsPage>'
                    end
                end
                class MessagingGeopermissionsInstance < InstanceResource
                    ##
                    # Initialize the MessagingGeopermissionsInstance
                    # @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 MessagingGeopermissions
                    #   resource.
                    # @param [String] sid The SID of the Call resource to fetch.
                    # @return [MessagingGeopermissionsInstance] MessagingGeopermissionsInstance
                    def initialize(version, payload )
                        super(version)
                        
                        # Marshaled Properties
                        @properties = { 
                            'permissions' => payload['permissions'],
                        }
                    end

                    
                    ##
                    # @return [Hash] A list of objects where each object represents the result of processing a messaging Geo Permission. Each object contains the following fields: `country_code`, the country code of the country for which the permission was updated; `type`, the type of the permission i.e. country; `enabled`, true if the permission is enabled else false; `error_code`, an integer where 0 indicates success and any non-zero value represents an error; and `error_messages`, an array of strings describing specific validation errors encountered. If the request is successful, the error_messages array will be empty.
                    def permissions
                        @properties['permissions']
                    end
                    
                    ##
                    # Provide a user friendly representation
                    def to_s
                        "<Twilio.Accounts.V1.MessagingGeopermissionsInstance>"
                    end

                    ##
                    # Provide a detailed, user friendly representation
                    def inspect
                        "<Twilio.Accounts.V1.MessagingGeopermissionsInstance>"
                    end
                end

            end
        end
    end
end
