mremi/dolist-bundle

Implementation of Dolist library for Symfony2

v1.0.0 2013-07-20 09:15 UTC

README

SensioLabsInsight

Build Status Total Downloads Latest Stable Version

This bundle implements the Dolist library for Symfony2.

License

This bundle is available under the MIT license.

Prerequisites

This version of the bundle requires Symfony 2.1+.

Basic Docs

Installation

Installation is a quick 3 step process:

  1. Download MremiDolistBundle using composer
  2. Enable the Bundle
  3. Configure the MremiDolistBundle

Step 1: Download MremiDolistBundle using composer

Add MremiDolistBundle in your composer.json:

{
    "require": {
        "mremi/dolist-bundle": "dev-master"
    }
}

Now tell composer to download the bundle by running the command:

$ php composer.phar update mremi/dolist-bundle

Composer will install the bundle to your project's vendor/mremi directory.

Step 2: Enable the bundle

Enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Mremi\DolistBundle\MremiDolistBundle(),
    );
}

Step 3: Configure the MremiDolistBundle

The bundle comes with a sensible default configuration, which is listed below. However you have to configure at least your account identifier and authentication key.

# app/config/config.yml
mremi_dolist:
    api:
        # mandatory
        account_id:         your_account_identifier
        authentication_key: your_authentication_key

        # optional, default values are:
        authentication:
            wsdl:    http://api.dolist.net/v2/AuthenticationService.svc?wsdl
            options:
                soap_version:       1 # SOAP_1_1
                proxy_host:         ~
                proxy_port:         ~
                proxy_login:        ~
                proxy_password:     ~
                compression:        ~
                encoding:           ~
                trace:              %kernel.debug%
                classmap:           ~
                exceptions:         ~
                connection_timeout: 2
                typemap:            ~
                cache_wsdl:         ~
                user_agent:         ~
                stream_context:     ~
                features:           ~
                keep_alive:         ~
            retries: 1

        # optional, default values are:
        contact:
            wsdl:          http://api.dolist.net/v2/ContactManagementService.svc?wsdl
            options:
                soap_version:       1 # SOAP_1_1
                proxy_host:         ~
                proxy_port:         ~
                proxy_login:        ~
                proxy_password:     ~
                compression:        ~
                encoding:           ~
                trace:              %kernel.debug%
                classmap:           ~
                exceptions:         ~
                connection_timeout: 2
                typemap:            ~
                cache_wsdl:         ~
                user_agent:         ~
                stream_context:     ~
                features:           ~
                keep_alive:         ~
            retries: 1

Add/update a contact

Two services allow you to add or update a contact, to use like this:

<?php

$contactManager = $container->get('mremi_dolist.api.contact_manager');
$fieldManager = $container->get('mremi_dolist.api.field_manager');

$contact = $contactManager->create();
$contact->setEmail('test@example.com');
$contact->addField($fieldManager->create('firstname', 'Firstname'));
$contact->addField($fieldManager->create('lastname', 'Lastname'));

$ticket = $contactManager->save($contact);

$saved = $contactManager->getStatusByTicket($ticket);

if ($saved->isOk()) {
    // contact has been saved...
} else {
    // something is wrong...
    echo sprintf('Returned code: %s, description: %s', $saved->getReturnCode(), $saved->getDescription());
}

Retrieve contacts

<?php

use Mremi\Dolist\Contact\GetContactRequest;

$contactManager = $container->get('mremi_dolist.api.contact_manager');

$request = new GetContactRequest;
$request->setOffset(50);
// ...

$contacts = $contactManager->getContacts($request);

Contribution

Any question or feedback? Open an issue and I will try to reply quickly.

A feature is missing here? Feel free to create a pull request to solve it!

I hope this has been useful and has helped you. If so, share it and recommend it! :)

@mremitsme