Package zendeskapi.exception

Examples of zendeskapi.exception.ZendeskApiException


   * @throws ZendeskApiException
   */
  public <T extends Object> List<T> getEntitiesFromSearch(Class<T> objectClass) throws ZendeskApiException {
    String nameOfClass = objectClass.getName().replaceFirst(".*\\.", "").toLowerCase();
    if (!VALID_SEARCH_CLASSES.contains(nameOfClass)) {
      throw new ZendeskApiException("Class " + objectClass.getName() + " is not supported by the search API");
    }

    List<T> entities = new ArrayList<T>();
    for (Object result : results) {
      @SuppressWarnings("unchecked")
      Map<String, String> map = (Map<String, String>) result;
      if (map.get("result_type").contentEquals(nameOfClass)) {
        Map<String, String> resultMap = new HashMap<String, String>();
        resultMap.putAll(map);
        resultMap.remove("result_type");
        try {
          String json = JsonHelper.getJsonString(resultMap);
          entities.add(JsonHelper.unmarshal(json, objectClass));
        } catch (Exception e) {
          throw new ZendeskApiException(e);
        }
      }
    }

    if (entities.size() > 0) {
View Full Code Here


   */
  public GroupCategoryResponse getCategories() throws ZendeskApiException {
    try {
      return genericGet("categories.json", GroupCategoryResponse.class);
    } catch (Exception e) {
      throw new ZendeskApiException("Getting categories failed", e);
    }
  }
View Full Code Here

   */
  public IndividualCategoryResponse getCategoryById(long id) throws ZendeskApiException {
    try {
      return genericGet("categories/" + id + ".json", IndividualCategoryResponse.class);
    } catch (Exception e) {
      throw new ZendeskApiException("Getting category with id " + id + " failed", e);
    }
  }
View Full Code Here

    IndividualCategoryResponse categoryToCreate = new IndividualCategoryResponse();
    categoryToCreate.setCategory(category);
    try {
      return genericPost("categories.json", categoryToCreate, IndividualCategoryResponse.class);
    } catch (Exception e) {
      throw new ZendeskApiException("Faled to create categery " + category.getName(), e);
    }
  }
View Full Code Here

    IndividualCategoryResponse categoryToUpdate = new IndividualCategoryResponse();
    categoryToUpdate.setCategory(category);
    try {
      return genericPut("categories/" + category.getId() + ".json", categoryToUpdate, IndividualCategoryResponse.class);
    } catch (Exception e) {
      throw new ZendeskApiException("Update of category " + category.getName() + " failed", e);
    }
  }
View Full Code Here

   */
  public boolean deleteCategory(long id) throws ZendeskApiException {
    try {
      return genericDelete("categories/" + id + ".json");
    } catch (Exception e) {
      throw new ZendeskApiException("Deletion of category with id " + id + " failed", e);
    }
  }
View Full Code Here

   */
  public GroupLocaleResponse getAllLocales() throws ZendeskApiException {
    try {
      return genericGet("locales.json", GroupLocaleResponse.class);
    } catch (Exception e) {
      throw new ZendeskApiException("Failed to get a list of all locales", e);
    }
  }
View Full Code Here

   */
  public GroupLocaleResponse getLocalesForAgents() throws ZendeskApiException {
    try {
      return genericGet("locales/agent.json", GroupLocaleResponse.class);
    } catch (Exception e) {
      throw new ZendeskApiException("Failed to get a list locales for agents that have been localised", e);
    }
  }
View Full Code Here

   */
  public IndividualLocaleResponse getLocaleById(long id) throws ZendeskApiException {
    try {
      return genericGet("locales/" + id + ".json", IndividualLocaleResponse.class);
    } catch (Exception e) {
      throw new ZendeskApiException("Failed to get a list locales with id " + id + " for agents that have been localised", e);
    }
  }
View Full Code Here

   */
  public IndividualLocaleResponse getCurrentLocale() throws ZendeskApiException {
    try {
      return genericGet("locales/current.json", IndividualLocaleResponse.class);
    } catch (Exception e) {
      throw new ZendeskApiException("Failed to get current locale", e);
    }
  }
View Full Code Here

TOP

Related Classes of zendeskapi.exception.ZendeskApiException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.