2017 © Pedro Peláez
 

library agendor-php

Agendor PHP Library

image

ivanwitzke/agendor-php

Agendor PHP Library

  • Thursday, July 28, 2016
  • by ivanwitzke
  • Repository
  • 1 Watchers
  • 2 Stars
  • 36 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

agendor-php

Code Climate, (*1)

About

This is a php lib to be used with the Agendor API. To use it you will first need an API Token, that can be found here, (*2)

Install

Install it using Composer:, (*3)

composer require ivanwitzke/agendor-php, (*4)

or download the latest zip file and extract to your project folder, then require the agendor-php/Agendor.php file., (*5)

<?php
    require("PATH_TO_PROJECT_FOLDER/agendor-php/Agendor.php");

Then on the controller (where you are going to use it) we set the API Key / Token, (*6)

Ivanwitzke\Agendor\Agendor::setApiKey('YOURTOKEN');, (*7)

The models

The Agendor API supports requests to "People", "Organization", "Task" and "Deal". Each one of those are represented by a Class with the same name on this lib, and have the same properties as defined on the Api docs., (*8)

The Methods

Requesting all items (paginated), (*9)

$page is the page to be returned; $limit is how many items per page;, (*10)

$peopleList = Ivanwitzke\Agendor\People::all($page, $limit);
$orgsList = Ivanwitzke\Agendor\Organization::all($page, $limit);
$dealsList = Ivanwitzke\Agendor\Deal::all($page, $limit);
$tasksList = Ivanwitzke\Agendor\Task::all($page, $limit);

Request one item, (*11)

$person = Ivanwitzke\Agendor\People::findById($peopleId);
$org = Ivanwitzke\Agendor\Organization::findById($organizationId);
$deal = Ivanwitzke\Agendor\Deal::findById($dealId);
$task = Ivanwitzke\Agendor\Task::findById($taskId);

Creating a new item, (*12)

Create a new object instance passing an array with all the info needed and then run $object->create();, (*13)

Example:, (*14)

$personData = array(
    "name" => "Person Name",
    "role" => "Manager",
    "emails" => array(
        "mail1@mail.com",
        "mail2@mail.com"
        "mailN@mail.com"
    ),
    "address" => array(
        "postalCode" => 12345678, // numbers only
        "streetName" => "Example Street",
        "streetNumber" => 9999 // numbers only
    );
);

$person = new Ivanwitzke\Agendor\People($personData);

try {
    $person->create();
} catch (Exception $e) {
    die($e->getMessage());
}

Or use the "set" methods: set + property name camel cased (Ex: $object->setName("Item Name");), (*15)

Example:, (*16)

$person = new Ivanwitzke\Agendor\People();
$person->setName("Person Name");
$person->setCategoryId(123);

$mobilePhone = new Ivanwitzke\Agendor\Object();
$mobilePhone->setType('mobile');
$mobilePhone->setNumber("1198765432");

$workPhone = new Ivanwitzke\Agendor\Object();
$workPhone->setType('work');
$workPhone->setNumber("1198765432");

$person->setPhones(array($mobilePhone, $workPhone));

$address = new Ivanwitzke\Agendor\Object();
$address->setStreetName("Street");
$address->setStreetNumber(999); // Must be number
$address->setCountry("Country");

$person->setAddress($address);

try {
    $person->create();
} catch (Exception $e) {
    die($e->getMessage());
}

If everything goes well, the response will be the object instance, otherwise it will throw the error sent from the API., (*17)

For properties that must be passed as an object to the API (like the Ivanwitzke\Agendor\People->address, there is a generic Ivanwitzke\Agendor\Object class that you can instantiate and use to set its values just like any other of the main classes., (*18)

Obs: They can also be set as an array., (*19)

Updating data, (*20)

First we find what to update:, (*21)

$organization = Ivanwitzke\Agendor\Organization::findById($id);, (*22)

then we update whatever we need and save, (*23)

if ($organization) { // We update only if the item was found
    $organization->setNickname("New nickname");
    $organization->setLegalName("New Legal Name");
    $organization->setEmails(array($newEmail));
    // Address property can be an Array or an Agendor\Object() instance;
    $organization->setAddress(array(
        'postalCode' => $newPostalCode, // numbers only;
        'streetName' => $newStreetName,
        'streetNumber' => $newStreetNumber // Also only numbers;
    ));
    try {
        $organization->save(); // Save the changes
    } catch (Exception $e) {
        return $response->withStatus($e->getCode())->write($e->getMessage());
    }
}

Same as in the create() method, the save() will return the object in case it succeeds to update and throw any error sent from the API, (*24)

Deleting objects, (*25)

Call the Ivanwitzke\Agendor\<Object>::delete($id) method., (*26)

Example:, (*27)

$response = Ivanwitzke\Agendor\Task::delete($taskId);

It returns true if successful and throws the errors send from the API, (*28)

The Versions

28/07 2016

dev-master

9999999-dev https://github.com/ivanwitzke/agendor-php

Agendor PHP Library

  Sources   Download

MIT

The Requires

  • php >5.3
  • ext-curl *
  • ext-json *
  • ext-mbstring *

 

by Avatar ivanwitzke

php library crm agendor agendor-php

23/07 2016

dev-dev

dev-dev https://github.com/ivanwitzke/agendor-php

Agendor PHP Library

  Sources   Download

MIT

The Requires

  • php >5.3
  • ext-curl *
  • ext-json *
  • ext-mbstring *

 

by Avatar ivanwitzke

php library crm agendor agendor-php

23/07 2016

v1.1.5

1.1.5.0 https://github.com/ivanwitzke/agendor-php

Agendor PHP Library

  Sources   Download

MIT

The Requires

  • php >5.3
  • ext-curl *
  • ext-json *
  • ext-mbstring *

 

by Avatar ivanwitzke

php library crm agendor agendor-php

23/07 2016

v1.1.4

1.1.4.0 https://github.com/ivanwitzke/agendor-php

Agendor PHP Library

  Sources   Download

MIT

The Requires

  • php >5.3
  • ext-curl *
  • ext-json *
  • ext-mbstring *

 

by Avatar ivanwitzke

php library crm agendor agendor-php

14/07 2016

v1.1.3

1.1.3.0 https://github.com/ivanwitzke/agendor-php

Agendor PHP Library

  Sources   Download

MIT

The Requires

  • php >5.3
  • ext-curl *
  • ext-json *
  • ext-mbstring *

 

by Avatar ivanwitzke

api

29/06 2016

v1.1.2

1.1.2.0 http://websix.com.br

Agendor PHP Library

  Sources   Download

MIT

The Requires

  • php >5.3
  • ext-curl *
  • ext-json *
  • ext-mbstring *

 

by Avatar websix

api

29/06 2016

v1.1.1

1.1.1.0 http://websix.com.br

Agendor PHP Library

  Sources   Download

MIT

The Requires

  • php >5.3
  • ext-curl *
  • ext-json *
  • ext-mbstring *

 

by Avatar websix

api

28/06 2016

v1.0.0

1.0.0.0 http://websix.com.br

Agendor PHP Library

  Sources   Download

MIT

The Requires

  • php >5.3
  • ext-curl *
  • ext-json *
  • ext-mbstring *

 

by Avatar websix

api