Skip to content

Commit

Permalink
feat: handle pictures on person
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidRouyer committed Aug 22, 2018
1 parent bbe8c44 commit 398c6b1
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ public async Task ReturnsDistinctInfosBasedOnStartPage()
}
}

public class TheGetMethod
{
[IntegrationTest]
public async Task CanRetrieveOrganization()
{
var pipedrive = Helper.GetAuthenticatedClient();

var person = await pipedrive.Organization.Get(217);

Assert.Equal("david rouyer", person.Name);
}
}

public class TheGetByNameMethod
{
[IntegrationTest]
Expand Down
13 changes: 13 additions & 0 deletions src/Pipedrive.net.Tests.Integration/Clients/PersonsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ public async Task ReturnsDistinctInfosBasedOnStartPage()
}
}

public class TheGetMethod
{
[IntegrationTest]
public async Task CanRetrievePerson()
{
var pipedrive = Helper.GetAuthenticatedClient();

var person = await pipedrive.Person.Get(141);

Assert.Equal("[email protected]", person.Email[0].Value);
}
}

public class TheGetByNameMethod
{
[IntegrationTest]
Expand Down
33 changes: 33 additions & 0 deletions src/Pipedrive.net/Models/Common/Picture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Newtonsoft.Json;
using System;

namespace Pipedrive
{
public class Picture
{
[JsonProperty("item_type")]
public string ItemType { get; set;}

[JsonProperty("item_id")]
public long ItemId { get; set; }

[JsonProperty("active_flag")]
public bool ActiveFlag { get; set; }

[JsonProperty("add_time")]
public DateTime AddTime { get; set; }

[JsonProperty("update_time")]
[JsonConverter(typeof(ZeroDateConverter))]
public DateTime? UpdateTime { get; set; }

[JsonProperty("added_by_user_id")]
public long AddedByUserId { get; set; }

[JsonProperty("pictures")]
public object Pictures { get; set; }

[JsonProperty("value")]
public long Value { get; set; }
}
}
19 changes: 19 additions & 0 deletions src/Pipedrive.net/Models/Common/SimplePicture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Newtonsoft.Json;

namespace Pipedrive
{
public class SimplePicture
{
[JsonProperty("id")]
public long Id { get; set; }

[JsonProperty("url")]
public string Url { get; set; }

[JsonProperty("width")]
public int Width { get; set; }

[JsonProperty("height")]
public int Height { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/Pipedrive.net/Models/Response/Organization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class Organization : IEntityWithCustomFields
public long? CategoryId { get; set; }

[JsonProperty("picture_id")]
public long? PictureId { get; set; }
public Picture PictureId { get; set; }

[JsonProperty("country_code")]
public string CountryCode { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/Pipedrive.net/Models/Response/Person.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public class Person : IEntityWithCustomFields
public Visibility VisibleTo { get; set; }

[JsonProperty("picture_id")]
public int? PictureId { get; set; }
public Picture PictureId { get; set; }

[JsonProperty("next_activity_date")]
public string NextActivityDate { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/Pipedrive.net/Models/Response/SimplePerson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public class SimplePerson
public string VisibleTo { get; set; }

[JsonProperty("picture")]
public object Picture { get; set; }
public SimplePicture Picture { get; set; }
}
}

0 comments on commit 398c6b1

Please sign in to comment.