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

Bug fixes and updates #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion Source/Podio .NET/Models/Task.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace PodioAPI.Models
public class Task
{
[JsonProperty("task_id")]
public string TaskId { get; set; }
public int TaskId { get; set; }

[JsonProperty("status")]
public string Status { get; set; }
Expand Down
8 changes: 5 additions & 3 deletions Source/Podio .NET/Podio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ internal async Task<T> Get<T>(string url, Dictionary<string, string> requestData
}
else
{
var jsonString = JSONSerializer.Serilaize(requestData);
request.Content = new StringContent(jsonString, Encoding.UTF8, "application/json");
if (requestData != null)
{
var jsonString = JSONSerializer.Serilaize(requestData);
request.Content = new StringContent(jsonString, Encoding.UTF8, "application/json");
}
}

return await Request<T>(request);
}

Expand Down
10 changes: 10 additions & 0 deletions Source/Podio .NET/Services/FileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,5 +318,15 @@ public async Task<FileResponse> DownloadFile(FileAttachment fileAttachment)
};
return await _podio.Get<FileResponse>(fileLink, new Dictionary<string, string>(), true);
}

public async Task<FileAttachment> UploadLinkedAccountFile(int linkedAccountId, string externalFileId, bool preservePermissions = true)
{
var url = $"/file/linked_account/{linkedAccountId}/";
var request = new
{
external_file_id = externalFileId
};
return await _podio.Post<FileAttachment>(url, request);
}
}
}
8 changes: 4 additions & 4 deletions Source/Podio .NET/Services/TaskService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,18 +225,18 @@ public async System.Threading.Tasks.Task IncompleteTask(int taskId, bool hook =
/// If set to true, the object will not be bumped up in the stream and notifications will not be
/// generated. Default value: false
/// </param>
/// <param name="externalId"></param>
/// <returns></returns>
public async Task<List<Models.Task>> CreateTask(string text, DateTime? dueDate = null, string description = null,
int? responsible = null, bool isPrivate = true, string refType = null, int? refId = null, bool hook = true,
bool silent = false)
public async Task<List<Models.Task>> CreateTask(string text, DateTime? dueDate = null, string description = null, int? responsible = null, bool isPrivate = true, string refType = null, int? refId = null, bool hook = true, bool silent = false, string externalId = null)
{
var task = new TaskCreateUpdateRequest
{
Text = text,
Description = description,
DueDate = dueDate,
Responsible = responsible,
Private = isPrivate
Private = isPrivate,
ExternalId = externalId
};
return await CreateTask(task, refType, refId, hook, silent);
}
Expand Down
67 changes: 52 additions & 15 deletions Source/Podio .NET/Utils/ItemFields/LocationItemField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,24 @@ public IEnumerable<string> Locations
get
{
if (this.Values != null && this.Values.Any())
{
return new List<string>(this.Values.Select(s => (string) s["value"]));
}
else
return new List<String>();
{
return new List<string>();
}
}

set
{
EnsureValuesInitialized();
foreach (var location in value)
{
var jobject = new JObject();
jobject["value"] = location;
var jobject = new JObject
{
["value"] = location
};
this.Values.Add(jobject);
}
}
Expand All @@ -36,8 +42,10 @@ public string Location
{
EnsureValuesInitialized();

var jobject = new JObject();
jobject["value"] = value;
var jobject = new JObject
{
["value"] = value
};
this.Values.Add(jobject);
}
}
Expand All @@ -53,11 +61,6 @@ public double? Latitude

return null;
}
set
{
EnsureValuesInitialized(true);
this.Values.First()["lat"] = value;
}
}

public double? Longitude
Expand All @@ -71,10 +74,44 @@ public double? Longitude

return null;
}
set
}

public string StreetAddress
{
get
{
if (this.Values.Any())
{
return (string)this.Values.First["street_address"];
}

return null;
}
}

public string City
{
get
{
if (this.Values.Any())
{
return (string)this.Values.First["city"];
}

return null;
}
}

public string PostalCode
{
get
{
EnsureValuesInitialized(true);
this.Values.First()["lng"] = value;
if (this.Values.Any())
{
return (string)this.Values.First["postal_code"];
}

return null;
}
}

Expand Down Expand Up @@ -102,6 +139,6 @@ public string State

return null;
}
}
}
}
}
}