定制 ivanwitzke/agendor-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ivanwitzke/agendor-php

Composer 安装命令:

composer require ivanwitzke/agendor-php

包简介

Agendor PHP Library

README 文档

README

#agendor-php #

Code Climate

###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

###Install### Install it using Composer:

composer require ivanwitzke/agendor-php

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

<?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

Ivanwitzke\Agendor\Agendor::setApiKey('YOURTOKEN');

###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.

###The Methods### Requesting all items (paginated)

$page is the page to be returned; $limit is how many items per page;

$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

$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

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

Example:

$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");)

Example:

$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.

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.

Obs: They can also be set as an array.

Updating data

First we find what to update:

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

then we update whatever we need and save

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

Deleting objects

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

Example:

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

It returns true if successful and throws the errors send from the API

ivanwitzke/agendor-php 适用场景与选型建议

ivanwitzke/agendor-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 45 次下载、GitHub Stars 达 4, 最近一次更新时间为 2016 年 06 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「library」 「crm」 「agendor」 「agendor-php」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ivanwitzke/agendor-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ivanwitzke/agendor-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 ivanwitzke/agendor-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 45
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-06-28