GithubHelp home page GithubHelp logo

hubspot-api-php's Introduction

hubspot-api-php

Latest Packagist Version Total Downloads

PHP HubSpot API v3 SDK(Client) files

Installation

composer require hubspot/api-client

Requirements

The current package requirements are:

PHP >= 7.4

Sample apps

Please, take a look at our Sample apps

Quickstart

To instantiate API Client using access token use Factory

$hubspot = \HubSpot\Factory::createWithAccessToken('your-access-token');

You'll need to create a private app to get your access token or you can obtain OAuth2 access token.

To instantiate API Client using developer apikey use Factory

$hubspot = \HubSpot\Factory::createWithDeveloperApiKey('your-developer-apikey');

also you can pass custom client to Factory

$client = new \GuzzleHttp\Client([...]);

$hubspot = \HubSpot\Factory::createWithAccessToken('your-access-token', $client);

To change the base path

$config = new \GuzzleHttp\Config();
$config->setBasePath('*');
$config->setAccessToken('*');
$config->setDeveloperApiKey('*');

$hubspot = \HubSpot\Factory::create(null, $config);

API Client comes with Middleware for implementation of Rate and Concurrent Limiting

It provides an ability to turn on retry for failed requests with statuses 429 or 500. Please note that Apps using OAuth are only subject to a limit of 100 requests every 10 seconds.

$handlerStack = \GuzzleHttp\HandlerStack::create();
$handlerStack->push(
    \HubSpot\RetryMiddlewareFactory::createRateLimitMiddleware(
        \HubSpot\Delay::getConstantDelayFunction()
    )
);

$handlerStack->push(
    \HubSpot\RetryMiddlewareFactory::createInternalErrorsMiddleware(
        \HubSpot\Delay::getExponentialDelayFunction(2)
    )
);

$client = new \GuzzleHttp\Client(['handler' => $handlerStack]);

$hubspot = \HubSpot\Factory::createWithAccessToken('your-access-token', $client);

Get contacts page

$response = $hubspot->crm()->contacts()->basicApi()->getPage();

Get contact by email

$contact = $hubSpot->crm()->contacts()->basicApi()->getById('[email protected]', null, null, null, false, 'email');

Search for a contact

$filter = new \HubSpot\Client\Crm\Contacts\Model\Filter();
$filter
    ->setOperator('EQ')
    ->setPropertyName('email')
    ->setValue($search);

$filterGroup = new \HubSpot\Client\Crm\Contacts\Model\FilterGroup();
$filterGroup->setFilters([$filter]);

$searchRequest = new \HubSpot\Client\Crm\Contacts\Model\PublicObjectSearchRequest();
$searchRequest->setFilterGroups([$filterGroup]);

// Get specific properties
$searchRequest->setProperties(['firstname', 'lastname', 'date_of_birth', 'email']);

// @var CollectionResponseWithTotalSimplePublicObject $contactsPage
$contactsPage = $hubspot->crm()->contacts()->searchApi()->doSearch($searchRequest);

Create a contact

$contactInput = new \HubSpot\Client\Crm\Contacts\Model\SimplePublicObjectInput();
$contactInput->setProperties([
    'email' => '[email protected]'
]);

$contact = $hubspot->crm()->contacts()->basicApi()->create($contactInput);

Update a contact

$newProperties = new \HubSpot\Client\Crm\Contacts\Model\SimplePublicObjectInput();
$newProperties->setProperties([
    'email' => '[email protected]'
]);

$hubspot->crm()->contacts()->basicApi()->update($contactId, $newProperties);

Archive a contact

$hubspot->crm()->contacts()->basicApi()->archive($contactId);

Get custom objects page

$hubspot->crm()->objects()->basicApi()->getPage(HubSpot\Crm\ObjectType::CONTACTS)

File uploading

$file = new \SplFileObject('file path');
$response = $hubspot->files()->filesApi()->upload($file, null, '/', null, null, json_encode([
    'access' => 'PRIVATE',
    'ttl' => 'P2W',
    'overwrite' => false,
    'duplicateValidationStrategy' => 'NONE',
    'duplicateValidationScope' => 'EXACT_FOLDER'
]) );

Not wrapped endpoint(s)

It is possible to access the hubspot request method directly, it could be handy if client doesn't have implementation for some endpoint yet. Exposed request method benefits by having all configured client params.

$response = $hubspot->apiRequest([
    'method' => 'PUT',
    'path' => '/some/api/not/wrapped/yet',
    'body' => ['key' => 'value'],
]);

apiRequest options

[
    'method' => string, // Http method (e.g.: GET, POST, etc). Default value GET
    'path' => string, // URL path (e.g.: '/crm/v3/objects/contacts'). Optional
    'headers' => array, // Http headers. Optional.
    'body' => mixed, // Request body (if defaultJson set body will be transforted to json string).Optional.
    'authType' => enum(none, accessToken, hapikey, developerApiKey), // Auth type. if it isn't set it will use accessToken or hapikey. Default value is non empty auth type.
    'baseUrl' => string, // Base URL. Default value 'https://api.hubapi.com'.
    'qs' => array, // Query parameters. Optional.
    'defaultJson' => bool, // Default Json. if it is set to true it add to headers [ 'Content-Type' => 'application/json', 'Accept' => 'application/json, */*;q=0.8',]
    // and transfort body to json string. Default value true
];

get contacts

$response = $hubspot->apiRequest([
    'path' => '/crm/v3/objects/contacts',
]);

Contributing

Run spec tests

vendor/bin/phpspec run

Run unit tests

vendor/bin/phpunit ./tests

hubspot-api-php's People

Contributors

arthurguy avatar asilverstein avatar atanasiuk-hubspot avatar d3v1 avatar dependabot[bot] avatar juliennoksi avatar ksvirkou-hubspot avatar mattdfloyd avatar pimpeters avatar rattone avatar rossjcooper avatar ryross avatar taras-by avatar tiffany-taylor avatar yfaktor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hubspot-api-php's Issues

How To Get Next Page of the Deals That Have More Than 100?

I found there are models call Paging, NextPage, PreviousPage but how can we use them?

I can get the deal results with the below but I need to get the rest, after the 100th record.

$response = $hubSpot->crm()->deals()->searchApi()->doSearch($searchRequest);

Kindly advice.

contacts update not working

Hi, on free environnement, i cant update a contact. Could you help?

    public function updateContactsByBatch(array $employees): void
    {
        $contactInputs = new BatchInputSimplePublicObjectBatchInput([
            'inputs' => array_map([$this, 'createContactParametersWithId'], $employees),
        ]);

        $response = $this->client->crm()->contacts()->batchApi()->update($contactInputs);
    }

where $contactInputs is:

HubSpot\Client\Crm\Contacts\Model\BatchInputSimplePublicObjectBatchInput^ {#716
  #container: array:1 [
    "inputs" => array:1 [
      0 => array:2 [
        "id" => "9828"
        0 => HubSpot\Client\Crm\Contacts\Model\SimplePublicObjectInput^ {#1899
          #container: array:1 [
            "properties" => array:1 [
              "lastname" => "lol"
            ]
          ]
        }
      ]
    ]
  ]
}

hubspot response is:

HubSpot\Client\Crm\Contacts\Model\BatchResponseSimplePublicObject^ {#1865
  #container: array:6 [
    "status" => "COMPLETE"
    "results" => array:1 [
      0 => HubSpot\Client\Crm\Contacts\Model\SimplePublicObject^ {#1876
        #container: array:7 [
          "id" => "9828"
          "properties" => []
          "properties_with_history" => null
          "created_at" => DateTime @1647518288 {#1977
            date: 2022-03-17 11:58:08.914 +00:00
          }
          "updated_at" => DateTime @1647518299 {#1974
            date: 2022-03-17 11:58:19.474 +00:00
          }
          "archived" => false
          "archived_at" => null
        ]
      }
    ]
    "requested_at" => null
    "started_at" => DateTime @1647519900 {#1975
      date: 2022-03-17 12:25:00.304 +00:00
    }
    "completed_at" => DateTime @1647519900 {#1881
      date: 2022-03-17 12:25:00.348 +00:00
    }
    "links" => null
  ]
}

am i doing something wrong?

Get Properties from the Associations - php

How to get the properties from the associations? The results only return id and type, where I need the full properties of the type. For example, contacts, how to return email, firstname, lastname and etc as associations?

I tried below and managed to get associationsApi() but then cannot get().
$hubSpot = Factory::createWithApiKey($apiKey);
$response = $hubSpot->crm()->deals()->associationsApi();

also possible to get the deals from a selected pipeline?

Experiencing Slow Speed While Getting Associated Contacts from the Deals

Hi! I'm experiencing a very slow speed while I'm getting the set of associated contacts or companies from the deals. Below is the line.
$result = $hubSpot->crm()->deals()->associationsApi()->getAll($dealId, "contacts");

I loop a set of deals by passing in each $dealId to the Associations API, and I also tried to get from just one deal also very slow.

Kindly advise how to make it faster or any alternative API I could use as I would have more than 100 deals to check with. :)

Thank you!

How to set a PublicAssociationMulti

I need to associate many contacts to a deal but i could not find a way how to do it. Can anyone put an example here? it would be nice also if you could update the README.md with an example

Make the library more developer friendly

This Friday, 2020-07-10, I started to use the library and after two hours I just stopped and started to use the old library again. The problem I had was I couldn't figure out to get a batch of contacts by email.

The next day I decided to create a more user friendly library. And I discovered poor design choices in the generator code.
So what i did was to create a CMS class instead of a Factory that returns an instance of the Discovery class, https://github.com/xwero/hubspot-api-php/blob/master/lib/CMS.php. Adding an api key or an access token is two lines of code why would you want to hide that in a Factory class?
The same thing with the http client, you use a plain Guzzle client instance, and if middleware is needed the developer can add it. Why won't you expose that from the start?
Why should we have to type $hubspot->cms()->auditLogs()->defaultApi()->getPage(); when you can remove the discovery and type $cms->getAuditLogs($options) . The discovery system exposes too much of the file structure, what it you want to change that?

Next thing I noticed that different endpoint groups have a DefaultApi class. And in those classes there is the getPage method, which allows the developer to get a range of data. Naming is an important developer task because it's the way you communicate with other developers. In my CMS class the getPage methods are named getAuditLogs, getDomains, getPerformances, getRedirects.
I was thinking about making the getPage method wrappers nullable, ´function getAuditLogs(?AuditLogOptions)´ but it is going to be very rare that you want the default data from an endpoint. So $hubspot->cms()->auditLogs()->defaultApi()->getPage(); is not going to be seen in many codebases except for examples.

In the getPage method the generator calls the getPageWithHttpInfo method, in the getPageWithHttpInfo method the generator calls the getPageRequest method. Why are they all public? How many times are developers going to use the getPageWithHttpInfo and getPageRequest methods?

The getPage methods all have too many parameters. I understand that the endpoint has that many options but use a DTO to pass on all those parameters, it is more developer friendly because you don't have to count parameters to get the correct one (https://github.com/xwero/hubspot-api-php/blob/master/lib/PerformanceOptions.php). It also allows you to add convenience methods for static input values. I used class variable type hinting because I was lazy, so the DTO can only be used from php 7.4 on. But if you want to support older php versions you can use setters to type hint the values.

I read the documentation in the classes and in some classes you have to use a timestamp, and in other classes you can add a DateTime instance for dates. Wouldn't it be better that a date is always added as a DateTime instance, or even better a DateTimeImmutable instance? Let the library code pass on the correct date format to the endpoint. Consistency makes a library more developer friendly.

It took me a few hours and a bit of thinking to make the CMS endpoints easier to use. I understand the decision to go with the code generator, you can build libraries with minimal effort for many languages. But if there are so many quirks people will start writing wrappers of just ignore the library all together for a better option.

retrieve the response headers for crm()->contacts()->searchApi()->doSearch

Hi,

In https://github.com/HubSpot/hubspot-api-php/blob/master/codegen/Crm/Contacts/Api/SearchApi.php#L129
I've noticed that the $response->getHeaders() is passed as result of doSearchWithHttpInfo function

            switch($statusCode) {
                case 200:
                    if ('\HubSpot\Client\Crm\Contacts\Model\CollectionResponseWithTotalSimplePublicObjectForwardPaging' === '\SplFileObject') {
                        $content = $response->getBody(); //stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                    }

                    return [
                        ObjectSerializer::deserialize($content, '\HubSpot\Client\Crm\Contacts\Model\CollectionResponseWithTotalSimplePublicObjectForwardPaging', []),
                        $response->getStatusCode(),
                        $response->getHeaders()
                    ];

but when it is being returned in https://github.com/HubSpot/hubspot-api-php/blob/master/codegen/Crm/Contacts/Api/SearchApi.php#L127-L130
the list only returns the CollectionResponseWithTotalSimplePublicObjectForwardPaging

What if I wanted to get it return the values returned by $response->getHeaders() as well?

Thanks in advance.

Marketing API: Forms support

Hey, I'm basically looking for this client's equivalent of the v2 API client's form retrieval. In the v2 API client, I suppose it would be something like this:

$form = $hubspot->forms()->geById(MY_FORM_ID);

This v3 API client implementation does not seem to support forms (yet?), i. e. there is no abstraction here for a v3 API call like this:

curl --request GET \
  --url 'https://api.hubapi.com/marketing/v3/forms/formId?hapikey=YOUR_HUBSPOT_API_KEY'

Is that correct or am I just looking in the wrong place?

Possibility to get the original result (response)

Hi folks,

do you plan to give the users an option to decide to return raw data instead of objects? As much as I like the client taking care of creating objects, in my use case I create custom object structures anyway and don't want to have the result as an object, convert it to raw data (getProperties()) and then unserialize into my object structure again.

It would be great to have an extra method (like all the async methods) that directly return the response and don't process it any further.

What do you think about that?

Webhook Subscription Duplicate App ID

On the Subscriptions API Client, I can see that on most endpoints you must provide a appId and a appId2 property. Could you please explain why this is required? What is the purpose of appId2?

I can see the change was introduced as of 5.1.0 but there didn't appear to be a mention about this change within your release notes.

5.0.0 - https://github.com/HubSpot/hubspot-api-php/blob/5.0.0/codegen/Webhooks/Api/SubscriptionsApi.php#L388
5.1.0 - https://github.com/HubSpot/hubspot-api-php/blob/5.1.0/codegen/Webhooks/Api/SubscriptionsApi.php#L398

I can see on all requests, that appId is ignored if appId2 is provided, which will always be replaced since the code type-hint indicates that you must provide both.

Reference: https://github.com/HubSpot/hubspot-api-php/blob/master/codegen/Webhooks/Api/SubscriptionsApi.php#L316

Could this be an error in your specification file, so when the code is auto-generated it's producing this confusing code smell?

Associations v4

Hi,
how about adding association v4 support? I know that this is beta, so likely on a branch. We are currently implementing this and would be cool not to reinvent the wheel.

regards
Alex

Company Default properties and address is missing

Why are default properties missing from the company object?

HubSpot\\Client\\Crm\\Companies\\Model\\SimplePublicObject::__set_state(array(\n 'container' => \n array (\n 'id' => '6069095424',\n 'properties' => \n array (\n 'createdate' => '2021-05-13T18:31:59.188Z',\n 'domain' => 'brewbench.co',\n 'hs_lastmodifieddate' => '2021-05-25T03:42:18.135Z',\n 'hs_object_id' => '6069095424',\n 'name' => 'BrewBench',\n ),\n 'created_at' => \n DateTime::__set_state(array(\n 'date' => '2021-05-13 18:31:59.188000',\n 'timezone_type' => 2,\n 'timezone' => 'Z',\n )),\n 'updated_at' => \n DateTime::__set_state(array(\n 'date' => '2021-05-25 03:42:18.135000',\n 'timezone_type' => 2,\n 'timezone' => 'Z',\n )),\n 'associations' => NULL,\n 'archived' => false,\n 'archived_at' => NULL,\n ),\n))

How to set the BatchInputPublicObjectId for Associations

I am trying to send with postman the correct request for calling the Batch API Read for Associations, here is my code:

$associationRequest = new \HubSpot\Client\Crm\Associations\Model\BatchInputPublicObjectId();
  $id = new \HubSpot\Client\Crm\Associations\Model\PublicObjectId;
  $associationRequest->setInputs($id->setId("4324519850"));
  $associationsObj = $hubspot->crm()->associations()->batchApi()->read("deals", "line_items", $associationRequest)->getResults();

And in Postman I am sending a POST request with x-www-form-urlencoded request with id:4324519850 (the id of the deal)

But I get an error:
resulted in a400 Bad Requestresponse:\n{\"status\":\"error\",\"message\":\"Invalid input JSON on line 1, column 11: Cannot deserialize instance ofjava.util.ArrayLis (truncated...)\n"`

Any thoughts?

Crm/Contacts/Api/BasicApi.php:getById Doesn't work as described when passed an array

This method only returns the provided fields when passed a CSV list of items (no space between commas).

Also the docblock describes how the parameters takes string[], but it also just takes string and as such needs updating.

* @param string|string[] $properties A comma separated list of the properties to be returned in the response. If any of the specified properties are not present on the requested object(s), they will be ignored. (optional)

DateTime format API error

Hi,

I'm trying to create a deal using the batch deals API, but I get an error about an invalid datetime format.

Here is my example:

public function createBatchDealsFromOrder(Order $order)
    {
        $deals = [];

        foreach ($order->getOrderItems() as $orderItem) {
            $deals[] = ['properties' => [
                 "amount" => $orderItem->getPrice(),
                 "closedate" => (clone $order->getPaidAt())
                         ->setTimezone(new \DateTime('UTC'))
                         ->format('Y-m-d\TH:i:s\Z'),
                 "dealname" => $orderItem->getName(),
                 "pipeline" => "default",
            ]];
        }

        $batchInputSimplePublicObjectInput = new \HubSpot\Client\Crm\Deals\Model\BatchInputSimplePublicObjectInput(['inputs' => $deals]);

        $response = $this->hubspot->crm()->deals()->batchApi()->create($batchInputSimplePublicObjectInput);
    }

I try to set the timezone for UTC as mentioned but the documentation, and format the string with Zulu time but I get this API error:

{
  "status": "error",
  "message": "Property values were not valid: [{\"isValid\":false,\"message\":\"1635535865 is at 22:18:55.865 UTC, not midnight!\",\"error\":\"INVALID_DATE\",\"name\":\"closedate\"}]",
  "correlationId": "d05f36c6-2052-453c-bd83-7813a009c43d",
  "category": "VALIDATION_ERROR"
}

I tried to modify the datetime by adding a ->modify('midnight'); but still got the same error.
I also tryed do send only timestamps but it didn't work either.

Do you have any ideas ?

Thank you :)

createTableRow() returns protected object

When calling Cms()->Hubdb()->rowsApi()->createTableRow(), the response from HubSpot (containing the created row ID etc), is returned as a HubDbTableRowV3 object, which is a protected container and can't be parsed. First time I've had this with a method and can't see any other methods to call instead.

How to enroll contact in a workflow

Is it possible to enroll a contact in a workflow using this library? If so, how? If no, what is the recommended way to do this via a HubSpot supported PHP SDK/library?

I am seeing this in the documentation, but I am not seeing any mention to workflows in this repository. However, I am seeing it in the hubspot-php repo here:
https://github.com/HubSpot/hubspot-php/blob/84481770034bff0c0aed7865ec91d0a39dcd5e94/src/Resources/Workflows.php#L55
The HubSpot documentation references this (hubspot-api-php) repo as the SDK for PHP, so I am not sure how the hubspot-php repo relates.

How to create object instance?

How is it possible to send request like POST https://api.hubapi.com/crm/v3/objects/object_name?portalId=PORTAL_ID&hapikey=HUBSPOT_API_KEY, In particular how to set portalId?

So far I found only one method $hubspot->crm()->objects()->basicApi()->create('object_name', $input);, but it is not clear about portalId parameter.

Possible nullables in object chains contradict the idea of fluent interfaces

Hi folks,

I am using your new client to fetch data and in theory it's great to be able to chain all the calls, such as the following.

/** @var \HubSpot\Client\Crm\Contacts\Model\CollectionResponseAssociatedId $deals */
$deals->getPaging()->getNext()

* @return \HubSpot\Client\Crm\Contacts\Model\Paging|null

Method getPaging() possibly returns null, which contradicts the idea of fluent interfaces. If you worked with NullObjects e.g. instead, it would make much more sense but this way I have to type check all the method results before knowing if I can actually chain them without causing a NullPointerException.

Is there anything planned to make the client more type safe?

json data sample object need

HubSpot\Client\Crm\Contacts\ApiException: [400] Client error: POST https://api.hubapi.com/crm/v3/objects/contacts?hapikey=1f430c92-a780-4a35-a7a0-f0546f8ebbcc resulted in a 400 Bad Request response:
{"status":"error","message":"Invalid input JSON on line 1, column 15: Cannot construct instance of `java.util.LinkedHash (truncated...)


$contactInput = new \HubSpot\Client\Crm\Contacts\Model\SimplePublicObjectInput();
$contactInput->setProperties($_POST);

$contact = $hubSpot->crm()->contacts()->basicApi()->create($contactInput);

Investigate if it should make more methods private

In the getPage method the generator calls the getPageWithHttpInfo method, in the getPageWithHttpInfo method the generator calls the getPageRequest method. Why are they all public? How many times are developers going to use the getPageWithHttpInfo and getPageRequest methods?

cc @xwero

crm()->companies()->getAll() fails with message "Unable to infer object type from: false"

I started working with the Hubspot API client for PHP and ran into an issue that looks like a bug to me.

I'm trying to get a list of all companies using the crm()->companies()->getAll() Method. Doing this I get the following message from the API.

  [HubSpot\Client\Crm\Companies\ApiException (400)]                                                                                                                
  [400] Client error: `GET https://api.hubapi.com/crm/v3/objects/companies?limit=100&associations=false&archived=false` resulted in a `400 Bad Request` response:  
  {"status":"error","message":"Unable to infer object type from: false","correlationId":.....................

Looking exactly at the error message you can see that the associactions parameter is set to false.

I think this happens because HubSpot\Discovery\Crm\ObjectDiscovery::getAll() calls the getPage(...) method with $archived as fifth property. In HubSpot\Client\Crm\Companies\Api\BasicApi::getPage(...) it is the sixth property though.

The fifth property in the BasicApi class is $associations. This is why in the API call sets this parameter to false.

Custom Objects

As custom objects have been released, the library should be updated to reflect the new endpoints

Search API delay after insert

After inserting a new contact using \HubSpot\Client\Crm\Contacts\Model\SimplePublicObjectInput (I assume this happens with companies, deals etc too) and then immediately afterwards searching for said contact using \HubSpot\Client\Crm\Contacts\Model\PublicObjectSearchRequest it does not return any contact.

If you wait for an arbitrary amount of time and then search it does return a contact.

This is clearly a bug no? How can we get around it? We're importing thousands of contacts and sometimes the same contact shows up in the list twice, preventing our import script from running. This wouldn't be an issue if we were only importing contacts but in the same script we create companies and deals too, and if the same contact shows up twice no deal is created.

Another, much better solution imo, would be to have a "create or update" endpoint. That way we wouldn't even need to check if the contact exists first and could cut our code with like 75%.

It's a bad design to make an API can throw exception and also return error

We have to write code like this

try {
  $contact = $hubSpot->crm()->contacts()->basicApi()->create($contactInput);

  if ($contact instanceof \HubSpot\Client\Crm\Contacts\Model\Error) {
    // error handling
  }
} catch (ApiException $e) {
  // exception handling
}

I think it should convert \HubSpot\Client\Crm\Contacts\Model\Error to a ModelException so the code will be

try {
  $contact = $hubSpot->crm()->contacts()->basicApi()->create($contactInput);
} catch (ApiException $e) {
  // exception handling
} catch (ModelException $e) {
  // exception handling
}

No way to update a contact by email

HubSpot\Client\Crm\Contacts\Api\BasicApi::update($contact_id, $simple_public_object_input) corresponds to the PATCH /crm/v3/objects/contacts/{contactId} endpoint of the API. However, the API allows you to update a contact by email by setting idProperty in the query params to email, such as this:

PATCH /crm/v3/objects/contacts/[email protected]?idProperty=email

While the php library offers no such convenience. We do not store the hubspot contact id in our database, but we need to keep hubspot updated of changes on our side using email as the identifier. What approach do you suggest to achieve this?

GDPR Delete not working

Calling the following is throwing authentication issues:

$client->crm()->contacts()->gdprApi()->postCrmV3ObjectsContactsGdprDelete($objectId);

Looking at the code I can see that the changes in #68 have introduced this issue, which is strange since it is supposed to fix it.
The underlying issue is that the configuration details are empty due to the GDPRApi being created with no params.

I have also tried to follow the example from here:
https://developers.hubspot.com/docs/api/crm/contacts

  1. There is a syntax error in the code:
    $apiResponse = $client->crm()->contacts()->gdprDelete()->gdprApi()->post-/crm/v3/objects/contacts/gdprDelete($PublicGdprDeleteInput);
  2. There isn't a gdprDelete object.

Associations request body format

crm()->associations()->batchApi()->read() formats the request body incorrectly. Currently it just sends the ID on its own, when it needs to be in the following JSON format:

{
"inputs": [
{
"id": "1234"
}
]
}

Way to access API client itself

Should we want to access "undocumented" APIs like https://api.hubapi.com/engagements/v1/activity-types how can we go about that with this library?

PHP 8.1 Deprecated

`Deprecated: Return type of HubSpot\Client\Crm\Contacts\Model\Filter::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /vendor/hubspot/api-client/codegen/Crm/Contacts/Model/Filter.php on line 360

Deprecated: Return type of HubSpot\Client\Crm\Contacts\Model\Filter::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /vendor/hubspot/api-client/codegen/Crm/Contacts/Model/Filter.php on line 372`

`ArrayAccess` implementations dockblocks are incorrect

The classes that implement the ArrayAccess interface in the codegen folder have incorrect type hinting in their docblocks.

It implies that the keys of $this->container are integers. But they are actually strings.

Example:

/**
 * Returns true if offset exists. False otherwise.
 *
 * @param integer $offset Offset
 *
 * @return boolean
 */
public function offsetExists($offset)
{
    return isset($this->container[$offset]);
}

Should be:

/**
 * Returns true if offset exists. False otherwise.
 *
 * @param string $offset Offset
 *
 * @return boolean
 */
public function offsetExists($offset)
{
    return isset($this->container[$offset]);
}

I don't know how the codegen folder is generated, so I can't do it for you unfortunately.

GuzzleHTTP PSR7 not working

in /codegen/Crm/Contacts/Api/BasicApi.php

Line 614 is $httpBody = \GuzzleHttp\Psr7\build_query($formParams);

Should be $httpBody = \GuzzleHttp\Psr7\Query::build($formParams);

Same for Line 643,

And presumably anywhere else trying to call now undefined functions....

Incorrect $attributeMap in BlogPost model

\HubSpot\Client\Cms\Blogs\BlogPosts\Model\BlogPost::$attributeMap = [
    ...,
    'created_at' => 'createdAt',
    'updated_at' => 'updatedAt',
    ...
]

While provided attributes are missing from actual API response body. It has updated and created instead.

Is this library using semantic versioning?

Hi folks, I just updated the library from 1.3.1 to 1.3.2 and the public api broke:

1.3.1: https://github.com/HubSpot/hubspot-api-php/blob/1.3.1/codegen/Crm/Contacts/Api/BatchApi.php#L670
1.3.2: https://github.com/HubSpot/hubspot-api-php/blob/1.3.2/codegen/Crm/Contacts/Api/BatchApi.php#L682

The method signature has changed from

    public function read($archived = false, $batch_read_input_simple_public_object_id = null)
    {
        list($response) = $this->readWithHttpInfo($archived, $batch_read_input_simple_public_object_id);
        return $response;
    }

to

    public function read($batch_read_input_simple_public_object_id, $archived = false)
    {
        list($response) = $this->readWithHttpInfo($batch_read_input_simple_public_object_id, $archived);
        return $response;
    }

I only realized that since phpstan threw new errors. If your library is following semantic versioning, this change is a no go. Please clarify which version strategy you are using.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.