Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new template.
        /// POST /templates
        /// </summary>
        /// <param name="newTemplateVersion">The new version for the template</param>
        /// <returns>The new template</returns>
        /// <exception cref="AggregateException">Thrown when the API response status code is not success or when the API call times out</exception>
        /// <exception cref="InvalidOperationException">Thrown when making a Batch API Request that has already reached the maxmimum API calls per batch request</exception>
        public static async Task <Template> CreateTemplateAsync(TemplateVersion newTemplateVersion)
        {
            // Send the POST request
            var resource     = "templates";
            var jsonResponse = await RequestManager.SendPostRequestAsync(resource, newTemplateVersion);

            // Convert the JSON result into an object
            return(JsonConvert.DeserializeObject <Template>(jsonResponse));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a New Template Version.
        /// POST /templates/(:template_id)/locales/(:locale)/versions
        /// </summary>
        /// <param name="templateId">The ID of the template to add the version to</param>
        /// <param name="locale">The locale of the template to add the version to</param>
        /// /// <param name="templateVersion">The new verison to add to the template</param>
        /// <returns>The newly created template version</returns>
        /// <exception cref="AggregateException">Thrown when the API response status code is not success or when the API call times out</exception>
        /// <exception cref="InvalidOperationException">Thrown when making a Batch API Request that has already reached the maxmimum API calls per batch request</exception>
        public static async Task <TemplateVersion> CreateTemplateVersion(string templateId, string locale, TemplateVersion templateVersion)
        {
            // Send the POST request
            var resource     = String.Format("templates/{0}/locales/{1}/versions", templateId, locale);
            var jsonResponse = await RequestManager.SendPostRequestAsync(resource, templateVersion);

            // Convert the JSON result into an object
            var response = JsonConvert.DeserializeObject <TemplateVersion>(jsonResponse);

            return(response);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Update a Template Version.
        /// PUT /templates/(:template_id)/locales/(:locale)/versions/(:version_id)
        /// </summary>
        /// <param name="templateId">The ID of the template</param>
        /// <param name="locale">The locale of the template</param>
        /// <param name="versionId">The ID of the version</param>
        /// <param name="updatedTemplateVersion">The updated template version</param>
        /// <returns>The template version associated with the given ID</returns>
        /// <exception cref="AggregateException">Thrown when the API response status code is not success or when the API call times out</exception>
        /// <exception cref="InvalidOperationException">Thrown when making a Batch API Request that has already reached the maxmimum API calls per batch request</exception>
        public static async Task <TemplateVersion> UpdateTemplateVersionAsync(string templateId, string locale, string versionId, TemplateVersion updatedTemplateVersion)
        {
            // Send the PUT request
            var resource     = String.Format("templates/{0}/locales/{1}/versions/{2}", templateId, locale, versionId);
            var jsonResponse = await RequestManager.SendPutRequestAsync(resource, updatedTemplateVersion);

            // Convert the JSON result into an object
            var response = JsonConvert.DeserializeObject <TemplateVersion>(jsonResponse);

            return(response);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Add Locale to Existing Template.
        /// POST /templates/(:template_id)/locales
        /// </summary>
        /// <param name="templateId">The ID of the template to add the locale to</param>
        /// <param name="locale">The locale to add</param>
        /// <param name="templateVersion">The template version</param>
        /// <returns>The template with the updated locale</returns>
        /// <exception cref="AggregateException">Thrown when the API response status code is not success or when the API call times out</exception>
        /// <exception cref="InvalidOperationException">Thrown when making a Batch API Request that has already reached the maxmimum API calls per batch request</exception>
        public static async Task <Template> AddLocaleToTemplate(string templateId, string locale, TemplateVersion templateVersion)
        {
            templateVersion.locale = locale;
            // Send the POST request
            var resource     = String.Format("templates/{0}/locales", templateId);
            var jsonResponse = await RequestManager.SendPostRequestAsync(resource, templateVersion);

            // Convert the JSON result into an object
            return(JsonConvert.DeserializeObject <Template>(jsonResponse));
        }