Library to build valid Auto-Lead Data Format ADF/XML leads.

0.3.0 2024-08-14 13:09 UTC

This package is auto-updated.

Last update: 2024-10-19 13:59:36 UTC


README

PHP library that builds valid Auto-Lead Data Format ADF/XML leads.

Supports

Features

  • Complete ADF implementation
  • Validate tags and attributes (optional)
  • Custom tags and attributes
  • Data entry via an associative array, object, or JSON
  • Attempts date conversion to ISO 8601:1988
  • Default attributes for name, phone, prospect, and vehicle

Install

Include SendADF in your project with Composer:

composer require carmelosantana/sendadf

Requirements:

Usage

Basic lead

This example lead represents the minimum data required to comply with ADF specifications.

$adf = ( new CarmeloSantana\SendAdf\SendAdf() )
    ->addProspect( 'new' )
    ->addRequestdate( '2/9/2020 6:26PM' )
    ->addVehicle( [
        'year' => 1999,
        'make' => 'Chevrolet',
        'model' => 'Blazer'
    ], 'buy', 'used' )
    ->addCustomer()
        ->addContact()
            ->addName( 'John Doe' )
            ->addPhone( '393-999-3922' )
    ->addVendor()
        ->addContact()
            ->addName( 'Acura of Bellevue' );

Output

Basic output with no tabs.

echo $adf->getXml();
<?xml version="1.0" encoding="UTF-8"?>
<?adf version="1.0"?>
<adf><prospect status="new"><requestdate>2020-02-09T18:26:00-05:00</requestdate><vehicle interest="buy" status="used"><year>1999</year><make>Chevrolet</make><model>Blazer</model></vehicle><customer><contact><name part="full" type="individual">John Doe</name><phone type="voice" time="nopreference">393-999-3922</phone></contact></customer><vendor><contact><name part="full" type="individual">Acura of Bellevue</name></contact></vendor></prospect></adf>

Pretty print output.

echo $adf->getPrettyPrintXML();
<?xml version="1.0" encoding="UTF-8"?>
<?adf version="1.0"?>
<adf>
  <prospect status="new">
    <requestdate>2020-02-09T18:26:00-05:00</requestdate>
    <vehicle interest="buy" status="used">
      <year>1999</year>
      <make>Chevrolet</make>
      <model>Blazer</model>
    </vehicle>
    <customer>
      <contact>
        <name part="full" type="individual">John Doe</name>
        <phone type="voice" time="nopreference">393-999-3922</phone>
      </contact>
    </customer>
    <vendor>
      <contact>
        <name part="full" type="individual">Acura of Bellevue</name>
      </contact>
    </vendor>
  </prospect>
</adf>

Default values

Default attribute values are added if none are supplied. This is to adhere to the ADF standard.

$adf = ( new CarmeloSantana\SendAdf\SendAdf() )
    ->addRequestdate()
    ->addVehicle( [
        'year' => 2020,
        'make' => 'Chevrolet',
        'model' => 'Blazer'
    ] )
    ->addCustomer()
        ->addContact()
            ->addName( 'John Doe' )
            ->addPhone( '393-999-3922' );

echo $adf->getPrettyPrintXML();
<?xml version="1.0" encoding="UTF-8"?>
<?adf version="1.0"?>
<adf>
  <prospect status="new">
    <requestdate>2021-02-09T19:32:16-05:00</requestdate>
    <vehicle interest="buy" status="new">
      <year>1999</year>
      <make>Chevrolet</make>
      <model>Blazer</model>
    </vehicle>
    <customer>
      <contact>
        <name part="full" type="individual">John Doe</name>
        <phone type="voice" time="nopreference">393-999-3922</phone>
      </contact>
    </customer>
  </prospect>
</adf>
  • prospect tag is opened with status new without calling addProspect.
  • addRequestdate current server time is used as the default for requestdate when none is provided.
  • name part and type are provided.
  • phone type and time are provided.

Default values can be avoided by using addProspectparent_node and addNode as seen in example 3.

Sending empty values as shown in example 1 can disable these attributes as well.

Examples

Example 1

  • Bare minimum to get started

Example 2

  • Full document with all elements and attribute examples

Example 3

  • Avoid default values
  • Manually open and close nodes

Example 4

  • Disable validation
  • Custom tags and attributes

Example 5

  • Data entry via arrays, objects and JSON

Support

Community support available on Discord.

Funding

If you find this project useful or use it in a commercial environment please consider donating today with one of the following options.

Changelog

  • 0.3.0 - Aug 6, 2024
    • Fix psr-4 namespace
    • Update all methods from underscores to camelCase
    • Update PHP requirements

License

The code is licensed MIT and the documentation is licensed CC BY-SA 4.0.