Code Monkey home page Code Monkey logo

dotnetcore-hubspot-client's People

Contributors

benhamiltonpro avatar dantheother avatar davymirfin avatar etx-eme avatar leestevens318 avatar nover avatar pingvinen avatar rjn368 avatar roycornelissen avatar spitball-ram avatar

Stargazers

 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

dotnetcore-hubspot-client's Issues

Linking contact to company

Excited to find this project.

I need to create a Contact, Company, and Deal.

First I create a contact. Now when I am creating the Company, how do I link the contact to that company?

Is there an ETA for the Deal client?

Technical question about Line Items API

Hi,

This is more of a technical question...

I have a few more entities I need to support: Product and Line Item (well, I need at least the latter because I need to create line items from our application), so I'm attempting to add them to this library. Mind you I'm quite new to the HubSpot API so it takes some research for me to figure it out... I think I can cover most of the operations and map them to the structure of this component. I just wonder how to map the result from this method: https://legacydocs.hubspot.com/docs/methods/line-items/batch-get-line-items

{
  "9845651": {
    "objectType": "LINE_ITEM",
    "portalId": 62515,
    "objectId": 9845651,
    "properties": {
      "hs_product_id": {
        "versions": [
          {
            "name": "hs_product_id",
            "value": "1645342",
            "sourceVid": []
          }
        ],
        "value": "1645342",
        "timestamp": 0,
        "source": null,
        "sourceId": null
      }
    },
    "version": 1,
    "isDeleted": false
  },
  "9867373": {
    "objectType": "LINE_ITEM",
    "portalId": 62515,
    "objectId": 9867373,
    "properties": {
      "hs_product_id": {
        "versions": [
          {
            "name": "hs_product_id",
            "value": "1645187",
            "sourceVid": []
          }
        ],
        "value": "1645187",
        "timestamp": 0,
        "source": null,
        "sourceId": null
      }
    },
    "version": 1,
    "isDeleted": false
  }
}

This seems like a dictionary, and doesn't really look like the other response types you use in this library, am I correct?

Getting contacts by company ID

Is there a way to get a list of contacts by a given company ID? Or get a company along with a list of contact associations?

Add interfaces to *HubSpotClient

Thank you for this library! Works like a charm ๐Ÿ‘

I was wondering if you considered adding interfaces for all the *HubSpotClient classes so that they can be easily injected/mocked in unit tests? Or do you have another vision for mocking these?

Hubspot Auth API changes

Hi,
We received a notification that the hubspot authentication API was changing - will this library be affected by that or was it already using the newer auth methods?

Private Apps migration

Hubspot will be updating its authentication mechanism to use Private Apps only in November 2022

image

After initial tests, it looks like the library is compatible except for the authentication mechanism.

Are there any plans to support this change?

New HubSpot API

I also noticed that HubSpot has a new API, but it seems to be work in progress. Are there plans to migrate to this API? There seem to be some community questions/initiatives around generating OpenApi specs so that a client could be generated but I have no idea about the timeline.

So I guess my question is... how much should be invested in binding old v1 or v2 endpoints...?

As mentioned in #47, I do need to bind Line Items on a short term, so I'll attempt to add this based on the v1 API.

Some bugs in Associations

I noticed some bugs in the Associations implementation. Working on a fix, will submit a PR ASAP.

  • The methods on the HubSpotAssociationsClient all have a parameter for the definition ID, but they are never used since the entities also have a field for this. I think this should be removed (will break the API though).
  • The list associations operation on the HubSpot API doesn't return full entities, only a list of ID's, so deserialization of this fails.

CompanyClient ListAsync wrong return type?

I'm trying to get a list of Companies using ListAsync but noticed it has the wrong return type:

public async Task<T> ListAsync<T>(CompanyListRequestOptions opts = null) where T : IHubSpotEntity, new()

Instead of like the Owners ListAsync

public async Task<IEnumerable<T>> ListAsync<T>(OwnerListRequestOptions opts = null) where T : IOwnerHubSpotEntity, new()

Also can you provide a sample of how to use the pagination?

Error in GetByEmailAsync in Company

Salutations,
I state that I have been using your library with satisfaction for a long time but now I need to search for the Companies with the email
GetByEmailAsync.

Unfortunately I get the following error:

System.ArgumentException: Unable to locate a property on the data class that implements IList where T is a IHubSpotEntity

Unfortunately it is an error that is blocking me and I don't know how to go on.
I would be very grateful if you could point me to a quick fix ... or have you planned to release a fix.

I thank you

Setting custom properties

Hello,
Is there currently an implementation to allow the setting of custom properties for contacts? If so how is it done?

System.FormatException when using HubSpotContactClient.ListAsync for models with a DateTime

When running the following code:

var customers = await
                        _hubSpotApi.ListAsync<ContactListHubSpotEntity<HubspotCustomer>>(new ContactListRequestOptions
                        {
                            ContactOffset = offset,
                            NumberOfContactsToReturn = _hubspotConfig.BatchSize,
                            PropertiesToInclude = _propertiesToInclude
                        });

I get the following exception:

System.FormatException
String '1594252800000' was not recognized as a valid DateTime  

  at System.DateTimeParse.Parse(ReadOnlySpan`1 s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
   at System.Convert.ToDateTime(String value, IFormatProvider provider)
   at System.String.System.IConvertible.ToDateTime(IFormatProvider provider)
   at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
   at Skarp.HubSpotClient.Core.Requests.RequestDataConverter.ConvertSingleEntity(ExpandoObject dynamicObject, Object dto)
   at Skarp.HubSpotClient.Core.Requests.RequestDataConverter.FromHubSpotListResponse[T](ExpandoObject dynamicObject)
   at Skarp.HubSpotClient.Core.Requests.RequestSerializer.DeserializeListEntity[T](String json)
   at Skarp.HubSpotClient.Core.HubSpotBaseClient.<ListAsync>b__11_0[T](String responseData)
   at Skarp.HubSpotClient.Core.HubSpotBaseClient.<SendRequestAsync>d__17`1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Skarp.HubSpotClient.Core.HubSpotBaseClient.<ListAsync>d__11`1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Skarp.HubSpotClient.Contact.HubSpotContactClient.<ListAsync>d__7`1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at MyProject.HubSpotService.<DownloadCustomers>d__9.MoveNext()

My HubspotCustomer class has a DateTime property.
The issue seems to be that the hubspot client is not parsing the returned date correctly.

Get Deals

Hi!
Congratulations on your amazing project.๐Ÿ‘๐Ÿ‘
When I tried to get all deals, I use this code line

var deals =
               await _client.ListAsync<DealListHubSpotEntity<DealHubSpotEntity>>(new DealListRequestOptions
               {
                   PropertiesToInclude = new List<string> { "dealname", "amount", "hubspot_owner_id" },
                   NumberOfDealsToReturn = 2
               });

I checked the method and he is waiting for ContactListRequestOptions and not DealListRequestOptions.

  public async Task<T> ListAsync<T>(ContactListRequestOptions opts = null) where T : IHubSpotEntity, new()
        {
            Logger.LogDebug("Contact ListAsync");

and throw this error
Error CS1503 Argument 1: cannot convert from 'Skarp.HubSpotClient.Deal.DealListRequestOptions' to 'Skarp.HubSpotClient.Contact.ContactListRequestOptions'

I use library 0.22.0 installed by nuggets package

Support Cancellation Tokens

I like all the async methods. But it would be nice if an (optional) cancellation token could be passed to them. Are there plans to support this?

Contact ListAsync returns null

ListAsync for contacts currently seems to return a null list. Is this method still under development? Is there a way to implement this from outside the library?

Transitive dependency issue when building for Linux

As I was updating dependencies in our project (including this HubSpot library), I noticed that there's an issue with a transitive dependency (via RapidCore). The situation is that we are running this in a .NET 6.0 application on Linux (Docker container). So when we build for the Linux platform, dotnet restore fails:

image

We have "resolved" this by explicitly referencing these assembly versions directly in the application, but I've yet to see whether it holds up at runtime. Unit tests look OK.

I guess it's not really an issue in this library, but rather in RapidCore or even SSH.NET, something to be aware of.

Fix test suite

The test suite is currently failing due to changes in the public hubspot demo account

GetListByIdAsync returns empty Contacts (with only "Id" set)

Hi,
I need to get a Contact list with their ID.
I solved the problem using this code:

var clientList = new HubSpotListOfContactsClient("XXX-XXXX-XXXXX");
var listResult = await clientList.GetListByIdAsync<ContactListHubSpotEntity<ContactHubSpotEntity>>(123, new ListOfContactsRequestOptions { NumberOfContactsToReturn = 50 });

In the result all the Contacts (ContactHubSpotEntity) present in the list I searched for appear correctly but these Contacts are empty except for the ID field.
In order to get the remaining Contacts data I am forced to make a further call (GetByIdAsync) for each ID obtained.

Is it possible to have all the Contacts data directly called GetListByIdAsync?

Thank you in advance and I am waiting for your reply.

With best regards
Michele

.Net Framework support

I know description states that this is a .Net-Core project, however this Nuget package states that this is a Net Standard 2.0 project. But if I use it will a .Net Framework project get a loader issue with (SimpleInjector) stating that it can't load the assembly that contains Skarp.HubspotClient.

Should this package be usable with .Net Core?

Update client to send auth key as authorization header

Right now we're sending it as the hapikey= query parameter which kind of sucks of you do request logging in c# or some proxies or other intermediaries are logging requested URLs.

According to docs it should be possible to send the authentication details along as a standard Authorization Bearer header - I think we should do that.

Thread Exits with a status code of zero when calling GetByEmailAsync<ContactHubSpotEntity>

Here is a sample code snippet; bear in mind i have been adding try catches as an attempt to work around the issue.

ContactHubSpotEntity hubspotContact = null;
var hubspotClient = new HubSpotContactClient(ConfigurationManager.AppSettings["HubSpotApiKey"]);
try
{
    hubspotContact = await hubspotClient.GetByEmailAsync<ContactHubSpotEntity>(viewModel.Email);
}
catch (Exception e)
{
    return false;
}
finally
{
    if (hubspotContact == null)
    {
        hubspotContact = new ContactHubSpotEntity()
        {
            Address = viewModel.AddressLine1 + " " + viewModel.AddressLine2,
            Company = viewModel.CompanyName,
            City = viewModel.City,
            Email = viewModel.Email,
            FirstName = viewModel.FirstName,
            Lastname = viewModel.LastName,
            Phone = viewModel.PhoneNumber, 
            State = viewModel.State,
            ZipCode = viewModel.ZipCode,
        };
        var success = await hubspotClient.CreateAsync<ContactHubSpotEntity>(hubspotContact);
    }
}     
return true; 

when the first await line is hit a 404 response is received from hubspot because the contact doesn't exist; but the response body is not empty and the object shape is not the same as the serializer is expecting.

{
status=error,
correlationId=42022ea2-0916-41d5-bfee-57edd3a23b60,
message=contact does not exist,
requestId=73bf33242099220cd1ab6e842e063d29
}

I believe the code in the SendRequestAsync method in the HubSpotBaseClient class needs some critiquing to handle the response when a 404 is returned with the error message.

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.