Giter Site home page Giter Site logo

connect-php-worker-aws's Introduction

PHP: Connect Worker for AWS

Repository: connect-php-worker-aws

Introduction

This is an example worker application for Connect webhook notification messages sent via the AWS SQS (Simple Queueing System).

This application receives DocuSign Connect messages from the queue and then processes them:

  • If the envelope is complete, the application uses a DocuSign JWT Grant token to retrieve the envelope's combined set of documents, and stores them in the output directory.

    For this example, the envelope must include an Envelope Custom Field named Sales order. The Sales order field is used to name the output file.

Architecture

Connect listener architecture

AWS has SQS SDK libraries for C#, Java, Node.js, Python, Ruby, C++, and Go.

Installation

Introduction

First, install the Lambda listener on AWS and set up the SQS queue.

Then set up this code example to receive and process the messages received via the SQS queue.

Installing the Lambda Listener

Install the example Connect listener for AWS on AWS. At the end of this step, you will have the Queue URL, Queue Region and Enqueue url that you need for the next step.

Installing the worker (this repository)

Requirements

  • PHP version 7.3.5 or later
  1. Download or clone this repository. Then:

    cd connect-php-worker-aws
    composer install
    
  2. Using AWS IAM, create an IAM User with access to your SQS queue.

  3. Configure the ds_config.ini file: ds_config.ini The application uses the OAuth JWT Grant flow.

    If consent has not been granted to the application by the user, then the application provides a url that can be used to grant individual consent.

    To enable individual consent: either add the URL https://www.docusign.com as a redirect URI for the Integration Key, or add a different URL and update the oAuthConsentRedirectURI setting in the ds_config.ini file.

  4. Creating the Integration Key Your DocuSign Integration Key must be configured for a JWT OAuth authentication flow:

    • Create a public/private key pair for the key. Store the private key in a secure location. You can use a file or a key vault.
    • The example requires the private key. Store the private key in the ds_config.ini file.

    Note: the private key's second and subsequent lines need to have a space added at the beginning due to requirements from the Python configuration file parser. Example:

DS_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
....
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXz1pr9mKfwmamtPXeMSJeEZUVmh7mNx
PEHgznlGh/vUboCuA4tQOcKytxFfKG4F+jM/g4GH9z46KZOow3Hb6g==
-----END RSA PRIVATE KEY-----"  

Run the examples

php aws_worker.php

Testing

Configure a DocuSign Connect subscription to send notifications to the Cloud Function. Create / complete a DocuSign envelope. The envelope must include an Envelope Custom Field named "Sales order".

  • Check the Connect logs for feedback.

  • Check the console output of this app for log output.

  • Check the output directory to see if the envelope's combined documents and CoC were downloaded.

    For this code example, the envelope's documents will only be downloaded if the envelope is complete and includes a Sales order custom field.

Unit Tests

Includes three types of testing:

  • SavingEnvelopeTest.cs allow you to send an envelope to your amazon sqs from the program. The envelope is saved at output directory although its status is sent.

  • RunTest.cs divides into two types of tests, both submits tests for 8 hours and updates every hour about the amount of successes or failures that occurred in that hour, the differences between the two are:

    • few - Submits 5 tests every hour.
    • many - Submits many tests every hour.

To run the tests, split the terminal in two inside Visual Studio Code. In the first terminal run the connect-csharp-worker-aws program. In the second terminal choose the wanted test. You can see above at Run the examples part how the files can be run.

Note: make sure your composer conatains:

    "require-dev": {
        "phpunit/phpunit": "8.3"
    }

If not, write in the terminal:

composer require --dev phpunit/phpunit ^8.3

Support, Contributions, License

Submit support questions to StackOverflow. Use tag docusignapi.

Contributions via Pull Requests are appreciated. All contributions must use the MIT License.

This repository uses the MIT license, see the LICENSE file.

connect-php-worker-aws's People

Contributors

larryklugerds avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.