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
4 changes: 3 additions & 1 deletion Podio.API/Client.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Podio.API.Exceptions;
using System.Web.Configuration;
using Podio.API.Exceptions;
using Podio.API.Utils;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -188,5 +189,6 @@ public static Client ConnectWithAuthorizationCode(string clientId, string client

public Services.TaskService TaskService { get { return new Services.TaskService(this); } }

public Services.ContactService ContactService { get { return new Services.ContactService(this); } }
}
}
1 change: 1 addition & 0 deletions Podio.API/Podio.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\ApplicationService.cs" />
<Compile Include="Services\CalendarService.cs" />
<Compile Include="Services\ContactService.cs" />
<Compile Include="Services\EmbedService.cs" />
<Compile Include="Services\FileService.cs" />
<Compile Include="Services\ItemService.cs" />
Expand Down
84 changes: 84 additions & 0 deletions Podio.API/Services/ContactService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using System.Runtime.Serialization;
using Podio.API.Model;
using Podio.API.Utils;

namespace Podio.API.Services
{
public class ContactService
{
private Client _client;
/// <summary>
/// Add a client and you can use this as a shortcut to the Podio REST API
/// </summary>
public ContactService(Client client)
{
_client = client;
}


// TODO
[DataContract]
public struct CreateUpdateRequest
{
[DataMember(IsRequired = false, Name = "name")]
public string Name { get; set; }

[DataMember(IsRequired = false, Name = "address")]
public string[] Address { get; set; }

[DataMember(IsRequired = false, Name = "city")]
public string City { get; set; }

[DataMember(IsRequired = false, Name = "state")]
public string State { get; set; }

[DataMember(IsRequired = false, Name = "zip")]
public string Zip { get; set; }

[DataMember(IsRequired = false, Name = "country")]
public string Country { get; set; }

[DataMember(IsRequired = false, Name = "mail")]
public string[] Mail { get; set; }

[DataMember(IsRequired = false, Name = "phone")]
public string[] Phone { get; set; }

[DataMember(IsRequired = false, Name = "url")]
public string[] Url { get; set; }
}




/// <summary>
/// https://developers.podio.com/doc/items/add-new-item-22362
/// </summary>
public int CreateSpaceContact(int spaceId, Contact contact)
{
var requestData = new CreateUpdateRequest
{
Name = contact.Name,
Address = contact.Address,
City = contact.City,
State = contact.State,
Zip = contact.Zip,
Country = contact.Country,
Mail = contact.Mail,
Phone = contact.Phone,
Url = contact.Url
};
var newContact = CreateSpaceContact(spaceId, requestData);
contact.ProfileId = newContact.ProfileId;
return (int)contact.ProfileId;
}

/// <summary>
/// https://developers.podio.com/doc/items/add-new-item-22362
/// </summary>
public Contact CreateSpaceContact(int spaceId, CreateUpdateRequest requestData)
{
return PodioRestHelper.JSONRequest<Contact>(Constants.PODIOAPI_BASEURL + "/contact/space/" + spaceId + "/", _client.AuthInfo.AccessToken, requestData, PodioRestHelper.RequestMethod.POST).Data;
}
}
}