Skip to content

Commit

Permalink
fix: deal activities
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidRouyer committed Apr 18, 2019
1 parent 6a301f5 commit 6b2ea88
Show file tree
Hide file tree
Showing 9 changed files with 222 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Pipedrive.net.Tests/Clients/DealsClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NSubstitute;
using Pipedrive.CustomFields;
using Pipedrive.Models.Response;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
Expand Down Expand Up @@ -330,7 +331,7 @@ public async Task RequestsCorrectUrl()

Received.InOrder(async () =>
{
await connection.GetAll<Activity>(
await connection.GetAll<DealActivity>(
Arg.Is<Uri>(u => u.ToString() == "deals/123/activities"),
Arg.Is<Dictionary<string, string>>(d => d.Count == 2
&& d["id"] == "123"
Expand Down
5 changes: 3 additions & 2 deletions src/Pipedrive.net/Clients/DealsClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Pipedrive.Helpers;
using Pipedrive.Models.Response;
using System.Collections.Generic;
using System.Threading.Tasks;

Expand Down Expand Up @@ -125,7 +126,7 @@ public Task<IReadOnlyList<Follower>> GetFollowers(long dealId)
return ApiConnection.GetAll<Follower>(ApiUrls.DealFollowers(dealId), parameters);
}

public Task<IReadOnlyList<Activity>> GetActivities(long dealId, DealActivityFilters filters)
public Task<IReadOnlyList<DealActivity>> GetActivities(long dealId, DealActivityFilters filters)
{
Ensure.ArgumentNotNull(filters, nameof(filters));

Expand All @@ -138,7 +139,7 @@ public Task<IReadOnlyList<Activity>> GetActivities(long dealId, DealActivityFilt
PageSize = filters.PageSize
};

return ApiConnection.GetAll<Activity>(ApiUrls.DealActivities(dealId), parameters, options);
return ApiConnection.GetAll<DealActivity>(ApiUrls.DealActivities(dealId), parameters, options);
}
}
}
3 changes: 2 additions & 1 deletion src/Pipedrive.net/Clients/IDealsClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Pipedrive.Models.Response;

namespace Pipedrive
{
Expand Down Expand Up @@ -30,6 +31,6 @@ public interface IDealsClient

Task<IReadOnlyList<Follower>> GetFollowers(long dealId);

Task<IReadOnlyList<Activity>> GetActivities(long dealId, DealActivityFilters filters);
Task<IReadOnlyList<DealActivity>> GetActivities(long dealId, DealActivityFilters filters);
}
}
27 changes: 27 additions & 0 deletions src/Pipedrive.net/Models/Response/AssociatedDeal.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Newtonsoft.Json;

namespace Pipedrive.Models.Response
{
public class AssociatedDeal
{
public long Id { get; set; }

[JsonProperty("title")]
public string Title { get; set; }

[JsonProperty("status")]
public DealStatus Status { get; set; }

[JsonProperty("value")]
public long Value { get; set; }

[JsonProperty("currency")]
public string Currency { get; set; }

[JsonProperty("stage_id")]
public long StageId { get; set; }

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

namespace Pipedrive.Models.Response
{
public class AssociatedOrganization
{
[JsonProperty("name")]
public string Name { get; set; }

[JsonProperty("people_count")]
public long PeopleCount { get; set; }

[JsonProperty("owner_id")]
public long OwnerId { get; set; }

[JsonProperty("address")]
public string Address { get; set; }

[JsonProperty("cc_email")]
public string CcEmail { get; set; }

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

namespace Pipedrive.Models.Response
{
public class AssociatedPerson
{
[JsonProperty("name")]
public string Name { get; set; }

[JsonProperty("email")]
public List<Email> Email { get; set; }

[JsonProperty("phone")]
public List<Phone> Phone { get; set; }

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

namespace Pipedrive.Models.Response
{
public class AssociatedUser
{
public long Id { get; set; }

[JsonProperty("name")]
public string Name { get; set; }

[JsonProperty("email")]
public string Email { get; set; }

[JsonProperty("has_pic")]
public bool HasPic { get; set; }

[JsonProperty("pic_hash")]
public string PicHash { get; set; }

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

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

namespace Pipedrive.Models.Response
{
public class DealActivity
{
public long Id { get; set; }

[JsonProperty("company_id")]
public long CompanyId { get; set; }

[JsonProperty("user_id")]
public AssociatedUser UserId { get; set; }

[JsonProperty("done")]
public bool Done { get; set; }

[JsonProperty("type")]
public string Type { get; set; }

[JsonProperty("reference_type")]
public string ReferenceType { get; set; }

[JsonProperty("reference_id")]
public string ReferenceId { get; set; }

[JsonProperty("due_date")]
public DateTime? DueDate { get; set; }

[JsonProperty("due_time")]
public string DueTime { get; set; }

[JsonProperty("duration")]
public string Duration { get; set; }

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

[JsonProperty("marked_as_done_time")]
public DateTime? MarkedAsDoneTime { get; set; }

[JsonProperty("last_notification_time")]
public DateTime? LastNotificationTime { get; set; }

[JsonProperty("last_notification_user_id")]
public long? LastNotificationUserId { get; set; }

[JsonProperty("notification_language_id")]
public long? NotificationLanguageId { get; set; }

[JsonProperty("subject")]
public string Subject { get; set; }

[JsonProperty("org_id")]
public AssociatedOrganization OrgId { get; set; }

[JsonProperty("person_id")]
public AssociatedPerson PersonId { get; set; }

[JsonProperty("deal_id")]
public AssociatedDeal DealId { get; set; }

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

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

[JsonProperty("update_user_id")]
public long? UpdateUserId { get; set; }

[JsonProperty("gcal_event_id")]
public string GcalEventId { get; set; }

[JsonProperty("google_calendar_id")]
public string GoogleCalendarId { get; set; }

[JsonProperty("google_calendar_etag")]
public string GoogleCalendarEtag { get; set; }

[JsonProperty("note")]
public string Note { get; set; }

[JsonProperty("created_by_user_id")]
public AssociatedUser CreatedByUserId { get; set; }

[JsonProperty("participants")]
public List<Participant> Participants { get; set; }

[JsonProperty("org_name")]
public string OrgName { get; set; }

[JsonProperty("person_name")]
public string PersonName { get; set; }

[JsonProperty("deal_title")]
public string DealTitle { get; set; }

[JsonProperty("owner_name")]
public string OwnerName { get; set; }

[JsonProperty("person_dropbox_bcc")]
public string PersonDropboxBcc { get; set; }

[JsonProperty("deal_dropbox_bcc")]
public string DealDropboxBcc { get; set; }

[JsonProperty("assigned_to_user_id")]
public long? AssignedToUserId { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/Pipedrive.net/Models/Response/SimpleOrganization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ public class SimpleOrganization

[JsonProperty("visible_to")]
public string VisibleTo { get; set; }

[JsonProperty("details")]
public object Details { get; set; }
}
}

0 comments on commit 6b2ea88

Please sign in to comment.