engaging-io/hubspot-manager 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

engaging-io/hubspot-manager

Composer 安装命令:

composer require engaging-io/hubspot-manager

包简介

A Laravel package to manage HubSpot API interactions with rollback capabilities.

README 文档

README

Total Downloads Latest Stable Version License

About HubSpot Manager

A Laravel package to manage HubSpot API interactions with rollback capabilities.

Setup

Installation

composer require engaging-io/hubspot-manager

Add this to your `.env` file
HUBSPOT_API_KEY=<HubSpot Private App Access Token>

Usage

<?php

use EngagingIo\HubSpotManager\HubSpotManager;
use HubSpot\Client\Crm\Deals\Model\SimplePublicObjectInput;

$hubSpotManager = new HubSpotManager;

$properties1 = [
    'property_date' => '1572480000000',
    'property_radio' => 'option_1',
    'property_number' => '17',
    'property_string' => 'value',
    'property_checkbox' => 'false',
    'property_dropdown' => 'choice_b',
    'property_multiple_checkboxes' => 'chocolate;strawberry'
];

$simplePublicObjectInput = new SimplePublicObjectInput([
    'properties' => $properties1,
]);

try {
    // Call the updateDeal method on the HubSpotManager instance.
    // This method sends a request to the HubSpot API to update a deal with the given ID.
    // The second parameter, $simplePublicObjectInput, contains the new data for the deal.
    // The method returns an API response which contains the updated deal data or an error message.
    $apiResponse = $hubSpotManager->updateDeal('dealId', $simplePublicObjectInput);

    var_dump($apiResponse);
} catch (\Exception $e) {
    // Rollback any changes made during the process.
    // This method is called when an exception occurs during the process.
    // It ensures that the state of the system is consistent by undoing any changes that were made.
    $hubSpotManager->rollback();

    throw $e;
}

This example creates a HubSpot company and a contact object. If an exception occurs during the process, it calls the rollback method on the HubSpotManager instance and rollback any changes made to HubSpot objects.

<?php

namespace App\Http\Controllers;

use EngagingIo\HubSpotManager\HubSpotManager;
use HubSpot\Client\Crm\Companies\Model\AssociationSpec as CompanyAssociationSpec;
use HubSpot\Client\Crm\Companies\Model\PublicAssociationsForObject as CompanyPublicAssociationsForObject;
use HubSpot\Client\Crm\Companies\Model\PublicObjectId as CompanyPublicObjectId;
use HubSpot\Client\Crm\Companies\Model\SimplePublicObjectInputForCreate as CompanySimplePublicObjectInputForCreate;

use HubSpot\Client\Crm\Contacts\Model\AssociationSpec as ContactAssociationSpec;
use HubSpot\Client\Crm\Contacts\Model\PublicAssociationsForObject as ContactPublicAssociationsForObject;
use HubSpot\Client\Crm\Contacts\Model\PublicObjectId as ContactPublicObjectId;
use HubSpot\Client\Crm\Contacts\Model\SimplePublicObjectInputForCreate as ContactSimplePublicObjectInputForCreate;

class SampleController extends Controller
{
    private $hubSpotManager;

    /**
     * Construct a new instance of IndexController.
     *
     * This constructor method injects a HubSpotManager instance into the controller.
     * The HubSpotManager instance is used to interact with the HubSpot API.
     *
     * @param HubSpotManager $hubSpotManager An instance of HubSpotManager.
     */
    public function __construct(HubSpotManager $hubSpotManager)
    {
        $this->hubSpotManager = $hubSpotManager;
    }

    /**
     * Handle the incoming request.
     *
     * This method creates a HubSpot company and a contact object.
     * It first creates an association specification and a public object ID for the company,
     * then it creates a simple public object input for the company with the association and properties.
     * It then calls the createCompany method on the HubSpotManager instance with the simple public object input.
     * It repeats the same process for the contact object.
     * If an exception occurs during the process, it calls the rollback method on the HubSpotManager instance.
     * If the process is successful, it returns a JSON response with a message.
     *
     * @throws \Exception If an error occurs during the process.
     * @return \Illuminate\Http\JsonResponse A JSON response with a message.
     */
    public function __invoke()
    {
        try {
            $associationSpec1 = new CompanyAssociationSpec([
                'association_category' => 'HUBSPOT_DEFINED',
                'association_type_id' => 0
            ]);

            $to1 = new CompanyPublicObjectId([
                'id' => 'string'
            ]);

            $publicAssociationsForObject1 = new CompanyPublicAssociationsForObject([
                'types' => [$associationSpec1],
                'to' => $to1
            ]);

            $properties1 = [
                'additionalProp1' => 'string',
                'additionalProp2' => 'string',
                'additionalProp3' => 'string'
            ];

            $simplePublicObjectInputForCreate = new CompanySimplePublicObjectInputForCreate([
                'associations' => [$publicAssociationsForObject1],
                'properties' => $properties1,
            ]);

            // Create a HubSpot company object
            $this->hubSpotManager->createCompany($simplePublicObjectInputForCreate);

            $associationSpec1 = new ContactAssociationSpec([
                'association_category' => 'HUBSPOT_DEFINED',
                'association_type_id' => 0
            ]);

            $to1 = new ContactPublicObjectId([
                'id' => 'string'
            ]);

            $publicAssociationsForObject1 = new ContactPublicAssociationsForObject([
                'types' => [$associationSpec1],
                'to' => $to1
            ]);

            $properties1 = [
                'additionalProp1' => 'string',
                'additionalProp2' => 'string',
                'additionalProp3' => 'string'
            ];

            $simplePublicObjectInputForCreate = new ContactSimplePublicObjectInputForCreate([
                'associations' => [$publicAssociationsForObject1],
                'properties' => $properties1,
            ]);

            // Create a HubSpot contact object
            $this->hubSpotManager->createContact($simplePublicObjectInputForCreate);

            return response()->json('Hello World!', 200);
        } catch (\Exception $e) {
            // Rollback any changes made to HubSpot objects
            $this->hubSpotManager->rollback();

            throw $e;
        }
    }
}

Security Vulnerabilities

If you discover a security vulnerability within Laravel, please send an e-mail to Danniel Libor via danniel@engaging.io. All security vulnerabilities will be promptly addressed.

License

The HubSpot Manager is open-sourced software licensed under the MIT license.

TODO

  • custom objects
  • batch companies
  • batch contacts
  • batch deals
  • batch custom objects
  • tasks
  • batch tasks
  • notes
  • batch notes
  • associations
  • batch associations
  • better documentation
  • etc.

engaging-io/hubspot-manager 适用场景与选型建议

engaging-io/hubspot-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 06 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 engaging-io/hubspot-manager 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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