-
Notifications
You must be signed in to change notification settings - Fork 47
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
Implement addLead
#174
base: master
Are you sure you want to change the base?
Implement addLead
#174
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Lead> Get(Guid id) | |
{ | ||
return ApiConnection.Get<Lead>(ApiUrls.Lead(id)); | ||
} | ||
|
||
public Task<LeadCreated> Create(NewLead data) | ||
{ | ||
Ensure.ArgumentNotNull(data, nameof(data)); | ||
|
||
return ApiConnection.Post<LeadCreated>(ApiUrls.Leads(), JObject.FromObject(data)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using {
"success":false,
"data":null,
"additional_data":null,
"error":"provided dataset is not valid",
"error_info":"\"owner_id\" must be a number"
} Example of request: var data = new NewLead("Lead created from C#")
{
OrganizationId = 1
};
var createdLead = await client.Lead.Create(data); |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Guid> 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<string, ICustomField> CustomFields { get; set; } = new Dictionary<string, ICustomField>(); | ||
|
||
public NewLead(string title) | ||
{ | ||
this.Title = title; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,28 +20,26 @@ public abstract class AbstractLead | |
[JsonProperty("label_ids")] | ||
public List<Guid> 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; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added null possible for Exception:
|
||
|
||
[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; } | ||
Comment on lines
+52
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added missing fields |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace Pipedrive | ||
{ | ||
public class LeadCreated : AbstractLead { } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.