Class Items


public class Items extends AccountingResource
FreshBooks items resource with calls to get, list, create, update, delete
  • Constructor Details

  • Method Details

    • getPath

      protected String getPath()
      Specified by:
      getPath in class AccountingResource
    • list

      public ItemList list(String accountId) throws FreshBooksException
      Get a list of items using the query strings generated by the QueryBuilder list.
      Parameters:
      accountId - Id of the account
      Returns:
      ItemList containing items and pagination details
      Throws:
      FreshBooksException - If the call is not successful
    • list

      public ItemList list(String accountId, List<QueryBuilder> builders) throws FreshBooksException
      Get a list of items using the query strings generated by the QueryBuilder list.
      Parameters:
      accountId - Id of the account
      builders - List of QueryBuilders
      Returns:
      ItemList containing items and pagination details
      Throws:
      FreshBooksException - If the call is not successful
    • get

      public Item get(String accountId, long itemId) throws FreshBooksException
      Get a single item with the corresponding id.
      Parameters:
      accountId - The alpha-numeric account id
      itemId - Id of the resource to return
      Returns:
      The Item
      Throws:
      FreshBooksException - If the call is not successful
    • get

      public Item get(String accountId, long itemId, IncludesQueryBuilder builder) throws FreshBooksException
      Get a single item with the corresponding id.
      Parameters:
      accountId - The alpha-numeric account id
      itemId - Id of the resource to return
      builder - IncludesQueryBuilder object for including additional data, sub-resources, etc.
      Returns:
      The Item
      Throws:
      FreshBooksException - If the call is not successful
    • create

      public Item create(String accountId, Item data) throws FreshBooksException
      Create a new item from the provided Item model. Makes a POST call against the item resource endpoint. This calls `item.getContent()` to get a hash map of data.
      Parameters:
      accountId - The alpha-numeric account id
      data - Ttem model with create data
      Returns:
      The created Item
      Throws:
      FreshBooksException - If the call is not successful
    • create

      public Item create(String accountId, Map<String,Object> data) throws FreshBooksException
      Create a new item from the provided data. Makes a POST call against the item resource endpoint.
      Parameters:
      accountId - The alpha-numeric account id
      data - Map of create data
      Returns:
      The created Item
      Throws:
      FreshBooksException - If the call is not successful
    • update

      public Item update(String accountId, long itemId, Item data) throws FreshBooksException
      Update the item with the corresponding id. Makes a PUT call against the item resource endpoint.
      Parameters:
      accountId - The alpha-numeric account id
      itemId - Id of the resource to return
      data - Item model with updated data
      Returns:
      The updated Item
      Throws:
      FreshBooksException - If the call is not successful
    • update

      public Item update(String accountId, long itemId, Map<String,Object> data) throws FreshBooksException
      Update the item with the corresponding id. Makes a PUT call against the item resource endpoint.
      Parameters:
      accountId - The alpha-numeric account id
      itemId - Id of the resource to update
      data - Map of data to change
      Returns:
      The updated Item
      Throws:
      FreshBooksException - If the call is not successful
    • delete

      public Item delete(String accountId, long itemId) throws FreshBooksException
      Delete the item with the corresponding id. Makes a PUT call against the item resource endpoint with a `vis_state` of deleted.

      Note: Most FreshBooks resources are soft-deleted,
      Parameters:
      accountId - The alpha-numeric account id
      itemId - Id of the resource to update
      Returns:
      The deleted Item
      Throws:
      FreshBooksException - If the call is not successful
      See Also: