updateTemplate method

Future<TransloaditResponse> updateTemplate({
  1. required String templateID,
  2. required Map<String, dynamic> template,
  3. Map<String, dynamic>? params,
  4. bool merge = false,
})

Updates a Transloadit template from a templateID merge is still being implemented (does nothing currently)

Implementation

Future<TransloaditResponse> updateTemplate(
    {required String templateID,
    required Map<String, dynamic> template,
    Map<String, dynamic>? params,
    bool merge = false}) async {
  params = params ?? {};

  Map<String, dynamic> templateCopy = {};
  templateCopy["steps"] = template;
  params["template"] = templateCopy;

  // TODO: Implement instruction merging
  // if (merge) {
  //   Map<String, dynamic> currentInstructions = {};
  //   _getCurrentInstructions(templateID)
  //       .then((value) => currentInstructions = value);
  //   for (var key in template.keys) {}
  //   print(currentInstructions);
  // }

  final response = await request.httpPut(
      service: service,
      assemblyPath: "/templates/$templateID",
      params: params);
  return response;
}