Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions HubSpot.NET.Examples/Companies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,44 @@ private static void Tests(HubSpotApi api)
/**
* Create a company
*/
var company = api.Company.Create(new CompanyHubSpotModel()
{
Domain = "squaredup.com",
Name = "Squared Up"
});
//var company = api.Company.Create(new CompanyHubSpotModel()
//{
// Domain = "squaredup.com",
// Name = "Squared Up"
//});

/**
* Update a company's property
*/
company.Description = "Data Visualization for Enterprise IT";
api.Company.Update(company);
//company.Description = "Data Visualization for Enterprise IT";
//api.Company.Update(company);


/**
* Get all companies with domain name "squaredup.com"
*/
var companies = api.Company.GetByDomain("squaredup.com", new CompanySearchByDomain()
//var companies = api.Company.GetByDomain("squaredup.com", new CompanySearchByDomain()
//{
// Limit = 10
//});

var companiesList = api.Company.List(new ListRequestOptions()
{
Limit = 10
Limit = 10,
//PropertiesToInclude = new List<string>() {
// "name",
// "description",
// "companyId"
//}
//Offset = companyLists.Offset
});

Console.WriteLine($"Pass...");

/**
* Delete a contact
*/
api.Company.Delete(company.Id.Value);
//api.Company.Delete(company.Id.Value);

}
}
Expand Down
4 changes: 2 additions & 2 deletions HubSpot.NET.Examples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ private static void RunApiKeyExamples(HubSpotApi hapiApi)
//EmailSubscriptions.Example(hapiApi);
//Deals.Example(hapiApi);
//Contacts.Example(hapiApi);
//Companies.Example(hapiApi);
Companies.Example(hapiApi);
//CompanyProperties.Example(hapiApi);
Pipelines.Example(hapiApi);
//Pipelines.Example(hapiApi);
}

private static void RunOAuthExamples(HubSpotApi oauthApi)
Expand Down
33 changes: 29 additions & 4 deletions HubSpot.NET/Api/Company/HubSpotCompanyApi.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace HubSpot.NET.Api.Company
{
using Flurl;
using HubSpot.NET.Api.Company.Dto;
using HubSpot.NET.Core;
using HubSpot.NET.Core.Abstracts;
Expand Down Expand Up @@ -76,19 +77,43 @@ public CompanySearchResultModel<CompanyHubSpotModel> GetByDomain(string domain,

public CompanyListHubSpotModel<CompanyHubSpotModel> List(ListRequestOptions opts = null)
{

opts = opts ?? new ListRequestOptions();

string path = GetRoute<CompanyHubSpotModel>("companies", "paged");
//string path = GetRoute<CompanyHubSpotModel>("companies", "paged");
var path = GetRoute<CompanyHubSpotModel>("companies", "paged").SetQueryParam("limit", opts.Limit);

//path += $"{QueryParams.COUNT}={opts.Limit}";

path += $"{QueryParams.COUNT}={opts.Limit}";
//if (opts.PropertiesToInclude.Any())
// path += $"{QueryParams.PROPERTIES}={opts.PropertiesToInclude}";

if (opts.PropertiesToInclude.Any())
path += $"{QueryParams.PROPERTIES}={opts.PropertiesToInclude}";
path.SetQueryParam("properties", opts.PropertiesToInclude);

//if (opts.Offset.HasValue)
// path += $"{QueryParams.OFFSET}={opts.Offset}";

if (opts.Offset.HasValue)
path += $"{QueryParams.OFFSET}={opts.Offset}";
path = path.SetQueryParam("offset", opts.Offset);

return _client.Execute<CompanyListHubSpotModel<CompanyHubSpotModel>, ListRequestOptions>(path, opts);

//return _client.Execute<CompanyListHubSpotModel<T>, ListRequestOptions>(path, opts, Method.GET, Enums.RequestType.List);

//opts = opts ?? new ListRequestOptions();

//string path = GetRoute<CompanyHubSpotModel>("companies", "paged");

//path += $"{QueryParams.COUNT}={opts.Limit}";

//if (opts.PropertiesToInclude.Any())
// path += $"{QueryParams.PROPERTIES}={opts.PropertiesToInclude}";

//if (opts.Offset.HasValue)
// path += $"{QueryParams.OFFSET}={opts.Offset}";

//return _client.Execute<CompanyListHubSpotModel<CompanyHubSpotModel>, ListRequestOptions>(path, opts);
}

/// <summary>
Expand Down
16 changes: 16 additions & 0 deletions HubSpot.NET/Api/Shared/Associations.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace HubSpot.NET.Api.Shared
{
[DataContract]
public class Associations
{
[DataMember(Name = "associatedCompanyIds")]
public List<long> AssociatedCompanyIds { get; set; }
[DataMember(Name = "associatedVids")]
public List<long> AssociatedVids { get; set; }
}
}
Loading