Modules

The scope of each interaction is bundled into a module, which consists of customizable displays, actions, events, parameters and objectives.

Modules function independently or in sequence when connected to other modules.

Retrieve a Module

GET /v1/{access-token}/module
                            
use \FormSynergy\Init as FS;

$api = FS::Api()->Load($profileid);

$api->Get('module')
    ->Where([
        'moduleid' => $moduleid,
    ])
    ->As('GetModule');
 
 
                            
                            
{
    "lastused": "2019-02-27 16:25:47",
    "profileid": "profile-c2300300a5075ee8adae51da57c39f90",
    "moduleid": "module-d468092d4209efec3a50b88",
    "modid": "mod-d2bee61964ff44202fde3f2d315317b7",
    "siteid": "web-169b185e8dc05ad610a6e3a50a6e3712",
    "name": "Contact Us",
    "form": [{
            "x": 0,
            "type": "text",
            "system": "fname",
            "label": "First Name",
            "name": "fname",
            "class": "form-control"
        },
        {
            "x": 1,
            "type": "text",
            "system": "lname",
            "label": "Last Name",
            "name": "lname",
            "class": "form-control"
        },
        {
            "x": 2,
            "type": "email",
            "system": "email",
            "label": "Email Address",
            "name": "email",
            "class": "form-control",
            "validation": "yes"
        },
        {
            "x": 3,
            "type": "tel",
            "system": "mobile",
            "label": "Phone Number",
            "name": "mobile",
            "class": "form-control",
            "validation": "yes"
        },
        {
            "x": 4,
            "type": "textarea",
            "system": "custom",
            "label": "Message",
            "name": "message",
            "class": "form-control h-3"
        }
    ],
    "headings": [{
        "subject": "Subject 1",
        "body": "Message body 1"
    }],
    "events": [{
            "type": "click:contact-form",
            "rec": 1
        },
        {
            "type": "mouseover:email-icon",
            "rec": 5
        }
    ],
    "success": "Success Message",
    "dismiss": "Dismiss Message",
    "customcss": "https:\/\/...",
    "delay": 0,
    "page": "demo.....com\/page\/",
    "term": null,
    "buttonsdisabled": "no",
    "buttonsubmit": "Submit",
    "buttondismiss": "Dismiss"
}
                            

Finding Modules

GET /v1/{access-token}/modules
                            
use \FormSynergy\Init as FS;

$api = FS::Api()->Load($profileid);

// Search for modules.
$api->Find('modules')
    ->Where([
        'modid' => $modid, 
    ])
    ->As('FindModules');
 
// Search for modules.
$api->Find('modules')
    ->Where([
        'modid' => $modid,  
    ])
    ->As('FindModule', 0);
 
                            
                            
// All stored modules.
[{
        "lastused": "2019-02-28 16:25:47",
        "profileid": "profile-c2300300a5075ee8adae51da57c39f90",
        "moduleid": "module-d468092d4209efec3a50b88",
        "modid": "mod-d2bee61964ff44202fde3f2d315317b7",
        "siteid": "web-169b185e8dc05ad610a6e3a50a6e3712",
        "name": "Contact Us",
        "form": [{
                "x": 0,
                "type": "text",
                "system": "fname",
                "label": "First Name",
                "name": "fname",
                "class": "form-control"
            },
            {
                "x": 1,
                "type": "text",
                "system": "lname",
                "label": "Last Name",
                "name": "lname",
                "class": "form-control"
            },
            {
                "x": 2,
                "type": "email",
                "system": "email",
                "label": "Email Address",
                "name": "email",
                "class": "form-control",
                "validation": "yes"
            },
            {
                "x": 3,
                "type": "tel",
                "system": "mobile",
                "label": "Phone Number",
                "name": "mobile",
                "class": "form-control",
                "validation": "yes"
            },
            {
                "x": 4,
                "type": "textarea",
                "system": "custom",
                "label": "Message",
                "name": "message",
                "class": "form-control h-3"
            }
        ],
        "headings": [{
            "subject": "Subject 1",
            "body": "Message body 1"
        }],
        "events": [{
                "type": "click:contact-form",
                "rec": 1
            },
            {
                "type": "mouseover:email-icon",
                "rec": 5
            }
        ],
        "success": "Success Message",
        "dismiss": "Dismiss Message",
        "customcss": "https:\/\/...",
        "delay": 0,
        "page": "demo.....com\/page\/",
        "term": null,
        "buttonsdisabled": "no",
        "buttonsubmit": "Submit",
        "buttondismiss": "Dismiss"
    },

    {
        "lastused": "2019-02-27 16:25:47",
        "profileid": "profile-c2300300a5075ee8adae51da57c39f90",
        "moduleid": "module-56fgbfghd92d4209efec3a50b88",
        "modid": "mod-d2bee61964ff44202fde3f2d315317b7",
        "siteid": "web-169b185e8dc05ad610a6e3a50a6e3712",
        "name": "Contact Us 2",
        "form": [{
                "x": 0,
                "type": "text",
                "system": "fname",
                "label": "First Name",
                "name": "fname",
                "class": "form-control"
            },
            {
                "x": 1,
                "type": "text",
                "system": "lname",
                "label": "Last Name",
                "name": "lname",
                "class": "form-control"
            },
            {
                "x": 2,
                "type": "email",
                "system": "email",
                "label": "Email Address",
                "name": "email",
                "class": "form-control",
                "validation": "yes"
            },
            {
                "x": 3,
                "type": "tel",
                "system": "mobile",
                "label": "Phone Number",
                "name": "mobile",
                "class": "form-control",
                "validation": "yes"
            },
            {
                "x": 4,
                "type": "textarea",
                "system": "custom",
                "label": "Message",
                "name": "message",
                "class": "form-control h-3"
            }
        ],
        "headings": [{
            "subject": "Subject 1",
            "body": "Message body 1"
        }],
        "events": [{
                "type": "click:contact-form",
                "rec": 1
            },
            {
                "type": "mouseover:email-icon",
                "rec": 5
            }
        ],
        "success": "Success Message",
        "dismiss": "Dismiss Message",
        "customcss": "https:\/\/...",
        "delay": 0,
        "page": "demo.....com\/page\/",
        "term": null,
        "buttonsdisabled": "no",
        "buttonsubmit": "Submit",
        "buttondismiss": "Dismiss"
    }
]

// The fist stored module.
{
    "lastused": "2019-02-27 16:25:47",
    "profileid": "profile-c2300300a5075ee8adae51da57c39f90",
    "moduleid": "module-d468092d4209efec3a50b88",
    "modid": "mod-d2bee61964ff44202fde3f2d315317b7",
    "siteid": "web-169b185e8dc05ad610a6e3a50a6e3712",
    "name": "Contact Us",
    "form": [{
            "x": 0,
            "type": "text",
            "system": "fname",
            "label": "First Name",
            "name": "fname",
            "class": "form-control"
        },
        {
            "x": 1,
            "type": "text",
            "system": "lname",
            "label": "Last Name",
            "name": "lname",
            "class": "form-control"
        },
        {
            "x": 2,
            "type": "email",
            "system": "email",
            "label": "Email Address",
            "name": "email",
            "class": "form-control",
            "validation": "yes"
        },
        {
            "x": 3,
            "type": "tel",
            "system": "mobile",
            "label": "Phone Number",
            "name": "mobile",
            "class": "form-control",
            "validation": "yes"
        },
        {
            "x": 4,
            "type": "textarea",
            "system": "custom",
            "label": "Message",
            "name": "message",
            "class": "form-control h-3"
        }
    ],
    "headings": [{
        "subject": "Subject 1",
        "body": "Message body 1"
    }],
    "events": [{
            "type": "click:contact-form",
            "rec": 1
        },
        {
            "type": "mouseover:email-icon",
            "rec": 5
        }
    ],
    "success": "Success Message",
    "dismiss": "Dismiss Message",
    "customcss": "https:\/\/...",
    "delay": 0,
    "page": "demo.....com\/page\/",
    "term": null,
    "buttonsdisabled": "no",
    "buttonsubmit": "Submit",
    "buttondismiss": "Dismiss"
}
                            

Create a Module

POST /v1/{access-token}/module
                            
use \FormSynergy\Init as FS;

$api = FS::Api()->Load($profileid);

$api->Create('module')
    ->Attributes([
        'name' => 'Contact Us',
        'modid' => $modid,
        'siteid' => $siteid,
        'form' => [
            [
                'x' => 0,
                'type' => 'text',
                'system' => 'fname',
                'label' => 'First Name',
                'name' => 'fname',
                'class' => 'form-control'
            ],
            [
                'x' => 1,
                'type' => 'text',
                'system' => 'lname',
                'label' => 'Last Name',
                'name' => 'lname',
                'class' => 'form-control'
            ],
            [
                'x' => 2,
                'type' => 'email',
                'system' => 'email',
                'label' => 'Email Address',
                'name' => 'email',
                'class' => 'form-control',
                'validation' => 'yes'
            ],
            [
                'x' => 3,
                'type' => 'tel',
                'system' => 'mobile',
                'label' => 'Phone Number',
                'name' => 'mobile',
                'class' => 'form-control',
                'validation' => 'yes' // Enable validation
            ],
            [
                'x' => 4,
                'type' => 'textarea',
                'system' => 'custom',
                'label' => 'Message',
                'name' => 'message',
                'class' => 'form-control h-3' // <- Add class name h-3 for height: 3rem;
            ]
        ],
        'headings' => [ // Add multiple headings to alternate between headings.
            [
                'subject' => 'Subject 1',
                'body' => 'Message body 1'
            ],
        ]
    ])
    ->As('CreateModule');

 
                            
                            
{
    "lastused": "2019-02-27 16:25:47",
    "profileid": "profile-c2300300a5075ee8adae51da57c39f90",
    "moduleid": "module-a333c5a55d468092d4209efec3a50b88",
    "modid": "mod-d2bee61964ff44202fde3f2d315317b7",
    "siteid": "web-169b185e8dc05ad610a6e3a50a6e3712",
    "name": "Contact Us",
    "form": [
        {
            "x": 0,
            "type": "text",
            "system": "fname",
            "label": "First Name",
            "name": "fname",
            "class": "form-control"
        },
        {
            "x": 1,
            "type": "text",
            "system": "lname",
            "label": "Last Name",
            "name": "lname",
            "class": "form-control"
        },
        {
            "x": 2,
            "type": "email",
            "system": "email",
            "label": "Email Address",
            "name": "email",
            "class": "form-control",
            "validation": "yes"
        },
        {
            "x": 3,
            "type": "tel",
            "system": "mobile",
            "label": "Phone Number",
            "name": "mobile",
            "class": "form-control",
            "validation": "yes"
        },
        {
            "x": 4,
            "type": "textarea",
            "system": "custom",
            "label": "Message",
            "name": "message",
            "class": "form-control h-3"
        }
    ],
    "headings": [
        {
            "subject": "Subject 1",
            "body": "Message body 1"
        }
    ],
    "success": "Success Message",
    "dismiss": "Dismiss Message",
    "delay": 0,
    "buttonsdisabled": "no",
    "buttonsubmit": "Submit",
    "buttondismiss": "Dismiss"
}
                            

Connecting Modules

PUT /v1/{access-token}/module
                            
use \FormSynergy\Init as FS;

/**
 * In this example we have three modules and each requesting one item.
 * To create a connection between multiple modules, we the need module id of each module.
 * If module id already exits, there is no reason to find modules.  
 **/

$api = FS::Api()->Load($profileid);

/**
 * Skip: If module ids already exists 
 **/  
$api->Find('modules')
    ->Where([
        'name' => 'your First Name'
    ])
    ->As('fname', 0);

$api->Find('modules')
    ->Where([
        'name' => 'your Last Name?'
    ])
    ->As('lname', 0);

$api->Find('modules')
    ->Where([
        'name' => 'your Email Address'
    ])
    ->As('email', 0);

/** 
 *Skip: End 
 **/

/**
 * If the module id was stored by finding the module, retrieve the module id: $api->_fname('moduleid')
 * If module ids already exists, simply use the variable. 
 */
$api->Get('module')
    ->Where([
        'moduleid' => $api->_fname('moduleid')
    ])
    ->Update([
        'onsubmit' => $api->_lname('moduleid')
    ]);

$api->Get('module')
    ->Where([
        'moduleid' => $api->_lname('moduleid')
    ])
    ->Update([
        'onsubmit' => $api->_email('moduleid')
    ]);





 
                            
                            
{
    "fname": {
        "profileid": "profile-3be1fa342a520cbdf28aa43ab8edefee",
        "moduleid": "module-df1e0f06a7bd66ce181275c7e11c8c7a",
        "name": "What's your First Name?",
        "lastused": "2019-03-03 09:19:23",
        "form": {
            "1": {
                "type": "text",
                "system": "fname",
                "label": "First Name",
                "name": "fname",
                "class": "form-control"
            }
        },
        "status": "off",
        "description": "Get the first name",
        "type": "standard",
        "button": "Send",
        "modid": "strategy-214d683d70840ed37e4b5db5e7efb529",
        "siteid": "site-9540cd7dfdbfc4756b1d8f21cadb94ea",
        "onsubmit": "module-ceeb6be671ce5534540ed5b163d5e466",
        "ondismiss": "module-f96a1fa5c7b17bce3cae480171a40c8f",
        "events": null,
        "headings": [{
            "subject": "Hi there",
            "message": "What's your First Name?"
        }],
        "altmessage": "0",
        "success": "",
        "dismiss": "",
        "customcss": "",
        "delay": "0",
        "page": "",
        "term": null,
        "family": null,
        "tagname": null,
        "buttonsdisabled": null,
        "buttonsubmit": "Submit",
        "buttondismiss": "Dismiss"
    },
    "lname": {
        "profileid": "profile-3be1fa342a520cbdf28aa43ab8edefee",
        "moduleid": "module-ceeb6be671ce5534540ed5b163d5e466",
        "name": "What's your Last Name?",
        "lastused": "2019-03-03 09:19:23",
        "form": {
            "1": {
                "type": "text",
                "system": "lname",
                "label": "Last Name",
                "name": "lname",
                "class": "form-control"
            }
        },
        "status": "off",
        "description": "Get the last name",
        "type": "standard",
        "button": "Send",
        "modid": "strategy-214d683d70840ed37e4b5db5e7efb529",
        "siteid": "site-9540cd7dfdbfc4756b1d8f21cadb94ea",
        "onsubmit": "module-f96a1fa5c7b17bce3cae480171a40c8f",
        "ondismiss": "module-f96a1fa5c7b17bce3cae480171a40c8f",
        "events": null,
        "headings": [{
            "subject": "It's me again",
            "message": "What's your First Name?"
        }],
        "altmessage": "0",
        "success": "",
        "dismiss": "",
        "customcss": "",
        "delay": "0",
        "page": "",
        "term": null,
        "family": null,
        "tagname": null,
        "buttonsdisabled": null,
        "buttonsubmit": "Submit",
        "buttondismiss": "Dismiss"
    },
    "email": {
        "profileid": "profile-3be1fa342a520cbdf28aa43ab8edefee",
        "moduleid": "module-f96a1fa5c7b17bce3cae480171a40c8f",
        "name": "What's your Email Address",
        "lastused": "2019-01-26 01:46:05",
        "form": [{
            "type": "email",
            "system": "email",
            "label": "Email Address",
            "name": "email",
            "class": "form-control"
        }],
        "status": "off",
        "description": "Get the email address",
        "type": "standard",
        "button": "Send",
        "modid": "strategy-214d683d70840ed37e4b5db5e7efb529",
        "siteid": "site-9540cd7dfdbfc4756b1d8f21cadb94ea",
        "onsubmit": null,
        "ondismiss": null,
        "events": null,
        "headings": [{
            "subject": "One more thing",
            "message": "What's your Email Address?"
        }],
        "altmessage": "0",
        "success": "",
        "dismiss": "",
        "customcss": "",
        "delay": "0",
        "page": "",
        "term": null,
        "family": null,
        "tagname": null,
        "buttonsdisabled": null,
        "buttonsubmit": "Submit",
        "buttondismiss": "Dismiss"
    }
}
                            

Update Module Properties

PUT /v1/{access-token}/module
                            
use \FormSynergy\Init as FS;

$api = FS::Api()->Load($profileid);

$api->Get('module')
    ->Where([
        'moduleid' => $moduleid,
    ])
    ->Update([
        'headings' => [
            [
                'subject' => 'My new title',
                'body' => 'New body'
            ]
        ],
    ])
    ->As('UpdateModule');
 
                            
                            
{
    "profileid": "profile-c2300300a5075ee8adae51da57c39f90",
    "moduleid": "module-ce3b159e2b4093ea5ed8f654f49a6333",
    "name": "Contact Form",
    "lastused": "2019-02-27 16:27:08",
    "form": [{
        "x": 2,
        "type": "text",
        "system": "fname",
        "label": "First Name",
        "name": "fname",
        "class": "form-control"
    }, {
        "x": 3,
        "type": "text",
        "system": "lname",
        "label": "Last Name",
        "name": "lname",
        "class": "form-control"
    }, {
        "x": 0,
        "type": "email",
        "system": "email",
        "label": "Email Address",
        "name": "email",
        "class": "form-control",
        "validation": "yes"
    }, {
        "x": 1,
        "type": "tel",
        "system": "mobile",
        "label": "Phone Number",
        "name": "mobile",
        "class": "form-control",
        "validation": "yes"
    }, {
        "x": 4,
        "type": "textarea",
        "system": "custom",
        "label": "Message",
        "name": "message",
        "class": "form-control h-3"
    }],
    "description": null,
    "button": "Send",
    "modid": "mod-d2bee61964ff44202fde3f2d315317b7",
    "siteid": "web-169b185e8dc05ad610a6e3a50a6e3712",
    "onsubmit": null,
    "ondismiss": null,
    "success": "",
    "dismiss": "",
    "delay": "0",
    "buttonsdisabled": null,
    "buttonsubmit": "Submit",
    "buttondismiss": "Dismiss"
}
                            

Replace Module Properties

PUT /v1/{access-token}/module
                            
use \FormSynergy\Init as FS;

$api = FS::Api()->Load($profileid);

$api->Get('module')
    ->Where([
        'moduleid' => $moduleid,
    ])
    ->Replace([
        'form' => [
            [
                'x' => 2,
                'type' => 'text',
                'system' => 'fname',
                'label' => 'First Name',
                'name' => 'fname',
                'class' => 'form-control'
            ],
            [
                'x' => 3,
                'type' => 'text',
                'system' => 'lname',
                'label' => 'Last Name',
                'name' => 'lname',
                'class' => 'form-control'
            ],
            [
                'x' => 0,
                'type' => 'email',
                'system' => 'email',
                'label' => 'Email Address',
                'name' => 'email',
                'class' => 'form-control',
                'validation' => 'yes'
            ],
            [
                'x' => 1,
                'type' => 'tel',
                'system' => 'mobile',
                'label' => 'Phone Number',
                'name' => 'mobile',
                'class' => 'form-control',
                'validation' => 'yes' // Enable validation
            ],
            [
                'x' => 4,
                'type' => 'textarea',
                'system' => 'custom',
                'label' => 'Message',
                'name' => 'message',
                'class' => 'form-control h-3' // <- Add class name h-3 for height: 3rem;
            ]
        ] 
    ])
    ->As('ReplaceModule');
 
                            
                            
{
    "profileid": "profile-c2300300a5075ee8adae51da57c39f90",
    "moduleid": "module-ce3b159e2b4093ea5ed8f654f49a6333",
    "name": "Contact Form",
    "lastused": "2019-02-27 16:26:59",
    "form": [{
        "x": 2,
        "type": "text",
        "system": "fname",
        "label": "First Name",
        "name": "fname",
        "class": "form-control"
    }, {
        "x": 3,
        "type": "text",
        "system": "lname",
        "label": "Last Name",
        "name": "lname",
        "class": "form-control"
    }, {
        "x": 0,
        "type": "email",
        "system": "email",
        "label": "Email Address",
        "name": "email",
        "class": "form-control",
        "validation": "yes"
    }, {
        "x": 1,
        "type": "tel",
        "system": "mobile",
        "label": "Phone Number",
        "name": "mobile",
        "class": "form-control",
        "validation": "yes"
    }, {
        "x": 4,
        "type": "textarea",
        "system": "custom",
        "label": "Message",
        "name": "message",
        "class": "form-control h-3"
    }],
    "status": "on",
    "description": null,
    "type": "standard",
    "button": "Send",
    "modid": "mod-d2bee61964ff44202fde3f2d315317b7",
    "siteid": "web-169b185e8dc05ad610a6e3a50a6e3712",
    "onsubmit": null,
    "ondismiss": null,
    "headings": [{
        "subject": "Contact Us",
        "message": ""
    }],
    "success": "",
    "dismiss": "",
    "delay": "0",
    "buttonsdisabled": null,
    "buttonsubmit": "Submit",
    "buttondismiss": "Dismiss"
}
                            

Delete a Module

DELETE /v1/{access-token}/module
                            
use \FormSynergy\Init as FS;

$api = FS::Api()->Load($profileid);

$api->Get('module')
    ->Where([
        'moduleid' => $moduleid,
    ])->Delete()
    ->As('DeleteModule');
 
                            
                            
{
    "code": 200,
    "messages": ["Item removed"],
    "AccessPoint": "754a3683204940fd0f6ac39b25d127e3",
    "profileid": "profile-3be1fa342a520cbdf28aa43ab8edefee",
    "uri": "\/v1\/754a3683204940fd0f6ac39b25d127e3\/module"
}