-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
583d5d4
commit b23d116
Showing
15 changed files
with
283 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace Pipedrive.Internal | ||
{ | ||
public class CurrencyValueConverter : JsonConverter | ||
{ | ||
public override bool CanConvert(Type objectType) | ||
{ | ||
return objectType == typeof(Dictionary<string, decimal>); | ||
} | ||
|
||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
var values = new Dictionary<string, decimal>(); | ||
|
||
Console.WriteLine(reader.TokenType); | ||
if (reader.TokenType == JsonToken.StartObject) | ||
{ | ||
var jObject = JObject.Load(reader); | ||
foreach (var property in jObject.Properties()) | ||
{ | ||
values.Add(property.Name, property.Value.ToObject<decimal>()); | ||
} | ||
} | ||
|
||
if (reader.TokenType == JsonToken.StartArray) | ||
{ | ||
JArray.Load(reader); | ||
} | ||
|
||
return values; | ||
} | ||
|
||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Pipedrive | ||
{ | ||
public enum DateInterval | ||
{ | ||
Day, | ||
Week, | ||
Month, | ||
Quarter | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Pipedrive | ||
{ | ||
public enum ExcludeDeals | ||
{ | ||
None = 0, | ||
Exclude = 1 | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
src/Pipedrive.net/Models/Request/Deals/DealsTimelineFilters.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
|
||
namespace Pipedrive | ||
{ | ||
public class DealsTimelineFilters | ||
{ | ||
[JsonProperty("start_date")] | ||
public DateTime StartDate { get; set; } | ||
|
||
public DateInterval Interval { get; set; } | ||
|
||
public long Amount { get; set; } | ||
|
||
[JsonProperty("field_key")] | ||
public string FieldKey { get; set; } | ||
|
||
[JsonProperty("user_id")] | ||
public long? UserId { get; set; } | ||
|
||
[JsonProperty("pipeline_id")] | ||
public long? PipelineId { get; set; } | ||
|
||
[JsonProperty("filter_id")] | ||
public long? FilterId { get; set; } | ||
|
||
[JsonProperty("exclude_deals")] | ||
public ExcludeDeals ExcludeDeals { get; set; } | ||
|
||
[JsonProperty("totals_convert_currency")] | ||
public string TotalsConvertCurrency { get; set; } | ||
|
||
/// <summary> | ||
/// Get the query parameters that will be appending onto the search | ||
/// </summary> | ||
public IDictionary<string, string> Parameters | ||
{ | ||
get | ||
{ | ||
var d = new Dictionary<string, string>(); | ||
|
||
d.Add("start_date", StartDate.ToString("yyyy-MM-dd")); | ||
d.Add("interval", Interval.ToString().ToLower()); | ||
d.Add("amount", Amount.ToString()); | ||
d.Add("field_key", FieldKey); | ||
|
||
if (FilterId.HasValue) | ||
{ | ||
d.Add("filter_id", FilterId.Value.ToString()); | ||
} | ||
|
||
if (PipelineId.HasValue) | ||
{ | ||
d.Add("pipeline_id", PipelineId.Value.ToString()); | ||
} | ||
|
||
if (UserId.HasValue) | ||
{ | ||
d.Add("user_id", UserId.Value.ToString()); | ||
} | ||
|
||
d.Add("exclude_deals", ((long)ExcludeDeals).ToString()); | ||
|
||
if (!string.IsNullOrWhiteSpace(TotalsConvertCurrency)) | ||
{ | ||
d.Add("totals_convert_currency", TotalsConvertCurrency); | ||
} | ||
|
||
return d; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using Pipedrive.Internal; | ||
|
||
namespace Pipedrive | ||
{ | ||
public class DealTimeline | ||
{ | ||
[JsonProperty("period_start")] | ||
public DateTime PeriodStart { get; set; } | ||
|
||
[JsonProperty("period_end")] | ||
public DateTime PeriodEnd { get; set; } | ||
|
||
public IReadOnlyList<DealTimelineDeal> Deals { get; set; } = new List<DealTimelineDeal>(); | ||
|
||
public DealTimelineTotals Totals { get; set; } | ||
} | ||
|
||
public class DealTimelineTotals | ||
{ | ||
public long Count { get; set; } | ||
|
||
[JsonProperty("values")] | ||
[JsonConverter(typeof(CurrencyValueConverter))] | ||
public IReadOnlyDictionary<string, decimal> Values { get; set; } | ||
|
||
[JsonProperty("weighted_values")] | ||
[JsonConverter(typeof(CurrencyValueConverter))] | ||
public IReadOnlyDictionary<string, decimal> WeightedValues { get; set; } | ||
|
||
[JsonProperty("open_count")] | ||
public long OpenCount { get; set; } | ||
|
||
[JsonProperty("open_values")] | ||
[JsonConverter(typeof(CurrencyValueConverter))] | ||
public IReadOnlyDictionary<string, decimal> OpenValues { get; set; } | ||
|
||
[JsonProperty("weighted_open_values")] | ||
[JsonConverter(typeof(CurrencyValueConverter))] | ||
public IReadOnlyDictionary<string, decimal> WeightedOpenValues { get; set; } | ||
|
||
[JsonProperty("won_count")] | ||
public long WonCount { get; set; } | ||
|
||
[JsonProperty("won_values")] | ||
[JsonConverter(typeof(CurrencyValueConverter))] | ||
public IReadOnlyDictionary<string, decimal> WonValues { get; set; } | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/Pipedrive.net/Models/Response/Deals/DealTimelineDeal.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using Pipedrive.Internal; | ||
|
||
namespace Pipedrive | ||
{ | ||
[JsonConverter(typeof(CustomFieldConverter))] | ||
public class DealTimelineDeal : AbstractDeal<long?, long?, long?>, IEntityWithCustomFields | ||
{ | ||
[JsonIgnore] | ||
public IDictionary<string, ICustomField> CustomFields { get; set; } | ||
} | ||
} |