closeio-api-wrapper
PHP Wrapper to use the Close.io API
Installation and Configuration
Require via Composer
composer require loopline-systems/closeio-api-wrapper
Usage
// you can optionally pass in close.io api endpoint as init argument (it defaults to 'https://app.close.io/api/v1')
$closeIoConfig = new CloseIoConfig();
$closeIoConfig->setApiKey('yourApiKey');
$closeIoApiWrapper = new CloseIoApiWrapper($closeIoConfig);
$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('testy-testersson@test-company.com');
$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);
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);
Console runner
For testing purposes there is a simple console runner.
bin/console -a <api name> -r <request name> -k <api key> [-d payload as json]
Examples:
bin/console -k your_api_key -r getAllLeads -a LeadApi
bin/console -k your_api_key -r addLead -a LeadApi -d '{...}'
The is output will be displayed on the console as json.
Info
Right now just a few request are implemented, because the main need was to create leads. Feel free to add requests and create pull requests or go on forking the repo.
We use https://github.com/btford/adj-noun for our release names, so don`t worry they have no special meaning :)
Requirements
PHP 5.6.0 or above
Authors
Michael Devery - michaeldevery@gmail.com
Marco Roßdeutscher - marco.rossdeutscher@loopline-systems.com
Marco Roßdeutscher - marc.zahn@loopline-systems.com
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 details
! We are not affiliated with Close.io itself.