diff --git a/readme.md b/readme.md
index f6be18f9..771ca01d 100644
--- a/readme.md
+++ b/readme.md
@@ -123,7 +123,7 @@ You can debug this library right from your application by configuring the [NuGet
- [ ] Leads
- [x] getLeads
- [x] getLead
- - [ ] addLead
+ - [x] addLead
- [ ] deleteLead
- [ ] updateLead
diff --git a/src/Pipedrive.net/Clients/ILeadsClient.cs b/src/Pipedrive.net/Clients/ILeadsClient.cs
index 82d7ba31..c1df3045 100644
--- a/src/Pipedrive.net/Clients/ILeadsClient.cs
+++ b/src/Pipedrive.net/Clients/ILeadsClient.cs
@@ -9,10 +9,13 @@ namespace Pipedrive
///
///
/// See the Lead API documentation for more information.
+ ///
public interface ILeadsClient
{
Task> GetAll(LeadFilters filters);
Task Get(Guid id);
+
+ Task Create(NewLead data);
}
}
diff --git a/src/Pipedrive.net/Clients/LeadsClient.cs b/src/Pipedrive.net/Clients/LeadsClient.cs
index dd977db4..86fcb14f 100644
--- a/src/Pipedrive.net/Clients/LeadsClient.cs
+++ b/src/Pipedrive.net/Clients/LeadsClient.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
+using Newtonsoft.Json.Linq;
using Pipedrive.Helpers;
namespace Pipedrive
@@ -39,5 +40,12 @@ public Task Get(Guid id)
{
return ApiConnection.Get(ApiUrls.Lead(id));
}
+
+ public Task Create(NewLead data)
+ {
+ Ensure.ArgumentNotNull(data, nameof(data));
+
+ return ApiConnection.Post(ApiUrls.Leads(), JObject.FromObject(data));
+ }
}
}
diff --git a/src/Pipedrive.net/Models/Request/Leads/NewLead.cs b/src/Pipedrive.net/Models/Request/Leads/NewLead.cs
new file mode 100644
index 00000000..249acb27
--- /dev/null
+++ b/src/Pipedrive.net/Models/Request/Leads/NewLead.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using Newtonsoft.Json;
+using Pipedrive.Models.Response;
+
+namespace Pipedrive
+{
+ public class NewLead : IEntityWithCustomFields
+ {
+ [JsonProperty("title")]
+ public string Title { get; set; }
+
+ [JsonProperty("owner_id", NullValueHandling = NullValueHandling.Ignore)]
+ public long? OwnerId { get; set; }
+
+ [JsonProperty("label_ids", NullValueHandling = NullValueHandling.Ignore)]
+ public IEnumerable LabelIds { get; set; }
+
+ [JsonProperty("person_id", NullValueHandling = NullValueHandling.Ignore)]
+ public long? PersonId { get; set; }
+
+ [JsonProperty("organization_id", NullValueHandling = NullValueHandling.Ignore)]
+ public long? OrganizationId { get; set; }
+
+ [JsonProperty("value", NullValueHandling = NullValueHandling.Ignore)]
+ public CurrencyAmount Value { get; set; }
+
+ [JsonProperty("expected_close_date", NullValueHandling = NullValueHandling.Ignore)]
+ public DateTime? ExpectedCloseDate { get; set; }
+
+ [JsonProperty("visible_to", NullValueHandling = NullValueHandling.Ignore)]
+ public Visibility? VisibleTo { get; set; }
+
+ [JsonProperty("was_seen", NullValueHandling = NullValueHandling.Ignore)]
+ public bool? WasSeen { get; set; }
+
+ [JsonIgnore]
+ public IDictionary CustomFields { get; set; } = new Dictionary();
+
+ public NewLead(string title)
+ {
+ this.Title = title;
+ }
+ }
+}
diff --git a/src/Pipedrive.net/Models/Response/Leads/AbstractLead.cs b/src/Pipedrive.net/Models/Response/Leads/AbstractLead.cs
index a1a43e13..ef58a748 100644
--- a/src/Pipedrive.net/Models/Response/Leads/AbstractLead.cs
+++ b/src/Pipedrive.net/Models/Response/Leads/AbstractLead.cs
@@ -20,28 +20,26 @@ public abstract class AbstractLead
[JsonProperty("label_ids")]
public List LabelIds { get; set; }
- public CurrencyAmount Value { get; set; }
-
- [JsonProperty("expected_close_date")]
- public DateTime? ExpectedCloseDate { get; set; }
-
- public string Note { get; set; }
-
[JsonProperty("person_id")]
- public long PersonId { get; set; }
+ public long? PersonId { get; set; }
[JsonProperty("organization_id")]
public long? OrganizationId { get; set; }
- [JsonProperty("is_archived")]
- public bool IsArchived { get; set; }
-
[JsonProperty("source_name")]
public string SourceName { get; set; }
+ [JsonProperty("is_archived")]
+ public bool IsArchived { get; set; }
+
[JsonProperty("was_seen")]
public bool WasSeen { get; set; }
+ public CurrencyAmount Value { get; set; }
+
+ [JsonProperty("expected_close_date")]
+ public DateTime? ExpectedCloseDate { get; set; }
+
[JsonProperty("next_activity_id")]
public long? NextActivityId { get; set; }
@@ -50,5 +48,11 @@ public abstract class AbstractLead
[JsonProperty("update_time")]
public DateTime? UpdateTime { get; set; }
+
+ [JsonProperty("visible_to")]
+ public string VisibleTo { get; set; }
+
+ [JsonProperty("cc_email")]
+ public string CcEmail { get; set; }
}
}
diff --git a/src/Pipedrive.net/Models/Response/Leads/Lead.cs b/src/Pipedrive.net/Models/Response/Leads/Lead.cs
index c233b92b..8c860e24 100644
--- a/src/Pipedrive.net/Models/Response/Leads/Lead.cs
+++ b/src/Pipedrive.net/Models/Response/Leads/Lead.cs
@@ -7,6 +7,8 @@ namespace Pipedrive
[JsonConverter(typeof(CustomFieldConverter))]
public class Lead : AbstractLead, IEntityWithCustomFields
{
+ public string Note { get; set; }
+
[JsonIgnore]
public IDictionary CustomFields { get; set; }
}
diff --git a/src/Pipedrive.net/Models/Response/Leads/LeadCreated.cs b/src/Pipedrive.net/Models/Response/Leads/LeadCreated.cs
new file mode 100644
index 00000000..f75d9f34
--- /dev/null
+++ b/src/Pipedrive.net/Models/Response/Leads/LeadCreated.cs
@@ -0,0 +1,4 @@
+namespace Pipedrive
+{
+ public class LeadCreated : AbstractLead { }
+}