コード例 #1
0
 private void deleteTemplate(RestConnection connection, String templateId)
     throws SparkPostException {
   Response deleteResponse = ResourceTemplates.delete(connection, templateId);
   if (deleteResponse.getResponseCode() == 200) {
     System.out.println("\tdeleted: " + templateId);
   } else {
     System.out.println(
         "\tError: Failed to delete: "
             + templateId
             + ") because "
             + deleteResponse.getResponseMessage());
   }
 }
コード例 #2
0
  private void runApp() throws SparkPostException, IOException {
    client = this.newConfiguredClient();
    RestConnection connection = new RestConnection(client, getEndPoint());

    // Get All Templates
    TemplateListResponse listResponse = ResourceTemplates.listAll(connection);
    List<TemplateItem> results = listResponse.getResults();

    for (TemplateItem item : results) {

      // Delete any template with the name  "_TMP_TEMPLATE_TEST"
      if (item.getName().equals(SAMPLE_TEMPLATE_NAME)) {
        deleteTemplate(connection, item.getId());
      }
    }
  }