I have a multi tenant, web based, Perl application that integrates with 37 Signals' Highrise CRM. I need a new Perl module that implements a caching layer between my application and Highrise, that is also flexible enough to be extended to other web based contact management systems in the future. The module must provide methods that:
1. Sync the local cache with Highrise. The synchronization method(s) should:
a. Obtain all new entries that have been added to the specified Highrise account (defined by the contacts_owner_id) since the last sync
b. Update any entries that have changed since the last sync
c. Delete any entries in the local cache that have been deleted from Highrise since the last sync
2. Allow new entries to be created
a. New contacts (people or companies) must be created in the local cache and sent to Highrise. The correct account will be specified by passing in the contacts_owner_id for the account.
b. The method needs to return the contacts_contact_id for the new entry
3. Allow contacts to be updated
a. The method will accept the contact_contact_id for the contact to update, as well as the information to be updated
a. When a contact is updated locally the update needs to be sent to Highrise
4. Allow contacts to be deleted
a. The method will accept the contacts_contact_id for the contact to delete
b. When a contact is deleted locally the deletion needs to be sent to Highrise
5. Allow contacts to be read
a. One method should provide a list of all contacts for a given contact_owner_id. The list should contain the contacts_contact_id, first_name, last_name, and type
b. Another method should provide detail for a given contact_contact_id. The returned hash ref should contain fields for all contact details, including array refs for the emails, phone numbers, and addresses for the contact.
In addition to supporting Highrise, the system MUST also have a mode that allows contacts to be created/modified/deleted locally without being stored in Highrise. Basically, this module needs to abstract away the interaction with Highrise or (with additional changes to be made in the future) other contact management systems, and prevent my application with a consistent interface for accessing and modifying contacts.
The module must be capable of obtaining thousands of contacts from Highrise (the Highrise API limits requests to 500 contacts at a time so pagination must be implemented). It must gracefully handle errors.
The contacts should be locally stored in a database with the table described in the attached file. The database will be accessed through a DBI database handle passed to the methods.
The contacts_owner table described in the file provides a way to associate a Highrise (or other system) account with a group of contacts. The URL and api_token are the values that should be used to connect to the Highrise service for that account. If the type field of the contacts_owner record is local then instead of any contacts with that contacts_owner_id being stored in Highrise, they should only be stored locally.
Please contact me with any questions. I want to make sure we get the requirements worked out clearly to ensure that the module functions as needed.