Skip to content

Commit

Permalink
Add a method to fetch the hubspot hours mileage (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
kundu-ramit123 authored Oct 6, 2023
1 parent 3ebf7b2 commit eefaaa3
Show file tree
Hide file tree
Showing 5 changed files with 282 additions and 3 deletions.
9 changes: 7 additions & 2 deletions HubSpot.NET.Examples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ static async Task Main(string[] args)
{"year1", 2014},
{"make", "Ford"},
{"model", "150" + DateTime.Now.Hour + DateTime.Now.Minute},
{"name", $"2015 Ford 150"}
{"name", $"2015 Ford 150"},
{"hoursmileage", $"1000" }
},
Associations = new List<CreateCustomObjectHubSpotModel.Association>()
{
Expand Down Expand Up @@ -107,7 +108,11 @@ static async Task Main(string[] args)
// 9909067546 => deal id
var newEquipmentId = api.CustomObjects.CreateWithDefaultAssociationToObject(newEquipment, "0-3", "9909067546");


var getEquipment = api.CustomObjects.GetEquipmentDataById<GetHubspotEquipmentObjectModel>(id, newEquipmentId);


var getEquipmentHours = api.CustomObjects.GetEquipmentDataById<GetHubspotEquipmentObjectModel>(id, newEquipmentId, "hoursmileage");

var result3 = api.CustomObjects.GetAssociationsToCustomObject
<CustomObjectAssociationModel>("2-4390924", "3254092177",
"0-1", CancellationToken.None);
Expand Down
77 changes: 77 additions & 0 deletions HubSpot.NET/Api/CustomObject/EquipmentObjectList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;

namespace HubSpot.NET.Api.CustomObject
{
public static class EquipmentObjectList
{
public static string GetEquipmentPropsList()
{
var equipmentPropsList = new List<string>
{
"additional_information",
"backoffice_id",
"bb_eng_legacy_equipmentcategory_slug",
"category",
"city",
"commission_percent",
"date_of_first_qualified_lead",
"equipment_title",
"fleet_identifier",
"hs_all_accessible_team_ids",
"hs_all_assigned_business_unit_ids",
"hs_all_owner_ids",
"hs_all_team_ids",
"hs_created_by_user_id",
"hs_createdate",
"hs_lastmodifieddate",
"hs_merged_object_ids",
"hs_object_id",
"hs_object_source",
"hs_object_source_id",
"hs_object_source_user_id",
"hs_pinned_engagement_id",
"hs_read_only",
"hs_unique_creation_key",
"hs_updated_by_user_id",
"hs_user_ids_of_all_notification_followers",
"hs_user_ids_of_all_notification_unfollowers",
"hs_user_ids_of_all_owners",
"hs_was_imported",
"hubspot_owner_assigneddate",
"hubspot_owner_id",
"hubspot_team_id",
"item_number",
"karintest",
"line_item_id",
"listing_to_lead_time",
"location",
"location_combined",
"machine_posted_datestamp",
"make",
"make__other",
"new_associated_deal",
"photo",
"poc_email",
"product_id",
"qualified_to_buy_datestamp",
"seller_company_id",
"seller_company_name",
"seller_contact_id",
"seller_deal_id",
"state",
"submission_idempotent_id",
"time_between_posted_and_first_buyer",
"warranty_eligible",
"year",
"year1",
"zip_code",
"name",
"model",
"vin",
"hoursmileage"
};
return string.Join(",", equipmentPropsList);
}
}
}
181 changes: 181 additions & 0 deletions HubSpot.NET/Api/CustomObject/EquipmentObjectModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
using HubSpot.NET.Core.Interfaces;
using System.Collections.Generic;
using System;
using System.Runtime.Serialization;
using System.Xml.Linq;

namespace HubSpot.NET.Api.CustomObject;
public class GetHubspotEquipmentObjectModel : IHubSpotModel
{
#nullable enable

[DataMember(Name = "additional_information")]
public string? AdditionalInformation { get; set; }

[DataMember(Name = "backoffice_id")]
public string? BackofficeId { get; set; }

[DataMember(Name = "bb_eng_legacy_equipmentcategory_slug")]
public string? BbEngLegacyEquipmentCategorySlug { get; set; }

[DataMember(Name = "category")]
public string? Category { get; set; }

[DataMember(Name = "city")]
public string? City { get; set; }

[DataMember(Name = "commission_percent")]
public double? CommissionPercent { get; set; }

[DataMember(Name = "date_of_first_qualified_lead")]
public DateTime? DateOfFirstQualifiedLead { get; set; }

[DataMember(Name = "equipment_title")]
public string? EquipmentTitle { get; set; }

[DataMember(Name = "fleet_identifier")]
public string? FleetIdentifier { get; set; }

[DataMember(Name = "hs_created_by_user_id")]
public string? HsCreatedByUserId { get; set; }

[DataMember(Name = "hs_createdate")]
public DateTime? HsCreateDate { get; set; }

[DataMember(Name = "hs_lastmodifieddate")]
public DateTime? HsLastModifiedDate { get; set; }

[DataMember(Name = "hs_object_id")]
public string? HsObjectId { get; set; }

[DataMember(Name = "hs_object_source")]
public string? HsObjectSource { get; set; }

[DataMember(Name = "hs_object_source_id")]
public string? HsObjectSourceId { get; set; }

[DataMember(Name = "hs_object_source_user_id")]
public string? HsObjectSourceUserId { get; set; }

[DataMember(Name = "hs_pinned_engagement_id")]
public string? HsPinnedEngagementId { get; set; }

[DataMember(Name = "hs_read_only")]
public bool? HsReadOnly { get; set; }

[DataMember(Name = "hs_unique_creation_key")]
public string? HsUniqueCreationKey { get; set; }

[DataMember(Name = "hs_updated_by_user_id")]
public string? HsUpdatedByUserId { get; set; }

[DataMember(Name = "hs_was_imported")]
public bool? HsWasImported { get; set; }

[DataMember(Name = "hubspot_owner_assigneddate")]
public DateTime? HubspotOwnerAssignedDate { get; set; }

[DataMember(Name = "hubspot_owner_id")]
public string? HubspotOwnerId { get; set; }

[DataMember(Name = "hubspot_team_id")]
public string? HubspotTeamId { get; set; }

[DataMember(Name = "item_number")]
public string? ItemNumber { get; set; }

[DataMember(Name = "karintest")]
public string? KarinTest { get; set; }

[DataMember(Name = "line_item_id")]
public string? LineItemId { get; set; }

[DataMember(Name = "listing_to_lead_time")]
public string? ListingToLeadTime { get; set; }

[DataMember(Name = "location")]
public string? Location { get; set; }

[DataMember(Name = "location_combined")]
public string? LocationCombined { get; set; }

[DataMember(Name = "machine_posted_datestamp")]
public DateTime? MachinePostedDatestamp { get; set; }

[DataMember(Name = "make")]
public string? Make { get; set; }

[DataMember(Name = "make__other")]
public string? MakeOther { get; set; }

[DataMember(Name = "new_associated_deal")]
public bool? NewAssociatedDeal { get; set; }

[DataMember(Name = "photo")]
public string? Photo { get; set; }

[DataMember(Name = "poc_email")]
public string? PocEmail { get; set; }

[DataMember(Name = "product_id")]
public string? ProductId { get; set; }

[DataMember(Name = "qualified_to_buy_datestamp")]
public DateTime? QualifiedToBuyDatestamp { get; set; }

[DataMember(Name = "seller_company_id")]
public string? SellerCompanyId { get; set; }

[DataMember(Name = "seller_company_name")]
public string? SellerCompanyName { get; set; }

[DataMember(Name = "seller_contact_id")]
public string? SellerContactId { get; set; }

[DataMember(Name = "seller_deal_id")]
public string? SellerDealId { get; set; }

[DataMember(Name = "state")]
public string? State { get; set; }

[DataMember(Name = "submission_idempotent_id")]
public string? SubmissionIdempotentId { get; set; }

[DataMember(Name = "time_between_posted_and_first_buyer")]
public string? TimeBetweenPostedAndFirstBuyer { get; set; }

[DataMember(Name = "warranty_eligible")]
public bool? WarrantyEligible { get; set; }

[DataMember(Name = "year")]
public string? Year { get; set; }

[DataMember(Name = "year1")]
public string? Year1 { get; set; }

[DataMember(Name = "zip_code")]
public string? ZipCode { get; set; }

[DataMember(Name = "name")]
public string? Name { get; set; }

[DataMember(Name = "model")]
public string? Model { get; set; }

[DataMember(Name = "vin")]
public string? Vin { get; set; }

[DataMember(Name = "hoursmileage")]
public string? HoursMileage { get; set; }

public bool IsNameValue => false;
public void ToHubSpotDataEntity(ref dynamic dataEntity)
{
}

public void FromHubSpotDataEntity(dynamic hubspotData)
{
}

public string RouteBasePath => "crm/v3/objects";
}
17 changes: 16 additions & 1 deletion HubSpot.NET/Api/CustomObject/HubSpotCustomObjectApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ public void FromHubSpotDataEntity(dynamic hubspotData)
public string RouteBasePath => "crm/v3/objects";
}


public class CustomObjectListAssociationsModel<T> : IHubSpotModel where T : CustomObjectAssociationModel, new()
{
[DataMember(Name = "results")]
Expand Down Expand Up @@ -242,4 +241,20 @@ public CustomObjectListAssociationsModel<T> GetAssociationsToCustomObject<T>(str

return string.Empty;
}

public T GetEquipmentDataById<T>(string schemaId, string entityId, string properties = "") where T : GetHubspotEquipmentObjectModel, new()
{
if(properties == "")
{
properties = EquipmentObjectList.GetEquipmentPropsList();
}

var path = $"{RouteBasePath}/{schemaId}/{entityId}";

path = path.SetQueryParam("properties", properties); //properties is comma seperated value of properties to include

var res = _client.Execute<T>(path, Method.GET, convertToPropertiesSchema: true);

return res;
}
}
1 change: 1 addition & 0 deletions HubSpot.NET/Core/Interfaces/IHubSpotCustomObjectApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ string CreateWithDefaultAssociationToObject<T>(T entity, string associateObjectT

string UpdateObject<T>(T entity)
where T : UpdateCustomObjectHubSpotModel, new();
T GetEquipmentDataById<T>(string schemaId, string entityId, string properties="") where T : GetHubspotEquipmentObjectModel, new();
}

0 comments on commit eefaaa3

Please sign in to comment.