Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add hidden option #11

Merged
merged 2 commits into from
Oct 6, 2023
Merged
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
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; }
}
}