Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Pipedrive.net/Clients/FilesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public async Task<File> Create(NewFile data)
content.Add(new StringContent(data.NoteId.ToString()), "note_id");
}

if (!string.IsNullOrEmpty(data.LeadId))
{
content.Add(new StringContent(data.LeadId), "lead_id");
}

return await ApiConnection.Post<File>(ApiUrls.Files(), content, "application/json", "multipart/form-data");
}

Expand Down
3 changes: 3 additions & 0 deletions src/Pipedrive.net/Clients/ILeadsClient.cs
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 Pipedrive.Models.Response.Leads;

namespace Pipedrive
{
Expand All @@ -14,5 +15,7 @@ public interface ILeadsClient
Task<IReadOnlyList<Lead>> GetAll(LeadFilters filters);

Task<Lead> Get(Guid id);

Task<Lead> Create(NewLead newLead);
}
}
6 changes: 6 additions & 0 deletions src/Pipedrive.net/Clients/LeadsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Pipedrive.Helpers;
using Pipedrive.Models.Response.Leads;

namespace Pipedrive
{
Expand Down Expand Up @@ -39,5 +40,10 @@ public Task<Lead> Get(Guid id)
{
return ApiConnection.Get<Lead>(ApiUrls.Lead(id));
}

public Task<Lead> Create(NewLead newLead)
{
return ApiConnection.Post<Lead>(ApiUrls.Leads(), newLead);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,10 @@ public AddressCustomField(
PostalCode = postalCode;
FormattedAddress = formattedAddress;
}

public override string ToString()
{
return FormattedAddress;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@ public DateCustomField(DateTime value)
{
Value = value;
}

public override string ToString()
{
return Value.ToString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,12 @@ public DateRangeCustomField(DateTime? startDate, DateTime? endDate)
StartDate = startDate;
EndDate = endDate;
}

public override string ToString()
{
string startDateString = StartDate.HasValue ? StartDate.Value.ToString() : "-";
string endDateString = EndDate.HasValue ? EndDate.Value.ToString() : "-";
return $"{startDateString} to {endDateString}";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@ public DecimalCustomField(decimal value)
{
Value = value;
}

public override string ToString()
{
return Value.ToString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
{
public interface ICustomField
{
string ToString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,10 @@ public LongCustomField(long value)
{
Value = value;
}

public override string ToString()
{
return Value.ToString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@ public MonetaryCustomField(decimal value, string currency)
Value = value;
Currency = currency;
}

public override string ToString()
{
return $"{Currency} {Value}";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,10 @@ public class OrganizationCustomField : ICustomField

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

public override string ToString()
{
return Name;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;

namespace Pipedrive.CustomFields
Expand All @@ -16,5 +17,10 @@ public class PersonCustomField : ICustomField

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

public override string ToString()
{
return $"{Name}, <{string.Join(", ", Email.Select(e => e.Value))}>";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,10 @@ public StringCustomField(string value)
{
Value = value;
}

public override string ToString()
{
return Value;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@ public TimeCustomField(TimeSpan value, int timezoneId)
Value = value;
TimezoneId = timezoneId;
}

public override string ToString()
{
return Value.ToString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,10 @@ public TimeRangeCustomField(TimeSpan startTime, TimeSpan endTime, int timezoneId
EndTime = endTime;
TimezoneId = timezoneId;
}

public override string ToString()
{
return $"{StartTime} to {EndTime}";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,10 @@ public class UserCustomField : ICustomField

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

public override string ToString()
{
return $"{Name}, <{Email}>";
}
}
}
3 changes: 3 additions & 0 deletions src/Pipedrive.net/Models/Request/Files/NewFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public class NewFile
[JsonProperty("note_id")]
public long? NoteId { get; set; }

[JsonProperty("lead_id")]
public string LeadId { get; set; }

public NewFile(RawFile file)
{
this.File = file;
Expand Down
3 changes: 3 additions & 0 deletions src/Pipedrive.net/Models/Request/Notes/NewNote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public class NewNote
[JsonProperty("pinned_to_person_flag")]
public bool PinnedToPersonFlag { get; set; }

[JsonProperty("lead_id")]
public string LeadId { get; set; }

public NewNote(string content)
{
Content = content;
Expand Down
3 changes: 3 additions & 0 deletions src/Pipedrive.net/Models/Request/Persons/PersonUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public class PersonUpdate : IEntityWithCustomFields
[JsonProperty("visible_to")]
public Visibility VisibleTo { get; set; }

[JsonProperty("marketing_status")]
public string MarketingStatus { get; set; }

[JsonIgnore]
public IDictionary<string, ICustomField> CustomFields { get; set; }
}
Expand Down
87 changes: 87 additions & 0 deletions src/Pipedrive.net/Models/Response/Leads/NewLead.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json;

namespace Pipedrive.Models.Response.Leads
{
/// <summary>
/// https://developers.pipedrive.com/docs/api/v1/Leads#addLead
/// </summary>
/*
{
"title": "<string>",
"owner_id": "<integer>",
"label_ids": [
"<uuid>",
"<uuid>"
],
"person_id": "<integer>",
"organization_id": "<integer>",
"value": {
"amount": "<number>",
"currency": "<string>"
},
"expected_close_date": "<date>",
"visible_to": "<string>",
"was_seen": "<boolean>"
}
*/
public class NewLead
{
[JsonProperty("title")]
public string Title { get; set; }

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

[JsonIgnore]
[JsonProperty("creator_id")]
public long CreatorId { get; set; }

[JsonProperty("label_ids")]
public List<Guid> LabelIds { get; set; }

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

[JsonIgnore]
[JsonProperty("expected_close_date")]
public DateTime? ExpectedCloseDate { get; set; }

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

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

[JsonProperty("organization_id")]
public long? OrganizationId { get; set; }

[JsonIgnore]
[JsonProperty("is_archived")]
public bool IsArchived { get; set; }

[JsonIgnore]
[JsonProperty("source_name")]
public string SourceName { get; set; }

[JsonIgnore]
[JsonProperty("was_seen")]
public bool WasSeen { get; set; }

[JsonIgnore]
[JsonProperty("next_activity_id")]
public long? NextActivityId { get; set; }

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

[JsonIgnore]
[JsonProperty("update_time")]
public DateTime? UpdateTime { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/Pipedrive.net/Models/Response/Persons/AbstractPerson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,8 @@ public abstract class AbstractPerson<TUser, TOrganization, TPicture>

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

[JsonProperty("marketing_status")]
public string MarketingStatus { get; set; }
}
}
3 changes: 2 additions & 1 deletion src/Pipedrive.net/Models/Response/Persons/Person.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public PersonUpdate ToUpdate()
OrgId = OrgId?.Value,
OwnerId = OwnerId?.Value,
VisibleTo = VisibleTo,
CustomFields = CustomFields
CustomFields = CustomFields,
MarketingStatus = MarketingStatus
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Pipedrive.net/Pipedrive.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down