定制 1337erik/zoho-laravel-api 二次开发

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

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

1337erik/zoho-laravel-api

Composer 安装命令:

composer require 1337erik/zoho-laravel-api

包简介

Fork from Asciisd's Laravel Zoho API V3 Package, need to take over maintaining and improving this for my own personal purposes. Feel free to use and contribute, this is my first time doing something like this.

README 文档

README

Latest Version on Packagist GitHub Code Style Action Status Total Downloads

This package used to integrate with the new Zoho V3 Api CRM

Requirements

  • PHP >= 8.0
  • Laravel >= 8.0

Registering a Zoho Client

Since Zoho CRM APIs are authenticated with OAuth2 standards, you should register your client app with Zoho. To register your app:

  1. Visit this page https://api-console.zoho.com/
  2. Click on ADD CLIENT.
  3. Choose a Self Client.
  4. Enter Scope: aaaserver.profile.READ,ZohoCRM.modules.ALL,ZohoCRM.settings.ALL.
  5. Create grant token by providing the necessary scopes, time duration (the duration for which the generated token is valid) and Scope Description.
  6. Your Client app would have been created and displayed by now.
  7. Select the created OAuth client.

Installation

You can install the package via composer require:

composer require asciisd/zoho-v3

You'll need to add the following variables to your .env file. Use the credentials previously obtained registering your application.

ZOHO_CLIENT_ID="Code from Client Secrit Section"
ZOHO_CLIENT_SECRET="Code from Client Secrit Section"
ZOHO_REDIRECT_URI=https://APP_URL/zoho/oauth2callback
ZOHO_CURRENT_USER_EMAIL=admin@example.com
ZOHO_TOKEN="Code Generated from last step"

# available datacenters (USDataCenter, EUDataCenter, INDataCenter, CNDataCenter, AUDataCenter)
ZOHO_DATACENTER=USDataCenter
ZOHO_SANDBOX=true

You can publish the config file with:

php artisan vendor:publish --tag="zoho-v3-config"

You can publish and run the migrations with:

php artisan vendor:publish --tag="zoho-v3-migrations"
php artisan migrate

Environments

maybe in some cases you wish to enforce zoho to use one of zoho's environments, so you can go to AppServiceProvider and use Zoho::useEnvironment() method

Zoho::useEnvironment(EUDataCenter::DEVELOPER());

So that will override config settings.

Usage

Imagine that you need to get all modules from Zoho system.

use Asciisd\Zoho\ZohoManager;

$response = ZohoManager::make(self::TESTING_MODULE);
$modules  = $response->getAllModules();

Model Can be used like this:-

Available only starting from v1.1.0

add Zohoable as extended class like this:-

use Asciisd\Zoho\Zohoable;
use Asciisd\Zoho\ZohoManager;

class Invoice extends Zohoable {
    
    // this is your Zoho module API Name
    protected $zoho_module_name = 'Payments';

    public function searchCriteria(){
        // you should return string of criteria that you want to find current record in crm with.
        //EX:
        return ZohoManager::make('Payments')
                            ->where('PaymentID', $this->payment_id)
                            ->andWhere('Order_ID', $this->order_id)
                            ->getCriteria();
    }

    public function zohoMandatoryFields() {
        // you should return array of mandatory fields to create module from this model
        // EX:
        return ['Base_Currency' => $this->currency];
    }
}

so now you can use invoice like this

$invoice = \App\Invoice::find(1);

// to check if has zoho id stored on local database or not
$invoice->hasZohoId();

// to return the stored zoho id
$invoice->zohoId();

// that will search on zoho with provided criteria to find the record and associated your model with returned id if exist
// if you provided an `id` that will be used instead of searching on Zoho
$invoice->createOrUpdateZohoId($id = null);

// you can also send current model to zoho
// that wil use `zohoMandatoryFields` method to Serialize model to zohoObject
// Also you can pass additional fields as array to this method
$invoice->createAsZohoable($options = []);

Note: To use the Invoice like this, you must have the invoices table in your database just like you would for any Laravel model. This allows you to save data to the database and also be able to link it to the zohos table and use all the functions in Zohoable. Use the CRUD functions below if you do not intend to use the Zohoable model this way.

CRUD Can be used like this:-

READ

use Asciisd\Zoho\ZohoManager;

// we can now deal with leads module
$leads = ZohoManager::useModule('Leads');

// OR

$leads = ZohoManager::make('Leads');

// find record by its ID
$lead = $leads->getRecord('3582074000002383003');

UPDATE

$record = new Record();
$record->setId('3582074000002383003');

// Set value as field
$record->addFieldValue(Leads::FirstName(), 'Updated');
$record->addFieldValue(Leads::LastName(), 'Record');

// Set value as key value
$lead->setKeyValue('Phone', '5555555555552');

// Then call update() method
$response = $leads->update($record);

CREATE

// create the record into zoho crm then get the created instance data
$response = $leads->create([
    'First_Name' => 'Amr',
    'Last_Name' => 'Emad',
    'Email' => 'test@asciisd.com',
    'Phone' => '012345678910',
]);

DELETE

// delete record by its id
$lead = $leads->delete('3582074000002383003');

SEARCH

Word
use Asciisd\Zoho\ZohoManager;

$records = ZohoManager::useModule('Leads')->searchRecordsByWord('word to be searched');
$first_record = $records[0];
Phone
use Asciisd\Zoho\ZohoManager;

$records = ZohoManager::useModule('Leads')->searchRecordsByPhone('12345678910');
$first_record = $records[0];
Email
use Asciisd\Zoho\ZohoManager;

$records = ZohoManager::make('Leads')->searchRecordsByEmail('nobody@asciisd.com');
$first_record = $records[0];
Criteria
use Asciisd\Zoho\ZohoManager;

$records = ZohoManager::make('Leads')->searchRecordsByCriteria('(City:equals:NY) and (State:equals:Alden)')->get();
$first_record = $records[0];
Custom
use Asciisd\Zoho\ZohoManager;

$records = ZohoManager::make('Leads')
                    ->where('City', 'NY')
                    ->andWhere('State','Alden')
                    ->get();

$first_record = $records[0];

International Versions

If you're using zoho.com, you don't have to change anything.

If you're using zoho.eu, add to .env:

ZOHO_ACCOUNTS_URL=https://accounts.zoho.eu
ZOHO_API_BASE_URL=www.zohoapis.eu

If you're using zoho.com.cn, add to .env:

ZOHO_ACCOUNTS_URL=https://accounts.zoho.com.cn
ZOHO_API_BASE_URL=www.zohoapis.com.cn

Support

Contact:
asciisd.com
aemad@asciisd.com
+2-010-1144-1444

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

1337erik/zoho-laravel-api 适用场景与选型建议

1337erik/zoho-laravel-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 52 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 02 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 1337erik/zoho-laravel-api 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 20
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-26