/** * Attempts to create a new contact entry in the associated FreeAgent account. * * <p>Will return null if the contact instance provided is null or cannot be saved into the * account. * * @param contact The populated contact instance. * @return The updated contact instance or null. */ public FreeAgentContact createContact(FreeAgentContact contact) { if (contact != null) { FreeAgentContactWrapper contactWrapper = freeAgentServiceInstance.createContact(new FreeAgentContactWrapper(contact)); if (contactWrapper != null) { return contactWrapper.getContact(); } } return null; }
/** * Attempts to import a new contact into the associated FreeAgent account by deserialising the * specified JSON contact information and requesting a new contact be created. * * <p>NOTE: The import (creation within FreeAgent) will only be actioned if no URL property is * present or if the URL property is not populated. Otherwise null will be returned. * * @param contactJSON A string containing contact information in FreeAgent friendly format. * @return The newly populated contact instance that has been imported into FreeAgent or null. * @throws JsonSyntaxException If the format does not match the FreeAgent V2 Contact format. */ public FreeAgentContact importContact(String contactJSON) throws JsonSyntaxException { if (contactJSON == null || contactJSON.isEmpty()) { return null; } FreeAgentContact contact = buildContact(contactJSON); if (contact != null && (contact.getUrl() == null || contact.getUrl().isEmpty())) { FreeAgentContactWrapper contactWrapper = freeAgentServiceInstance.createContact(new FreeAgentContactWrapper(contact)); if (contactWrapper != null) { return contactWrapper.getContact(); } } return null; }