=begin #Voucherify API #Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. The version of the OpenAPI document: v2018-08-01 Contact: support@voucherify.io Generated by: https://openapi-generator.tech OpenAPI Generator version: 7.0.1 =end require 'cgi' module VoucherifySdk class TemplatesApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Add Promotion Tier From Template # Creates a promotion tier out of a discount campaign template and adds it to an existing promotion campaign. To add a promotion tier to a campaign, you need to provide the name in the request and the campaign ID. Other fields are optional. If no other fields are sent, the configuration from the template will be used. You can send new values of the fields listed below to replace the settings saved in the template. However, you cannot assign an action or an existing validation rule or create a new one in the request. If the template has a validation rule, a new validation rule is always created for the promotion tier. When the promotion tier has been created, then you can: - Update the validation rule, - Unassign the validation rule, - Assign an existing validation rule. 👍 Promotion Tiers and Campaign Templates You can create a campaign template out of a promotion tier. Promotion tiers are converted to a discount campaign with the DISCOUNT_COUPON type. You can use this template to create: - Discount campaign - Promotion tier 📘 Campaign Templates – Documentation Read the [Campaign Templates documentation](https://support.voucherify.io/article/620-campaign-templates) to learn more about this feature. # @param campaign_template_id [String] Pass the campaign template ID that was assigned by Voucherify. # @param [Hash] opts the optional parameters # @option opts [TemplatesCampaignsTierSetupCreateRequestBody] :templates_campaigns_tier_setup_create_request_body Only name and campaign_id are required. The rest of the fields will overwrite the template configuration. # @return [TemplatesCampaignsTierSetupCreateResponseBody] def add_tier_from_template(campaign_template_id, opts = {}) data, _status_code, _headers = add_tier_from_template_with_http_info(campaign_template_id, opts) data end # Add Promotion Tier From Template # Creates a promotion tier out of a discount campaign template and adds it to an existing promotion campaign. To add a promotion tier to a campaign, you need to provide the name in the request and the campaign ID. Other fields are optional. If no other fields are sent, the configuration from the template will be used. You can send new values of the fields listed below to replace the settings saved in the template. However, you cannot assign an action or an existing validation rule or create a new one in the request. If the template has a validation rule, a new validation rule is always created for the promotion tier. When the promotion tier has been created, then you can: - Update the validation rule, - Unassign the validation rule, - Assign an existing validation rule. 👍 Promotion Tiers and Campaign Templates You can create a campaign template out of a promotion tier. Promotion tiers are converted to a discount campaign with the DISCOUNT_COUPON type. You can use this template to create: - Discount campaign - Promotion tier 📘 Campaign Templates – Documentation Read the [Campaign Templates documentation](https://support.voucherify.io/article/620-campaign-templates) to learn more about this feature. # @param campaign_template_id [String] Pass the campaign template ID that was assigned by Voucherify. # @param [Hash] opts the optional parameters # @option opts [TemplatesCampaignsTierSetupCreateRequestBody] :templates_campaigns_tier_setup_create_request_body Only name and campaign_id are required. The rest of the fields will overwrite the template configuration. # @return [Array<(TemplatesCampaignsTierSetupCreateResponseBody, Integer, Hash)>] TemplatesCampaignsTierSetupCreateResponseBody data, response status code and response headers private def add_tier_from_template_with_http_info(campaign_template_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TemplatesApi.add_tier_from_template ...' end # resource path local_var_path = '/v1/templates/campaigns/{campaignTemplateId}/tier-setup'.sub('{' + 'campaignTemplateId' + '}', CGI.escape(campaign_template_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(opts[:'templates_campaigns_tier_setup_create_request_body']) # return_type return_type = opts[:debug_return_type] || 'TemplatesCampaignsTierSetupCreateResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"TemplatesApi.add_tier_from_template", :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: TemplatesApi#add_tier_from_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create Campaign From Template # Creates a campaign out of a campaign template. To create a campaign, you need to provide the name in the request, while other fields are optional. If no other fields are sent, the configuration from the template will be used. You can send new values of the fields listed below to replace the settings saved in the template. However, you cannot assign an existing validation rule or create a new one in the request. If the template has a validation rule, a new validation rule is always created for the campaign. When the campaign has been created, then you can: - Update the validation rule, - Unassign the validation rule, - Assign an existing validation rule. 👍 Promotion Tiers and Campaign Templates You can create a campaign template out of a promotion tier. Promotion tiers are converted to a discount campaign with the DISCOUNT_COUPON type. You can use this template to create: - Discount campaign - Promotion tier 📘 Campaign Templates – Documentation Read the [Campaign Templates documentation](https://support.voucherify.io/article/620-campaign-templates) to learn more about this feature. # @param campaign_template_id [String] Pass the campaign template ID that was assigned by Voucherify. # @param [Hash] opts the optional parameters # @option opts [TemplatesCampaignsCampaignSetupCreateRequestBody] :templates_campaigns_campaign_setup_create_request_body Only name is required. The rest of the fields will overwrite the template configuration. # @return [TemplatesCampaignsCampaignSetupCreateResponseBody] def create_campaign_from_template(campaign_template_id, opts = {}) data, _status_code, _headers = create_campaign_from_template_with_http_info(campaign_template_id, opts) data end # Create Campaign From Template # Creates a campaign out of a campaign template. To create a campaign, you need to provide the name in the request, while other fields are optional. If no other fields are sent, the configuration from the template will be used. You can send new values of the fields listed below to replace the settings saved in the template. However, you cannot assign an existing validation rule or create a new one in the request. If the template has a validation rule, a new validation rule is always created for the campaign. When the campaign has been created, then you can: - Update the validation rule, - Unassign the validation rule, - Assign an existing validation rule. 👍 Promotion Tiers and Campaign Templates You can create a campaign template out of a promotion tier. Promotion tiers are converted to a discount campaign with the DISCOUNT_COUPON type. You can use this template to create: - Discount campaign - Promotion tier 📘 Campaign Templates – Documentation Read the [Campaign Templates documentation](https://support.voucherify.io/article/620-campaign-templates) to learn more about this feature. # @param campaign_template_id [String] Pass the campaign template ID that was assigned by Voucherify. # @param [Hash] opts the optional parameters # @option opts [TemplatesCampaignsCampaignSetupCreateRequestBody] :templates_campaigns_campaign_setup_create_request_body Only name is required. The rest of the fields will overwrite the template configuration. # @return [Array<(TemplatesCampaignsCampaignSetupCreateResponseBody, Integer, Hash)>] TemplatesCampaignsCampaignSetupCreateResponseBody data, response status code and response headers private def create_campaign_from_template_with_http_info(campaign_template_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TemplatesApi.create_campaign_from_template ...' end # resource path local_var_path = '/v1/templates/campaigns/{campaignTemplateId}/campaign-setup'.sub('{' + 'campaignTemplateId' + '}', CGI.escape(campaign_template_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(opts[:'templates_campaigns_campaign_setup_create_request_body']) # return_type return_type = opts[:debug_return_type] || 'TemplatesCampaignsCampaignSetupCreateResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"TemplatesApi.create_campaign_from_template", :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: TemplatesApi#create_campaign_from_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create Campaign Template # Creates a template for a discount or gift campaign, or a promotion tier. A template stores campaign configuration **without** the following details: - Campaign name - Category - Code count The following elements are not supported by campaign templates: - Redeeming API keys - Redeeming users - Customer loyalty tier - Static segments 👍 Promotion Tiers and Campaign Templates You can create a campaign template out of a promotion tier. Promotion tiers are converted to a discount campaign with the DISCOUNT_COUPON type. You can use this template to create: - Discount campaign, - Promotion tier. 📘 Campaign Templates – Documentation Read the [Campaign Templates documentation](https://support.voucherify.io/article/620-campaign-templates) to learn more about this feature. # @param [Hash] opts the optional parameters # @option opts [TemplatesCampaignsCreateRequestBody] :templates_campaigns_create_request_body Provide details for a campaign template # @return [TemplatesCampaignsCreateTemplateResponseBody] def create_campaign_template(opts = {}) data, _status_code, _headers = create_campaign_template_with_http_info(opts) data end # Create Campaign Template # Creates a template for a discount or gift campaign, or a promotion tier. A template stores campaign configuration **without** the following details: - Campaign name - Category - Code count The following elements are not supported by campaign templates: - Redeeming API keys - Redeeming users - Customer loyalty tier - Static segments 👍 Promotion Tiers and Campaign Templates You can create a campaign template out of a promotion tier. Promotion tiers are converted to a discount campaign with the DISCOUNT_COUPON type. You can use this template to create: - Discount campaign, - Promotion tier. 📘 Campaign Templates – Documentation Read the [Campaign Templates documentation](https://support.voucherify.io/article/620-campaign-templates) to learn more about this feature. # @param [Hash] opts the optional parameters # @option opts [TemplatesCampaignsCreateRequestBody] :templates_campaigns_create_request_body Provide details for a campaign template # @return [Array<(TemplatesCampaignsCreateTemplateResponseBody, Integer, Hash)>] TemplatesCampaignsCreateTemplateResponseBody data, response status code and response headers private def create_campaign_template_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TemplatesApi.create_campaign_template ...' end # resource path local_var_path = '/v1/templates/campaigns' # 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(opts[:'templates_campaigns_create_request_body']) # return_type return_type = opts[:debug_return_type] || 'TemplatesCampaignsCreateTemplateResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"TemplatesApi.create_campaign_template", :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: TemplatesApi#create_campaign_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete Campaign Template # Deletes the campaign template permanently. 📘 Campaign Templates – Documentation Read the [Campaign Templates documentation](https://support.voucherify.io/article/620-campaign-templates) to learn more about this feature. # @param campaign_template_id [String] Pass the campaign template ID that was assigned by Voucherify. # @param [Hash] opts the optional parameters # @return [nil] def delete_campaign_template(campaign_template_id, opts = {}) delete_campaign_template_with_http_info(campaign_template_id, opts) nil end # Delete Campaign Template # Deletes the campaign template permanently. 📘 Campaign Templates – Documentation Read the [Campaign Templates documentation](https://support.voucherify.io/article/620-campaign-templates) to learn more about this feature. # @param campaign_template_id [String] Pass the campaign template ID that was assigned by Voucherify. # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers private def delete_campaign_template_with_http_info(campaign_template_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TemplatesApi.delete_campaign_template ...' end # resource path local_var_path = '/v1/templates/campaigns/{campaignTemplateId}'.sub('{' + 'campaignTemplateId' + '}', CGI.escape(campaign_template_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # 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] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"TemplatesApi.delete_campaign_template", :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: TemplatesApi#delete_campaign_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Campaign Template # Retrieves a campaign template available in the project. 📘 Campaign Templates – Documentation Read the [Campaign Templates documentation](https://support.voucherify.io/article/620-campaign-templates) to learn more about this feature. # @param campaign_template_id [String] Pass the campaign template ID that was assigned by Voucherify. # @param [Hash] opts the optional parameters # @return [TemplatesCampaignsGetResponseBody] def get_campaign_template(campaign_template_id, opts = {}) data, _status_code, _headers = get_campaign_template_with_http_info(campaign_template_id, opts) data end # Get Campaign Template # Retrieves a campaign template available in the project. 📘 Campaign Templates – Documentation Read the [Campaign Templates documentation](https://support.voucherify.io/article/620-campaign-templates) to learn more about this feature. # @param campaign_template_id [String] Pass the campaign template ID that was assigned by Voucherify. # @param [Hash] opts the optional parameters # @return [Array<(TemplatesCampaignsGetResponseBody, Integer, Hash)>] TemplatesCampaignsGetResponseBody data, response status code and response headers private def get_campaign_template_with_http_info(campaign_template_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TemplatesApi.get_campaign_template ...' end # resource path local_var_path = '/v1/templates/campaigns/{campaignTemplateId}'.sub('{' + 'campaignTemplateId' + '}', CGI.escape(campaign_template_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] || 'TemplatesCampaignsGetResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"TemplatesApi.get_campaign_template", :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: TemplatesApi#get_campaign_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List Campaign Templates # Lists all campaign templates available in the project. 📘 Campaign Templates – Documentation Read the [Campaign Templates documentation](https://support.voucherify.io/article/620-campaign-templates) to learn more about this feature. # @param [Hash] opts the optional parameters # @option opts [Integer] :limit Limits the number of objects to be returned. The limit can range between 1 and 100 items. If no limit is set, it returns 10 items. # @option opts [String] :starting_after_id A cursor for pagination. It retrieves the campaign templates created after a template with the given ID. # @option opts [ParameterTemplatesList] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. # @option opts [Boolean] :include_total If set to true, the response returns the number of all campaign templates, regardless of the applied filters or limits. Set to false by default. # @option opts [ParameterFiltersListTemplates] :filters Filters for listing templates. # @return [TemplatesCampaignsListResponseBody] def list_campaign_templates(opts = {}) data, _status_code, _headers = list_campaign_templates_with_http_info(opts) data end # List Campaign Templates # Lists all campaign templates available in the project. 📘 Campaign Templates – Documentation Read the [Campaign Templates documentation](https://support.voucherify.io/article/620-campaign-templates) to learn more about this feature. # @param [Hash] opts the optional parameters # @option opts [Integer] :limit Limits the number of objects to be returned. The limit can range between 1 and 100 items. If no limit is set, it returns 10 items. # @option opts [String] :starting_after_id A cursor for pagination. It retrieves the campaign templates created after a template with the given ID. # @option opts [ParameterTemplatesList] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. # @option opts [Boolean] :include_total If set to true, the response returns the number of all campaign templates, regardless of the applied filters or limits. Set to false by default. # @option opts [ParameterFiltersListTemplates] :filters Filters for listing templates. # @return [Array<(TemplatesCampaignsListResponseBody, Integer, Hash)>] TemplatesCampaignsListResponseBody data, response status code and response headers private def list_campaign_templates_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TemplatesApi.list_campaign_templates ...' end # resource path local_var_path = '/v1/templates/campaigns' # query parameters query_params = opts[:query_params] || {} query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? query_params[:'starting_after_id'] = opts[:'starting_after_id'] if !opts[:'starting_after_id'].nil? query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? query_params[:'include_total'] = opts[:'include_total'] if !opts[:'include_total'].nil? query_params[:'filters'] = opts[:'filters'] if !opts[:'filters'].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] || 'TemplatesCampaignsListResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"TemplatesApi.list_campaign_templates", :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: TemplatesApi#list_campaign_templates\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update Campaign Template # Updates the name or description of the campaign template. 📘 Campaign Templates – Documentation Read the [Campaign Templates documentation](https://support.voucherify.io/article/620-campaign-templates) to learn more about this feature. # @param campaign_template_id [String] Pass the campaign template ID that was assigned by Voucherify. # @param [Hash] opts the optional parameters # @option opts [TemplatesCampaignsUpdateRequestBody] :templates_campaigns_update_request_body Provide the new name or description for the campaign template # @return [TemplatesCampaignsUpdateResponseBody] def update_campaign_template(campaign_template_id, opts = {}) data, _status_code, _headers = update_campaign_template_with_http_info(campaign_template_id, opts) data end # Update Campaign Template # Updates the name or description of the campaign template. 📘 Campaign Templates – Documentation Read the [Campaign Templates documentation](https://support.voucherify.io/article/620-campaign-templates) to learn more about this feature. # @param campaign_template_id [String] Pass the campaign template ID that was assigned by Voucherify. # @param [Hash] opts the optional parameters # @option opts [TemplatesCampaignsUpdateRequestBody] :templates_campaigns_update_request_body Provide the new name or description for the campaign template # @return [Array<(TemplatesCampaignsUpdateResponseBody, Integer, Hash)>] TemplatesCampaignsUpdateResponseBody data, response status code and response headers private def update_campaign_template_with_http_info(campaign_template_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TemplatesApi.update_campaign_template ...' end # resource path local_var_path = '/v1/templates/campaigns/{campaignTemplateId}'.sub('{' + 'campaignTemplateId' + '}', CGI.escape(campaign_template_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(opts[:'templates_campaigns_update_request_body']) # return_type return_type = opts[:debug_return_type] || 'TemplatesCampaignsUpdateResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"TemplatesApi.update_campaign_template", :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(:PUT, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: TemplatesApi#update_campaign_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end