Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.podio.item;
import java.util.List;
import java.util.Map;
import javax.ws.rs.core.MediaType;
import com.podio.ResourceFactory;
import com.podio.filter.ExternalIdFilterBy;
import com.podio.filter.FilterByValue;
import com.podio.filter.SortBy;
import com.sun.jersey.api.client.GenericType;
import com.sun.jersey.api.client.WebResource;
/**
* Items are entries in an app. If you think of app as a table, items will be
* the rows in the table. Items consists of some basic information as well
* values for each of the fields in the app. For each field there can be
* multiple values (F.ex. there can be multiple links to another app) and
* multiple types of values (F.ex. a field of type date field consists of both a
* start date and an optional end date). The type is denoted by an string id
* called a sub_id. Most types of fields have only one type, which is denoted by
* the sub_id values. Others have multiple sub_ids.
*/
public class ItemAPI {
private final ResourceFactory resourceFactory;
public ItemAPI(ResourceFactory resourceFactory) {
this.resourceFactory = resourceFactory;
}
/**
* Adds a new item to the given app.
*
* @param appId
* The id of the app the item should be added to
* @param create
* The data for the new item
* @param silent
* True if the create should be silten, false otherwise
* @return The id of the newly created item
*/
public int addItem(int appId, ItemCreate create, boolean silent) {
return resourceFactory.getApiResource("/item/app/" + appId + "/")
.queryParam("silent", silent ? "1" : "0")
.entity(create, MediaType.APPLICATION_JSON_TYPE)
.post(ItemCreateResponse.class).getId();
}
/**
* Gets the item with the given id
*
* @param itemId
* The id of the item
* @return The item with given id
*/
public Item getItem(int itemId) {
return resourceFactory.getApiResource("/item/" + itemId)
.get(Item.class);
}
/**
* Updates the entire item. Only fields which have values specified will be
* updated. To delete the contents of a field, pass an empty array for the
* value.
*
* @param itemId
* The id of the item to update
* @param update
* The data for the update
* @param silent
* True if the update should be silent, false otherwise
*/
public void updateItem(int itemId, ItemUpdate update, boolean silent) {
resourceFactory.getApiResource("/item/" + itemId)
.queryParam("silent", silent ? "1" : "0")
.entity(update, MediaType.APPLICATION_JSON_TYPE).put();
}
/**
* Updates all the values for an item
*
* @param itemId
* The id of the item
* @param values
* The values for the fields
* @param silent
* True if the update should be silent, false otherwise
*/
public void updateItemValues(int itemId, List values,
boolean silent) {
resourceFactory.getApiResource("/item/" + itemId + "/value/")
.queryParam("silent", silent ? "1" : "0")
.entity(values, MediaType.APPLICATION_JSON_TYPE).put();
}
/**
* Update the item values for a specific field.
*
* @param itemId
* The id of the item
* @param fieldId
* The id of the field
* @param values
* The new values for the field
* @param silent
* True if the update should be silent, false otherwise
*/
public void updateItemFieldValues(int itemId, int fieldId,
List