Skip to content

About

Symfony2 Client Bundle For Practo Communicator

Resources

Stars

0 stars

Watchers

2 watching

Forks

Repository files navigation

CommunicatorBundle

Installation

Step 1: Download the Bundle

Add the dependency in your project's composer.json:

"require": {
    "practo/communicator-bundle": "dev-master"
},
"repositories": [
    {
        "type": "vcs",
        "url": "git@github.com:practo/CommunicatorBundle.git"
    }
]

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

$ composer update practo/communicator-bundle

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Practo\CommunicatorBundle\PractoCommunicatorBundle(),
        );

        // ...
    }

    // ...
}

Step 3: Add required parameters

Communicator has 4 required parameters, add them to your parameters.yml

communicator.queue.uri: beanstalk://localhost/
communicator.base_uri: replace-with-communicator-url
communicator.api.secret: replace-with-communicator-api-secret
communicator.api.app_name: replace-with-application-name
communicator.s3.bucket: attachment-bucket-name

Per-service auth for HTTP calls

By default the HTTP calls this bundle makes to communicator (message and mail lookups, SMS credit, device information, WhatsApp lookups) are signed with the shared communicator.api.secret and send no service header. Communicator is retiring that shared key (PLAT-2408), so each app should switch to its own key:

communicator.api.app_name: FABRIC              # your app; sent as the `service` header
communicator.api.v2_secret: <your app's key>   # must equal SIGNING_KEYS[<app_name lowercased>] in communicator
communicator.api.use_service_auth: true        # defaults to false

Turn it on only after confirming your v2_secret matches communicator's entry for your app name, or communicator will reject the calls with 403. Setting it back to false restores the old behaviour. Queue-based sends, push endpoints and WhatsApp consent calls are not affected by this flag.

Version Control

There are no release tags for this bundle. If you want to update, please use commit references.

  • Update commit reference in your composer.lock:

{
    "name": "practo/communicator-bundle",
    "version": "dev-master",
    "target-dir": "Practo/CommunicatorBundle",
    "source": {
        "type": "git",
        "url": "git@github.com:practo/CommunicatorBundle.git",
        "reference": "" /* Update this reference to your target commit hash */
    },
},

  • Run the following command to update composer hash:
$ composer update --lock
  • Below is snippet to send doctor sms:
$sms = $this->container->get('practo_communicator.sms_doctor');
$sms>sendSms(
             $reference_id, $reference_type,
             $name, $to, $messageType, $body,
             $notes = null, $expiryTime = null
            );
  • Below is snippet to send staff mail:
$mailStaff = $this->container->get('practo_communicator.mail_staff');
$mailStaff->sendMail(
                     $fromName, $fromMail, $toName = "", $to,
                     $cc = "", $bcc = "", $subject, $body, $type,
                     $files, $hash, $plaintext = "", $replyTo = NULL,
                     $reference_id = NULL, $reference_type = NULL,
                     $expiryTime = NULL, $appName = null)s = null, $expiryTime = null
            );

FAQ

  • Getting error pheanstalk_pheanstalk not found

There are two ways to solve it.

  1. Use version ~2.1 of pheanstalk.
  2. In communicatatorbundle change pheanstalk_pheanstalk to pheanstalk/pheanstalk.

About

Symfony2 Client Bundle For Practo Communicator

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages