PHP code example of fotografde / notification-library

1. Go to this page and download the library: Download fotografde/notification-library library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fotografde / notification-library example snippets


    use GetPhoto\Notification;
    

    (new Notification)->pushEvent($data);
    

        $data = [
            'eventTypeId' => 'User.Login',
            'dateTime' => '20170117 232900',
            'userId' => '1',
            'photographerId' => '1',
        ];
        (new Notification)->pushEvent($data);
        

        $data = [
            'eventTypeId' => 'Contactsheet.Created',
            'dateTime' => '20170115 080005',
            'userId' => '5',
            'photographerId' => '2',
            'contactsheetId' => 'a0shfd0a9shf9',
        ];
        (new Notification)->pushEvent($data);
        

    use GetPhoto\Trigger;
    

    //Trigger ID => Unique name for your trigger
    //Trigger type => EventBased, Scheduled, TimeBased or Manual
    //Trigger action => Action to be executed
    $trigger = new Trigger('trigger id', 'trigger description', 'trigger type', 'trigger action');
  
    //optional methods
    $trigger->addSubscriptionKey('value');
    $trigger->addDelay('value');
    $trigger->addWhen('value');
  
    //auxiliar methods
    $trigger->createActionParameterConstant('constant', 'value');
    $trigger->createActionParameterVariable('variable', 'value');
    $trigger->createActionParameterMethod('variable', 'method', ['arguments', ...]);

    //optional methods that can be used multiple times
    $trigger->addActionParameter($parameter);
    $trigger->addParameter(['data key' => 'data value', ...]);
    
    $trigger->save();
    

    $trigger = new Trigger('UserLogins.v1', 'Shows all logins from an user', 'Manual', 'method::returnJson');
    $trigger->addSubscriptionKey('UserId');
  
    $userId = $trigger->createVariable('userId', 'userId');
    $eventTypeId = $trigger->createConstant('eventTypeId', 'User.Login');
    $eventsMethod = $trigger->createMethod('returnJson', [$userId, $eventTypeId]);
    $events = $trigger->createVariable('events', $eventsMethod);
   
    $trigger->addActionParameter($events);
    $trigger->save();
    

    (project folder)> cp vendor/GetPhoto/notification-library/config/notification.php.default vendor/GetPhoto/notification-library/config/notification.php
    OR
    (project folder)> cp src/vendors/GetPhoto/notification-library/config/notification.php.default src/vendors/GetPhoto/notification-library/config/notification.php
    

    (project folder)> cp config/notification.php.default config/notification.php