Coder Social home page Coder Social logo

smith-carson / prosperworks-sdk Goto Github PK

View Code? Open in Web Editor NEW
7.0 4.0 8.0 61 KB

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

Home Page: https://smith-carson.github.io/prosperworks-sdk/

License: MIT License

PHP 100.00%
prosperworks crm api guzzle guzzlehttp sdk php php7

prosperworks-sdk's People

Contributors

andyhot avatar gte451f avatar igorsantos07 avatar kapolos avatar lpedretti avatar marceloandrader avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

prosperworks-sdk's Issues

Validate verb+endpoint combinations before the HTTP call is fired

Not all endpoints have all operations available. This was solved for the Webhooks endpoint as it needs some custom methods as well, but it would defeat the purpose of the magic calls happening in the library for other endpoints.

Instead, on debug mode (i.e. Config::debugLevel(DEBUG_BASIC)) we should run conservative validation rules to warn the developer the call they're trying to run is not available on the API. There are already specifications for that (on BaseEndpoint::$specs) but that's not yet used.

That's more friendly than a random 404 error with no specification on what went wrong from ProsperWorks.

PSR-4 violations reported by composer

Composer recently started throwing deprecation notices in the console, saying these violations would prevent classes to be autoloaded with Composer 2.0 onwards.

It looks like the casing of the folder name does not match the namespace.

Here is the full message from composer:

Deprecation Notice: Class ProsperWorks\Interfaces\Cache located in ./vendor/smith-carson/prosperworks-sdk/src/interfaces/Cache.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class ProsperWorks\Interfaces\Crypt located in ./vendor/smith-carson/prosperworks-sdk/src/interfaces/Crypt.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201

Bug with fieldList method dealing with custom fields.

I'm not sure if this is a problem because of the way the API returns objects when there is only one instance of said object type but I ran into this and I only have 1 custom field defined. I did not try the existing code with multiple fields but I did come up with a fix / workaround for this.

I really dont have time to do a PR and I'm also not sure if this is the best way to fix this however in CRM.php at Line 162 you have the following code:

if ($resource == 'activityType') { //yet another API inconsistency to deal with
	$list = array_merge($list->user, $list->system);
}

$result = array_column($list, $detailed ? null : 'name', 'id');

if ($detailed && $resource == 'customFieldDefinition') {
	array_walk($result, function (&$field) {
		if (isset($field->options) && $field->options) {
			$field->options = array_column($field->options, 'name', 'id');
		}
	});
}

return $result;

The problem here is that in my particular instance the $list variable was of type ProsperWorks\Resrouces\BareResource and not Array as expected by the call to array_column within this block.

I was able to fix / work around this by changing the above block to this:

if ($resource == 'activityType') { //yet another API inconsistency to deal with
	$list = array_merge($list->user, $list->system);
}


// START NEW
if ($resource == 'customFieldDefinition') {
	if($detailed) {
		$result = [$list->id => $list];
	} else {
		$result = [$list->id => $list->name];
	}
} else {
	$result = array_column($list, $detailed ? null : 'name', 'id');
}
// END NEW


if ($detailed && $resource == 'customFieldDefinition') {
	array_walk($result, function (&$field) {
		if (isset($field->options) && $field->options) {
			$field->options = array_column($field->options, 'name', 'id');
		}
	});
}

return $result;

What do you think?

Fix "error margin" on Endpoint::search()

For some odd reason, the ProsperWorks API is not reliable in regards to the number of records returned on search calls. Thus, there's a hacky code that tries to get as much as possible, with a safe margin to allow us to retrieve all paged records.

We should talk with the ProsperWorks Support team about that, get it fixed somehow, and update Endpoint::search().

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.