##
#    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 ExternalCampaignList < ListResource
                
                    ##
                    # Initialize the ExternalCampaignList
                    # @param [Version] version Version that contains the resource
                    # @return [ExternalCampaignList] ExternalCampaignList
                    def initialize(version)
                        super(version)
                        # Path Solution
                        @solution = {  }
                        @uri = "/Services/PreregisteredUsa2p"
                        
                    end
                    ##
                    # Create the ExternalCampaignInstance
                    # @param [String] campaign_id ID of the preregistered campaign.
                    # @param [String] messaging_service_sid The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) that the resource is associated with.
                    # @param [Boolean] cnp_migration Customers should use this flag during the ERC registration process to indicate to Twilio that the campaign being registered is undergoing CNP migration. It is important for the user to first trigger the CNP migration process for said campaign in their CSP portal and have Twilio accept the sharing request, before making this api call.
                    # @return [ExternalCampaignInstance] Created ExternalCampaignInstance
                    def create(
                        campaign_id: nil, 
                        messaging_service_sid: nil, 
                        cnp_migration: :unset
                    )

                        data = Twilio::Values.of({
                            'CampaignId' => campaign_id,
                            'MessagingServiceSid' => messaging_service_sid,
                            'CnpMigration' => cnp_migration,
                        })

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

                


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

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

                        # Path Solution
                        @solution = solution
                    end

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

                    ##
                    # Provide a user friendly representation
                    def to_s
                        '<Twilio.Messaging.V1.ExternalCampaignPage>'
                    end
                end
                class ExternalCampaignInstance < InstanceResource
                    ##
                    # Initialize the ExternalCampaignInstance
                    # @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 ExternalCampaign
                    #   resource.
                    # @param [String] sid The SID of the Call resource to fetch.
                    # @return [ExternalCampaignInstance] ExternalCampaignInstance
                    def initialize(version, payload )
                        super(version)
                        
                        # Marshaled Properties
                        @properties = { 
                            'sid' => payload['sid'],
                            'account_sid' => payload['account_sid'],
                            'campaign_id' => payload['campaign_id'],
                            'messaging_service_sid' => payload['messaging_service_sid'],
                            'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
                        }
                    end

                    
                    ##
                    # @return [String] The unique string that identifies a US A2P Compliance resource `QE2c6890da8086d771620e9b13fadeba0b`.
                    def sid
                        @properties['sid']
                    end
                    
                    ##
                    # @return [String] The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that the Campaign belongs to.
                    def account_sid
                        @properties['account_sid']
                    end
                    
                    ##
                    # @return [String] ID of the preregistered campaign.
                    def campaign_id
                        @properties['campaign_id']
                    end
                    
                    ##
                    # @return [String] The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) that the resource is associated with.
                    def messaging_service_sid
                        @properties['messaging_service_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
                    
                    ##
                    # Provide a user friendly representation
                    def to_s
                        "<Twilio.Messaging.V1.ExternalCampaignInstance>"
                    end

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

            end
        end
    end
end
