├── .gitattributes
├── .gitignore
├── Build.ps1
├── Directory.Build.props
├── LICENSE
├── README.md
├── appveyor.yml
├── dotnetcore-hubspot-client.sln
├── src
├── Associations
│ ├── AssociationListRequestOptions.cs
│ ├── Dto
│ │ ├── AssociationHubSpotEntity.cs
│ │ └── AssociationListHubSpotEntity.cs
│ ├── HubSpotAssociationsClient.cs
│ └── Interfaces
│ │ ├── IAssociationHubSpotEntity.cs
│ │ ├── IAssociationListHubSpotEntity.cs
│ │ └── IHubSpotAssociationsClient.cs
├── Common
│ ├── Dto
│ │ └── Properties
│ │ │ ├── PropertyHubSpotEntity.cs
│ │ │ ├── PropertyListHubSpotEntity.cs
│ │ │ └── PropertyOptionHubSpotEntity.cs
│ └── Interfaces
│ │ └── IPropertyHubSpotEntity.cs
├── Company
│ ├── CompanyListRequestOptions.cs
│ ├── CompanySearchByDomain.cs
│ ├── CompanySearchOffset.cs
│ ├── CompanySearchRequestOptions.cs
│ ├── Dto
│ │ ├── CompanyHubSpotEntity.cs
│ │ ├── CompanyListHubSpotEntity.cs
│ │ ├── CompanyPropertyHubSpotEntity.cs
│ │ └── CompanySearchResultEntity.cs
│ ├── HubSpotCompanyClient.cs
│ └── Interfaces
│ │ ├── ICompanyHubSpotEntity.cs
│ │ ├── ICompanyListHubSpotEntity.cs
│ │ ├── ICompanyPropertyHubSpotEntity.cs
│ │ ├── ICompanySearchResultEntity.cs
│ │ └── IHubSpotCompanyClient.cs
├── Contact
│ ├── ContactFormSubmissionMode.cs
│ ├── ContactGetRequestOptions.cs
│ ├── ContactRequestOptions.cs
│ ├── Dto
│ │ ├── ContactHubSpotEntity.cs
│ │ └── ContactListHubSpotEntity.cs
│ ├── HubSpotContactClient.cs
│ └── Interfaces
│ │ ├── IContactHubSpotEntity.cs
│ │ ├── IContactListHubSpotEntity.cs
│ │ └── IHubSpotContactClient.cs
├── Core
│ ├── HubSpotAction.cs
│ ├── HubSpotAssociationDefinitions.cs
│ ├── HubSpotBaseClient.cs
│ ├── Interfaces
│ │ └── IHubSpotEntity.cs
│ ├── JsonContent.cs
│ ├── NoopLogger.cs
│ ├── NoopLoggerFactory.cs
│ ├── ReflectionExtensions.cs
│ └── Requests
│ │ ├── HubspotDataEntityProp.cs
│ │ ├── RequestDataConverter.cs
│ │ └── RequestSerializer.cs
├── Deal
│ ├── DealListRequestOptions.cs
│ ├── Dto
│ │ ├── DealHubSpotAssociations.cs
│ │ ├── DealHubSpotEntity.cs
│ │ ├── DealListHubSpotEntity.cs
│ │ └── DealPropertyHubSpotEntity.cs
│ ├── HubSpotDealClient.cs
│ └── Interfaces
│ │ ├── IDealHubSpotEntity.cs
│ │ ├── IDealListHubSpotEntity.cs
│ │ ├── IDealPropertyHubSpotEntity.cs
│ │ └── IHubSpotDealClient.cs
├── HubSpotException.cs
├── LineItem
│ ├── Dto
│ │ ├── LineItemHubSpotEntity.cs
│ │ └── LineItemListHubSpotEntity.cs
│ ├── HubSpotLineItemClient.cs
│ └── Interfaces
│ │ ├── IHubSpotLineItemClient.cs
│ │ ├── ILineItemHubSpotEntity.cs
│ │ ├── ILineItemListHubSpotEntity.cs
│ │ ├── LineItemListRequestOptions.cs
│ │ ├── LineItemRequestOptions.cs
│ │ └── ListOfLineItemIds.cs
├── ListOfContacts
│ ├── Dto
│ │ ├── ContactListFilter.cs
│ │ ├── ContactListMetaData.cs
│ │ ├── CreateContactListRequestHubSpotEntity.cs
│ │ ├── CreateContactListResponseHubSpotEntity.cs
│ │ ├── HubSpotListOfContactsEntity.cs
│ │ ├── ListOfContactListsHubSpotEntity.cs
│ │ └── ListOfContactsHubSpotEntity.cs
│ ├── HubSpotListOfContactsClient.cs
│ ├── Interfaces
│ │ ├── IContactListFilter.cs
│ │ ├── ICreateContactListRequestHubSpotEntity.cs
│ │ ├── IHubSpotListOfContactsClient.cs
│ │ ├── IHubSpotListOfContactsEntity.cs
│ │ └── IListOfContactsHubSpotEntity.cs
│ ├── ListOfContactListsRequestOptions.cs
│ └── ListOfContactsRequestOptions.cs
├── Owner
│ ├── Dto
│ │ └── OwnerHubSpotEntity.cs
│ ├── HubSpotOwnerClient.cs
│ ├── Interfaces
│ │ ├── IHubSpotOwnerClient.cs
│ │ └── IOwnerHubSpotEntity.cs
│ └── OwnerListRequestOptions.cs
├── Properties
│ └── AssemblyInfo.cs
└── hubspot-client.csproj
└── test
├── functional
├── Association
│ └── HubSpotAssociationClientFunctionalTest.cs
├── Company
│ └── HubSpotCompanyClientFunctionalTest.cs
├── Contact
│ └── HubSpotContactClientFunctionalTest.cs
├── Deal
│ └── HubSpotDealClientFunctionalTest.cs
├── FunctionalTestBase.cs
├── LineItem
│ └── HubSpotLineItemClientFunctionalTest.cs
├── Mocks
│ ├── Association
│ │ ├── CreateAssociationMockTestCase.cs
│ │ ├── CreateBatchAssociationMockTestCase.cs
│ │ ├── CreateBatchAssociationMockTestFailCase.cs
│ │ ├── DeleteAssociationMockTestCase.cs
│ │ ├── DeleteBatchAssociationMockTestCase.cs
│ │ └── ListAssociationMockTestCase.cs
│ ├── Company
│ │ ├── CreateCompanyMockTestCase.cs
│ │ ├── DeleteCompanyMockTestCase.cs
│ │ ├── GetCompanyByIdNotFoundMockTestCase.cs
│ │ ├── GetCompanyMockTestCase.cs
│ │ ├── ListCompanyMockTestCase.cs
│ │ ├── SearchByDomainMockTestCase.cs
│ │ └── UpdateCompanyMockTestCase.cs
│ ├── Contact
│ │ ├── CreateContactMockTestCase.cs
│ │ ├── CreateOrUpdateContactMockTestCase.cs
│ │ ├── DeleteContactMockTestCase.cs
│ │ ├── GetContactByEmailMockTestCase.cs
│ │ ├── GetContactByEmailNotFoundMockTestCase.cs
│ │ ├── GetContactMockTestCase.cs
│ │ ├── ListContactMockTestCase.cs
│ │ └── UpdateContactMockTestCase.cs
│ ├── Deal
│ │ ├── CreateDealMockTestCase.cs
│ │ ├── DeleteDealMockTestCase.cs
│ │ ├── GetDealByIdNotFoundMockTestCase.cs
│ │ ├── GetDealMockTestCase.cs
│ │ └── UpdateDealMockTestCase.cs
│ ├── LineItem
│ │ ├── CreateBatchLineItemMockTestCase.cs
│ │ ├── CreateLineItemMockTestCase.cs
│ │ ├── DeleteBatchLineItemMockTestCase.cs
│ │ ├── DeleteLineItemMockTestCase.cs
│ │ ├── GetLineItemMockTestCase.cs
│ │ ├── GetLineItemNotFoundMockTestCase.cs
│ │ ├── ListLineItemMockTestCase.cs
│ │ ├── ReadBatchLineItemMockTestCase.cs
│ │ ├── UpdateBatchLineItemMockTestCase.cs
│ │ └── UpdateLineItemMockTestCase.cs
│ └── Owner
│ │ ├── GetOwnerByIdNotFoundMockTestCase.cs
│ │ ├── GetOwnerMockTestCase.cs
│ │ └── ListOwnerMockTestCase.cs
├── Owner
│ └── HubSpotOwnerClientFunctionalTest.cs
└── functional.csproj
├── integration
├── Company
│ └── HubSpotCompanyClientIntegrationTest.cs
├── Contact
│ ├── Dto
│ │ └── ContactHubSpotEntityExtended.cs
│ └── HubSpotContactClientIntegrationTest.cs
├── Deal
│ └── HubSpotDealClientIntegrationTest.cs
├── IntegrationTestBase.cs
└── integration.csproj
└── unit
├── Association
└── HubSpotAssociationClientTest.cs
├── Company
└── HubSpotCompanyClientTest.cs
├── Contact
├── HubSpotContactClientTest.cs
└── ListContactsRequestOptionsTest.cs
├── Core
├── HubspotExceptionTest.cs
├── ReflectionExtensionTest.cs
└── Requests
│ ├── RequestDataConverterTest.cs
│ └── RequestSerializerTest.cs
├── Deal
└── HubSpotDealClientTest.cs
├── LineItem
└── HubSpotLineItemClientTest.cs
├── Owner
└── HubSpotOwnerClientTest.cs
├── UnitTestBase.cs
└── unit.csproj
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/Build.ps1:
--------------------------------------------------------------------------------
1 | # Taken from psake https://github.com/psake/psake
2 |
3 | <#
4 | .SYNOPSIS
5 | This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode
6 | to see if an error occcured. If an error is detected then an exception is thrown.
7 | This function allows you to run command-line programs without having to
8 | explicitly check the $lastexitcode variable.
9 | .EXAMPLE
10 | exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN command-line client is installed"
11 | #>
12 | function Exec
13 | {
14 | [CmdletBinding()]
15 | param(
16 | [Parameter(Position=0,Mandatory=1)][scriptblock]$cmd,
17 | [Parameter(Position=1,Mandatory=0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd)
18 | )
19 | & $cmd
20 | if ($lastexitcode -ne 0) {
21 | throw ("Exec: " + $errorMessage)
22 | }
23 | }
24 |
25 | if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse }
26 |
27 | exec { & dotnet restore }
28 |
29 | $revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
30 | $revision = "{0:D4}" -f [convert]::ToInt32($revision, 10)
31 |
32 | exec { & dotnet build }
33 |
34 | exec { & dotnet test .\test\unit\unit.csproj -c Release }
35 | exec { & dotnet test .\test\functional\functional.csproj -c Release }
36 | exec { & dotnet test .\test\integration\integration.csproj -c Release }
37 |
38 | exec { & dotnet pack .\src\hubspot-client.csproj -c Release -o .\artifacts --include-source }
39 |
--------------------------------------------------------------------------------
/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | latest
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 SKARP ApS
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | version: '{build}'
2 | # Build worker image (VM template)
3 | image: Visual Studio 2022
4 | environment:
5 | HUBSPOT_API_KEY:
6 | secure: nEkpqjqVe4G73k8gkmpYndR8GGQdK58k98IxzWwoZS4Rvq+bTOR9Yok2ISgjjNWr
7 | HUBSPOT_API_TOKEN:
8 | secure: nWXtqDplY3BMELyLFkxVlKcMECU4+rs9sJuWaNkFbHik3n9VOeRGPLOGsUN3UMAz
9 | pull_requests:
10 | do_not_increment_build_number: true
11 | branches:
12 | only:
13 | - master
14 | nuget:
15 | disable_publish_on_pr: true
16 | build_script:
17 | - ps: .\Build.ps1
18 | test: off
19 | artifacts:
20 | - path: '**\*.nupkg'
21 | name: NuGet
22 | deploy:
23 | - provider: NuGet
24 | name: production
25 | api_key:
26 | secure: ZT7fXPicb4xNWbc+ciajbmrXRTiMSjwQFkF5wrGIhcLW96WHQBFQjSZTDfn+ldbY
27 | skip_symbols: true
28 | on:
29 | appveyor_repo_tag: true
--------------------------------------------------------------------------------
/src/Associations/AssociationListRequestOptions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Skarp.HubSpotClient.Associations
6 | {
7 | public class AssociationListRequestOptions
8 | {
9 | private int _numberOfAssociationsToReturn = 100;
10 |
11 | ///
12 | /// Gets or sets the number of associations to return.
13 | ///
14 | ///
15 | /// Defaults to 20 which is also the hubspot api default. Max value is 100
16 | ///
17 | ///
18 | /// The number of contacts to return.
19 | ///
20 | public int NumberOfAssociationsToReturn
21 | {
22 | get => _numberOfAssociationsToReturn;
23 | set
24 | {
25 | if (value < 1 || value > 100)
26 | {
27 | throw new ArgumentException(
28 | $"Number of associations to return must be a positive ingeteger greater than 0 and less than 101 - you provided {value}");
29 | }
30 | _numberOfAssociationsToReturn = value;
31 | }
32 | }
33 |
34 | public long? AssociationOffset { get; set; } = null;
35 |
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Associations/Dto/AssociationHubSpotEntity.cs:
--------------------------------------------------------------------------------
1 | using Skarp.HubSpotClient.Associations.Interfaces;
2 | using Skarp.HubSpotClient.Core;
3 | using System.Runtime.Serialization;
4 |
5 | namespace Skarp.HubSpotClient.Associations.Dto
6 | {
7 | [DataContract]
8 | public class AssociationHubSpotEntity : IAssociationHubSpotEntity
9 | {
10 | [DataMember(Name = "fromObjectId")]
11 | public long FromObjectId { get; set; }
12 | [DataMember(Name = "toObjectId")]
13 | public long ToObjectId { get; set; }
14 |
15 | [DataMember(Name = "category")]
16 | public string Category => "HUBSPOT_DEFINED";
17 |
18 | [DataMember(Name = "definitionId")]
19 | public int DefinitionId { get; set; }
20 |
21 | public string RouteBasePath => "/crm-associations/v1";
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Associations/Dto/AssociationListHubSpotEntity.cs:
--------------------------------------------------------------------------------
1 | using Skarp.HubSpotClient.Associations.Interfaces;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Runtime.Serialization;
5 | using System.Text;
6 |
7 | namespace Skarp.HubSpotClient.Associations.Dto
8 | {
9 | [DataContract]
10 | public class AssociationListHubSpotEntity : IAssociationListHubSpotEntity
11 | {
12 | [DataMember(Name = "results")]
13 | public IList Results { get; set; } = new List();
14 | [DataMember(Name = "hasMore")]
15 | public bool MoreResultsAvailable { get; set; }
16 | [DataMember(Name = "offset")]
17 | public long ContinuationOffset { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Associations/Interfaces/IAssociationHubSpotEntity.cs:
--------------------------------------------------------------------------------
1 | using Skarp.HubSpotClient.Core;
2 |
3 | namespace Skarp.HubSpotClient.Associations.Interfaces
4 | {
5 | // not using IHubSpotEntity because the api does not map to and from with property values. Mostly uses just ids
6 | public interface IAssociationHubSpotEntity
7 | {
8 | long FromObjectId { get; set; }
9 | long ToObjectId { get; set; }
10 | string Category { get; }
11 | int DefinitionId { get; set; }
12 | string RouteBasePath { get; }
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/Associations/Interfaces/IAssociationListHubSpotEntity.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Skarp.HubSpotClient.Associations.Interfaces
4 | {
5 | public interface IAssociationListHubSpotEntity
6 | {
7 | ///
8 | /// Gets or sets the association results.
9 | ///
10 | ///
11 | /// The contacts.
12 | ///
13 | IList Results { get; set; }
14 |
15 | ///
16 | /// Gets or sets a value indicating whether more results are available.
17 | ///
18 | ///
19 | /// This is a mapping of the "has-more" prop in the JSON return data from HubSpot
20 | ///
21 | ///
22 | /// true if [more results available]; otherwise, false.
23 | ///
24 | bool MoreResultsAvailable { get; set; }
25 |
26 | ///
27 | /// Gets or sets the continuation offset.
28 | ///
29 | ///
30 | /// This is a mapping of the "vid-offset" prop in the JSON reeturn data from HubSpot
31 | ///
32 | ///
33 | /// The continuation offset.
34 | ///
35 | long ContinuationOffset { get; set; }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Associations/Interfaces/IHubSpotAssociationsClient.cs:
--------------------------------------------------------------------------------
1 | using Skarp.HubSpotClient.Associations.Interfaces;
2 | using Skarp.HubSpotClient.Core;
3 | using System.Collections.Generic;
4 | using System.Threading.Tasks;
5 |
6 | namespace Skarp.HubSpotClient.Associations
7 | {
8 | public interface IHubSpotAssociationsClient
9 | {
10 | ///
11 | /// Create association based on definition id
12 | ///
13 | ///
14 | ///
15 | Task Create(T entity);
16 | ///
17 | /// Create in batch associations based on definition id
18 | ///
19 | ///
20 | ///
21 | Task CreateBatch(List entities);
22 | ///
23 | /// Delete association based on definition id
24 | ///
25 | ///
26 | ///
27 | Task Delete(T entity);
28 | ///
29 | /// Delete in batch associations based on definition id
30 | ///
31 | ///
32 | ///
33 | Task DeleteBatch(List entities);
34 | ///
35 | /// Return a list of associations for a CRM object by id from hubspot based on the association definition id
36 | ///
37 | /// Object ID for which to list its associations
38 | /// The definition ID of the associations to list
39 | /// Additional request options, use for limiting and pagination
40 | ///
41 | Task> GetListByIdAsync(long fromObjectId, HubSpotAssociationDefinitions definitionId, AssociationListRequestOptions opts = null);
42 | }
43 | }
--------------------------------------------------------------------------------
/src/Common/Dto/Properties/PropertyHubSpotEntity.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Runtime.Serialization;
3 | using Skarp.HubSpotClient.Common.Interfaces;
4 |
5 | namespace Skarp.HubSpotClient.Common.Dto.Properties
6 | {
7 | [DataContract]
8 | public class PropertyHubSpotEntity : IPropertyHubSpotEntity
9 | {
10 | [DataMember(Name = "name")]
11 | public string Name { get; set; }
12 |
13 | [DataMember(Name = "label")]
14 | public string Label { get; set; }
15 |
16 | [DataMember(Name = "description")]
17 | public string Description { get; set; }
18 |
19 | [DataMember(Name = "groupName")]
20 | public string GroupName { get; set; }
21 |
22 | [DataMember(Name = "type")]
23 | public string Type { get; set; }
24 |
25 | [DataMember(Name = "fieldType")]
26 | public string FieldType { get; set; }
27 |
28 | [DataMember(Name = "options")]
29 | public List Options { get; set; }
30 |
31 | public bool IsNameValue => false;
32 |
33 | public string RouteBasePath => "/properties/v1";
34 |
35 | public virtual void ToHubSpotDataEntity(ref dynamic dataEntity)
36 | {
37 |
38 | }
39 |
40 | public virtual void FromHubSpotDataEntity(dynamic hubspotData)
41 | {
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/Common/Dto/Properties/PropertyListHubSpotEntity.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.Runtime.Serialization;
4 | using Skarp.HubSpotClient.Common.Interfaces;
5 | using Skarp.HubSpotClient.Core.Interfaces;
6 |
7 | namespace Skarp.HubSpotClient.Common.Dto.Properties
8 | {
9 | [DataContract]
10 | public class PropertyListHubSpotEntity : IHubSpotEntity, ICollection
11 | where T : IPropertyHubSpotEntity
12 | {
13 | private List Properties { get; } = new();
14 |
15 | public bool IsNameValue => false;
16 |
17 | public IEnumerator GetEnumerator()
18 | => Properties.GetEnumerator();
19 |
20 | IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
21 |
22 | public void Add(T item)
23 | => Properties.Add(item);
24 |
25 | public void Clear()
26 | => Properties.Clear();
27 |
28 | public bool Contains(T item)
29 | => Properties.Contains(item);
30 |
31 | public void CopyTo(T[] array, int arrayIndex)
32 | => Properties.CopyTo(array, arrayIndex);
33 |
34 | public bool Remove(T item)
35 | => Properties.Remove(item);
36 |
37 | public int Count
38 | => Properties.Count;
39 |
40 | public bool IsReadOnly
41 | => false;
42 |
43 | public virtual void ToHubSpotDataEntity(ref dynamic dataEntity)
44 | {
45 |
46 | }
47 |
48 | public virtual void FromHubSpotDataEntity(dynamic hubspotData)
49 | {
50 |
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/Common/Dto/Properties/PropertyOptionHubSpotEntity.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace Skarp.HubSpotClient.Common.Dto.Properties
4 | {
5 | [DataContract]
6 | public class PropertyOptionHubSpotEntity
7 | {
8 | [DataMember(Name = "label")]
9 | public string Label { get; set; }
10 |
11 | [DataMember(Name = "value")]
12 | public string Value { get; set; }
13 |
14 | [DataMember(Name = "description")]
15 | public string Description { get; set; }
16 |
17 | [DataMember(Name = "readOnly")]
18 | public bool? ReadOnly { get; set; }
19 |
20 | [DataMember(Name = "hidden")]
21 | public bool Hidden { get; set; }
22 |
23 | [DataMember(Name = "displayOrder")]
24 | public long DisplayOrder { get; set; }
25 |
26 | [DataMember(Name = "doubleData")]
27 | public object DoubleData { get; set; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Common/Interfaces/IPropertyHubSpotEntity.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Skarp.HubSpotClient.Common.Dto.Properties;
3 | using Skarp.HubSpotClient.Core.Interfaces;
4 |
5 | namespace Skarp.HubSpotClient.Common.Interfaces
6 | {
7 | public interface IPropertyHubSpotEntity : IHubSpotEntity
8 | {
9 | string Name { get; set; }
10 |
11 | string Label { get; set; }
12 |
13 | string Description { get; set; }
14 |
15 | string GroupName { get; set; }
16 |
17 | string Type { get; set; }
18 |
19 | string FieldType { get; set; }
20 |
21 | string RouteBasePath { get; }
22 |
23 | List Options { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Company/CompanyListRequestOptions.cs:
--------------------------------------------------------------------------------
1 | using Skarp.HubSpotClient.Core.Interfaces;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Skarp.HubSpotClient.Company
7 | {
8 | public class CompanyListRequestOptions
9 | {
10 | private int _numberOfCompaniesToReturn = 100;
11 |
12 | ///
13 | /// Gets or sets the number of companies to return.
14 | ///
15 | ///
16 | /// Defaults to 20 which is also the hubspot api default. Max value is 100
17 | ///
18 | ///
19 | /// The number of companies to return.
20 | ///
21 | public int NumberOfCompaniesToReturn
22 | {
23 | get => _numberOfCompaniesToReturn;
24 | set
25 | {
26 | if (value < 1 || value > 250)
27 | {
28 | throw new ArgumentException(
29 | $"Number of companies to return must be a positive ingeteger greater than 0 and less than 251 - you provided {value}");
30 | }
31 | _numberOfCompaniesToReturn = value;
32 | }
33 | }
34 |
35 | ///
36 | /// Get or set the continuation offset when calling list many times to enumerate all your companies
37 | ///
38 | ///
39 | /// The return DTO from List contains the current "offset" that you can inject into your next list call
40 | /// to continue the listing process
41 | ///
42 | public long? CompanyOffset { get; set; } = null;
43 | public List PropertiesToInclude { get; set; } = new List();
44 |
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Company/CompanySearchByDomain.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace Skarp.HubSpotClient.Company
4 | {
5 | [DataContract]
6 | public class CompanySearchByDomain
7 | {
8 | [DataMember(Name = "limit")]
9 | public int Limit { get; set; } = 100;
10 |
11 | [DataMember(Name = "requestOptions")]
12 | public CompanySearchRequestOptions RequestOptions { get; set; } = new CompanySearchRequestOptions();
13 |
14 | [DataMember(Name = "offset")]
15 | public CompanySearchOffset Offset { get; set; } = new CompanySearchOffset();
16 |
17 | public string RouteBasePath => "/companies/v2";
18 | public bool IsNameValue => true;
19 | public void AcceptHubSpotDataEntity(ref object converted)
20 | {
21 |
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/Company/CompanySearchOffset.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace Skarp.HubSpotClient.Company
4 | {
5 | [DataContract]
6 | public class CompanySearchOffset
7 | {
8 |
9 | [DataMember(Name = "isPrimary")]
10 | public bool IsPrimary { get; set; } = true;
11 |
12 | [DataMember(Name = "companyId")]
13 | public long CompanyId { get; set; } = 0;
14 | }
15 | }
--------------------------------------------------------------------------------
/src/Company/CompanySearchRequestOptions.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Runtime.Serialization;
3 |
4 | namespace Skarp.HubSpotClient.Company
5 | {
6 | [DataContract]
7 | public class CompanySearchRequestOptions
8 | {
9 | [DataMember(Name = "properties")]
10 | public List Properties { get; set; } = new List { "domain", "name", "website" };
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Company/Dto/CompanyHubSpotEntity.cs:
--------------------------------------------------------------------------------
1 | using Skarp.HubSpotClient.Company.Interfaces;
2 | using System.Runtime.Serialization;
3 |
4 | namespace Skarp.HubSpotClient.Company.Dto
5 | {
6 | [DataContract]
7 | public class CompanyHubSpotEntity : ICompanyHubSpotEntity
8 | {
9 | [IgnoreDataMember]
10 | [DataMember(Name = "companyId")]
11 | public long? Id { get; set; }
12 |
13 | [DataMember(Name = "hubspot_owner_id")]
14 | public long? OwnerId { get; set; }
15 |
16 | [DataMember(Name = "name")]
17 | public string Name { get; set; }
18 |
19 | [DataMember(Name = "domain")]
20 | public string Domain { get; set; }
21 |
22 | [DataMember(Name = "website")]
23 | public string Website { get; set; }
24 |
25 | [DataMember(Name = "description")]
26 | public string Description { get; set; }
27 |
28 | public string RouteBasePath => "/companies/v2";
29 | public bool IsNameValue => true;
30 | public virtual void ToHubSpotDataEntity(ref dynamic converted)
31 | {
32 |
33 | }
34 |
35 | public virtual void FromHubSpotDataEntity(dynamic hubspotData)
36 | {
37 |
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/Company/Dto/CompanyListHubSpotEntity.cs:
--------------------------------------------------------------------------------
1 | using Skarp.HubSpotClient.Company.Interfaces;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Runtime.Serialization;
5 | using System.Text;
6 |
7 | namespace Skarp.HubSpotClient.Company.Dto
8 | {
9 | [DataContract]
10 | public class CompanyListHubSpotEntity : ICompanyListHubSpotEntity where T : ICompanyHubSpotEntity
11 | {
12 | ///
13 | ///
14 | /// Gets or sets the companies.
15 | ///
16 | ///
17 | /// The companies.
18 | ///
19 | [DataMember(Name = "companies")]
20 | public IList Companies { get; set; } = new List();
21 |
22 | ///
23 | ///
24 | /// Gets or sets a value indicating whether more results are available.
25 | ///
26 | ///
27 | /// true if [more results available]; otherwise, false.
28 | ///
29 | ///
30 | /// This is a mapping of the "has-more" prop in the JSON return data from HubSpot
31 | ///
32 | [DataMember(Name = "has-more")]
33 | public bool MoreResultsAvailable { get; set; }
34 |
35 | ///
36 | ///
37 | /// Gets or sets the continuation offset.
38 | ///
39 | ///
40 | /// The continuation offset.
41 | ///
42 | ///
43 | /// This is a mapping of the "offset" prop in the JSON reeturn data from HubSpot
44 | ///
45 | [DataMember(Name = "offset")]
46 | public long ContinuationOffset { get; set; }
47 |
48 | public string RouteBasePath => "/companies/v2";
49 |
50 | public bool IsNameValue => false;
51 | public List PropertiesToInclude { get; set; } = new List();
52 | public virtual void ToHubSpotDataEntity(ref dynamic converted)
53 | {
54 |
55 | }
56 |
57 | public virtual void FromHubSpotDataEntity(dynamic hubspotData)
58 | {
59 |
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/Company/Dto/CompanyPropertyHubSpotEntity.cs:
--------------------------------------------------------------------------------
1 | using Skarp.HubSpotClient.Common.Dto.Properties;
2 | using Skarp.HubSpotClient.Company.Interfaces;
3 |
4 | namespace Skarp.HubSpotClient.Company.Dto
5 | {
6 | ///
7 | /// Deal Property
8 | ///
9 | /// Documentation
10 | public class CompanyPropertyHubSpotEntity : PropertyHubSpotEntity, ICompanyPropertyHubSpotEntity
11 | {
12 |
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/Company/Dto/CompanySearchResultEntity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Runtime.Serialization;
4 | using System.Text;
5 | using Skarp.HubSpotClient.Company.Interfaces;
6 | using Skarp.HubSpotClient.Contact.Interfaces;
7 |
8 | namespace Skarp.HubSpotClient.Company.Dto
9 | {
10 | [DataContract]
11 | public class CompanySearchResultEntity : ICompanySearchResultEntity where T : ICompanyHubSpotEntity
12 | {
13 | [DataMember(Name = "results")]
14 | public IList Results { get; set; }
15 |
16 | [DataMember(Name = "hasMore")]
17 | public bool MoreResultsAvailable { get; set; }
18 |
19 | [DataMember(Name="offset")]
20 | public CompanySearchOffset Offset { get; set; }
21 |
22 | public bool IsNameValue => false;
23 |
24 | public void ToHubSpotDataEntity(ref dynamic dataEntity)
25 | {
26 | }
27 |
28 | public virtual void FromHubSpotDataEntity(dynamic hubspotData)
29 | {
30 |
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/src/Company/Interfaces/ICompanyHubSpotEntity.cs:
--------------------------------------------------------------------------------
1 | using Skarp.HubSpotClient.Core.Interfaces;
2 |
3 | namespace Skarp.HubSpotClient.Company.Interfaces
4 | {
5 | public interface ICompanyHubSpotEntity : IHubSpotEntity
6 | {
7 | long? Id { get; set; }
8 | long? OwnerId { get; set; }
9 | string Name { get; set; }
10 | string Domain { get; set; }
11 | string Website { get; set; }
12 | string Description { get; set; }
13 | string RouteBasePath { get; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/Company/Interfaces/ICompanyListHubSpotEntity.cs:
--------------------------------------------------------------------------------
1 | using Skarp.HubSpotClient.Core.Interfaces;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Skarp.HubSpotClient.Company.Interfaces
7 | {
8 | public interface ICompanyListHubSpotEntity : IHubSpotEntity where T : ICompanyHubSpotEntity
9 | {
10 | ///
11 | /// Gets or sets the companies.
12 | ///
13 | ///
14 | /// The companies.
15 | ///
16 | IList Companies { get; set; }
17 |
18 | ///
19 | /// Gets or sets a value indicating whether more results are available.
20 | ///
21 | ///
22 | /// This is a mapping of the "has-more" prop in the JSON return data from HubSpot
23 | ///
24 | ///
25 | /// true if [more results available]; otherwise, false.
26 | ///
27 | bool MoreResultsAvailable { get; set; }
28 |
29 | ///
30 | /// Gets or sets the continuation offset.
31 | ///
32 | ///
33 | /// This is a mapping of the "vid-offset" prop in the JSON reeturn data from HubSpot
34 | ///
35 | ///
36 | /// The continuation offset.
37 | ///
38 | long ContinuationOffset { get; set; }
39 |
40 | string RouteBasePath { get; }
41 | List PropertiesToInclude { get; set; }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/Company/Interfaces/ICompanyPropertyHubSpotEntity.cs:
--------------------------------------------------------------------------------
1 | using Skarp.HubSpotClient.Common.Interfaces;
2 |
3 | namespace Skarp.HubSpotClient.Company.Interfaces
4 | {
5 | public interface ICompanyPropertyHubSpotEntity : IPropertyHubSpotEntity
6 | {
7 |
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/Company/Interfaces/ICompanySearchResultEntity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using Skarp.HubSpotClient.Core.Interfaces;
5 |
6 | namespace Skarp.HubSpotClient.Company.Interfaces
7 | {
8 | public interface ICompanySearchResultEntity : IHubSpotEntity where T : ICompanyHubSpotEntity
9 | {
10 | IList Results { get; set; }
11 |
12 | bool MoreResultsAvailable { get; set; }
13 |
14 | CompanySearchOffset Offset { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Company/Interfaces/IHubSpotCompanyClient.cs:
--------------------------------------------------------------------------------
1 | using Skarp.HubSpotClient.Core.Interfaces;
2 | using System.Threading.Tasks;
3 |
4 | namespace Skarp.HubSpotClient.Company.Interfaces
5 | {
6 | public interface IHubSpotCompanyClient
7 | {
8 | ///
9 | /// Creates the Company entity asynchronously.
10 | ///
11 | /// The entity.
12 | ///
13 | ///
14 | Task CreateAsync(ICompanyHubSpotEntity entity) where T : IHubSpotEntity, new();
15 | ///
16 | /// Delete a company from hubspot by id
17 | ///
18 | ///
19 | ///
20 | Task DeleteAsync(long CompanyId);
21 | ///
22 | /// Get a Company by email address (only searches on domain)
23 | ///
24 | ///
25 | ///
26 | ///
27 | Task GetByEmailAsync(string email, CompanySearchByDomain opts = null) where T : IHubSpotEntity, new();
28 | ///
29 | /// Return a single Company by id from hubspot
30 | ///
31 | ///
32 | ///
33 | ///
34 | Task GetByIdAsync(long CompanyId) where T : IHubSpotEntity, new();
35 | ///
36 | /// List Companies
37 | ///
38 | /// Request options - use for pagination
39 | ///
40 | ///
41 | Task ListAsync(CompanyListRequestOptions opts = null) where T : IHubSpotEntity, new();
42 | ///
43 | /// Update an existing company in hubspot
44 | ///
45 | ///
46 | ///
47 | ///
48 | Task UpdateAsync(ICompanyHubSpotEntity entity) where T : IHubSpotEntity, new();
49 | ///
50 | /// List company properties
51 | ///
52 | ///
53 | ///
54 | Task GetPropertiesAsync() where T : IHubSpotEntity, new();
55 | }
56 | }
--------------------------------------------------------------------------------
/src/Contact/ContactFormSubmissionMode.cs:
--------------------------------------------------------------------------------
1 | namespace Skarp.HubSpotClient.Contact
2 | {
3 | public enum ContactFormSubmissionMode
4 | {
5 | All,
6 | None,
7 | Newest,
8 | Oldest
9 | }
10 | }
--------------------------------------------------------------------------------
/src/Contact/ContactGetRequestOptions.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Skarp.HubSpotClient.Contact
4 | {
5 | public class ContactGetRequestOptions
6 | {
7 | public List PropertiesToInclude { get; set; } = new List();
8 | public bool IncludeHistory { get; set; } = true; // this is the default in HubSpot
9 | public ContactFormSubmissionMode FormSubmissionMode { get; set; } = ContactFormSubmissionMode.All; // this is the default in HubSpot
10 | public bool IncludeListMemberships { get; set; } = true; // this is the default in HubSpot
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Contact/ContactRequestOptions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Skarp.HubSpotClient.Contact
5 | {
6 | public class ContactListRequestOptions
7 | {
8 | private int _numberOfContactsToReturn = 20;
9 |
10 | ///
11 | /// Gets or sets the number of contacts to return.
12 | ///
13 | ///
14 | /// Defaults to 20 which is also the hubspot api default. Max value is 100
15 | ///
16 | ///
17 | /// The number of contacts to return.
18 | ///
19 | public int NumberOfContactsToReturn
20 | {
21 | get => _numberOfContactsToReturn;
22 | set
23 | {
24 | if (value < 1 || value > 100)
25 | {
26 | throw new ArgumentException(
27 | $"Number of contacts to return must be a positive ingeteger greater than 0 - you provided {value}");
28 | }
29 | _numberOfContactsToReturn = value;
30 | }
31 | }
32 |
33 | ///
34 | /// Get or set the continuation offset when calling list many times to enumerate all your contacts
35 | ///
36 | ///
37 | /// The return DTO from List contains the current "offset" that you can inject into your next list call
38 | /// to continue the listing process
39 | ///
40 | public long? ContactOffset { get; set; } = null;
41 | public List PropertiesToInclude { get; set; } = new List();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/Contact/Dto/ContactHubSpotEntity.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 | using Skarp.HubSpotClient.Contact.Interfaces;
3 |
4 | namespace Skarp.HubSpotClient.Contact.Dto
5 | {
6 | [DataContract]
7 | public class ContactHubSpotEntity : IContactHubSpotEntity
8 | {
9 | ///
10 | /// Contacts unique Id in HubSpot
11 | ///
12 | [DataMember(Name = "vid")]
13 | [IgnoreDataMember]
14 | public long? Id { get; set; }
15 | [DataMember(Name = "email")]
16 | public string Email { get; set; }
17 | [DataMember(Name = "firstname")]
18 | public string FirstName { get; set; }
19 | [DataMember(Name = "lastname")]
20 | public string Lastname { get; set; }
21 | [DataMember(Name = "website")]
22 | public string Website { get; set; }
23 | [DataMember(Name = "company")]
24 | public string Company { get; set; }
25 | [DataMember(Name = "phone")]
26 | public string Phone { get; set; }
27 | [DataMember(Name = "address")]
28 | public string Address { get; set; }
29 | [DataMember(Name = "city")]
30 | public string City { get; set; }
31 | [DataMember(Name = "state")]
32 | public string State { get; set; }
33 | [DataMember(Name = "zip")]
34 | public string ZipCode { get; set; }
35 |
36 | public string RouteBasePath => "/contacts/v1";
37 | public bool IsNameValue => false;
38 | public virtual void ToHubSpotDataEntity(ref dynamic converted)
39 | {
40 |
41 | }
42 |
43 | public virtual void FromHubSpotDataEntity(dynamic hubspotData)
44 | {
45 |
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/Contact/Dto/ContactListHubSpotEntity.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Runtime.Serialization;
3 | using Skarp.HubSpotClient.Contact.Interfaces;
4 |
5 | namespace Skarp.HubSpotClient.Contact.Dto
6 | {
7 | [DataContract]
8 | public class ContactListHubSpotEntity : IContactListHubSpotEntity where T : IContactHubSpotEntity
9 | {
10 | ///
11 | ///
12 | /// Gets or sets the contacts.
13 | ///
14 | ///
15 | /// The contacts.
16 | ///
17 | [DataMember(Name = "contacts")]
18 | public IList Contacts { get; set; } = new List();
19 |
20 | ///
21 | ///
22 | /// Gets or sets a value indicating whether more results are available.
23 | ///
24 | ///
25 | /// true if [more results available]; otherwise, false.
26 | ///
27 | ///
28 | /// This is a mapping of the "has-more" prop in the JSON return data from HubSpot
29 | ///
30 | [DataMember(Name = "has-more")]
31 | public bool MoreResultsAvailable { get; set; }
32 |
33 | ///
34 | ///
35 | /// Gets or sets the continuation offset.
36 | ///
37 | ///
38 | /// The continuation offset.
39 | ///
40 | ///
41 | /// This is a mapping of the "vid-offset" prop in the JSON reeturn data from HubSpot
42 | ///
43 | [DataMember(Name = "vid-offset")]
44 | public long ContinuationOffset { get; set; }
45 |
46 | public string RouteBasePath => "/contacts/v1";
47 |
48 | public bool IsNameValue => false;
49 | public virtual void ToHubSpotDataEntity(ref dynamic converted)
50 | {
51 |
52 | }
53 |
54 | public virtual void FromHubSpotDataEntity(dynamic hubspotData)
55 | {
56 |
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/Contact/Interfaces/IContactHubSpotEntity.cs:
--------------------------------------------------------------------------------
1 | using Skarp.HubSpotClient.Core.Interfaces;
2 |
3 | namespace Skarp.HubSpotClient.Contact.Interfaces
4 | {
5 | public interface IContactHubSpotEntity : IHubSpotEntity
6 | {
7 | long? Id { get; set; }
8 | string Email { get; set; }
9 | string FirstName { get; set; }
10 | string Lastname { get; set; }
11 | string Website { get; set; }
12 | string Company { get; set; }
13 | string Phone { get; set; }
14 | string Address { get; set; }
15 | string City { get; set; }
16 | string State { get; set; }
17 | string ZipCode { get; set; }
18 | string RouteBasePath { get; }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Contact/Interfaces/IContactListHubSpotEntity.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Skarp.HubSpotClient.Core.Interfaces;
3 |
4 | namespace Skarp.HubSpotClient.Contact.Interfaces
5 | {
6 | public interface IContactListHubSpotEntity : IHubSpotEntity where T : IContactHubSpotEntity
7 | {
8 | ///
9 | /// Gets or sets the contacts.
10 | ///
11 | ///
12 | /// The contacts.
13 | ///
14 | IList Contacts { get; set; }
15 |
16 | ///
17 | /// Gets or sets a value indicating whether more results are available.
18 | ///
19 | ///
20 | /// This is a mapping of the "has-more" prop in the JSON return data from HubSpot
21 | ///
22 | ///
23 | /// true if [more results available]; otherwise, false.
24 | ///
25 | bool MoreResultsAvailable { get; set; }
26 |
27 | ///
28 | /// Gets or sets the continuation offset.
29 | ///
30 | ///
31 | /// This is a mapping of the "vid-offset" prop in the JSON reeturn data from HubSpot
32 | ///
33 | ///
34 | /// The continuation offset.
35 | ///
36 | long ContinuationOffset { get; set; }
37 |
38 | string RouteBasePath { get; }
39 | }
40 | }
--------------------------------------------------------------------------------
/src/Contact/Interfaces/IHubSpotContactClient.cs:
--------------------------------------------------------------------------------
1 | using Skarp.HubSpotClient.Core.Interfaces;
2 | using System.Threading.Tasks;
3 |
4 | namespace Skarp.HubSpotClient.Contact.Interfaces
5 | {
6 | public interface IHubSpotContactClient
7 | {
8 | ///
9 | /// Creates the contact entity asynchronously.
10 | ///
11 | /// The entity.
12 | ///
13 | ///
14 | Task CreateAsync(IContactHubSpotEntity entity) where T : IHubSpotEntity, new();
15 | ///
16 | /// Creates or updates the contact entity asynchronously.
17 | ///
18 | /// The entity.
19 | ///
20 | ///
21 | Task CreateOrUpdateAsync(IContactHubSpotEntity entity) where T : IHubSpotEntity, new();
22 | ///
23 | /// Delete an existing contact in hubspot by id
24 | ///
25 | ///
26 | ///
27 | Task DeleteAsync(long contactId);
28 | ///
29 | /// Get a contact by email address
30 | ///
31 | ///
32 | /// Options for enabling/disabling history and specifying properties
33 | ///
34 | ///
35 | Task GetByEmailAsync(string email, ContactGetRequestOptions opts = null) where T : IHubSpotEntity, new();
36 | ///
37 | /// Return a single contact by id from hubspot
38 | ///
39 | ///
40 | /// Options for enabling/disabling history and specifying properties
41 | ///
42 | ///
43 | Task GetByIdAsync(long contactId, ContactGetRequestOptions opts = null) where T : IHubSpotEntity, new();
44 | ///
45 | /// List contacts
46 | ///
47 | /// Request options - use for pagination
48 | ///
49 | ///
50 | Task ListAsync(ContactListRequestOptions opts = null) where T : IHubSpotEntity, new();
51 | ///
52 | /// Update an existing contact in hubspot
53 | ///
54 | ///
55 | ///
56 | Task UpdateAsync(IContactHubSpotEntity contact);
57 | }
58 | }
--------------------------------------------------------------------------------
/src/Core/HubSpotAction.cs:
--------------------------------------------------------------------------------
1 | namespace Skarp.HubSpotClient.Core
2 | {
3 | ///
4 | /// Enumerates the possible actions against the hubspot api
5 | ///
6 | public enum HubSpotAction
7 | {
8 | Create,
9 |
10 | Get,
11 |
12 | GetByEmail,
13 |
14 | List,
15 |
16 | Update,
17 |
18 | Delete,
19 |
20 | CreateOrUpdate,
21 |
22 | CreateBatch,
23 |
24 | DeleteBatch,
25 |
26 | UpdateBatch,
27 |
28 | ReadBatch,
29 |
30 | Lists
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Core/HubSpotAssociationDefinitions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Skarp.HubSpotClient.Core
6 | {
7 | public enum HubSpotAssociationDefinitions
8 | {
9 |
10 | ContactToCompany = 1,
11 |
12 | CompanyToContact = 2,
13 |
14 | DealToContact = 3,
15 |
16 | ContactToDeal = 4,
17 |
18 | DealToCompany = 5,
19 |
20 | CompanyToDeal = 6,
21 |
22 | CompanyToEngagement = 7,
23 |
24 | EngagementToCompany = 8,
25 |
26 | ContactToEngagement = 9,
27 |
28 | EngagementToContact = 10,
29 |
30 | DealToEngagement = 11,
31 |
32 | EngagementToDeal = 12,
33 |
34 | ParentCompanyToChildCompany = 13,
35 |
36 | ChildCompanyToParentCompany = 14,
37 |
38 | ContactToTicket = 15,
39 |
40 | TicketToContact = 16,
41 |
42 | TicketToEngagement = 17,
43 |
44 | EngagementToTicket = 18,
45 |
46 | DealToLineItem = 19,
47 |
48 | LineItemToDeal = 20,
49 |
50 | CompanyToTicket = 25,
51 |
52 | TicketToCompany = 26,
53 |
54 | DealToTicket = 27,
55 |
56 | TicketToDeal = 28,
57 |
58 | // special contact associations
59 |
60 | AdvisorToCompany = 33,
61 |
62 | CompanyToAdvisor = 34,
63 |
64 | BoardMemberToCompany = 35,
65 |
66 | CompanyToBoardMember = 36,
67 |
68 | ContractorToCompany = 37,
69 |
70 | CompanyToContractor = 38,
71 |
72 | ManagerToCompany = 39,
73 |
74 | CompanyToManager = 40,
75 |
76 | BusinessOwnerToCompany = 41,
77 |
78 | CompanyToBusinessOwner = 42,
79 |
80 | PartnerToCompany = 43,
81 |
82 | CompanyToPartner = 44,
83 |
84 | ResellerToCompany = 45,
85 |
86 | CompanyToReseller = 46
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/src/Core/Interfaces/IHubSpotEntity.cs:
--------------------------------------------------------------------------------
1 | using System.Dynamic;
2 |
3 | namespace Skarp.HubSpotClient.Core.Interfaces
4 | {
5 | public interface IHubSpotEntity
6 | {
7 | bool IsNameValue { get; }
8 |
9 | void ToHubSpotDataEntity(ref dynamic dataEntity);
10 |
11 | void FromHubSpotDataEntity(dynamic hubspotData);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/Core/JsonContent.cs:
--------------------------------------------------------------------------------
1 | using System.Net.Http;
2 | using System.Text;
3 |
4 | namespace Skarp.HubSpotClient.Core
5 | {
6 | public class JsonContent : StringContent
7 | {
8 | public JsonContent(string json) : this(json, Encoding.UTF8)
9 | {
10 | }
11 |
12 | public JsonContent(string json, Encoding encoding) : base(json, encoding, "application/json")
13 | {
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/Core/NoopLogger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.Extensions.Logging;
3 |
4 | namespace Skarp.HubSpotClient.Core
5 | {
6 | public class NoopLogger : ILogger
7 | {
8 | public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter)
9 | {
10 | return;
11 | }
12 |
13 | public bool IsEnabled(LogLevel logLevel)
14 | {
15 | return false;
16 | }
17 |
18 | public IDisposable BeginScope(TState state)
19 | {
20 | return new NoopDisposable();
21 | }
22 | }
23 |
24 | public class NoopDisposable : IDisposable
25 | {
26 | public void Dispose()
27 | {
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/src/Core/NoopLoggerFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using Microsoft.Extensions.Logging;
5 | using Microsoft.Extensions.Logging.Abstractions;
6 |
7 | namespace Skarp.HubSpotClient.Core
8 | {
9 | public static class NoopLoggerFactory
10 | {
11 | public static ILogger Get()
12 | {
13 | return new NoopLogger();
14 | }
15 |
16 | public static ILogger Get()
17 | {
18 | return new NoopLogger();
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Core/ReflectionExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Runtime.Serialization;
4 | using RapidCore.Reflection;
5 |
6 | namespace Skarp.HubSpotClient.Core
7 | {
8 | internal static class ReflectionExtensions
9 | {
10 | ///
11 | /// Returns the name of a given property either by name of
12 | ///
13 | ///
14 | /// If the is defined it will try to use the prop name defined there. If no name is explictily defined in the attribute the
15 | /// name of the actual property will be returned.
16 | ///
17 | ///
18 | ///
19 | internal static string GetPropSerializedName(this PropertyInfo prop)
20 | {
21 | if (prop == null) return null;
22 |
23 | var propName = prop.Name;
24 |
25 | var dataMemberAttr = prop.GetCustomAttribute();
26 | if (dataMemberAttr == null) return propName;
27 | if (string.IsNullOrWhiteSpace(dataMemberAttr.Name)) return propName;
28 |
29 | return dataMemberAttr.Name;
30 | }
31 |
32 | ///
33 | /// Finds the method recursively by searching in the given type and all implemented interfaces.
34 | ///
35 | /// The property.
36 | /// The name.
37 | /// The type arguments.
38 | ///
39 | ///
40 | internal static MethodInfo FindMethodRecursively(this Type prop, string name, params Type[] typeArgs)
41 | {
42 | if (prop == null) return null;
43 |
44 | // GetMethod searches base types...
45 | var method = prop.GetMethod(name, typeArgs);
46 | if (method != null) return method;
47 |
48 |
49 | foreach (var iface in prop.GetInterfaces())
50 | {
51 | method = iface.FindMethodRecursively(name, typeArgs);
52 | if (method != null) return method;
53 | }
54 |
55 | // TODO better bailout exception?
56 | throw new ArgumentException($"Unable to locate method with name: {name}", nameof(name));
57 | }
58 |
59 | ///
60 | /// Determines whether the given property has the
61 | ///
62 | /// The property.
63 | ///
64 | /// true if [has ignore data member attribute] [the specified property]; otherwise, false.
65 | ///
66 | internal static bool HasIgnoreDataMemberAttribute(this PropertyInfo prop)
67 | {
68 | if (prop == null) return false;
69 |
70 | return prop.HasAttribute(typeof(IgnoreDataMemberAttribute));
71 | }
72 |
73 | ///
74 | /// Determines whether the given is a complex type or a simple ValueType
75 | ///
76 | /// The type.
77 | ///
78 | /// true if [is complex type] [the specified type]; otherwise, false.
79 | ///
80 | internal static bool IsComplexType(this Object instance)
81 | {
82 | if (instance == null) return false;
83 |
84 | var type = instance.GetType();
85 | return type.IsComplexType();
86 | }
87 |
88 | ///
89 | /// Determines whether [is complex type].
90 | ///
91 | /// The type.
92 | ///
93 | /// true if [is complex type] [the specified type]; otherwise, false.
94 | ///
95 | internal static bool IsComplexType(this Type type)
96 | {
97 | if (type.GetTypeInfo().IsSubclassOf(typeof(ValueType)) || type == (typeof(string)))
98 | return false;
99 |
100 | return true;
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/src/Core/Requests/HubspotDataEntityProp.cs:
--------------------------------------------------------------------------------
1 | namespace Skarp.HubSpotClient.Core.Requests
2 | {
3 | ///
4 | /// Represents a property value instance that can be sent to HubSpot
5 | ///
6 | public class HubspotDataEntityProp
7 | {
8 | ///
9 | /// Gets or sets the property that has a value.
10 | ///
11 | ///
12 | /// Data will only be set here if the converted DTO returns a v1 route!
13 | ///
14 | ///
15 | /// The property value
16 | ///
17 | public string Property { get; set; }
18 |
19 | ///
20 | /// Gets or sets the actual value of the given property.
21 | ///
22 | ///
23 | /// The value.
24 | ///
25 | public object Value { get; set; }
26 |
27 | ///
28 | /// Gets or sets the name of the property that has a value.
29 | ///
30 | ///
31 | /// Data will only be set here if the converted DTO returns a v2 route!
32 | ///
33 | ///
34 | /// The name.
35 | ///
36 | public object Name { get; set; }
37 | }
38 | }
--------------------------------------------------------------------------------
/src/Deal/DealListRequestOptions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Skarp.HubSpotClient.Deal
5 | {
6 | public class DealListRequestOptions
7 | {
8 | private int _numberOfDealsToReturn = 100;
9 |
10 | ///
11 | /// Gets or sets the number of deals to return.
12 | ///
13 | ///
14 | /// Defaults to 20 which is also the hubspot api default. Max value is 100
15 | ///
16 | ///
17 | /// The number of deals to return.
18 | ///
19 | public int NumberOfDealsToReturn
20 | {
21 | get => _numberOfDealsToReturn;
22 | set
23 | {
24 | if (value < 1 || value > 250)
25 | {
26 | throw new ArgumentException(
27 | $"Number of deals to return must be a positive integer greater than 0 and less than 251 - you provided {value}");
28 | }
29 | _numberOfDealsToReturn = value;
30 | }
31 | }
32 |
33 | ///
34 | /// Get or set the continuation offset when calling list many times to enumerate all your deals
35 | ///
36 | ///
37 | /// The return DTO from List contains the current "offset" that you can inject into your next list call
38 | /// to continue the listing process
39 | ///
40 | public long? DealOffset { get; set; } = null;
41 |
42 | public List PropertiesToInclude { get; set; } = new List();
43 |
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Deal/Dto/DealHubSpotAssociations.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace Skarp.HubSpotClient.Deal.Dto
4 | {
5 | [DataContract]
6 | public class DealHubSpotAssociations
7 | {
8 |
9 | [DataMember(Name = "associatedCompanyIds")]
10 | public long[] AssociatedCompany { get; set; }
11 |
12 | [DataMember(Name = "associatedVids")]
13 | public long[] AssociatedContacts { get; set; }
14 | }
15 | }
--------------------------------------------------------------------------------
/src/Deal/Dto/DealHubSpotEntity.cs:
--------------------------------------------------------------------------------
1 | using Skarp.HubSpotClient.Deal.Interfaces;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Runtime.Serialization;
6 | using System.Text;
7 |
8 | namespace Skarp.HubSpotClient.Deal.Dto
9 | {
10 | [DataContract]
11 | public class DealHubSpotEntity : IDealHubSpotEntity
12 | {
13 | public DealHubSpotEntity()
14 | {
15 | Associations = new DealHubSpotAssociations();
16 | }
17 | ///
18 | /// Contacts unique Id in HubSpot
19 | ///
20 | [DataMember(Name = "dealId")]
21 | [IgnoreDataMember]
22 | public long? Id { get; set; }
23 | [DataMember(Name = "dealname")]
24 | public string Name { get; set; }
25 | [DataMember(Name = "dealstage")]
26 | public string Stage { get; set; }
27 | [DataMember(Name = "pipeline")]
28 | public string Pipeline { get; set; }
29 | [DataMember(Name = "hubspot_owner_id")]
30 | public long? OwnerId { get; set; }
31 | [DataMember(Name = "closedate")]
32 | public string CloseDate { get; set; }
33 | [DataMember(Name = "amount")]
34 | public decimal Amount { get; set; }
35 | [DataMember(Name = "dealtype")]
36 | public string DealType { get; set; }
37 | [IgnoreDataMember]
38 | public DealHubSpotAssociations Associations { get; private set; }
39 | public string RouteBasePath => "/deals/v1";
40 | public bool IsNameValue => true;
41 | public virtual void ToHubSpotDataEntity(ref dynamic converted)
42 | {
43 | converted.Associations = Associations;
44 | }
45 |
46 | public virtual void FromHubSpotDataEntity(dynamic hubspotData)
47 | {
48 | if (hubspotData.associations != null)
49 | {
50 | Associations.AssociatedContacts = ((List