Skip to content

Implement addLead#174

Open
ArdenHide wants to merge 3 commits intoDavidRouyer:masterfrom
The-Poolz:implement_add-lead
Open

Implement addLead#174
ArdenHide wants to merge 3 commits intoDavidRouyer:masterfrom
The-Poolz:implement_add-lead

Conversation

@ArdenHide
Copy link
Copy Markdown

No description provided.

- fix bug on try receive Lead with null person_id
- use `JObject` in `Create` operation, to remove null values from Body
@ArdenHide ArdenHide marked this pull request as ready for review March 6, 2024 16:03
/// </summary>
/// <remarks>
/// See the <a href="https://developers.pipedrive.com/docs/api/v1/Leads">Lead API documentation</a> for more information.
/// </remarks>
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Bugfix: This XML docs don't work because close tag missing.

{
Ensure.ArgumentNotNull(data, nameof(data));

return ApiConnection.Post<LeadCreated>(ApiUrls.Leads(), JObject.FromObject(data));
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using JObject.FromObject construction to handle null values.
Without null values handling receive error like:

{
   "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);


[JsonProperty("person_id")]
public long PersonId { get; set; }
public long? PersonId { get; set; }
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added null possible for person_id because, this value can be null. And we receive JsonSerialization exception on try set null in not-nullable PersonId

Exception:

Unhandled exception. Newtonsoft.Json.JsonSerializationException: Error converting value {null} to type 'System.Int64'. Path 'person_id'

Comment on lines +52 to +56
[JsonProperty("visible_to")]
public string VisibleTo { get; set; }

[JsonProperty("cc_email")]
public string CcEmail { get; set; }
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added missing fields

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant