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 Contacts in FreeAgent



Overview

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

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

OperationDescription

createContact

Creates a new contact.

getContactByIdRetrieves a single contact by ID.
listContactsRetrieves all contacts.

Operation details

This section provides further details on the operations related to contacts.

Creating a new contact

The createContact operation creates a new contact.

createContact
<freeagent.createContact>
	<organisationName>{$ctx:organisationName}</organisationName>
    <firstName>{$ctx:firstName}</firstName>
    <lastName>{$ctx:lastName}</lastName>
    <email>{$ctx:email}</email>
    <phoneNumber>{$ctx:phoneNumber}</phoneNumber>
    <address1>{$ctx:address1}</address1>
    <town>{$ctx:town}</town>
    <region>{$ctx:region}</region>
    <postcode>{$ctx:postcode}</postcode>
    <address2>{$ctx:address2}</address2>
    <address3>{$ctx:address3}</address3>
    <contactNameOnInvoices>{$ctx:contactNameOnInvoices}</contactNameOnInvoices>
    <country>{$ctx:country}</country>
	<salesTaxRegistrationNumber>{$ctx:salesTaxRegistrationNumber}</salesTaxRegistrationNumber>
	<usesContactInvoiceSequence>{$ctx:usesContactInvoiceSequence}</usesContactInvoiceSequence>
</freeagent.createContact>
Properties
  • organisationName: The name of the organization.
  • firstName: The first name of the contact.
  • lastName: The last name of the contact.
  • email: The e-mail address of the contact.
  • phoneNumber: The telephone number of the contact.
  • address1: The first address line of the contact.
  • town: The town of the contact.
  • region: The region of the contact.
  • postcode: The post code of the contact.
  • address2: The second address line of the contact.
  • address3: The third address line of the contact.
  • contactNameOnInvoices: The Boolean flag to indicate whether the contact name should be displayed in invoices.
  • country: The country of the contact.
  • salesTaxRegistrationNumber: The sales tax registration number of the contact.
  • usesContactInvoiceSequence: The Boolean flag to indicate use of the contact invoice sequence.
Sample request

Following is a sample REST/JSON request that can be handled by the createContact operation.

Sample Request for createContact
{
	"apiUrl" : "https://api.sandbox.freeagent.com",
	"accessToken" : "1YBpWH_SDwDUalF5Vv541uiW3zBIkjccmh817gRnV",
	"organisationName" : "Virtusa",
	"firstName" : "John",
	"lastName" : "Carter",
	"email" : "john.carter@gmail.com",
	"phoneNumber" : "98869558",
	"address1" : "234",
	"town" : "Colombo",
	"region" : "Western",
	"postcode" : "112233",
	"address2" : "Silva Avenue",
	"address3" : "Dematagoda",
	"contactNameOnInvoices" : "false",
	"country" : "Sri Lanka",
	"salesTaxRegistrationNumber" : "1311",
	"usesContactInvoiceSequence" : "true"
}
Related FreeAgent documentation

https://dev.freeagent.com/docs/contacts#create-a-contact

Retrieving a single contact by ID

The getContactById operation retrieves a single contact by ID.

getContactById
<freeagent.getContactById>
	<id>{$ctx:id}</id>
</freeagent.getContactById>
Properties
  • id: The ID of the contact.
Sample request

Following is a sample REST/JSON request that can be handled by the getContactById operation.

getContactById
{
	"apiUrl" : "https://api.sandbox.freeagent.com",
	"accessToken" : "1YBpWH_SDwDUalF5Vv541uiW3zBIkjccmh817gRnV",
	"id" : "28437"
}
Related FreeAgent documentation

https://dev.freeagent.com/docs/contacts#get-a-single-contact

Retrieving all contacts

The listContacts operation retrieves all contacts.

listContacts
<freeagent.listContacts>
	<view>{$ctx:view}</view>
    <sort>{$ctx:sort}</sort>
</freeagent.listContacts>
Properties
  • view: The value for view filter.
  • sort: The value for sort order.
Sample request

Following is a sample REST/JSON request that can be handled by the listContacts operation.

listContacts
{
	"apiUrl" : "https://api.sandbox.freeagent.com",
	"accessToken" : "1YBpWH_SDwDUalF5Vv541uiW3zBIkjccmh817gRnV",
	"view" : "all",
	"sort" : "name"
}
Related FreeAgent documentation

https://dev.freeagent.com/docs/contacts#list-all-contacts

Sample configuration

Following is a sample proxy service that illustrates how to connect to FreeAgent with the init operation and use the createContact operation. The sample request for this proxy can be found in the createContact 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="freeagent_createContact"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property name="accessToken" expression="json-eval($.accessToken)"/>
         <property name="apiUrl" expression="json-eval($.apiUrl)"/>
         <property name="organisationName" expression="json-eval($.organisationName)"/>
         <property name="firstName" expression="json-eval($.firstName)"/>
         <property name="lastName" expression="json-eval($.lastName)"/>
         <property name="email" expression="json-eval($.email)"/>
         <property name="phoneNumber" expression="json-eval($.phoneNumber)"/>
         <property name="address1" expression="json-eval($.address1)"/>
         <property name="town" expression="json-eval($.town)"/>
         <property name="region" expression="json-eval($.region)"/>
         <property name="postcode" expression="json-eval($.postcode)"/>
         <property name="address2" expression="json-eval($.address2)"/>
         <property name="address3" expression="json-eval($.address3)"/>
         <property name="contactNameOnInvoices"
                   expression="json-eval($.contactNameOnInvoices)"/>
         <property name="country" expression="json-eval($.country)"/>
         <property name="salesTaxRegistrationNumber"
                   expression="json-eval($.salesTaxRegistrationNumber)"/>
         <property name="usesContactInvoiceSequence"
                   expression="json-eval($.usesContactInvoiceSequence)"/>
         <freeagent.init>
            <accessToken>{$ctx:accessToken}</accessToken>
            <apiUrl>{$ctx:apiUrl}</apiUrl>
         </freeagent.init>
         <freeagent.createContact>
            <organisationName>{$ctx:organisationName}</organisationName>
            <firstName>{$ctx:firstName}</firstName>
            <lastName>{$ctx:lastName}</lastName>
            <email>{$ctx:email}</email>
            <phoneNumber>{$ctx:phoneNumber}</phoneNumber>
            <address1>{$ctx:address1}</address1>
            <town>{$ctx:town}</town>
            <region>{$ctx:region}</region>
            <postcode>{$ctx:postcode}</postcode>
            <address2>{$ctx:address2}</address2>
            <address3>{$ctx:address3}</address3>
            <contactNameOnInvoices>{$ctx:contactNameOnInvoices}</contactNameOnInvoices>
            <country>{$ctx:country}</country>
            <salesTaxRegistrationNumber>{$ctx:salesTaxRegistrationNumber}</salesTaxRegistrationNumber>
            <usesContactInvoiceSequence>{$ctx:usesContactInvoiceSequence}</usesContactInvoiceSequence>
         </freeagent.createContact>
         <respond/>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>