AgentOS

Setting up an import from AgentOS

This page contains information specific to AgentOS. For a general guide on setting up a property import, please see our 'Creating your first property import' guide.

When creating an import from AgentOS, you'll be presented with the following fields:

API Key - You will need to obtain your API Key directly from AgentOS.

Short Name - You will need to obtain your Short Name directly from AgentOS.

AgentOS are very strict on the number of requests made per minute. As it takes so many individual requests to obtain the data we require, we've had to add pauses to prevent you hitting this throttling limit.

As a result, imports from AgentOS may take a while and therefore you'll likely need to increase the timeout limit on your server.

Developer hooks

You'll notice some of the hook names contain 'let_mc'. This is because this is what AgentOS was called prior to being called AgentOS.

Hook name: propertyhive_let_mc_requests_per_chunk

Hook type: Filter

Description: As mentioned above, we throttle the number of requests to avoid hitting the AgentOS limits.

By default we send API requests in chunks of 10 every 5 seconds.

This filter allows you to customise how many are sent per chunk.

Example usage:

add_action( 'propertyhive_let_mc_requests_per_chunk', 'adjust_requests_per_chunk' );
function adjust_requests_per_chunk( $per_chunk)
{
    // $per_chunk (int) - number of API requests in each chunk
    // Default: 10

    return 20;
}

Hook name: propertyhive_let_mc_sleep_seconds

Hook type: Filter

Description: As mentioned above, we throttle the number of requests to avoid hitting the AgentOS limits.

By default we send API requests in chunks of 10 every 5 seconds.

This filter allows you to customise how many seconds it pauses between each chunk.

Example usage:

add_action( 'propertyhive_let_mc_sleep_seconds', 'adjust_requests_sleep' );
function adjust_requests_sleep( $sleep_seconds)
{
    // $sleep_seconds(int) - seconds to pause between each chunk of API requests are sent
    // Default: 5

    return 2;
}

Hook name: propertyhive_pre_import_properties_agentos_json

Hook type: Action

Description: Executed after the properties are parsed but before they are actually imported.

Example usage:

add_action( 'propertyhive_pre_import_properties_agentos_json', 'pre_import' );
function pre_import( $properties )
{
     // $properties (array) - Multidimensional array containing property data received in feed

    // do something here...
}

Hook name: propertyhive_agentos_json_properties_due_import

Hook type: Filter

Description: Executed after the properties are parsed but before actually being imported. Allows you to filter out any properties you don't want to import.

For example, maybe you want to only import properties belonging to a certain office.

Example usage:

add_filter( 'propertyhive_agentos_json_properties_due_import', 'filter_properties' );
function filter_properties( $properties )
{
    // $properties (array) - Multidimensional array containing property data parsed in feed

    $new_properties = array();
    
    foreach ($properties as $property)
    {
        if ( 
            isset($property['BranchOID']) && 
            $property['BranchOID'] == '12345' )
        {
            $new_properties[] = $property;
        }
    }
    return $new_properties;
}

Hook name: propertyhive_letmc_json_commercial_property_types

Hook type: Filter

Description: In order to correctly put a property into the 'Commercial' department in Property Hive, we look at the property type.

This filter allows you to specify which property types received in the AgentOS feed should classify a property as being commercial.

Example usage:

add_filter( 'propertyhive_letmc_json_commercial_property_types', 'set_commercial_types' );
function set_commercial_types($types)
{
    // $types (array) - defaults to ['CommercialProperty']

    // Also consider properties with type 'Warehouse' as commercial
    $types[] = 'Warehouse';

    return $types;
}

Hook name: propertyhive_agentos_json_address_fields_to_check

Hook type: Filter

Description: If you have locations setup under 'Property Hive > Settings > Custom Fields' we'll look at a number of address fields provided in the AgentOS data and, if a matching 'Location' is found, we'll set it accordingly.

Using this filter you can customise the address fields in the AgentOS data that we consider when looking for a matching location.

Example usage:

add_filter( 'propertyhive_agentos_json_address_fields_to_check', 'customise_address_fields' );
function customise_address_fields($address_fields)
{
    // $address_fields (array) - defaults to ['Address2', 'Address3', 'Address4']

    $address_fields[] = 'Address1'; // also look at address line 1 when mapping to location

    return $address_fields;
}

Hook name: propertyhive_property_imported_agentos_json

Hook type: Action

Description: Executed after each individual property is imported.

Example usage:

add_action( 'propertyhive_property_imported_agentos_json', 'property_imported', 10, 2 );
function property_imported( $post_id, $property )
{
    // $post_id (int) - the WordPress post ID of the imported property
    // $property (array) - The property received in the feed

    // do something here...
}

Hook name: propertyhive_post_import_properties_agentos_json

Hook type: Action

Description: Executed after all properties have been imported.

Example usage:

add_action( 'propertyhive_post_import_properties_agentos_json', 'post_import' );
function post_import()
{
    // do something here...
}

Hook name: propertyhive_property_removed_agentos_json

Hook type: Action

Description: Executed after a property has been removed from Property Hive due to it not being present in the feed.

Example usage:

add_action( 'propertyhive_property_removed_agentos_json', 'property_removed' );
function property_removed( $post_id )
{
    // $post_id (int) - the WordPress post ID of the imported property

    // do something here...
}