PHPackages                             smith-carson/prosperworks-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. smith-carson/prosperworks-sdk

AbandonedArchivedLibrary[HTTP &amp; Networking](/categories/http)

smith-carson/prosperworks-sdk
=============================

Unofficial (but pretty decent) SDK for the ProsperWorks CRM API

1.0.18(8y ago)71.3k7[3 issues](https://github.com/smith-carson/prosperworks-sdk/issues)[3 PRs](https://github.com/smith-carson/prosperworks-sdk/pulls)MITPHPPHP ^7.0

Since Jul 14Pushed 4y ago3 watchersCompare

[ Source](https://github.com/smith-carson/prosperworks-sdk)[ Packagist](https://packagist.org/packages/smith-carson/prosperworks-sdk)[ Docs](https://smith-carson.github.io/prosperworks-sdk)[ RSS](/packages/smith-carson-prosperworks-sdk/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (3)Versions (19)Used By (0)

   layout     default

  Introduction
============

[](#introduction)

At the time of implementation, there was no SDK for ProsperWorks, and we needed to do a bunch of operations to transfer data from our old CRM and synchronize information with the other subsystems, so we designed some classes to encapsulate the API operations. It uses Guzzle, but ended up overgrowing and we turned into a standalone library.

This project was originally written by [igorsantos07](https://github.com/igorsantos07) and is now maintained by [smith-carson](https://github.com/smith-carson)([website](https://smithcarson.com)).

Installation
============

[](#installation)

1. Install in your project
--------------------------

[](#1-install-in-your-project)

You need to be running **PHP 7** *(yep, it's stable since dec/2015 and packs a bunch of useful features, upgrade now!)*.

To add it to your project through Composer, run `composer require igorsantos07/prosperworks`. It will get the most stable version if your `min-requirements` are "stable" or `dev-master` otherwise.

2. Configure the package
------------------------

[](#2-configure-the-package)

There's a couple of things to configure to get the SDK running:

### API credentials

[](#api-credentials)

> Currently, there's no "API User" on ProsperWorks, so you need an active user to communicate with the API.

1. Sign in to ProsperWorks, go to **Settings &gt; Preferences / API Keys**. There you will be able to generate a new API Key for the logged user. Copy that key, along with the user email.
2. Create a bootstrap file, or include the following code in the config section of your project: `\ProsperWorks\Config::set($email, $token)`.

### Webhooks parameters

[](#webhooks-parameters)

**\[Optional\]** If you're going to use Webhooks to get updates from ProsperWorks, you'll also need to feed in three more arguments on that method:

1. A *Webhooks Secret*, that will be used to avoid unintended calls to your routes. That should be a plain string.
2. A *Root URL*. That's probably the same domain/path you use for your systems, and what ProsperWorks will POST to. More information on the [Webhooks](#webhooks) section.
3. A *Cryptography object*. It should respond to `encryptBase64()` and `decryptBase64()`, both receiving and returning a string (it can also implement `\ProsperWorks\Interfaces\Crypt` to make things easier). It will be used to send an encrypted secret, and decrypt it to make sure the call you receive comes from ProsperWorks (or, at least, someone that has the encrypted secret).

### Caching object

[](#caching-object)

**\[Optional\]** To make some parts faster, you can also feed the sixth argument with a caching layer. It's an object that needs to respond to `get()` and `save()`, or implement `\ProsperWorks\Interfaces\Cache`.

It's mainly used to cache (for an hour) meta-data from the API, such as Custom Fields, Activity and Contact Types, and so on. That's information that rarely changes so it's safe to cache, making calls much faster (otherwise, for every resource with custom fields we would need to retrieve from the custom fields endpoint as well).

3. Debug mode
-------------

[](#3-debug-mode)

During import scripts and similar tasks it could be useful to peek into the network traffic and see if what you intended to do is being done correctly. You can enable `echo`'s of debug information from the library by calling `ProsperWorks\Config::debugLevel()`:

 `ProsperWorks\Config::DEBUG_BASIC` will trigger some messages, such as "POST /people/search" so you know which requests are being sent. It also warns on Rate limits being hit. `ProsperWorks\Config::DEBUG_COMPLETE` does all above plus complete requests payload. `null`, `false`, `0` or `ProsperWorks\Config::DEBUG_NONE` will stop printing messages.> This doesn't need to be done together with `Config::set()`; it can happen anywhere and will change behavior from that part on.

### Tip: "sandbox" account

[](#tip-sandbox-account)

After a while, when implementing this library for the first time, we spoke with a support representative about the lack of a sandbox environment. They suggested us to create a trial account and use that instead of a user on the paying account, and mention to the Support that was being used to test-drive the API implementation - and thus, they would extend the trial of that solo account for as long as it was needed.

API Communication
=================

[](#api-communication)

Most of the operations are done through the `\ProsperWorks\CRM` abstract class, and the resulting objects from it (you can consider it some sort of Factory class). The exception are Webhooks, that have a special Endpoint class to make it easier.

> Tip: **ProsperWorks API Documentation**
> You may want to read the [REST API Docs](https://www.prosperworks.com/developer_api), to get an understanding of the inner pieces that make up this SDK.

With configurations in place, ProsperWorks API calls are done through a simple, fluent API. Most of the endpoints behave the same way, with special cases being the Account and most meta-data endpoints.

> On the following examples we'll consider the classes were imported in the current namespace.

Common endpoints
----------------

[](#common-endpoints)

Singular, empty static calls to `CRM` give an `Endpoint` object (see [saving instances](#i-dont-think-all-those-static-calls-are-performant)), that allows you to run all common operations:

```
