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
Binary file added .vs/Bamboo.Sharp.Api/v14/.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion Bamboo.Sharp.Api.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bamboo.Sharp.Api", "Bamboo.Sharp.Api\Bamboo.Sharp.Api.csproj", "{09B2E97B-6103-4693-9EBB-0450DF36465B}"
EndProject
Expand Down
5 changes: 5 additions & 0 deletions Bamboo.Sharp.Api/Bamboo.Sharp.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@
<Compile Include="Deserializers\ExceptionDeserializer.cs" />
<Compile Include="Exceptions\InternalServerError.cs" />
<Compile Include="Model\Author.cs" />
<Compile Include="Model\Calendar.cs" />
<Compile Include="Model\DeployProject.cs" />
<Compile Include="Model\DeployResult.cs" />
<Compile Include="Model\Employee.cs" />
<Compile Include="Model\Holiday.cs" />
<Compile Include="Model\Item.cs" />
<Compile Include="Model\Result.cs" />
<Compile Include="Model\Results.cs" />
<Compile Include="Model\WebException.cs" />
Expand Down Expand Up @@ -85,6 +89,7 @@
<Compile Include="Model\User.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\SearchService.cs" />
<Compile Include="Services\TimeOffService.cs" />
<Compile Include="Util\RequestTypeConverter.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions Bamboo.Sharp.Api/Clients/RequestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ internal class RequestClient

private RequestClient()
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

}

internal static RequestClient Instance
Expand Down
14 changes: 14 additions & 0 deletions Bamboo.Sharp.Api/Model/Calendar.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RestSharp.Deserializers;

namespace Bamboo.Sharp.Api.Model
{
public class Calendar : BaseNode
{
public List<item> WhosOut { get; set; }
}
}
24 changes: 24 additions & 0 deletions Bamboo.Sharp.Api/Model/Employee.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using RestSharp.Deserializers;

namespace Bamboo.Sharp.Api.Model
{
public class Employee
{
[DeserializeAs(Name = "id", Attribute = true)]
public string Id { get; set; }
//[XmlText]
public string Value { get; set; }


public override string ToString()
{
return string.Format("({0}) - {1}", Id.ToString(), Value);
}
}
}
17 changes: 17 additions & 0 deletions Bamboo.Sharp.Api/Model/Holiday.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RestSharp.Deserializers;

namespace Bamboo.Sharp.Api.Model
{
public class Holiday
{
[DeserializeAs(Name = "id", Attribute = true)]
public string Id { get; set; }
//[XmlText]
public string Value { get; set; }
}
}
32 changes: 32 additions & 0 deletions Bamboo.Sharp.Api/Model/Item.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RestSharp.Deserializers;

namespace Bamboo.Sharp.Api.Model
{
public class item
{
public Employee Employee { get; set; }

public Holiday Holiday { get; set; }

[DeserializeAs(Name = "start")]
public DateTime StartDate { get; set; }

[DeserializeAs(Name = "end")]
public DateTime EndDate { get; set; }

public bool IsHoliday()
{
return this.Holiday != null;
}
public bool IsEmployee()
{
return this.Employee != null;
}

}
}
41 changes: 41 additions & 0 deletions Bamboo.Sharp.Api/Services/TimeOffService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using RestSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Bamboo.Sharp.Api.Model;

namespace Bamboo.Sharp.Api.Services
{
public class TimeOffService : BaseService
{
public Calendar GetWhosOutToday(DateTime? startDate = null, DateTime? endDate = null)
{
//If there is an end date, must have a start date.
if (!startDate.HasValue && endDate.HasValue)
throw new DataMisalignedException("You must specify a Start Date if you specify an EndDate!");
// End date has to be == or after the start date.
if (endDate.HasValue && startDate.HasValue && endDate.Value.Subtract(startDate.Value).TotalDays <= 0)
throw new DataMisalignedException("Your End Date must equal to or after your startDate");
if(endDate.HasValue && (endDate.Value.Subtract(startDate.Value).TotalDays > 14) )
throw new DataMisalignedException("Your entire search scope may only be up to 14 days from the start request!");

var start = startDate.HasValue == true ? startDate.Value.ToString("yyyy-M-d") : string.Empty;
var end = endDate.HasValue == true ? endDate.Value.ToString("yyyy-M-d") : string.Empty;

var request = new RestRequest
{
Resource = "time_off/whos_out",
Method = Method.GET
};
if(!string.IsNullOrEmpty(start))
request.AddQueryParameter("start", start);

if(!string.IsNullOrEmpty(end))
request.AddQueryParameter("end", end);

return Client.Execute<Calendar>(request);
}
}
}