Ejemplo n.º 1
0
  private <T, F, R> List<T> getContactsCommon(
      WebResource resource,
      ProfileField<F, R> key,
      F value,
      Integer limit,
      Integer offset,
      final ProfileType<T> type,
      ContactOrder order,
      ContactType contactType) {
    if (key != null && value != null) {
      resource =
          resource
              .queryParam("key", key.getName().toLowerCase())
              .queryParam("value", key.format(value).toString());
    }
    if (limit != null) {
      resource = resource.queryParam("limit", limit.toString());
    }
    if (offset != null) {
      resource = resource.queryParam("offset", offset.toString());
    }
    resource = resource.queryParam("type", type.getName());
    if (order != null) {
      resource = resource.queryParam("order", order.name().toLowerCase());
    }
    if (contactType != null) {
      resource = resource.queryParam("contact_type", contactType.name().toLowerCase());
    }

    return resource.get(getGenericType(type));
  }
Ejemplo n.º 2
0
  /**
   * Returns the value of a contact with the specific field
   *
   * @param userId The id of the user
   * @param field The field for which data should be returned
   * @return The list of values for the given field
   */
  public <T, R> List<T> getContactField(int userId, ProfileField<T, R> field) {
    List<R> values =
        getResourceFactory()
            .getApiResource("/contact/" + userId + "/" + field.getName())
            .get(new GenericType<List<R>>() {});

    List<T> formatted = new ArrayList<T>();
    for (R value : values) {
      formatted.add(field.parse(value));
    }

    return formatted;
  }