Skip to content

Commit

Permalink
Add hidden option (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaohman authored Oct 6, 2023
1 parent eefaaa3 commit 386b5b9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 28 deletions.
59 changes: 31 additions & 28 deletions HubSpot.NET.Examples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ static async Task Main(string[] args)

var customSchemas = api.Schema.List<SchemaHubSpotModel>();
var id = "2-" + customSchemas.Results.First(x => x.Name == "Machine2").Id;

// get the equipment id off seller id...

var newEquipment = new CreateCustomObjectHubSpotModel
{
SchemaId = id,
Properties = new Dictionary<string, object>()
{

{"year1", 2014},
{"make", "Ford"},
{"model", "150" + DateTime.Now.Hour + DateTime.Now.Minute},
Expand All @@ -82,7 +82,7 @@ static async Task Main(string[] args)
{
new()
{
AssociationCategory = "USER_DEFINED",
AssociationCategory = "USER_DEFINED",
AssociationTypeId = 53 // id of the label that we want to assign it.
}
}
Expand All @@ -97,7 +97,7 @@ static async Task Main(string[] args)
{
new()
{
AssociationCategory = "USER_DEFINED",
AssociationCategory = "USER_DEFINED",
AssociationTypeId = 55 // id of the label that we want to assign it.
}
}
Expand All @@ -107,7 +107,9 @@ static async Task Main(string[] args)
// 0-3 => object type id that corresponds to the deal
// 9909067546 => deal id
var newEquipmentId = api.CustomObjects.CreateWithDefaultAssociationToObject(newEquipment, "0-3", "9909067546");




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


Expand All @@ -116,18 +118,18 @@ static async Task Main(string[] args)
var result3 = api.CustomObjects.GetAssociationsToCustomObject
<CustomObjectAssociationModel>("2-4390924", "3254092177",
"0-1", CancellationToken.None);



// 0-3 -> deal object type
// 9346274448 -> deal id
// 0-1 -> contact object type
// 68751 -> contact id
// USER_DEFINED -> associationCategory
// 55 -> association label
// api.Associations.AssociationToObjectByLabel("0-3", "9346274448", "0-1", "68751", "USER_DEFINED", 55);


var updatedEquipment = new UpdateCustomObjectHubSpotModel
{
Id = newEquipmentId,
Expand All @@ -140,20 +142,21 @@ static async Task Main(string[] args)
{"name", $"2024 Ford 550"}
}
};

var updatedResultId = api.CustomObjects.UpdateObject(updatedEquipment);
Console.Write(updatedResultId);

var customObjectProperty =
api.CustomObjectProperties.GetProperty<CustomObjectPropertyHubSpotModel>("Machine2", "karintest");
Console.Write(customObjectProperty);

customObjectProperty.Options.Add(new EnumerationOption()
{
Label = "KarinTest",
Value = "KarinTest"
Label = "KarinTest5",
Value = "KarinTest5",
Hidden = true
});

var result =
api.CustomObjectProperties.UpdateProperty<CustomObjectPropertyHubSpotModel>("Machine2", "karintest", customObjectProperty);
Console.Write(result);
Expand All @@ -167,17 +170,17 @@ public class EquipmentObject : CreateCustomObjectHubSpotModel
{


[DataMember(Name ="name")]
[DataMember(Name = "name")]
public new string Name => $"{Year} {Make} {Model}";
[DataMember(Name ="make")]

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

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

}


Expand All @@ -194,7 +197,7 @@ static async Task UploadNoteWithFile(HubSpotApi api)
{
Console.WriteLine(e);
}


var fileModel = new FileHubSpotRequestModel()
{
Expand All @@ -212,10 +215,10 @@ static async Task UploadNoteWithFile(HubSpotApi api)
};

var fileResponse = api.File.UploadFile(fileModel);

Console.Write(fileResponse);


var note = new NoteHubSpotRequestModel()
{
Properties = new NoteHubSpotRequestPropertiesModel()
Expand All @@ -238,13 +241,13 @@ static async Task UploadNoteWithFile(HubSpotApi api)
}
}
};

var noteResponse = api.Note.Create(note);

Console.Write(noteResponse);
}



}
}
3 changes: 3 additions & 0 deletions HubSpot.NET/Api/Properties/Dto/EnumerationOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ public class EnumerationOption

[DataMember(Name = "value")]
public string Value {get; set; }

[DataMember(Name = "hidden")]
public bool Hidden {get; set; }
}
}

0 comments on commit 386b5b9

Please sign in to comment.