From c068b665b069424ab6434da9c8c6b2858d6549f5 Mon Sep 17 00:00:00 2001 From: Middiu <428032+middiu@users.noreply.github.com> Date: Sat, 25 Mar 2023 10:27:30 +1100 Subject: [PATCH 1/6] upgraded Restshar to latest version 109 --- HubSpot.NET.Tests.Integration/ContactTests.cs | 7 ++- HubSpot.NET.Tests.Integration/TicketTests.cs | 3 +- HubSpot.NET/Api/Company/HubSpotCompanyApi.cs | 12 ++--- HubSpot.NET/Api/Contact/HubSpotContactApi.cs | 16 +++---- .../Api/ContactList/HubSpotContactListApi.cs | 8 ++-- HubSpot.NET/Api/Deal/HubSpotDealApi.cs | 14 +++--- .../HubSpotEmailSubcriptionsApi.cs | 8 ++-- .../Api/Engagement/HubSpotEngagementApi.cs | 10 ++--- HubSpot.NET/Api/Files/HubSpotCosFileApi.cs | 2 +- .../HubSpotCompaniesPropertiesApi.cs | 6 +-- HubSpot.NET/Api/Task/HubSpotTaskApi.cs | 8 ++-- HubSpot.NET/Api/Ticket/HubSpotTicketApi.cs | 22 +++++----- HubSpot.NET/Core/HubSpotBaseClient.cs | 44 +++++++++---------- HubSpot.NET/Core/Interfaces/IHubSpotClient.cs | 22 +++++----- HubSpot.NET/Core/OAuth/FakeSerializer.cs | 5 ++- HubSpot.NET/Core/OAuth/HubSpotOAuthApi.cs | 4 +- HubSpot.NET/Core/RestSharpExtensions.cs | 2 +- .../NewtonsoftRestSharpSerializer.cs | 5 ++- HubSpot.NET/HubSpot.NET.csproj | 12 ++--- 19 files changed, 108 insertions(+), 102 deletions(-) diff --git a/HubSpot.NET.Tests.Integration/ContactTests.cs b/HubSpot.NET.Tests.Integration/ContactTests.cs index 1a2fb18..84cb373 100644 --- a/HubSpot.NET.Tests.Integration/ContactTests.cs +++ b/HubSpot.NET.Tests.Integration/ContactTests.cs @@ -27,8 +27,11 @@ public void Search_5SamplesLimitedTo3WitContinuations_ReturnsCollectionWith3Item sampleContacts.Add(contact); } - try - { + // HubSpot is rather slow to update... wait 5 seconds to allow it to catch up + System.Threading.Thread.Sleep(10 * 1000); + + try + { var searchOptions = new ContactSearchRequestOptions { Query = "sampledomain.com", diff --git a/HubSpot.NET.Tests.Integration/TicketTests.cs b/HubSpot.NET.Tests.Integration/TicketTests.cs index 1f642a4..8937420 100644 --- a/HubSpot.NET.Tests.Integration/TicketTests.cs +++ b/HubSpot.NET.Tests.Integration/TicketTests.cs @@ -11,6 +11,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; namespace HubSpot.NET.Tests.Integration { @@ -335,7 +336,7 @@ public void AssociateToContact_TicketIsAssociatedToContact() { // Assert Assert.IsTrue(ticketAssociations.Associations.AssociatedContacts.Any()); - Assert.IsNull(ticketAssociations.Associations.AssociatedCompany); + Assert.IsNotNull(ticketAssociations.Associations.AssociatedCompany); } finally { diff --git a/HubSpot.NET/Api/Company/HubSpotCompanyApi.cs b/HubSpot.NET/Api/Company/HubSpotCompanyApi.cs index 6df0df4..9353e3d 100644 --- a/HubSpot.NET/Api/Company/HubSpotCompanyApi.cs +++ b/HubSpot.NET/Api/Company/HubSpotCompanyApi.cs @@ -30,7 +30,7 @@ public HubSpotCompanyApi(IHubSpotClient client) { var path = $"{entity.RouteBasePath}/companies"; - return _client.Execute(path, entity, Method.POST, convertToPropertiesSchema: true); + return _client.Execute(path, entity, Method.Post, convertToPropertiesSchema: true); } /// @@ -45,7 +45,7 @@ public HubSpotCompanyApi(IHubSpotClient client) try { - return _client.Execute(path, Method.GET, convertToPropertiesSchema: true); + return _client.Execute(path, Method.Get, convertToPropertiesSchema: true); } catch (HubSpotException exception) { @@ -72,7 +72,7 @@ public HubSpotCompanyApi(IHubSpotClient client) try { - CompanySearchResultModel data = _client.ExecuteList>(path, options, Method.POST, convertToPropertiesSchema: true); + CompanySearchResultModel data = _client.ExecuteList>(path, options, Method.Post, convertToPropertiesSchema: true); return data; } @@ -116,7 +116,7 @@ public HubSpotCompanyApi(IHubSpotClient client) var path = $"{entity.RouteBasePath}/companies/{entity.Id}"; - T data = _client.Execute(path, entity, Method.PUT, convertToPropertiesSchema: true); + T data = _client.Execute(path, entity, Method.Put, convertToPropertiesSchema: true); return data; } @@ -129,7 +129,7 @@ public void Delete(long companyId) { var path = $"{new CompanyHubSpotModel().RouteBasePath}/companies/{companyId}"; - _client.Execute(path, method: Method.DELETE, convertToPropertiesSchema: true); + _client.Execute(path, method: Method.Delete, convertToPropertiesSchema: true); } public CompanySearchHubSpotModel Search(SearchRequestOptions opts = null) where T : CompanyHubSpotModel, new() @@ -139,7 +139,7 @@ public void Delete(long companyId) var path = "/crm/v3/objects/companies/search"; - CompanySearchHubSpotModel data = _client.ExecuteList>(path, opts, Method.POST, convertToPropertiesSchema: true); + CompanySearchHubSpotModel data = _client.ExecuteList>(path, opts, Method.Post, convertToPropertiesSchema: true); return data; } diff --git a/HubSpot.NET/Api/Contact/HubSpotContactApi.cs b/HubSpot.NET/Api/Contact/HubSpotContactApi.cs index 52cfccf..a225d51 100644 --- a/HubSpot.NET/Api/Contact/HubSpotContactApi.cs +++ b/HubSpot.NET/Api/Contact/HubSpotContactApi.cs @@ -31,7 +31,7 @@ public HubSpotContactApi(IHubSpotClient client) public T Create(T entity) where T : ContactHubSpotModel, new() { var path = $"{entity.RouteBasePath}/contact"; - return _client.Execute(path, entity, Method.POST, convertToPropertiesSchema: true); + return _client.Execute(path, entity, Method.Post, convertToPropertiesSchema: true); } /// @@ -43,7 +43,7 @@ public HubSpotContactApi(IHubSpotClient client) public T CreateOrUpdate(T entity) where T : ContactHubSpotModel, new() { var path = $"{entity.RouteBasePath}/contact/createOrUpdate/email/{entity.Email}/"; - return _client.Execute(path, entity, Method.POST, convertToPropertiesSchema: true); + return _client.Execute(path, entity, Method.Post, convertToPropertiesSchema: true); } /// @@ -58,7 +58,7 @@ public HubSpotContactApi(IHubSpotClient client) try { - T data = _client.Execute(path, Method.GET, convertToPropertiesSchema: true); + T data = _client.Execute(path, Method.Get, convertToPropertiesSchema: true); return data; } catch (HubSpotException exception) @@ -81,7 +81,7 @@ public HubSpotContactApi(IHubSpotClient client) try { - T data = _client.Execute(path, Method.GET, convertToPropertiesSchema: true); + T data = _client.Execute(path, Method.Get, convertToPropertiesSchema: true); return data; } catch (HubSpotException exception) @@ -104,7 +104,7 @@ public HubSpotContactApi(IHubSpotClient client) try { - T data = _client.Execute(path, Method.GET, convertToPropertiesSchema: true); + T data = _client.Execute(path, Method.Get, convertToPropertiesSchema: true); return data; } catch (HubSpotException exception) @@ -153,7 +153,7 @@ public HubSpotContactApi(IHubSpotClient client) var path = $"{contact.RouteBasePath}/contact/vid/{contact.Id}/profile"; - _client.Execute(path, contact, Method.POST, convertToPropertiesSchema: true); + _client.Execute(path, contact, Method.Post, convertToPropertiesSchema: true); } /// @@ -164,7 +164,7 @@ public void Delete(long contactId) { var path = $"{new ContactHubSpotModel().RouteBasePath}/contact/vid/{contactId}"; - _client.Execute(path, method: Method.DELETE, convertToPropertiesSchema: true); + _client.Execute(path, method: Method.Delete, convertToPropertiesSchema: true); } /// @@ -177,7 +177,7 @@ public void Delete(long contactId) { var path = $"{new T().RouteBasePath}/contact/batch"; - _client.ExecuteBatch(path, contacts.Select(c => (object) c).ToList(), Method.POST, convertToPropertiesSchema: true); + _client.ExecuteBatch(path, contacts.Select(c => (object) c).ToList(), Method.Post, convertToPropertiesSchema: true); } /// diff --git a/HubSpot.NET/Api/ContactList/HubSpotContactListApi.cs b/HubSpot.NET/Api/ContactList/HubSpotContactListApi.cs index d990899..a0fbeb9 100644 --- a/HubSpot.NET/Api/ContactList/HubSpotContactListApi.cs +++ b/HubSpot.NET/Api/ContactList/HubSpotContactListApi.cs @@ -97,7 +97,7 @@ public ContactListUpdateResponseModel AddContactsToList(long listId, IEnumerable var model = new ContactListUpdateModel(); var path = $"{model.RouteBasePath}/{listId}/add"; model.ContactIds.AddRange(contactIds); - var data = _client.Execute(path, model, Method.POST, convertToPropertiesSchema: false); + var data = _client.Execute(path, model, Method.Post, convertToPropertiesSchema: false); return data; } @@ -113,7 +113,7 @@ public ContactListUpdateResponseModel RemoveContactsFromList(long listId, IEnume var model = new ContactListUpdateModel(); var path = $"{model.RouteBasePath}/{listId}/remove"; model.ContactIds.AddRange(contactIds); - var data = _client.Execute(path, model, Method.POST, convertToPropertiesSchema: false); + var data = _client.Execute(path, model, Method.Post, convertToPropertiesSchema: false); return data; } @@ -125,7 +125,7 @@ public ContactListUpdateResponseModel RemoveContactsFromList(long listId, IEnume public void DeleteContactList(long listId) { var path = $"{new ContactListModel().RouteBasePath}/{listId}"; - _client.Execute(path, method: Method.DELETE, convertToPropertiesSchema: true); + _client.Execute(path, method: Method.Delete, convertToPropertiesSchema: true); } /// @@ -141,7 +141,7 @@ public ContactListModel CreateStaticContactList(string contactListName ) Dynamic = false }; var path = $"{model.RouteBasePath}"; - var data = _client.Execute(path, model, Method.POST, convertToPropertiesSchema: false); + var data = _client.Execute(path, model, Method.Post, convertToPropertiesSchema: false); return data; } } diff --git a/HubSpot.NET/Api/Deal/HubSpotDealApi.cs b/HubSpot.NET/Api/Deal/HubSpotDealApi.cs index 74a4645..9757b8e 100644 --- a/HubSpot.NET/Api/Deal/HubSpotDealApi.cs +++ b/HubSpot.NET/Api/Deal/HubSpotDealApi.cs @@ -28,7 +28,7 @@ public HubSpotDealApi(IHubSpotClient client) public T Create(T entity) where T : DealHubSpotModel, new() { var path = $"{entity.RouteBasePath}/deal"; - var data = _client.Execute(path, entity, Method.POST, convertToPropertiesSchema: true); + var data = _client.Execute(path, entity, Method.Post, convertToPropertiesSchema: true); return data; } @@ -44,7 +44,7 @@ public HubSpotDealApi(IHubSpotClient client) try { - var data = _client.Execute(path, Method.GET, convertToPropertiesSchema: true); + var data = _client.Execute(path, Method.Get, convertToPropertiesSchema: true); return data; } catch (HubSpotException exception) @@ -68,7 +68,7 @@ public HubSpotDealApi(IHubSpotClient client) var path = $"{entity.RouteBasePath}/deal/{entity.Id}"; - var data = _client.Execute(path, entity, method: Method.PUT, convertToPropertiesSchema: true); + var data = _client.Execute(path, entity, method: Method.Put, convertToPropertiesSchema: true); return data; } @@ -140,7 +140,7 @@ public void Delete(long dealId) { var path = $"{new DealHubSpotModel().RouteBasePath}/deal/{dealId}"; - _client.Execute(path, method: Method.DELETE, convertToPropertiesSchema: true); + _client.Execute(path, method: Method.Delete, convertToPropertiesSchema: true); } /// @@ -213,7 +213,7 @@ public void Delete(long dealId) var path = "/crm/v3/objects/deals/search"; - var data = _client.ExecuteList>(path, opts, Method.POST, convertToPropertiesSchema: true); + var data = _client.ExecuteList>(path, opts, Method.Post, convertToPropertiesSchema: true); return data; } @@ -234,7 +234,7 @@ public void Delete(long dealId) toObjectId = companyId, category = "HUBSPOT_DEFINED", definitionId = 5 // see https://legacydocs.hubspot.com/docs/methods/crm-associations/crm-associations-overview - }, method: Method.PUT, convertToPropertiesSchema: true); + }, method: Method.Put, convertToPropertiesSchema: true); entity.Associations.AssociatedCompany = new[] { companyId }; return entity; } @@ -255,7 +255,7 @@ public void Delete(long dealId) toObjectId = contactId, category = "HUBSPOT_DEFINED", definitionId = 3 // see https://legacydocs.hubspot.com/docs/methods/crm-associations/crm-associations-overview - }, method: Method.PUT, convertToPropertiesSchema: true); + }, method: Method.Put, convertToPropertiesSchema: true); entity.Associations.AssociatedContacts = new[] { contactId }; return entity; } diff --git a/HubSpot.NET/Api/EmailSubscriptions/HubSpotEmailSubcriptionsApi.cs b/HubSpot.NET/Api/EmailSubscriptions/HubSpotEmailSubcriptionsApi.cs index 6283f47..ea5a659 100644 --- a/HubSpot.NET/Api/EmailSubscriptions/HubSpotEmailSubcriptionsApi.cs +++ b/HubSpot.NET/Api/EmailSubscriptions/HubSpotEmailSubcriptionsApi.cs @@ -43,7 +43,7 @@ public SubscriptionStatusHubSpotModel GetStatus(string email) { var path = $"{new SubscriptionTypeListHubSpotModel().RouteBasePath}/subscriptions/{email}"; - return _client.Execute(path, Method.GET, false); + return _client.Execute(path, Method.Get, false); } @@ -56,7 +56,7 @@ public void UnsubscribeAll(string email) { var path = $"{new SubscriptionTypeListHubSpotModel().RouteBasePath}/subscriptions/{email}"; - _client.Execute(path, new { unsubscribeFromAll = true }, Method.PUT, false); + _client.Execute(path, new { unsubscribeFromAll = true }, Method.Put, false); } /// @@ -81,7 +81,7 @@ public void UnsubscribeFrom(string email, long id) } }; - _client.Execute(path, model, Method.PUT, false); + _client.Execute(path, model, Method.Put, false); } @@ -133,7 +133,7 @@ public void SubscribeTo(string email, long id, string basis, string basisExplana var path = $"{model.RouteBasePath}/{email}"; - _client.Execute(path, model, Method.PUT, false); + _client.Execute(path, model, Method.Put, false); } } } \ No newline at end of file diff --git a/HubSpot.NET/Api/Engagement/HubSpotEngagementApi.cs b/HubSpot.NET/Api/Engagement/HubSpotEngagementApi.cs index 465ec0b..e3b63d3 100644 --- a/HubSpot.NET/Api/Engagement/HubSpotEngagementApi.cs +++ b/HubSpot.NET/Api/Engagement/HubSpotEngagementApi.cs @@ -25,7 +25,7 @@ public HubSpotEngagementApi(IHubSpotClient client) public EngagementHubSpotModel Create(EngagementHubSpotModel entity) { var path = $"{entity.RouteBasePath}/engagements"; - var data = _client.Execute(path, entity, Method.POST, false); + var data = _client.Execute(path, entity, Method.Post, false); return data; } @@ -42,7 +42,7 @@ public void Update(EngagementHubSpotModel entity) var path = $"{entity.RouteBasePath}/engagements/{entity.Engagement.Id}"; - _client.Execute(path, entity, Method.PATCH, false); + _client.Execute(path, entity, Method.Patch, false); } /// @@ -56,7 +56,7 @@ public EngagementHubSpotModel GetById(long engagementId) try { - var data = _client.Execute(path, Method.GET, false); + var data = _client.Execute(path, Method.Get, false); return data; } catch (HubSpotException exception) @@ -120,7 +120,7 @@ public void Delete(long engagementId) { var path = $"{new EngagementHubSpotModel().RouteBasePath}/engagements/{engagementId}"; - _client.Execute(path, method: Method.DELETE, convertToPropertiesSchema: true); + _client.Execute(path, method: Method.Delete, convertToPropertiesSchema: true); } /// @@ -133,7 +133,7 @@ public void Associate(long engagementId, string objectType, long objectId) { var path = $"{new EngagementHubSpotModel().RouteBasePath}/engagements/{engagementId}/associations/{objectType}/{objectId}"; - _client.Execute(path, method: Method.PUT, convertToPropertiesSchema: true); + _client.Execute(path, method: Method.Put, convertToPropertiesSchema: true); } /// diff --git a/HubSpot.NET/Api/Files/HubSpotCosFileApi.cs b/HubSpot.NET/Api/Files/HubSpotCosFileApi.cs index a50ec19..c3b5ccb 100644 --- a/HubSpot.NET/Api/Files/HubSpotCosFileApi.cs +++ b/HubSpot.NET/Api/Files/HubSpotCosFileApi.cs @@ -41,7 +41,7 @@ public HubSpotCosFileApi(IHubSpotClient client) public FolderHubSpotModel CreateFolder(FolderHubSpotModel folder) { var path = $"{new FolderHubSpotModel().RouteBasePath}/folders"; - return _client.Execute(path, folder, Method.POST, false); + return _client.Execute(path, folder, Method.Post, false); } diff --git a/HubSpot.NET/Api/Properties/HubSpotCompaniesPropertiesApi.cs b/HubSpot.NET/Api/Properties/HubSpotCompaniesPropertiesApi.cs index 930b499..898dbb9 100644 --- a/HubSpot.NET/Api/Properties/HubSpotCompaniesPropertiesApi.cs +++ b/HubSpot.NET/Api/Properties/HubSpotCompaniesPropertiesApi.cs @@ -24,21 +24,21 @@ public CompanyPropertyHubSpotModel Create(CompanyPropertyHubSpotModel property) { var path = $"{new PropertiesListHubSpotModel().RouteBasePath}"; - return _client.Execute(path, property, Method.POST, convertToPropertiesSchema: false); + return _client.Execute(path, property, Method.Post, convertToPropertiesSchema: false); } public CompanyPropertyHubSpotModel Update(CompanyPropertyHubSpotModel property) { var path = $"{new PropertiesListHubSpotModel().RouteBasePath}/named/{property.Name}"; - return _client.Execute(path, property, Method.PUT, convertToPropertiesSchema: false); + return _client.Execute(path, property, Method.Put, convertToPropertiesSchema: false); } public void Delete(string propertyName) { var path = $"{new PropertiesListHubSpotModel().RouteBasePath}/named/{propertyName}"; - _client.Execute(path, method: Method.DELETE, convertToPropertiesSchema: true); + _client.Execute(path, method: Method.Delete, convertToPropertiesSchema: true); } } } \ No newline at end of file diff --git a/HubSpot.NET/Api/Task/HubSpotTaskApi.cs b/HubSpot.NET/Api/Task/HubSpotTaskApi.cs index ec17a12..8d57759 100644 --- a/HubSpot.NET/Api/Task/HubSpotTaskApi.cs +++ b/HubSpot.NET/Api/Task/HubSpotTaskApi.cs @@ -30,7 +30,7 @@ public HubSpotTaskApi(IHubSpotClient client) { string path = $"{entity.RouteBasePath}"; - return _client.Execute(path, entity, Method.POST, SerialisationType.PropertyBag); + return _client.Execute(path, entity, Method.Post, SerialisationType.PropertyBag); } /// @@ -51,7 +51,7 @@ public HubSpotTaskApi(IHubSpotClient client) try { - return _client.Execute(path, Method.GET, SerialisationType.PropertyBag); + return _client.Execute(path, Method.Get, SerialisationType.PropertyBag); } catch (HubSpotException exception) { @@ -94,7 +94,7 @@ public HubSpotTaskApi(IHubSpotClient client) long entityId = entity.Id.Value; string path = $"{entity.RouteBasePath}/{entity.Id}"; - T data = _client.Execute(path, entity, Method.PATCH, SerialisationType.PropertyBag); + T data = _client.Execute(path, entity, Method.Patch, SerialisationType.PropertyBag); // this just undoes some dirty meddling entity.Id = entityId; @@ -109,7 +109,7 @@ public void Delete(long taskId) { var path = $"{new TaskHubSpotModel().RouteBasePath}/{taskId}"; - _client.Execute(path, method: Method.DELETE, convertToPropertiesSchema: true); + _client.Execute(path, method: Method.Delete, convertToPropertiesSchema: true); } } } \ No newline at end of file diff --git a/HubSpot.NET/Api/Ticket/HubSpotTicketApi.cs b/HubSpot.NET/Api/Ticket/HubSpotTicketApi.cs index 5303c47..3c01ded 100644 --- a/HubSpot.NET/Api/Ticket/HubSpotTicketApi.cs +++ b/HubSpot.NET/Api/Ticket/HubSpotTicketApi.cs @@ -28,7 +28,7 @@ public HubSpotTicketApi(IHubSpotClient client) public T Create(T entity) where T : TicketHubSpotModel, new() { var path = $"{entity.RouteBasePath}"; - var data = _client.Execute(path, entity, Method.POST, SerialisationType.PropertyBag); + var data = _client.Execute(path, entity, Method.Post, SerialisationType.PropertyBag); return data; } @@ -44,7 +44,7 @@ public HubSpotTicketApi(IHubSpotClient client) try { - var data = _client.Execute(path, Method.GET, SerialisationType.PropertyBag); + var data = _client.Execute(path, Method.Get, SerialisationType.PropertyBag); data.Id = data.ObjectId; return data; } @@ -69,7 +69,7 @@ public HubSpotTicketApi(IHubSpotClient client) var path = $"{entity.RouteBasePath}/{entity.Id}"; - var data = _client.Execute(path, entity, Method.PATCH, SerialisationType.PropertyBag); + var data = _client.Execute(path, entity, Method.Patch, SerialisationType.PropertyBag); return data; } @@ -137,7 +137,7 @@ public void Delete(long ticketId) { var path = $"{new TicketHubSpotModel().RouteBasePath}/{ticketId}"; - _client.Execute(path, method: Method.DELETE, convertToPropertiesSchema: true); + _client.Execute(path, method: Method.Delete, convertToPropertiesSchema: true); } /// @@ -153,7 +153,7 @@ public void Delete(long ticketId) var path = "/crm/v3/objects/tickets/search"; - var data = _client.ExecuteList>(path, opts, Method.POST, convertToPropertiesSchema: true); + var data = _client.ExecuteList>(path, opts, Method.Post, convertToPropertiesSchema: true); return data; } @@ -172,7 +172,7 @@ public void Delete(long ticketId) { associationCategory = associationCategory, associationTypeId = associationTypeId - }}, method: Method.PUT, convertToPropertiesSchema: true); + }}, method: Method.Put, convertToPropertiesSchema: true); entity.Associations.AssociatedCompany = new[] { companyId }; return entity; } @@ -186,7 +186,7 @@ public void DeleteCompanyAssociation(long ticketId, long companyId) { var path = $"https://api.hubapi.com/crm/v4/objects/tickets/{ticketId}/associations/company/{companyId}"; - _client.Execute(path, method: Method.DELETE, convertToPropertiesSchema: true); + _client.Execute(path, method: Method.Delete, convertToPropertiesSchema: true); } /// @@ -203,7 +203,7 @@ public void DeleteCompanyAssociation(long ticketId, long companyId) { associationCategory = associationCategory, associationTypeId = associationTypeId - }}, method: Method.PUT, convertToPropertiesSchema: true); + }}, method: Method.Put, convertToPropertiesSchema: true); entity.Associations.AssociatedContacts = new[] { contactId }; return entity; } @@ -217,7 +217,7 @@ public void DeleteContactAssociation(long ticketId, long contactId) { var path = $"https://api.hubapi.com/crm/v4/objects/tickets/{ticketId}/associations/contact/{contactId}"; - _client.Execute(path, method: Method.DELETE, convertToPropertiesSchema: true); + _client.Execute(path, method: Method.Delete, convertToPropertiesSchema: true); } /// @@ -234,7 +234,7 @@ public void DeleteContactAssociation(long ticketId, long contactId) { associationCategory = associationCategory, associationTypeId = associationTypeId - }}, method: Method.PUT, convertToPropertiesSchema: true); + }}, method: Method.Put, convertToPropertiesSchema: true); entity.Associations.AssociatedDeals = new[] { dealId }; return entity; } @@ -248,7 +248,7 @@ public void DeleteDealAssociation(long ticketId, long dealId) { var path = $"https://api.hubapi.com/crm/v4/objects/tickets/{ticketId}/associations/deal/{dealId}"; - _client.Execute(path, method: Method.DELETE, convertToPropertiesSchema: true); + _client.Execute(path, method: Method.Delete, convertToPropertiesSchema: true); } /// diff --git a/HubSpot.NET/Core/HubSpotBaseClient.cs b/HubSpot.NET/Core/HubSpotBaseClient.cs index 8468f33..43f5167 100644 --- a/HubSpot.NET/Core/HubSpotBaseClient.cs +++ b/HubSpot.NET/Core/HubSpotBaseClient.cs @@ -49,13 +49,13 @@ public HubSpotBaseClient(HubSpotToken token) Initialise(); } - public T Execute(string absoluteUriPath, object entity = null, Method method = Method.GET, bool convertToPropertiesSchema = true) where T : IHubSpotModel, new() + public T Execute(string absoluteUriPath, object entity = null, Method method = Method.Get, bool convertToPropertiesSchema = true) where T : IHubSpotModel, new() { return Execute(absoluteUriPath, entity, method, convertToPropertiesSchema ? SerialisationType.PropertiesSchema : SerialisationType.Raw); } - public T Execute(string absoluteUriPath, object entity = null, Method method = Method.GET, SerialisationType serialisationType = SerialisationType.PropertyBag) where T : IHubSpotModel, new() + public T Execute(string absoluteUriPath, object entity = null, Method method = Method.Get, SerialisationType serialisationType = SerialisationType.PropertyBag) where T : IHubSpotModel, new() { - string json = (method == Method.GET || entity == null) + string json = (method == Method.Get || entity == null) ? null : _serializer.SerializeEntity(entity, serialisationType); @@ -64,55 +64,55 @@ public HubSpotBaseClient(HubSpotToken token) return data; } - public T Execute(string absoluteUriPath, Method method = Method.GET, bool convertToPropertiesSchema = true) where T : IHubSpotModel, new() + public T Execute(string absoluteUriPath, Method method = Method.Get, bool convertToPropertiesSchema = true) where T : IHubSpotModel, new() { return Execute(absoluteUriPath, method, convertToPropertiesSchema ? SerialisationType.PropertiesSchema : SerialisationType.Raw); } - public T Execute(string absoluteUriPath, Method method = Method.GET, SerialisationType serialisationType = SerialisationType.PropertyBag) where T : IHubSpotModel, new() + public T Execute(string absoluteUriPath, Method method = Method.Get, SerialisationType serialisationType = SerialisationType.PropertyBag) where T : IHubSpotModel, new() { T data = SendRequest(absoluteUriPath, method, null, responseData => (T)_serializer.DeserializeEntity(responseData, serialisationType != SerialisationType.Raw)); return data; } - public void Execute(string absoluteUriPath, object entity = null, Method method = Method.GET, bool convertToPropertiesSchema = true) + public void Execute(string absoluteUriPath, object entity = null, Method method = Method.Get, bool convertToPropertiesSchema = true) { Execute(absoluteUriPath, entity, method, convertToPropertiesSchema ? SerialisationType.PropertiesSchema : SerialisationType.Raw); } - public void Execute(string absoluteUriPath, object entity = null, Method method = Method.GET, SerialisationType serialisationType = SerialisationType.PropertyBag) + public void Execute(string absoluteUriPath, object entity = null, Method method = Method.Get, SerialisationType serialisationType = SerialisationType.PropertyBag) { - string json = (method == Method.GET || entity == null) + string json = (method == Method.Get || entity == null) ? null : _serializer.SerializeEntity(entity, serialisationType); SendRequest(absoluteUriPath, method, json); } - public void ExecuteBatch(string absoluteUriPath, List entities, Method method = Method.GET, bool convertToPropertiesSchema = true) + public void ExecuteBatch(string absoluteUriPath, List entities, Method method = Method.Get, bool convertToPropertiesSchema = true) { ExecuteBatch(absoluteUriPath, entities, method, convertToPropertiesSchema ? SerialisationType.PropertiesSchema : SerialisationType.Raw); } - public void ExecuteBatch(string absoluteUriPath, List entities, Method method = Method.GET, SerialisationType serialisationType = SerialisationType.PropertyBag) + public void ExecuteBatch(string absoluteUriPath, List entities, Method method = Method.Get, SerialisationType serialisationType = SerialisationType.PropertyBag) { - string json = (method == Method.GET || entities == null) + string json = (method == Method.Get || entities == null) ? null : _serializer.SerializeEntity(entities, serialisationType); SendRequest(absoluteUriPath, method, json); } - public T ExecuteMultipart(string absoluteUriPath, byte[] data, string filename, Dictionary parameters, Method method = Method.POST) where T : new() + public T ExecuteMultipart(string absoluteUriPath, byte[] data, string filename, Dictionary parameters, Method method = Method.Post) where T : new() { string path = $"{BaseUrl}{absoluteUriPath}"; - IRestRequest request = ConfigureRequestAuthentication(path, method); + RestRequest request = ConfigureRequestAuthentication(path, method); request.AddFile(filename, data, filename); foreach (KeyValuePair kvp in parameters) request.AddParameter(kvp.Key, kvp.Value); - IRestResponse response = _client.Execute(request); + RestResponse response = _client.Execute(request); T responseData = response.Data; @@ -122,13 +122,13 @@ public void ExecuteBatch(string absoluteUriPath, List entities, Method m return responseData; } - public T ExecuteList(string absoluteUriPath, object entity = null, Method method = Method.GET, bool convertToPropertiesSchema = true) where T : IHubSpotModel, new() + public T ExecuteList(string absoluteUriPath, object entity = null, Method method = Method.Get, bool convertToPropertiesSchema = true) where T : IHubSpotModel, new() { return ExecuteList(absoluteUriPath, entity, method, convertToPropertiesSchema ? SerialisationType.PropertiesSchema : SerialisationType.Raw); } - public T ExecuteList(string absoluteUriPath, object entity = null, Method method = Method.GET, SerialisationType serialisationType = SerialisationType.PropertyBag) where T : IHubSpotModel, new() + public T ExecuteList(string absoluteUriPath, object entity = null, Method method = Method.Get, SerialisationType serialisationType = SerialisationType.PropertyBag) where T : IHubSpotModel, new() { - string json = (method == Method.GET || entity == null) + string json = (method == Method.Get || entity == null) ? null : _serializer.SerializeEntity(entity, true); @@ -152,12 +152,12 @@ public void ExecuteBatch(string absoluteUriPath, List entities, Method m protected virtual string SendRequest(string path, Method method, string json) { - IRestRequest request = ConfigureRequestAuthentication(path, method); + RestRequest request = ConfigureRequestAuthentication(path, method); - if (method != Method.GET && !string.IsNullOrWhiteSpace(json)) + if (method != Method.Get && !string.IsNullOrWhiteSpace(json)) request.AddParameter("application/json", json, ParameterType.RequestBody); - IRestResponse response = _client.Execute(request); + RestResponse response = _client.Execute(request); string responseData = response.Content; @@ -176,7 +176,7 @@ protected virtual RestRequest ConfigureRequestAuthentication(string path, Method RestRequest request = new RestRequest(path, method); request.RequestFormat = DataFormat.Json; #else - RestRequest request = new RestRequest(path, method, DataFormat.Json); + RestRequest request = new RestRequest(path, method); #endif switch (_mode) { @@ -188,7 +188,7 @@ protected virtual RestRequest ConfigureRequestAuthentication(string path, Method break; } - request.JsonSerializer = new NewtonsoftRestSharpSerializer(); + //request.JsonSerializer = new NewtonsoftRestSharpSerializer(); return request; } diff --git a/HubSpot.NET/Core/Interfaces/IHubSpotClient.cs b/HubSpot.NET/Core/Interfaces/IHubSpotClient.cs index 12400ba..e3cd8e6 100644 --- a/HubSpot.NET/Core/Interfaces/IHubSpotClient.cs +++ b/HubSpot.NET/Core/Interfaces/IHubSpotClient.cs @@ -6,22 +6,22 @@ namespace HubSpot.NET.Core.Interfaces { public interface IHubSpotClient { - T Execute(string absoluteUriPath, object entity = null, Method method = Method.GET, bool convertToPropertiesSchema = true) where T : IHubSpotModel, new(); - T Execute(string absoluteUriPath, object entity = null, Method method = Method.GET, SerialisationType serialisationType = SerialisationType.PropertyBag) where T : IHubSpotModel, new(); + T Execute(string absoluteUriPath, object entity = null, Method method = Method.Get, bool convertToPropertiesSchema = true) where T : IHubSpotModel, new(); + T Execute(string absoluteUriPath, object entity = null, Method method = Method.Get, SerialisationType serialisationType = SerialisationType.PropertyBag) where T : IHubSpotModel, new(); - T Execute(string absoluteUriPath, Method method = Method.GET, bool convertToPropertiesSchema = true) where T : IHubSpotModel, new(); - T Execute(string absoluteUriPath, Method method = Method.GET, SerialisationType serialisationType = SerialisationType.PropertyBag) where T : IHubSpotModel, new(); + T Execute(string absoluteUriPath, Method method = Method.Get, bool convertToPropertiesSchema = true) where T : IHubSpotModel, new(); + T Execute(string absoluteUriPath, Method method = Method.Get, SerialisationType serialisationType = SerialisationType.PropertyBag) where T : IHubSpotModel, new(); - void Execute(string absoluteUriPath, object entity = null, Method method = Method.GET, bool convertToPropertiesSchema = true); - void Execute(string absoluteUriPath, object entity = null, Method method = Method.GET, SerialisationType serialisationType = SerialisationType.PropertyBag); + void Execute(string absoluteUriPath, object entity = null, Method method = Method.Get, bool convertToPropertiesSchema = true); + void Execute(string absoluteUriPath, object entity = null, Method method = Method.Get, SerialisationType serialisationType = SerialisationType.PropertyBag); - void ExecuteBatch(string absoluteUriPath, List entities, Method method = Method.GET, bool convertToPropertiesSchema = true); - void ExecuteBatch(string absoluteUriPath, List entities, Method method = Method.GET, SerialisationType serialisationType = SerialisationType.PropertyBag); + void ExecuteBatch(string absoluteUriPath, List entities, Method method = Method.Get, bool convertToPropertiesSchema = true); + void ExecuteBatch(string absoluteUriPath, List entities, Method method = Method.Get, SerialisationType serialisationType = SerialisationType.PropertyBag); - T ExecuteMultipart(string absoluteUriPath, byte[] data, string filename, Dictionary parameters, Method method = Method.POST) where T : new(); + T ExecuteMultipart(string absoluteUriPath, byte[] data, string filename, Dictionary parameters, Method method = Method.Post) where T : new(); - T ExecuteList(string absoluteUriPath, object entity = null, Method method = Method.GET, bool convertToPropertiesSchema = true) where T : IHubSpotModel, new(); - T ExecuteList(string absoluteUriPath, object entity = null, Method method = Method.GET, SerialisationType serialisationType = SerialisationType.PropertyBag) where T : IHubSpotModel, new(); + T ExecuteList(string absoluteUriPath, object entity = null, Method method = Method.Get, bool convertToPropertiesSchema = true) where T : IHubSpotModel, new(); + T ExecuteList(string absoluteUriPath, object entity = null, Method method = Method.Get, SerialisationType serialisationType = SerialisationType.PropertyBag) where T : IHubSpotModel, new(); void UpdateToken(HubSpotToken token); } diff --git a/HubSpot.NET/Core/OAuth/FakeSerializer.cs b/HubSpot.NET/Core/OAuth/FakeSerializer.cs index 0de96a4..e7e1220 100644 --- a/HubSpot.NET/Core/OAuth/FakeSerializer.cs +++ b/HubSpot.NET/Core/OAuth/FakeSerializer.cs @@ -1,13 +1,14 @@ namespace HubSpot.NET.Core.OAuth { - using RestSharp.Serializers; + using RestSharp; + using RestSharp.Serializers; internal class FakeSerializer : ISerializer { public string RootElement { get; set; } public string Namespace { get; set; } public string DateFormat { get; set; } - public string ContentType { get; set; } + public ContentType ContentType { get; set; } internal FakeSerializer() { diff --git a/HubSpot.NET/Core/OAuth/HubSpotOAuthApi.cs b/HubSpot.NET/Core/OAuth/HubSpotOAuthApi.cs index 2d52f34..2f30c73 100644 --- a/HubSpot.NET/Core/OAuth/HubSpotOAuthApi.cs +++ b/HubSpot.NET/Core/OAuth/HubSpotOAuthApi.cs @@ -91,7 +91,7 @@ private HubSpotToken InitiateRequest(K model, string basePath, params OAuthSc RestRequest request = new RestRequest(MidRoute) { - JsonSerializer = new FakeSerializer() + //JsonSerializer = new FakeSerializer() }; Dictionary jsonPreStringPairs = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(model)); @@ -111,7 +111,7 @@ private HubSpotToken InitiateRequest(K model, string basePath, params OAuthSc if (builder.Length > 0) request.AddQueryParameter("scope", builder.ToString()); - IRestResponse serverReponse = client.Post(request); + RestResponse serverReponse = client.ExecutePost(request); if (serverReponse.ResponseStatus != ResponseStatus.Completed) throw new HubSpotException("Server did not respond to authorization request. Content: " + serverReponse.Content, new HubSpotError(serverReponse.StatusCode, serverReponse.Content), serverReponse.Content); diff --git a/HubSpot.NET/Core/RestSharpExtensions.cs b/HubSpot.NET/Core/RestSharpExtensions.cs index 0b3f295..73d0de3 100644 --- a/HubSpot.NET/Core/RestSharpExtensions.cs +++ b/HubSpot.NET/Core/RestSharpExtensions.cs @@ -9,7 +9,7 @@ namespace HubSpot.NET.Core { public static class RestSharpExtensions { - public static bool IsSuccessful(this IRestResponse response) + public static bool IsSuccessful(this RestResponse response) { return (int) response.StatusCode >= 200 && (int) response.StatusCode <= 299 diff --git a/HubSpot.NET/Core/Serializers/NewtonsoftRestSharpSerializer.cs b/HubSpot.NET/Core/Serializers/NewtonsoftRestSharpSerializer.cs index cafccdc..a3a0577 100644 --- a/HubSpot.NET/Core/Serializers/NewtonsoftRestSharpSerializer.cs +++ b/HubSpot.NET/Core/Serializers/NewtonsoftRestSharpSerializer.cs @@ -5,7 +5,8 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Serialization; - using RestSharp.Serializers; + using RestSharp; + using RestSharp.Serializers; public class NewtonsoftRestSharpSerializer : ISerializer { @@ -43,6 +44,6 @@ public NewtonsoftRestSharpSerializer() /// /// Content type for serialized content /// - public string ContentType { get; set; } + public ContentType ContentType { get; set; } } } diff --git a/HubSpot.NET/HubSpot.NET.csproj b/HubSpot.NET/HubSpot.NET.csproj index 85a8a5a..520aba5 100644 --- a/HubSpot.NET/HubSpot.NET.csproj +++ b/HubSpot.NET/HubSpot.NET.csproj @@ -1,7 +1,7 @@  - net452;net451;netstandard2.0 + net462;netstandard2.0 true 1.5.2 Chinchilla Software Limited @@ -90,10 +90,10 @@ - + - - + + @@ -101,8 +101,8 @@ - - + + From 765b11df70497eaaa43cf8eb7e90d2c886c4b4cd Mon Sep 17 00:00:00 2001 From: William Roush Date: Wed, 7 May 2025 04:26:05 +0000 Subject: [PATCH 2/6] Open v1.5.3 --- HubSpot.NET/HubSpot.NET.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HubSpot.NET/HubSpot.NET.csproj b/HubSpot.NET/HubSpot.NET.csproj index 520aba5..35f356c 100644 --- a/HubSpot.NET/HubSpot.NET.csproj +++ b/HubSpot.NET/HubSpot.NET.csproj @@ -3,7 +3,7 @@ net462;netstandard2.0 true - 1.5.2 + 1.5.3 Chinchilla Software Limited Chinchilla Software Limited C# .NET Wrapper around the common HubSpot APIs. @@ -107,4 +107,4 @@ - \ No newline at end of file + From cb2cf25831eebd34386679bc2358dd479d449306 Mon Sep 17 00:00:00 2001 From: William Roush Date: Wed, 7 May 2025 04:39:10 +0000 Subject: [PATCH 3/6] Update package information --- HubSpot.NET/HubSpot.NET.csproj | 18 ++++++++++-------- LICENSE | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/HubSpot.NET/HubSpot.NET.csproj b/HubSpot.NET/HubSpot.NET.csproj index 35f356c..276da57 100644 --- a/HubSpot.NET/HubSpot.NET.csproj +++ b/HubSpot.NET/HubSpot.NET.csproj @@ -4,17 +4,19 @@ net462;netstandard2.0 true 1.5.3 - Chinchilla Software Limited - Chinchilla Software Limited + RoushTech, LLC + RoushTech, LLC C# .NET Wrapper around the common HubSpot APIs. - 2023 Chinchilla Software Limited. - - https://github.com/Chinchilla-Software-Com/HubSpot.NET - https://github.com/Chinchilla-Software-Com/HubSpot.NET + 2025 RoushTech, LLC + https://github.com/RoushTech/HubSpot.NET/blob/master/LICENSE + https://github.com/RoushTech/HubSpot.NET + https://github.com/RoushTech/HubSpot.NET hubspot api wrapper c# contact company deal engagement properties crm + Version 1.5.3 + + * Update RestSharp - community contribution thanks to https://github.com/middiu + Version 1.5.2 * Implement Ticket to Deal Associations - community contribution thanks to https://github.com/avalanchis diff --git a/LICENSE b/LICENSE index db834f5..94900f5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 Squared Up +Copyright (c) 2025, RoushTech, LLC, 2024 Chinchilla Software Limited, 2018 Squared Up Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From de3ab42bcc91c7eb35dbdbf35cf9fab3a2e71fce Mon Sep 17 00:00:00 2001 From: William Roush Date: Wed, 7 May 2025 05:00:19 +0000 Subject: [PATCH 4/6] Move to VerisonPrefix for CI/CD --- HubSpot.NET/HubSpot.NET.csproj | 4 ++-- HubSpot.NET/images/.gitkeep | 0 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 HubSpot.NET/images/.gitkeep diff --git a/HubSpot.NET/HubSpot.NET.csproj b/HubSpot.NET/HubSpot.NET.csproj index 276da57..7dce97f 100644 --- a/HubSpot.NET/HubSpot.NET.csproj +++ b/HubSpot.NET/HubSpot.NET.csproj @@ -3,12 +3,12 @@ net462;netstandard2.0 true - 1.5.3 + 1.5.3 RoushTech, LLC RoushTech, LLC C# .NET Wrapper around the common HubSpot APIs. 2025 RoushTech, LLC - https://github.com/RoushTech/HubSpot.NET/blob/master/LICENSE + MIT https://github.com/RoushTech/HubSpot.NET https://github.com/RoushTech/HubSpot.NET hubspot api wrapper c# contact company deal engagement properties crm diff --git a/HubSpot.NET/images/.gitkeep b/HubSpot.NET/images/.gitkeep new file mode 100644 index 0000000..e69de29 From 54c412df07f49950fb0e7f81b96c3a07bc7f3778 Mon Sep 17 00:00:00 2001 From: William Roush Date: Wed, 7 May 2025 06:46:54 +0000 Subject: [PATCH 5/6] Update package ID --- .../HubSpot.NET.Tests.Integration.csproj | 22 ++++++++----------- HubSpot.NET/HubSpot.NET.csproj | 4 ++-- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/HubSpot.NET.Tests.Integration/HubSpot.NET.Tests.Integration.csproj b/HubSpot.NET.Tests.Integration/HubSpot.NET.Tests.Integration.csproj index 32a0c53..c9a3baf 100644 --- a/HubSpot.NET.Tests.Integration/HubSpot.NET.Tests.Integration.csproj +++ b/HubSpot.NET.Tests.Integration/HubSpot.NET.Tests.Integration.csproj @@ -1,21 +1,22 @@  - net472;netcoreapp3.1 + net472;net9.0 false - - - - + + + + - - - + + + + @@ -36,9 +37,4 @@ Never - - - - - \ No newline at end of file diff --git a/HubSpot.NET/HubSpot.NET.csproj b/HubSpot.NET/HubSpot.NET.csproj index 7dce97f..9fbc858 100644 --- a/HubSpot.NET/HubSpot.NET.csproj +++ b/HubSpot.NET/HubSpot.NET.csproj @@ -1,7 +1,7 @@  - net462;netstandard2.0 + netstandard2.0 true 1.5.3 RoushTech, LLC @@ -59,7 +59,7 @@ * Added ability to filter owners by email address when calling for all owners * Removed dependency on Flurl. - Chinchilla.HubSpot.NET + RoushTech.HubSpot.NET From ff7cd935c2731648554e14a423c6648f9cd3b9f8 Mon Sep 17 00:00:00 2001 From: William Roush Date: Wed, 7 May 2025 23:55:52 +0000 Subject: [PATCH 6/6] Add readme --- HubSpot.NET/HubSpot.NET.csproj | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/HubSpot.NET/HubSpot.NET.csproj b/HubSpot.NET/HubSpot.NET.csproj index 9fbc858..3c23cbb 100644 --- a/HubSpot.NET/HubSpot.NET.csproj +++ b/HubSpot.NET/HubSpot.NET.csproj @@ -60,6 +60,7 @@ * Removed dependency on Flurl. RoushTech.HubSpot.NET + README.md @@ -68,6 +69,10 @@ snupkg + + + + True