Working with Categories in FreshBooks

This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Working with Categories in FreshBooks



Overview

The following operations allow you to work with categories. Click an operation name to see details on how to use it.

For a sample proxy service that illustrates how to work with categories, see Sample configuration.

OperationDescription

createCategory

Creates a category.

deleteCategoryDeletes a category.
getCategoryRetrieves a category.
listCategoryLists categories.
updateCategoryUpdates a category's name.

Operation details

This section provides details on the operations.

 Creating a category

The createCategory operation allows the user to create a category.

createCategory
<freshbooks.createCategory>
	<name>{$ctx:name}</name>
</freshbooks.createCategory>
Properties
  • name: Required - The name for the new category.
Sample request

Following is a sample REST/XML request that can be handled by the createCategory operation.

Sample Request for createCategory
<createCategory>
   <arbitraryPassword></arbitraryPassword>
   <apiUrl>https://sansu.freshbooks.com</apiUrl>
   <authenticationToken>c361adfg63c7456519412fa8051ea605a6d</authenticationToken>
   <name>Test</name>
</createCategory>
Related FreshBooks documentation

http://developers.freshbooks.com/docs/categories/#category.create

 Deleting a category

The deleteCategory operation deletes an existing expense category.

deleteCategory
<freshbooks.deleteCategory>
	<categoryId>{$ctx:categoryId}</categoryId>
</freshbooks.deleteCategory>
Properties
  • categoryId: Required - The ID of the category to be deleted.
Sample request

Following is a sample REST/XML request that can be handled by the deleteCategory operation.

Sample Request for deleteCategory
<deleteCategory>
   <arbitraryPassword></arbitraryPassword>
   <apiUrl>https://sansu.freshbooks.com</apiUrl>
   <authenticationToken>c361dfga63c7456519412fa8051ea605a6d</authenticationToken>
   <categoryId>58</categoryId>
</deleteCategory>
Related FreshBooks documentation

http://developers.freshbooks.com/docs/categories/#category.delete

 Retrieving a category

The getCategory operation returns complete details on the category associated with the given category ID.

getCategory
<freshbooks.getCategory>
	<categoryId>{$ctx:categoryId}</categoryId>
</freshbooks.getCategory>
Properties
  • categoryId: Required - The ID of the category for which the details should be retrieved. 
Sample request

Following is a sample REST/XML request that can be handled by the getCategory operation.

Sample Request for getCategory
<getCategory>
   <arbitraryPassword></arbitraryPassword>
   <apiUrl>https://sansu.freshbooks.com</apiUrl>
   <authenticationToken>c361a63c7456519sdf412fa8051ea605a6d</authenticationToken>
   <categoryId>57</categoryId>
</getCategory>
Related FreshBooks documentation

http://developers.freshbooks.com/docs/categories/#category.get

 Listing categories

The listCategory operation returns a list of expense categories. This operation uses pagination.

listCategory
<freshbooks.listCategory>
	<parentId>{$ctx:parentId}</parentId>
    <order>{$ctx:order}</order>
    <page>{$ctx:page}</page>
    <perPage>{$ctx:perPage}</perPage>
</freshbooks.listCategory>
Properties
  • parentId: The parent ID required to select the subcategories.
  • order: The order in which the results should be displayed, either ASC or DESC
  • page: The page number of the results.
  • perPage: The number of entries to be displayed on a page.
Sample request

Following is a sample REST/XML request that can be handled by the listCategory operation.

Sample Request for listCategory
<listCategory>
   <arbitraryPassword></arbitraryPassword>
   <apiUrl>https://sansu.freshbooks.com</apiUrl>
   <authenticationToken>c361a63c7456dfg519412fa8051ea605a6d</authenticationToken>
   <parentId></parentId>
   <order>ASC</order>
   <page>2</page>
   <perPage>10</perPage>
</listCategory>
Related FreshBooks documentation

http://developers.freshbooks.com/docs/categories/#category.list

 Updating a category

The updateCategory operation allows you to update the name of an existing expense category.

updateCategory
<freshbooks.updateCategory>
	<categoryId>{$ctx:categoryId}</categoryId>	
	<name>{$ctx:name}</name>    
</freshbooks.updateCategory>
Properties
  • categoryId: Required - The ID of the category to be updated.
  • name: Optional - New name for the category.
Sample request

Following is a sample REST/XML request that can be handled by the updateCategory operation.

Sample Request for updateCategory
<updateCategory>
   <arbitraryPassword></arbitraryPassword>
   <apiUrl>https://sansu.freshbooks.com</apiUrl>
   <authenticationToken>c361a63c745dfg6519412fa8051ea605a6d</authenticationToken>
   <categoryId>57</categoryId>
   <name>update</name>
</updateCategory> 
Related FreshBooks documentation

http://developers.freshbooks.com/docs/categories/#category.update

Sample configuration

Following is a sample proxy service that illustrates how to connect to FreshBooks with the init operation and use the createCategory operation. The sample request for this proxy can be found in createCategory sample request. You can use this sample as a template for using other operations in this category.

Sample Proxy
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="freshbooks_createCategory"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence onError="faultHandlerSeq">
         <property name="arbitraryPassword" expression="//arbitraryPassword/text()"/>
         <property name="apiUrl" expression="//apiUrl/text()"/>
         <property name="authenticationToken" expression="//authenticationToken/text()"/>
         <property name="name" expression="//name/text()"/>
         <freshbooks.init>
            <arbitraryPassword>{$ctx:arbitraryPassword}</arbitraryPassword>
            <apiUrl>{$ctx:apiUrl}</apiUrl>
            <authenticationToken>{$ctx:authenticationToken}</authenticationToken>
         </freshbooks.init>
         <freshbooks.createCategory>
            <name>{$ctx:name}</name>
         </freshbooks.createCategory>
         <filter source="$axis2:HTTP_SC" regex="^[^2][0-9][0-9]">
            <then>
               <switch source="$axis2:HTTP_SC">
                  <case regex="400">
                     <property name="ERROR_CODE" value="600400"/>
                     <property name="ERROR_MESSAGE" expression="//*[local-name()='error']"/>
                  </case>
                  <case regex="401">
                     <property name="ERROR_CODE" value="600401"/>
                     <property name="ERROR_MESSAGE" expression="//*[local-name()='error']"/>
                  </case>
                  <case regex="404">
                     <property name="ERROR_CODE" value="600404"/>
                     <property name="ERROR_MESSAGE" expression="//*[local-name()='error']"/>
                  </case>
                  <case regex="403">
                     <property name="ERROR_CODE" value="600403"/>
                     <property name="ERROR_MESSAGE" expression="//*[local-name()='error']"/>
                  </case>
                  <case regex="500">
                     <property name="ERROR_CODE" value="600500"/>
                     <property name="ERROR_MESSAGE" expression="//*[local-name()='error']"/>
                  </case>
                  <default>
                     <property name="ERROR_CODE" expression="$axis2:HTTP_SC"/>
                     <property name="ERROR_MESSAGE" expression="//*[local-name()='error']"/>
                  </default>
               </switch>
               <sequence key="faultHandlerSeq"/>
            </then>
         </filter>
         <respond/>
      </inSequence>
      <outSequence>
        <send/>
      </outSequence>
   </target>
   <description/>
</proxy>