it-pirs / konnektive-api
A PHP implementation of the Konnektive CRM v2 API
Requires
- php: >=7.1.3
- ext-curl: *
- fzaninotto/faker: ^1.8
- illuminate/container: 5.7.*
- illuminate/database: 5.7.*
- illuminate/translation: 5.7.*
- illuminate/validation: 5.7.*
Requires (Dev)
- phpunit/phpunit: >=7.3.5
This package is auto-updated.
Last update: 2024-11-06 18:12:42 UTC
README
What It Is
A simple API integration that allows developers to interact with Konnektive CRM's v2 API. All methods are implemented and fully validated as of September 24, 2018
Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
Why Use This
When processing transactions and customer data through offers, marketers can benefit substantially from the use of a well tested and consistent 3rd party API integration.
Installation
Use composer require it-pirs/konnektive-api
or add it manually to composer.json
(See latest version in badges).
Getting Started
Konnektive
crm integration can be implemented easily by simply filling up one of the request classes and handing it off to the dispatcher for processing like so:
use Konnektive\Dispatcher; class OfferProcessor { public function addCustomerNote(){ $dispatcher = new Dispatcher(); /** * @var $request \Konnektive\Request\Customer\AddCustomerNoteRequest; */ $request = new AddCustomerNoteRequest(); $request->loginId = "SomeValidStringForID"; $request->password = "SomeValidPassword"; $request->customerId = "123123"; $request->message = "TestMessage"; /** * @var $response \Konnektive\Response\Response; */ $response = $dispatcher->handle($request); if($response->isSuccessful()){ //Do the thing. } } }
Note: Custom handlers can be created and passed to Dispatcher during construction.
Custom Handlers
If you would like to use a custom handler for the dispatch of your request, you can create a new Handler class that implements the IHandler interface:
use Konnektive\Contracts\IHandler; class CustomHandler implements IHandler { /** * @var $request \Konnektive\Request\Request * @return \Konnektive\Response\Response */ public function handle(Request $request){ //Handle that request return new Response(/* Some response data from cUrl */); } }
The new CustomHandler
can be passed into the dispatcher at construction or later:
$dispatcher = new Dispatcher(new CustomHandler()); //// $dispatcher->setHandler(new CustomHandler());
Validation
All requests will be validated prior to executing the handler. All validation failures are provided through the \Illuminate\Validation\ValidationException
. These exceptions are not caught and must be handled in your own code! Validation can also be done prior to dispatch by calling validate()
on the request object:
/** * @var $request \Konnektive\Request\Customer\AddCustomerNoteRequest; */ $request = new AddCustomerNoteRequest(); $request->loginId = "SomeValidStringForID"; $request->message = "TestMessage"; try { $request->validate(); } catch(ValidationException $ex){ //Fails for customerId and password }
Requirements
- PHP 7.0+