Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ArdenHide
Copy link

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
@@ -9,10 +9,13 @@ namespace Pipedrive
/// </summary>
/// <remarks>
/// See the <a href="https://developers.pipedrive.com/docs/api/v1/Leads">Lead API documentation</a> for more information.
/// </remarks>
Copy link
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
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
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
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