=begin
#Marketing Emails

#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

The version of the OpenAPI document: v3

Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1

=end

require 'cgi'

module Hubspot
  module Marketing
    module Emails
      class MarketingEmailsApi
        attr_accessor :api_client

        def initialize(api_client = ApiClient.default)
          @api_client = api_client
        end
        # Delete a marketing email.
        # @param email_id [String] The ID of the marketing email to delete.
        # @param [Hash] opts the optional parameters
        # @option opts [Boolean] :archived Whether to return only results that have been archived.
        # @return [nil]
        def archive(email_id, opts = {})
          archive_with_http_info(email_id, opts)
          nil
        end

        # Delete a marketing email.
        # @param email_id [String] The ID of the marketing email to delete.
        # @param [Hash] opts the optional parameters
        # @option opts [Boolean] :archived Whether to return only results that have been archived.
        # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
        def archive_with_http_info(email_id, opts = {})
          if @api_client.config.debugging
            @api_client.config.logger.debug 'Calling API: MarketingEmailsApi.archive ...'
          end
          # verify the required parameter 'email_id' is set
          if @api_client.config.client_side_validation && email_id.nil?
            fail ArgumentError, "Missing the required parameter 'email_id' when calling MarketingEmailsApi.archive"
          end
          # resource path
          local_var_path = '/marketing/v3/emails/{emailId}'.sub('{' + 'emailId' + '}', CGI.escape(email_id.to_s))

          # query parameters
          query_params = opts[:query_params] || {}
          query_params[:'archived'] = opts[:'archived'] if !opts[:'archived'].nil?

          # header parameters
          header_params = opts[:header_params] || {}
          # HTTP header 'Accept' (if needed)
          header_params['Accept'] = @api_client.select_header_accept(['*/*'])

          # form parameters
          form_params = opts[:form_params] || {}

          # http body (model)
          post_body = opts[:debug_body]

          # return_type
          return_type = opts[:debug_return_type]

          # auth_names
          auth_names = opts[:debug_auth_names] || ['oauth2']

          new_options = opts.merge(
            :operation => :"MarketingEmailsApi.archive",
            :header_params => header_params,
            :query_params => query_params,
            :form_params => form_params,
            :body => post_body,
            :auth_names => auth_names,
            :return_type => return_type
          )

          data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
          if @api_client.config.debugging
            @api_client.config.logger.debug "API called: MarketingEmailsApi#archive\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
          end
          return data, status_code, headers
        end

        # Clone a marketing email.
        # This will create a duplicate email with the same properties as the original, with the exception of a unique ID.
        # @param content_clone_request_v_next [ContentCloneRequestVNext] 
        # @param [Hash] opts the optional parameters
        # @return [PublicEmail]
        def clone(content_clone_request_v_next, opts = {})
          data, _status_code, _headers = clone_with_http_info(content_clone_request_v_next, opts)
          data
        end

        # Clone a marketing email.
        # This will create a duplicate email with the same properties as the original, with the exception of a unique ID.
        # @param content_clone_request_v_next [ContentCloneRequestVNext] 
        # @param [Hash] opts the optional parameters
        # @return [Array<(PublicEmail, Integer, Hash)>] PublicEmail data, response status code and response headers
        def clone_with_http_info(content_clone_request_v_next, opts = {})
          if @api_client.config.debugging
            @api_client.config.logger.debug 'Calling API: MarketingEmailsApi.clone ...'
          end
          # verify the required parameter 'content_clone_request_v_next' is set
          if @api_client.config.client_side_validation && content_clone_request_v_next.nil?
            fail ArgumentError, "Missing the required parameter 'content_clone_request_v_next' when calling MarketingEmailsApi.clone"
          end
          # resource path
          local_var_path = '/marketing/v3/emails/clone'

          # query parameters
          query_params = opts[:query_params] || {}

          # header parameters
          header_params = opts[:header_params] || {}
          # HTTP header 'Accept' (if needed)
          header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
          # HTTP header 'Content-Type'
          content_type = @api_client.select_header_content_type(['application/json'])
          if !content_type.nil?
              header_params['Content-Type'] = content_type
          end

          # form parameters
          form_params = opts[:form_params] || {}

          # http body (model)
          post_body = opts[:debug_body] || @api_client.object_to_http_body(content_clone_request_v_next)

          # return_type
          return_type = opts[:debug_return_type] || 'PublicEmail'

          # auth_names
          auth_names = opts[:debug_auth_names] || ['oauth2']

          new_options = opts.merge(
            :operation => :"MarketingEmailsApi.clone",
            :header_params => header_params,
            :query_params => query_params,
            :form_params => form_params,
            :body => post_body,
            :auth_names => auth_names,
            :return_type => return_type
          )

          data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
          if @api_client.config.debugging
            @api_client.config.logger.debug "API called: MarketingEmailsApi#clone\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
          end
          return data, status_code, headers
        end

        # Create a new marketing email.
        # Use this endpoint to create a new marketing email.
        # @param email_create_request [EmailCreateRequest] 
        # @param [Hash] opts the optional parameters
        # @return [PublicEmail]
        def create(email_create_request, opts = {})
          data, _status_code, _headers = create_with_http_info(email_create_request, opts)
          data
        end

        # Create a new marketing email.
        # Use this endpoint to create a new marketing email.
        # @param email_create_request [EmailCreateRequest] 
        # @param [Hash] opts the optional parameters
        # @return [Array<(PublicEmail, Integer, Hash)>] PublicEmail data, response status code and response headers
        def create_with_http_info(email_create_request, opts = {})
          if @api_client.config.debugging
            @api_client.config.logger.debug 'Calling API: MarketingEmailsApi.create ...'
          end
          # verify the required parameter 'email_create_request' is set
          if @api_client.config.client_side_validation && email_create_request.nil?
            fail ArgumentError, "Missing the required parameter 'email_create_request' when calling MarketingEmailsApi.create"
          end
          # resource path
          local_var_path = '/marketing/v3/emails/'

          # query parameters
          query_params = opts[:query_params] || {}

          # header parameters
          header_params = opts[:header_params] || {}
          # HTTP header 'Accept' (if needed)
          header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
          # HTTP header 'Content-Type'
          content_type = @api_client.select_header_content_type(['application/json'])
          if !content_type.nil?
              header_params['Content-Type'] = content_type
          end

          # form parameters
          form_params = opts[:form_params] || {}

          # http body (model)
          post_body = opts[:debug_body] || @api_client.object_to_http_body(email_create_request)

          # return_type
          return_type = opts[:debug_return_type] || 'PublicEmail'

          # auth_names
          auth_names = opts[:debug_auth_names] || ['oauth2']

          new_options = opts.merge(
            :operation => :"MarketingEmailsApi.create",
            :header_params => header_params,
            :query_params => query_params,
            :form_params => form_params,
            :body => post_body,
            :auth_names => auth_names,
            :return_type => return_type
          )

          data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
          if @api_client.config.debugging
            @api_client.config.logger.debug "API called: MarketingEmailsApi#create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
          end
          return data, status_code, headers
        end

        # Create an A/B test variation of a marketing email.
        # Create a variation of a marketing email for an A/B test. The new variation will be created as a draft. If an active variation already exists, a new one won't be created.
        # @param ab_test_create_request_v_next [AbTestCreateRequestVNext] 
        # @param [Hash] opts the optional parameters
        # @return [PublicEmail]
        def create_ab_test_variation(ab_test_create_request_v_next, opts = {})
          data, _status_code, _headers = create_ab_test_variation_with_http_info(ab_test_create_request_v_next, opts)
          data
        end

        # Create an A/B test variation of a marketing email.
        # Create a variation of a marketing email for an A/B test. The new variation will be created as a draft. If an active variation already exists, a new one won&#39;t be created.
        # @param ab_test_create_request_v_next [AbTestCreateRequestVNext] 
        # @param [Hash] opts the optional parameters
        # @return [Array<(PublicEmail, Integer, Hash)>] PublicEmail data, response status code and response headers
        def create_ab_test_variation_with_http_info(ab_test_create_request_v_next, opts = {})
          if @api_client.config.debugging
            @api_client.config.logger.debug 'Calling API: MarketingEmailsApi.create_ab_test_variation ...'
          end
          # verify the required parameter 'ab_test_create_request_v_next' is set
          if @api_client.config.client_side_validation && ab_test_create_request_v_next.nil?
            fail ArgumentError, "Missing the required parameter 'ab_test_create_request_v_next' when calling MarketingEmailsApi.create_ab_test_variation"
          end
          # resource path
          local_var_path = '/marketing/v3/emails/ab-test/create-variation'

          # query parameters
          query_params = opts[:query_params] || {}

          # header parameters
          header_params = opts[:header_params] || {}
          # HTTP header 'Accept' (if needed)
          header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
          # HTTP header 'Content-Type'
          content_type = @api_client.select_header_content_type(['application/json'])
          if !content_type.nil?
              header_params['Content-Type'] = content_type
          end

          # form parameters
          form_params = opts[:form_params] || {}

          # http body (model)
          post_body = opts[:debug_body] || @api_client.object_to_http_body(ab_test_create_request_v_next)

          # return_type
          return_type = opts[:debug_return_type] || 'PublicEmail'

          # auth_names
          auth_names = opts[:debug_auth_names] || ['oauth2']

          new_options = opts.merge(
            :operation => :"MarketingEmailsApi.create_ab_test_variation",
            :header_params => header_params,
            :query_params => query_params,
            :form_params => form_params,
            :body => post_body,
            :auth_names => auth_names,
            :return_type => return_type
          )

          data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
          if @api_client.config.debugging
            @api_client.config.logger.debug "API called: MarketingEmailsApi#create_ab_test_variation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
          end
          return data, status_code, headers
        end

        # Get the variation of a an A/B marketing email
        # This endpoint lets you obtain the variation of an A/B marketing email. If the email is variation A (master) it will return variation B (variant) and vice versa.
        # @param email_id [String] The ID of an A/B marketing email.
        # @param [Hash] opts the optional parameters
        # @return [PublicEmail]
        def get_ab_test_variation(email_id, opts = {})
          data, _status_code, _headers = get_ab_test_variation_with_http_info(email_id, opts)
          data
        end

        # Get the variation of a an A/B marketing email
        # This endpoint lets you obtain the variation of an A/B marketing email. If the email is variation A (master) it will return variation B (variant) and vice versa.
        # @param email_id [String] The ID of an A/B marketing email.
        # @param [Hash] opts the optional parameters
        # @return [Array<(PublicEmail, Integer, Hash)>] PublicEmail data, response status code and response headers
        def get_ab_test_variation_with_http_info(email_id, opts = {})
          if @api_client.config.debugging
            @api_client.config.logger.debug 'Calling API: MarketingEmailsApi.get_ab_test_variation ...'
          end
          # verify the required parameter 'email_id' is set
          if @api_client.config.client_side_validation && email_id.nil?
            fail ArgumentError, "Missing the required parameter 'email_id' when calling MarketingEmailsApi.get_ab_test_variation"
          end
          # resource path
          local_var_path = '/marketing/v3/emails/{emailId}/ab-test/get-variation'.sub('{' + 'emailId' + '}', CGI.escape(email_id.to_s))

          # query parameters
          query_params = opts[:query_params] || {}

          # header parameters
          header_params = opts[:header_params] || {}
          # HTTP header 'Accept' (if needed)
          header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])

          # form parameters
          form_params = opts[:form_params] || {}

          # http body (model)
          post_body = opts[:debug_body]

          # return_type
          return_type = opts[:debug_return_type] || 'PublicEmail'

          # auth_names
          auth_names = opts[:debug_auth_names] || ['oauth2']

          new_options = opts.merge(
            :operation => :"MarketingEmailsApi.get_ab_test_variation",
            :header_params => header_params,
            :query_params => query_params,
            :form_params => form_params,
            :body => post_body,
            :auth_names => auth_names,
            :return_type => return_type
          )

          data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
          if @api_client.config.debugging
            @api_client.config.logger.debug "API called: MarketingEmailsApi#get_ab_test_variation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
          end
          return data, status_code, headers
        end

        # Get the details of a specified marketing email.
        # Get the details for a marketing email.
        # @param email_id [String] The marketing email ID.
        # @param [Hash] opts the optional parameters
        # @option opts [Boolean] :include_stats Include statistics with email
        # @option opts [Boolean] :marketing_campaign_names 
        # @option opts [Boolean] :workflow_names 
        # @option opts [Array<String>] :included_properties 
        # @option opts [Boolean] :archived Whether to return only results that have been archived.
        # @return [PublicEmail]
        def get_by_id(email_id, opts = {})
          data, _status_code, _headers = get_by_id_with_http_info(email_id, opts)
          data
        end

        # Get the details of a specified marketing email.
        # Get the details for a marketing email.
        # @param email_id [String] The marketing email ID.
        # @param [Hash] opts the optional parameters
        # @option opts [Boolean] :include_stats Include statistics with email
        # @option opts [Boolean] :marketing_campaign_names 
        # @option opts [Boolean] :workflow_names 
        # @option opts [Array<String>] :included_properties 
        # @option opts [Boolean] :archived Whether to return only results that have been archived.
        # @return [Array<(PublicEmail, Integer, Hash)>] PublicEmail data, response status code and response headers
        def get_by_id_with_http_info(email_id, opts = {})
          if @api_client.config.debugging
            @api_client.config.logger.debug 'Calling API: MarketingEmailsApi.get_by_id ...'
          end
          # verify the required parameter 'email_id' is set
          if @api_client.config.client_side_validation && email_id.nil?
            fail ArgumentError, "Missing the required parameter 'email_id' when calling MarketingEmailsApi.get_by_id"
          end
          # resource path
          local_var_path = '/marketing/v3/emails/{emailId}'.sub('{' + 'emailId' + '}', CGI.escape(email_id.to_s))

          # query parameters
          query_params = opts[:query_params] || {}
          query_params[:'includeStats'] = opts[:'include_stats'] if !opts[:'include_stats'].nil?
          query_params[:'marketingCampaignNames'] = opts[:'marketing_campaign_names'] if !opts[:'marketing_campaign_names'].nil?
          query_params[:'workflowNames'] = opts[:'workflow_names'] if !opts[:'workflow_names'].nil?
          query_params[:'includedProperties'] = @api_client.build_collection_param(opts[:'included_properties'], :multi) if !opts[:'included_properties'].nil?
          query_params[:'archived'] = opts[:'archived'] if !opts[:'archived'].nil?

          # header parameters
          header_params = opts[:header_params] || {}
          # HTTP header 'Accept' (if needed)
          header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])

          # form parameters
          form_params = opts[:form_params] || {}

          # http body (model)
          post_body = opts[:debug_body]

          # return_type
          return_type = opts[:debug_return_type] || 'PublicEmail'

          # auth_names
          auth_names = opts[:debug_auth_names] || ['oauth2']

          new_options = opts.merge(
            :operation => :"MarketingEmailsApi.get_by_id",
            :header_params => header_params,
            :query_params => query_params,
            :form_params => form_params,
            :body => post_body,
            :auth_names => auth_names,
            :return_type => return_type
          )

          data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
          if @api_client.config.debugging
            @api_client.config.logger.debug "API called: MarketingEmailsApi#get_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
          end
          return data, status_code, headers
        end

        # Get draft version of a marketing email
        # Get the draft version of an email (if it exists). If no draft version exists, the published email is returned.
        # @param email_id [String] The marketing email ID.
        # @param [Hash] opts the optional parameters
        # @return [PublicEmail]
        def get_draft(email_id, opts = {})
          data, _status_code, _headers = get_draft_with_http_info(email_id, opts)
          data
        end

        # Get draft version of a marketing email
        # Get the draft version of an email (if it exists). If no draft version exists, the published email is returned.
        # @param email_id [String] The marketing email ID.
        # @param [Hash] opts the optional parameters
        # @return [Array<(PublicEmail, Integer, Hash)>] PublicEmail data, response status code and response headers
        def get_draft_with_http_info(email_id, opts = {})
          if @api_client.config.debugging
            @api_client.config.logger.debug 'Calling API: MarketingEmailsApi.get_draft ...'
          end
          # verify the required parameter 'email_id' is set
          if @api_client.config.client_side_validation && email_id.nil?
            fail ArgumentError, "Missing the required parameter 'email_id' when calling MarketingEmailsApi.get_draft"
          end
          # resource path
          local_var_path = '/marketing/v3/emails/{emailId}/draft'.sub('{' + 'emailId' + '}', CGI.escape(email_id.to_s))

          # query parameters
          query_params = opts[:query_params] || {}

          # header parameters
          header_params = opts[:header_params] || {}
          # HTTP header 'Accept' (if needed)
          header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])

          # form parameters
          form_params = opts[:form_params] || {}

          # http body (model)
          post_body = opts[:debug_body]

          # return_type
          return_type = opts[:debug_return_type] || 'PublicEmail'

          # auth_names
          auth_names = opts[:debug_auth_names] || ['oauth2']

          new_options = opts.merge(
            :operation => :"MarketingEmailsApi.get_draft",
            :header_params => header_params,
            :query_params => query_params,
            :form_params => form_params,
            :body => post_body,
            :auth_names => auth_names,
            :return_type => return_type
          )

          data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
          if @api_client.config.debugging
            @api_client.config.logger.debug "API called: MarketingEmailsApi#get_draft\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
          end
          return data, status_code, headers
        end

        # Get all marketing emails for a HubSpot account.
        # The results can be filtered, allowing you to find a specific set of emails. See the table below for a full list of filtering options.
        # @param [Hash] opts the optional parameters
        # @option opts [Time] :created_at Only return emails created at exactly the specified time.
        # @option opts [Time] :created_after Only return emails created after the specified time.
        # @option opts [Time] :created_before Only return emails created before the specified time.
        # @option opts [Time] :updated_at Only return emails last updated at exactly the specified time.
        # @option opts [Time] :updated_after Only return emails last updated after the specified time.
        # @option opts [Time] :updated_before Only return emails last updated before the specified time.
        # @option opts [Array<String>] :sort Specifies which fields to use for sorting results. Valid fields are &#x60;name&#x60;, &#x60;createdAt&#x60;, &#x60;updatedAt&#x60;, &#x60;createdBy&#x60;, &#x60;updatedBy&#x60;. &#x60;createdAt&#x60; will be used by default.
        # @option opts [String] :after The cursor token value to get the next set of results. You can get this from the &#x60;paging.next.after&#x60; JSON property of a paged response containing more results.
        # @option opts [Integer] :limit The maximum number of results to return. Default is 100.
        # @option opts [Boolean] :include_stats Include statistics with emails.
        # @option opts [Boolean] :marketing_campaign_names 
        # @option opts [Boolean] :workflow_names 
        # @option opts [String] :type Email types to be filtered by. Multiple types can be included. All emails will be returned if not present.
        # @option opts [Boolean] :is_published Filter by published/draft emails. All emails will be returned if not present.
        # @option opts [Array<String>] :included_properties 
        # @option opts [Boolean] :archived Specifies whether to return archived emails. Defaults to &#x60;false&#x60;.
        # @return [CollectionResponseWithTotalPublicEmailForwardPaging]
        def get_page(opts = {})
          data, _status_code, _headers = get_page_with_http_info(opts)
          data
        end

        # Get all marketing emails for a HubSpot account.
        # The results can be filtered, allowing you to find a specific set of emails. See the table below for a full list of filtering options.
        # @param [Hash] opts the optional parameters
        # @option opts [Time] :created_at Only return emails created at exactly the specified time.
        # @option opts [Time] :created_after Only return emails created after the specified time.
        # @option opts [Time] :created_before Only return emails created before the specified time.
        # @option opts [Time] :updated_at Only return emails last updated at exactly the specified time.
        # @option opts [Time] :updated_after Only return emails last updated after the specified time.
        # @option opts [Time] :updated_before Only return emails last updated before the specified time.
        # @option opts [Array<String>] :sort Specifies which fields to use for sorting results. Valid fields are &#x60;name&#x60;, &#x60;createdAt&#x60;, &#x60;updatedAt&#x60;, &#x60;createdBy&#x60;, &#x60;updatedBy&#x60;. &#x60;createdAt&#x60; will be used by default.
        # @option opts [String] :after The cursor token value to get the next set of results. You can get this from the &#x60;paging.next.after&#x60; JSON property of a paged response containing more results.
        # @option opts [Integer] :limit The maximum number of results to return. Default is 100.
        # @option opts [Boolean] :include_stats Include statistics with emails.
        # @option opts [Boolean] :marketing_campaign_names 
        # @option opts [Boolean] :workflow_names 
        # @option opts [String] :type Email types to be filtered by. Multiple types can be included. All emails will be returned if not present.
        # @option opts [Boolean] :is_published Filter by published/draft emails. All emails will be returned if not present.
        # @option opts [Array<String>] :included_properties 
        # @option opts [Boolean] :archived Specifies whether to return archived emails. Defaults to &#x60;false&#x60;.
        # @return [Array<(CollectionResponseWithTotalPublicEmailForwardPaging, Integer, Hash)>] CollectionResponseWithTotalPublicEmailForwardPaging data, response status code and response headers
        def get_page_with_http_info(opts = {})
          if @api_client.config.debugging
            @api_client.config.logger.debug 'Calling API: MarketingEmailsApi.get_page ...'
          end
          allowable_values = ["AB_EMAIL", "BATCH_EMAIL", "LOCALTIME_EMAIL", "AUTOMATED_AB_EMAIL", "BLOG_EMAIL", "BLOG_EMAIL_CHILD", "RSS_EMAIL", "RSS_EMAIL_CHILD", "RESUBSCRIBE_EMAIL", "OPTIN_EMAIL", "OPTIN_FOLLOWUP_EMAIL", "AUTOMATED_EMAIL", "FEEDBACK_CES_EMAIL", "FEEDBACK_CUSTOM_EMAIL", "FEEDBACK_CUSTOM_SURVEY_EMAIL", "FEEDBACK_NPS_EMAIL", "FOLLOWUP_EMAIL", "LEADFLOW_EMAIL", "SINGLE_SEND_API", "MARKETING_SINGLE_SEND_API", "SMTP_TOKEN", "TICKET_EMAIL", "MEMBERSHIP_REGISTRATION_EMAIL", "MEMBERSHIP_PASSWORD_SAVED_EMAIL", "MEMBERSHIP_PASSWORD_RESET_EMAIL", "MEMBERSHIP_EMAIL_VERIFICATION_EMAIL", "MEMBERSHIP_PASSWORDLESS_AUTH_EMAIL", "MEMBERSHIP_REGISTRATION_FOLLOW_UP_EMAIL", "MEMBERSHIP_OTP_LOGIN_EMAIL", "MEMBERSHIP_FOLLOW_UP_EMAIL", "MEMBERSHIP_VERIFICATION_EMAIL"]
          if @api_client.config.client_side_validation && opts[:'type'] && !allowable_values.include?(opts[:'type'])
            fail ArgumentError, "invalid value for \"type\", must be one of #{allowable_values}"
          end
          # resource path
          local_var_path = '/marketing/v3/emails/'

          # query parameters
          query_params = opts[:query_params] || {}
          query_params[:'createdAt'] = opts[:'created_at'] if !opts[:'created_at'].nil?
          query_params[:'createdAfter'] = opts[:'created_after'] if !opts[:'created_after'].nil?
          query_params[:'createdBefore'] = opts[:'created_before'] if !opts[:'created_before'].nil?
          query_params[:'updatedAt'] = opts[:'updated_at'] if !opts[:'updated_at'].nil?
          query_params[:'updatedAfter'] = opts[:'updated_after'] if !opts[:'updated_after'].nil?
          query_params[:'updatedBefore'] = opts[:'updated_before'] if !opts[:'updated_before'].nil?
          query_params[:'sort'] = @api_client.build_collection_param(opts[:'sort'], :multi) if !opts[:'sort'].nil?
          query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?
          query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
          query_params[:'includeStats'] = opts[:'include_stats'] if !opts[:'include_stats'].nil?
          query_params[:'marketingCampaignNames'] = opts[:'marketing_campaign_names'] if !opts[:'marketing_campaign_names'].nil?
          query_params[:'workflowNames'] = opts[:'workflow_names'] if !opts[:'workflow_names'].nil?
          query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?
          query_params[:'isPublished'] = opts[:'is_published'] if !opts[:'is_published'].nil?
          query_params[:'includedProperties'] = @api_client.build_collection_param(opts[:'included_properties'], :multi) if !opts[:'included_properties'].nil?
          query_params[:'archived'] = opts[:'archived'] if !opts[:'archived'].nil?

          # header parameters
          header_params = opts[:header_params] || {}
          # HTTP header 'Accept' (if needed)
          header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])

          # form parameters
          form_params = opts[:form_params] || {}

          # http body (model)
          post_body = opts[:debug_body]

          # return_type
          return_type = opts[:debug_return_type] || 'CollectionResponseWithTotalPublicEmailForwardPaging'

          # auth_names
          auth_names = opts[:debug_auth_names] || ['oauth2']

          new_options = opts.merge(
            :operation => :"MarketingEmailsApi.get_page",
            :header_params => header_params,
            :query_params => query_params,
            :form_params => form_params,
            :body => post_body,
            :auth_names => auth_names,
            :return_type => return_type
          )

          data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
          if @api_client.config.debugging
            @api_client.config.logger.debug "API called: MarketingEmailsApi#get_page\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
          end
          return data, status_code, headers
        end

        # Get a revision of a marketing email.
        # Get a specific revision of a marketing email.
        # @param email_id [String] The marketing email ID.
        # @param revision_id [String] The ID of a revision.
        # @param [Hash] opts the optional parameters
        # @return [VersionPublicEmail]
        def get_revision_by_id(email_id, revision_id, opts = {})
          data, _status_code, _headers = get_revision_by_id_with_http_info(email_id, revision_id, opts)
          data
        end

        # Get a revision of a marketing email.
        # Get a specific revision of a marketing email.
        # @param email_id [String] The marketing email ID.
        # @param revision_id [String] The ID of a revision.
        # @param [Hash] opts the optional parameters
        # @return [Array<(VersionPublicEmail, Integer, Hash)>] VersionPublicEmail data, response status code and response headers
        def get_revision_by_id_with_http_info(email_id, revision_id, opts = {})
          if @api_client.config.debugging
            @api_client.config.logger.debug 'Calling API: MarketingEmailsApi.get_revision_by_id ...'
          end
          # verify the required parameter 'email_id' is set
          if @api_client.config.client_side_validation && email_id.nil?
            fail ArgumentError, "Missing the required parameter 'email_id' when calling MarketingEmailsApi.get_revision_by_id"
          end
          # verify the required parameter 'revision_id' is set
          if @api_client.config.client_side_validation && revision_id.nil?
            fail ArgumentError, "Missing the required parameter 'revision_id' when calling MarketingEmailsApi.get_revision_by_id"
          end
          # resource path
          local_var_path = '/marketing/v3/emails/{emailId}/revisions/{revisionId}'.sub('{' + 'emailId' + '}', CGI.escape(email_id.to_s)).sub('{' + 'revisionId' + '}', CGI.escape(revision_id.to_s))

          # query parameters
          query_params = opts[:query_params] || {}

          # header parameters
          header_params = opts[:header_params] || {}
          # HTTP header 'Accept' (if needed)
          header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])

          # form parameters
          form_params = opts[:form_params] || {}

          # http body (model)
          post_body = opts[:debug_body]

          # return_type
          return_type = opts[:debug_return_type] || 'VersionPublicEmail'

          # auth_names
          auth_names = opts[:debug_auth_names] || ['oauth2']

          new_options = opts.merge(
            :operation => :"MarketingEmailsApi.get_revision_by_id",
            :header_params => header_params,
            :query_params => query_params,
            :form_params => form_params,
            :body => post_body,
            :auth_names => auth_names,
            :return_type => return_type
          )

          data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
          if @api_client.config.debugging
            @api_client.config.logger.debug "API called: MarketingEmailsApi#get_revision_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
          end
          return data, status_code, headers
        end

        # Get revisions of a marketing email
        # Get a list of all versions of a marketing email, with each entry including the full state of that particular version. The current revision has the ID -1.
        # @param email_id [String] The marketing email ID.
        # @param [Hash] opts the optional parameters
        # @option opts [String] :after The cursor token value to get the next set of results. You can get this from the &#x60;paging.next.after&#x60; JSON property of a paged response containing more results.
        # @option opts [String] :before The cursor token value to get the previous set of results. You can get this from the &#x60;paging.prev.before&#x60; JSON property of a paged response containing more results.
        # @option opts [Integer] :limit The maximum number of results to return. Default is 100.
        # @return [CollectionResponseWithTotalVersionPublicEmail]
        def get_revisions(email_id, opts = {})
          data, _status_code, _headers = get_revisions_with_http_info(email_id, opts)
          data
        end

        # Get revisions of a marketing email
        # Get a list of all versions of a marketing email, with each entry including the full state of that particular version. The current revision has the ID -1.
        # @param email_id [String] The marketing email ID.
        # @param [Hash] opts the optional parameters
        # @option opts [String] :after The cursor token value to get the next set of results. You can get this from the &#x60;paging.next.after&#x60; JSON property of a paged response containing more results.
        # @option opts [String] :before The cursor token value to get the previous set of results. You can get this from the &#x60;paging.prev.before&#x60; JSON property of a paged response containing more results.
        # @option opts [Integer] :limit The maximum number of results to return. Default is 100.
        # @return [Array<(CollectionResponseWithTotalVersionPublicEmail, Integer, Hash)>] CollectionResponseWithTotalVersionPublicEmail data, response status code and response headers
        def get_revisions_with_http_info(email_id, opts = {})
          if @api_client.config.debugging
            @api_client.config.logger.debug 'Calling API: MarketingEmailsApi.get_revisions ...'
          end
          # verify the required parameter 'email_id' is set
          if @api_client.config.client_side_validation && email_id.nil?
            fail ArgumentError, "Missing the required parameter 'email_id' when calling MarketingEmailsApi.get_revisions"
          end
          # resource path
          local_var_path = '/marketing/v3/emails/{emailId}/revisions'.sub('{' + 'emailId' + '}', CGI.escape(email_id.to_s))

          # query parameters
          query_params = opts[:query_params] || {}
          query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?
          query_params[:'before'] = opts[:'before'] if !opts[:'before'].nil?
          query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?

          # header parameters
          header_params = opts[:header_params] || {}
          # HTTP header 'Accept' (if needed)
          header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])

          # form parameters
          form_params = opts[:form_params] || {}

          # http body (model)
          post_body = opts[:debug_body]

          # return_type
          return_type = opts[:debug_return_type] || 'CollectionResponseWithTotalVersionPublicEmail'

          # auth_names
          auth_names = opts[:debug_auth_names] || ['oauth2']

          new_options = opts.merge(
            :operation => :"MarketingEmailsApi.get_revisions",
            :header_params => header_params,
            :query_params => query_params,
            :form_params => form_params,
            :body => post_body,
            :auth_names => auth_names,
            :return_type => return_type
          )

          data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
          if @api_client.config.debugging
            @api_client.config.logger.debug "API called: MarketingEmailsApi#get_revisions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
          end
          return data, status_code, headers
        end

        # Publish or send a marketing email.
        # If you have a Marketing Hub Enterprise account or the transactional email add-on, you can use this endpoint to publish an automated email or send/schedule a regular email.
        # @param email_id [String] 
        # @param [Hash] opts the optional parameters
        # @return [nil]
        def publish_or_send(email_id, opts = {})
          publish_or_send_with_http_info(email_id, opts)
          nil
        end

        # Publish or send a marketing email.
        # If you have a Marketing Hub Enterprise account or the transactional email add-on, you can use this endpoint to publish an automated email or send/schedule a regular email.
        # @param email_id [String] 
        # @param [Hash] opts the optional parameters
        # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
        def publish_or_send_with_http_info(email_id, opts = {})
          if @api_client.config.debugging
            @api_client.config.logger.debug 'Calling API: MarketingEmailsApi.publish_or_send ...'
          end
          # verify the required parameter 'email_id' is set
          if @api_client.config.client_side_validation && email_id.nil?
            fail ArgumentError, "Missing the required parameter 'email_id' when calling MarketingEmailsApi.publish_or_send"
          end
          # resource path
          local_var_path = '/marketing/v3/emails/{emailId}/publish'.sub('{' + 'emailId' + '}', CGI.escape(email_id.to_s))

          # query parameters
          query_params = opts[:query_params] || {}

          # header parameters
          header_params = opts[:header_params] || {}
          # HTTP header 'Accept' (if needed)
          header_params['Accept'] = @api_client.select_header_accept(['*/*'])

          # form parameters
          form_params = opts[:form_params] || {}

          # http body (model)
          post_body = opts[:debug_body]

          # return_type
          return_type = opts[:debug_return_type]

          # auth_names
          auth_names = opts[:debug_auth_names] || ['oauth2']

          new_options = opts.merge(
            :operation => :"MarketingEmailsApi.publish_or_send",
            :header_params => header_params,
            :query_params => query_params,
            :form_params => form_params,
            :body => post_body,
            :auth_names => auth_names,
            :return_type => return_type
          )

          data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
          if @api_client.config.debugging
            @api_client.config.logger.debug "API called: MarketingEmailsApi#publish_or_send\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
          end
          return data, status_code, headers
        end

        # Reset Draft
        # Resets the draft back to a copy of the live object.
        # @param email_id [String] The marketing email ID.
        # @param [Hash] opts the optional parameters
        # @return [nil]
        def reset_draft(email_id, opts = {})
          reset_draft_with_http_info(email_id, opts)
          nil
        end

        # Reset Draft
        # Resets the draft back to a copy of the live object.
        # @param email_id [String] The marketing email ID.
        # @param [Hash] opts the optional parameters
        # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
        def reset_draft_with_http_info(email_id, opts = {})
          if @api_client.config.debugging
            @api_client.config.logger.debug 'Calling API: MarketingEmailsApi.reset_draft ...'
          end
          # verify the required parameter 'email_id' is set
          if @api_client.config.client_side_validation && email_id.nil?
            fail ArgumentError, "Missing the required parameter 'email_id' when calling MarketingEmailsApi.reset_draft"
          end
          # resource path
          local_var_path = '/marketing/v3/emails/{emailId}/draft/reset'.sub('{' + 'emailId' + '}', CGI.escape(email_id.to_s))

          # query parameters
          query_params = opts[:query_params] || {}

          # header parameters
          header_params = opts[:header_params] || {}
          # HTTP header 'Accept' (if needed)
          header_params['Accept'] = @api_client.select_header_accept(['*/*'])

          # form parameters
          form_params = opts[:form_params] || {}

          # http body (model)
          post_body = opts[:debug_body]

          # return_type
          return_type = opts[:debug_return_type]

          # auth_names
          auth_names = opts[:debug_auth_names] || ['oauth2']

          new_options = opts.merge(
            :operation => :"MarketingEmailsApi.reset_draft",
            :header_params => header_params,
            :query_params => query_params,
            :form_params => form_params,
            :body => post_body,
            :auth_names => auth_names,
            :return_type => return_type
          )

          data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
          if @api_client.config.debugging
            @api_client.config.logger.debug "API called: MarketingEmailsApi#reset_draft\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
          end
          return data, status_code, headers
        end

        # Restore a revision of a marketing email to DRAFT state
        # Restores a previous revision of a marketing email to DRAFT state. If there is currently something in the draft for that object, it is overwritten. 
        # @param email_id [String] The marketing email ID.
        # @param revision_id [Integer] The ID of a revision.
        # @param [Hash] opts the optional parameters
        # @return [PublicEmail]
        def restore_draft_revision(email_id, revision_id, opts = {})
          data, _status_code, _headers = restore_draft_revision_with_http_info(email_id, revision_id, opts)
          data
        end

        # Restore a revision of a marketing email to DRAFT state
        # Restores a previous revision of a marketing email to DRAFT state. If there is currently something in the draft for that object, it is overwritten. 
        # @param email_id [String] The marketing email ID.
        # @param revision_id [Integer] The ID of a revision.
        # @param [Hash] opts the optional parameters
        # @return [Array<(PublicEmail, Integer, Hash)>] PublicEmail data, response status code and response headers
        def restore_draft_revision_with_http_info(email_id, revision_id, opts = {})
          if @api_client.config.debugging
            @api_client.config.logger.debug 'Calling API: MarketingEmailsApi.restore_draft_revision ...'
          end
          # verify the required parameter 'email_id' is set
          if @api_client.config.client_side_validation && email_id.nil?
            fail ArgumentError, "Missing the required parameter 'email_id' when calling MarketingEmailsApi.restore_draft_revision"
          end
          # verify the required parameter 'revision_id' is set
          if @api_client.config.client_side_validation && revision_id.nil?
            fail ArgumentError, "Missing the required parameter 'revision_id' when calling MarketingEmailsApi.restore_draft_revision"
          end
          # resource path
          local_var_path = '/marketing/v3/emails/{emailId}/revisions/{revisionId}/restore-to-draft'.sub('{' + 'emailId' + '}', CGI.escape(email_id.to_s)).sub('{' + 'revisionId' + '}', CGI.escape(revision_id.to_s))

          # query parameters
          query_params = opts[:query_params] || {}

          # header parameters
          header_params = opts[:header_params] || {}
          # HTTP header 'Accept' (if needed)
          header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])

          # form parameters
          form_params = opts[:form_params] || {}

          # http body (model)
          post_body = opts[:debug_body]

          # return_type
          return_type = opts[:debug_return_type] || 'PublicEmail'

          # auth_names
          auth_names = opts[:debug_auth_names] || ['oauth2']

          new_options = opts.merge(
            :operation => :"MarketingEmailsApi.restore_draft_revision",
            :header_params => header_params,
            :query_params => query_params,
            :form_params => form_params,
            :body => post_body,
            :auth_names => auth_names,
            :return_type => return_type
          )

          data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
          if @api_client.config.debugging
            @api_client.config.logger.debug "API called: MarketingEmailsApi#restore_draft_revision\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
          end
          return data, status_code, headers
        end

        # Restore a revision of a marketing email
        # Restores a previous revision of a marketing email. The current revision becomes old, and the restored revision is given a new version number.
        # @param email_id [String] The marketing email ID.
        # @param revision_id [String] The ID of a revision.
        # @param [Hash] opts the optional parameters
        # @return [nil]
        def restore_revision(email_id, revision_id, opts = {})
          restore_revision_with_http_info(email_id, revision_id, opts)
          nil
        end

        # Restore a revision of a marketing email
        # Restores a previous revision of a marketing email. The current revision becomes old, and the restored revision is given a new version number.
        # @param email_id [String] The marketing email ID.
        # @param revision_id [String] The ID of a revision.
        # @param [Hash] opts the optional parameters
        # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
        def restore_revision_with_http_info(email_id, revision_id, opts = {})
          if @api_client.config.debugging
            @api_client.config.logger.debug 'Calling API: MarketingEmailsApi.restore_revision ...'
          end
          # verify the required parameter 'email_id' is set
          if @api_client.config.client_side_validation && email_id.nil?
            fail ArgumentError, "Missing the required parameter 'email_id' when calling MarketingEmailsApi.restore_revision"
          end
          # verify the required parameter 'revision_id' is set
          if @api_client.config.client_side_validation && revision_id.nil?
            fail ArgumentError, "Missing the required parameter 'revision_id' when calling MarketingEmailsApi.restore_revision"
          end
          # resource path
          local_var_path = '/marketing/v3/emails/{emailId}/revisions/{revisionId}/restore'.sub('{' + 'emailId' + '}', CGI.escape(email_id.to_s)).sub('{' + 'revisionId' + '}', CGI.escape(revision_id.to_s))

          # query parameters
          query_params = opts[:query_params] || {}

          # header parameters
          header_params = opts[:header_params] || {}
          # HTTP header 'Accept' (if needed)
          header_params['Accept'] = @api_client.select_header_accept(['*/*'])

          # form parameters
          form_params = opts[:form_params] || {}

          # http body (model)
          post_body = opts[:debug_body]

          # return_type
          return_type = opts[:debug_return_type]

          # auth_names
          auth_names = opts[:debug_auth_names] || ['oauth2']

          new_options = opts.merge(
            :operation => :"MarketingEmailsApi.restore_revision",
            :header_params => header_params,
            :query_params => query_params,
            :form_params => form_params,
            :body => post_body,
            :auth_names => auth_names,
            :return_type => return_type
          )

          data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
          if @api_client.config.debugging
            @api_client.config.logger.debug "API called: MarketingEmailsApi#restore_revision\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
          end
          return data, status_code, headers
        end

        # Unpublish or cancel a marketing email.
        # If you have a Marketing Hub Enterprise account or the transactional email add-on, you can use this endpoint to unpublish an automated email or cancel a regular email. If the email is already in the process of being sent, canceling might not be possible.
        # @param email_id [String] 
        # @param [Hash] opts the optional parameters
        # @return [nil]
        def unpublish_or_cancel(email_id, opts = {})
          unpublish_or_cancel_with_http_info(email_id, opts)
          nil
        end

        # Unpublish or cancel a marketing email.
        # If you have a Marketing Hub Enterprise account or the transactional email add-on, you can use this endpoint to unpublish an automated email or cancel a regular email. If the email is already in the process of being sent, canceling might not be possible.
        # @param email_id [String] 
        # @param [Hash] opts the optional parameters
        # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
        def unpublish_or_cancel_with_http_info(email_id, opts = {})
          if @api_client.config.debugging
            @api_client.config.logger.debug 'Calling API: MarketingEmailsApi.unpublish_or_cancel ...'
          end
          # verify the required parameter 'email_id' is set
          if @api_client.config.client_side_validation && email_id.nil?
            fail ArgumentError, "Missing the required parameter 'email_id' when calling MarketingEmailsApi.unpublish_or_cancel"
          end
          # resource path
          local_var_path = '/marketing/v3/emails/{emailId}/unpublish'.sub('{' + 'emailId' + '}', CGI.escape(email_id.to_s))

          # query parameters
          query_params = opts[:query_params] || {}

          # header parameters
          header_params = opts[:header_params] || {}
          # HTTP header 'Accept' (if needed)
          header_params['Accept'] = @api_client.select_header_accept(['*/*'])

          # form parameters
          form_params = opts[:form_params] || {}

          # http body (model)
          post_body = opts[:debug_body]

          # return_type
          return_type = opts[:debug_return_type]

          # auth_names
          auth_names = opts[:debug_auth_names] || ['oauth2']

          new_options = opts.merge(
            :operation => :"MarketingEmailsApi.unpublish_or_cancel",
            :header_params => header_params,
            :query_params => query_params,
            :form_params => form_params,
            :body => post_body,
            :auth_names => auth_names,
            :return_type => return_type
          )

          data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
          if @api_client.config.debugging
            @api_client.config.logger.debug "API called: MarketingEmailsApi#unpublish_or_cancel\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
          end
          return data, status_code, headers
        end

        # Update a marketing email.
        # Change properties of a marketing email.
        # @param email_id [String] The ID of the marketing email that should get updated
        # @param email_update_request [EmailUpdateRequest] A marketing email object with properties that should overwrite the corresponding properties of the marketing email.
        # @param [Hash] opts the optional parameters
        # @option opts [Boolean] :archived Whether to return only results that have been archived.
        # @return [PublicEmail]
        def update(email_id, email_update_request, opts = {})
          data, _status_code, _headers = update_with_http_info(email_id, email_update_request, opts)
          data
        end

        # Update a marketing email.
        # Change properties of a marketing email.
        # @param email_id [String] The ID of the marketing email that should get updated
        # @param email_update_request [EmailUpdateRequest] A marketing email object with properties that should overwrite the corresponding properties of the marketing email.
        # @param [Hash] opts the optional parameters
        # @option opts [Boolean] :archived Whether to return only results that have been archived.
        # @return [Array<(PublicEmail, Integer, Hash)>] PublicEmail data, response status code and response headers
        def update_with_http_info(email_id, email_update_request, opts = {})
          if @api_client.config.debugging
            @api_client.config.logger.debug 'Calling API: MarketingEmailsApi.update ...'
          end
          # verify the required parameter 'email_id' is set
          if @api_client.config.client_side_validation && email_id.nil?
            fail ArgumentError, "Missing the required parameter 'email_id' when calling MarketingEmailsApi.update"
          end
          # verify the required parameter 'email_update_request' is set
          if @api_client.config.client_side_validation && email_update_request.nil?
            fail ArgumentError, "Missing the required parameter 'email_update_request' when calling MarketingEmailsApi.update"
          end
          # resource path
          local_var_path = '/marketing/v3/emails/{emailId}'.sub('{' + 'emailId' + '}', CGI.escape(email_id.to_s))

          # query parameters
          query_params = opts[:query_params] || {}
          query_params[:'archived'] = opts[:'archived'] if !opts[:'archived'].nil?

          # header parameters
          header_params = opts[:header_params] || {}
          # HTTP header 'Accept' (if needed)
          header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
          # HTTP header 'Content-Type'
          content_type = @api_client.select_header_content_type(['application/json'])
          if !content_type.nil?
              header_params['Content-Type'] = content_type
          end

          # form parameters
          form_params = opts[:form_params] || {}

          # http body (model)
          post_body = opts[:debug_body] || @api_client.object_to_http_body(email_update_request)

          # return_type
          return_type = opts[:debug_return_type] || 'PublicEmail'

          # auth_names
          auth_names = opts[:debug_auth_names] || ['oauth2']

          new_options = opts.merge(
            :operation => :"MarketingEmailsApi.update",
            :header_params => header_params,
            :query_params => query_params,
            :form_params => form_params,
            :body => post_body,
            :auth_names => auth_names,
            :return_type => return_type
          )

          data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
          if @api_client.config.debugging
            @api_client.config.logger.debug "API called: MarketingEmailsApi#update\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
          end
          return data, status_code, headers
        end

        # Create or update draft version
        # Create or update the draft version of a marketing email. If no draft exists, the system creates a draft from the current “live” email then applies the request body to that draft. The draft version only lives on the buffer—the email is not cloned.
        # @param email_id [String] The marketing email ID.
        # @param email_update_request [EmailUpdateRequest] A marketing email object with properties that should overwrite the corresponding properties in the email&#39;s current draft.
        # @param [Hash] opts the optional parameters
        # @return [PublicEmail]
        def upsert_draft(email_id, email_update_request, opts = {})
          data, _status_code, _headers = upsert_draft_with_http_info(email_id, email_update_request, opts)
          data
        end

        # Create or update draft version
        # Create or update the draft version of a marketing email. If no draft exists, the system creates a draft from the current “live” email then applies the request body to that draft. The draft version only lives on the buffer—the email is not cloned.
        # @param email_id [String] The marketing email ID.
        # @param email_update_request [EmailUpdateRequest] A marketing email object with properties that should overwrite the corresponding properties in the email&#39;s current draft.
        # @param [Hash] opts the optional parameters
        # @return [Array<(PublicEmail, Integer, Hash)>] PublicEmail data, response status code and response headers
        def upsert_draft_with_http_info(email_id, email_update_request, opts = {})
          if @api_client.config.debugging
            @api_client.config.logger.debug 'Calling API: MarketingEmailsApi.upsert_draft ...'
          end
          # verify the required parameter 'email_id' is set
          if @api_client.config.client_side_validation && email_id.nil?
            fail ArgumentError, "Missing the required parameter 'email_id' when calling MarketingEmailsApi.upsert_draft"
          end
          # verify the required parameter 'email_update_request' is set
          if @api_client.config.client_side_validation && email_update_request.nil?
            fail ArgumentError, "Missing the required parameter 'email_update_request' when calling MarketingEmailsApi.upsert_draft"
          end
          # resource path
          local_var_path = '/marketing/v3/emails/{emailId}/draft'.sub('{' + 'emailId' + '}', CGI.escape(email_id.to_s))

          # query parameters
          query_params = opts[:query_params] || {}

          # header parameters
          header_params = opts[:header_params] || {}
          # HTTP header 'Accept' (if needed)
          header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
          # HTTP header 'Content-Type'
          content_type = @api_client.select_header_content_type(['application/json'])
          if !content_type.nil?
              header_params['Content-Type'] = content_type
          end

          # form parameters
          form_params = opts[:form_params] || {}

          # http body (model)
          post_body = opts[:debug_body] || @api_client.object_to_http_body(email_update_request)

          # return_type
          return_type = opts[:debug_return_type] || 'PublicEmail'

          # auth_names
          auth_names = opts[:debug_auth_names] || ['oauth2']

          new_options = opts.merge(
            :operation => :"MarketingEmailsApi.upsert_draft",
            :header_params => header_params,
            :query_params => query_params,
            :form_params => form_params,
            :body => post_body,
            :auth_names => auth_names,
            :return_type => return_type
          )

          data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
          if @api_client.config.debugging
            @api_client.config.logger.debug "API called: MarketingEmailsApi#upsert_draft\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
          end
          return data, status_code, headers
        end
      end
    end
  end
end
