Giter Club home page Giter Club logo

closeio-api-wrapper's Introduction

closeio-api-wrapper

License Build Status Coverage Status

Packagist Packagist Packagist Packagist

The CloseIo API Wrapper is a package that allows you to access in an object oriented way the Close.io REST APIs and fetch or create data.

Installation

To install the library you will need to be using Composer in your project. To install it please see the official docs. CloseIo Api Wrapper uses Httplug to not be tied to any specific library that sends HTTP messages. This means that users are free to choose whichever PSR-7 implementation and HTTP client they want, be it Guzzle or a simple cURL client.

If you just want to get started quickly you should run the following command:

composer require loopline-systems/closeio-api-wrapper php-http/curl-client nyholm/psr7

This will install the library itself along with an HTTP client adapter for Httplug that uses cURL and a PSR-7 implementation needed to create the messages. You do not need to use those packages if you don't want to: you may use any package that provides php-http/async-client-implementation and http-message-implementation.

Usage

To get started you just need to create an instance of the client and then use its method to query the REST APIs of Close.io.

require_once __DIR__ . '/vendor/autoload.php';

use LooplineSystems\CloseIoApiWrapper\Client;
use LooplineSystems\CloseIoApiWrapper\CloseIoApiWrapper;
use LooplineSystems\CloseIoApiWrapper\Configuration;

$configuration = new Configuration('{api-key}');
$client = new Client($configuration);
$closeIoApiWrapper = new CloseIoApiWrapper($client);

$leadsApi = $closeIoApiWrapper->getLeadApi();

// create lead
$lead = new Lead();
$lead->setName('Test Company');
$lead->setDescription('Company description');
$lead->setUrl('www.test-company.com');

// address
$address = new Address();
$address->setCountry('DE');
$address->setCity('Berlin');
$address->setAddress1('Main Street');
$address->setAddress2('Mitte');

// contacts
$contact = new Contact();
$contact->setName('Testy Testersson');
$contact->setTitle('Chief Tester');

// emails
$email = new Email();
$email->setEmail('[email protected]');
$email->setType(Email::EMAIL_TYPE_OFFICE);
$contact->addEmail($email);

// phones
$phone = new Phone();
$phone->setPhone('+491234567890');
$phone->setType(Phone::PHONE_TYPE_MOBILE);
$contact->addPhone($phone);

$lead->addAddress($address);
$lead->addContact($contact);

$response = $leadsApi->addLead($lead);

Adding Opportunities

$opportunity = new Opportunity();
$opportunity->setValue(500);
$opportunity->setNote('My note on this opportunity');
$opportunity->setConfidence(85);
$opportunity->setValuePeriod(Opportunity::OPPORTUNITY_FREQUENCY_MONTHLY);

// you can use the leadApi to get ID for leads
$opportunity->setLeadId(<lead-id>);

$opportunityApi = $this->apiWrapper->getOpportunityApi();
$result = $opportunityApi->addOpportunity($opportunity);

Activities

$activityApi = $this->apiWrapper->getActivityApi();
// SMS
$sms = new SmsActivity();
$sms->setLocalPhone('12345');
$sms->setRemotePhone('23456');
$sms->setText('first sms');
$sms->setStatus(SmsActivity::STATUS_SCHEDULED);

$activityApi->addSms($sms);
// EMails
$email = new EmailActivity();
$email->setStatus(EmailActivity::STATUS_INBOX);
$email->setSubject('RE: Support');
$email->setSender('Support <[email protected]>');
$email->setTo('Customer <[email protected]>');

$activityApi->addEmail($sms);

Updating custom fields

$customField = new CustomField();
$customField->setId('Custom field id')
$customField->addChoice('Value for choices list');

$customFieldApi = $this->apiWrapper->getCustomFieldApi();
$result = $customFieldApi->updateCustomField($customField);

Info

Right now just a few APIs are implemented, because the main need was to create leads. Feel free to add requests and create pull requests or go on forking the repository.

We use https://github.com/btford/adj-noun for our release names, so don't worry they have no special meaning :)

Authors

Michael Devery - [email protected]
Marco Roßdeutscher - [email protected]
Marc Zahn - [email protected]

See also the list of contributors who participated in this project.

License

The Close.io API Wrapper is licensed under the MIT License: see the LICENSE file for more information.

! We are not affiliated with Close.io itself.

closeio-api-wrapper's People

Contributors

mavimo avatar ste93cry avatar marczahn avatar mickadoo avatar dlimars avatar nachitox avatar wridgers avatar albertobarba avatar danbarker avatar daneeveritt avatar enoahnetzach avatar kasparsj avatar rvitaliy avatar wodka avatar filchakov avatar eengoron 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.