Skip to content

Commit fc9344b

Browse files
committed
Adds support for extended_transparency on Events APIs
1 parent fc183a0 commit fc9344b

File tree

8 files changed

+236
-1
lines changed

8 files changed

+236
-1
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## [1.12.8]
2+
* Add support for extended_transparency for events. [#142]
3+
14
## [1.12.7]
25
* Add support for Availability Rules endpoints. [#139]
36

@@ -341,6 +344,7 @@
341344
[1.12.5]: https://github.com/cronofy/cronofy-csharp/releases/tag/rel-1.12.5
342345
[1.12.6]: https://github.com/cronofy/cronofy-csharp/releases/tag/rel-1.12.6
343346
[1.12.7]: https://github.com/cronofy/cronofy-csharp/releases/tag/rel-1.12.7
347+
[1.12.8]: https://github.com/cronofy/cronofy-csharp/releases/tag/rel-1.12.8
344348

345349
[#3]: https://github.com/cronofy/cronofy-csharp/pull/3
346350
[#10]: https://github.com/cronofy/cronofy-csharp/pull/10
@@ -416,3 +420,4 @@
416420
[#135]: https://github.com/cronofy/cronofy-csharp/pull/135
417421
[#137]: https://github.com/cronofy/cronofy-csharp/pull/137
418422
[#139]: https://github.com/cronofy/cronofy-csharp/pull/139
423+
[#142]: https://github.com/cronofy/cronofy-csharp/pull/142

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.12.7
1+
1.12.8

src/Cronofy/Event.cs

+11
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@ public sealed class Event
115115
/// </remarks>
116116
public string Transparency { get; set; }
117117

118+
/// <summary>
119+
/// Gets or sets the extended transparency of the event.
120+
/// </summary>
121+
/// <value>
122+
/// The extended transparency of the event.
123+
/// </value>
124+
/// <remarks>
125+
/// See <see cref="Cronofy.ExtendedTransparency"/> for potential values.
126+
/// </remarks>
127+
public string ExtendedTransparency { get; set; }
128+
118129
/// <summary>
119130
/// Gets or sets the status of the event.
120131
/// </summary>

src/Cronofy/ExtendedTransparency.cs

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
namespace Cronofy
2+
{
3+
/// <summary>
4+
/// Potential extended_transparency values.
5+
/// </summary>
6+
public static class ExtendedTransparency
7+
{
8+
/// <summary>
9+
/// The account should appear as busy for the duration of the event.
10+
/// </summary>
11+
public const string Opaque = "opaque";
12+
13+
/// <summary>
14+
/// The account should not appear as busy for the duration of the event.
15+
/// </summary>
16+
public const string Transparent = "transparent";
17+
18+
/// <summary>
19+
/// Indicates the user is working away from their normal site.
20+
/// </summary>
21+
public const string WorkingElsewhere = "working_elsewhere";
22+
23+
/// <summary>
24+
/// Indicates an event being only tentatively accepted.
25+
/// </summary>
26+
public const string Tentative = "tentative";
27+
28+
/// <summary>
29+
/// Indicates the user is unavailable due to being out of the office, such as being on vacation.
30+
/// </summary>
31+
public const string OutOfOffice = "out_of_office";
32+
33+
/// <summary>
34+
/// The appearance of the account for the duration of the event is not
35+
/// known.
36+
/// </summary>
37+
public const string Unknown = "unknown";
38+
}
39+
}

src/Cronofy/Requests/UpsertEventRequest.cs

+9
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ public sealed class UpsertEventRequest : BaseEventRequest
8282
[JsonProperty("attachments")]
8383
public IEnumerable<Attachment> Attachments { get; set; }
8484

85+
/// <summary>
86+
/// Gets or sets the extended_transparency of the event.
87+
/// </summary>
88+
/// <value>
89+
/// The extended_transparency of the event.
90+
/// </value>
91+
[JsonProperty("extended_transparency")]
92+
public string ExtendedTransparency { get; set; }
93+
8594
/// <summary>
8695
/// Class for the serialization of the attendees for an upsert event
8796
/// request.

src/Cronofy/UpsertEventRequestBuilder.cs

+30
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ public sealed class UpsertEventRequestBuilder : IBuilder<UpsertEventRequest>
107107
/// </summary>
108108
private string transparency;
109109

110+
/// <summary>
111+
/// The extended_transparency of the event.
112+
/// </summary>
113+
private string extendedTransparency;
114+
110115
/// <summary>
111116
/// The color of the event.
112117
/// </summary>
@@ -601,6 +606,30 @@ public UpsertEventRequestBuilder Transparency(string transparency)
601606
return this;
602607
}
603608

609+
/// <summary>
610+
/// Sets the extended transparency of the event.
611+
/// </summary>
612+
/// <param name="extendedTransparency">
613+
/// ExtendedTransparency, must not be empty.
614+
/// </param>
615+
/// <returns>
616+
/// A reference to the modified builder.
617+
/// </returns>
618+
/// <exception cref="ArgumentException">
619+
/// Thrown if <paramref name="extendedTransparency"/> is not
620+
/// transparent, opaque, working_elsewhere, tentative, or out_of_office.
621+
/// </exception>
622+
public UpsertEventRequestBuilder ExtendedTransparency(string extendedTransparency)
623+
{
624+
Preconditions.True(
625+
new[] { "transparent", "opaque", "working_elsewhere", "tentative", "out_of_office" }.Contains(extendedTransparency),
626+
"ExtendedTransparency must be `transparent`, `opaque`, `working_elsewhere`, `tentative`, or `out_of_office`.");
627+
628+
this.extendedTransparency = extendedTransparency;
629+
630+
return this;
631+
}
632+
604633
/// <summary>
605634
/// Sets the color of the event.
606635
/// </summary>
@@ -793,6 +822,7 @@ public UpsertEventRequest Build()
793822
End = GetEventTime("End", this.endTime, this.endDate, this.endTimeZoneId),
794823
Url = this.url,
795824
Transparency = this.transparency,
825+
ExtendedTransparency = this.extendedTransparency,
796826
TimeZoneId = this.timeZoneId,
797827
Color = this.color,
798828
RemindersCreateOnly = this.remindersCreateOnly,

test/Cronofy.Test/CronofyAccountClientTests/GetEvents.cs

+94
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,100 @@ public void CanGetEventWithMeetingUrl()
554554
events);
555555
}
556556

557+
[Test]
558+
public void CanGetEventWithExtendedTransparency()
559+
{
560+
this.Http.Stub(
561+
HttpGet
562+
.Url("https://api.cronofy.com/v1/events?tzid=Etc%2FUTC&localized_times=true")
563+
.RequestHeader("Authorization", "Bearer " + AccessToken)
564+
.ResponseCode(200)
565+
.ResponseBody(
566+
@"{
567+
""pages"": {
568+
""current"": 1,
569+
""total"": 1
570+
},
571+
""events"": [
572+
{
573+
""calendar_id"": ""cal_U9uuErStTG@EAAAB_IsAsykA2DBTWqQTf-f0kJw"",
574+
""event_uid"": ""evt_external_54008b1a4a41730f8d5c6037"",
575+
""summary"": ""Company Retreat"",
576+
""description"": ""Escape to the country"",
577+
""start"": ""2014-09-06"",
578+
""end"": ""2014-09-08"",
579+
""deleted"": false,
580+
""recurring"": true,
581+
""series_identifier"": ""identifier"",
582+
""participation_status"": ""needs_action"",
583+
""transparency"": ""opaque"",
584+
""extended_transparency"": ""working_elsewhere"",
585+
""status"": ""confirmed"",
586+
""categories"": [],
587+
""attendees"": [
588+
{
589+
""email"": ""[email protected]"",
590+
""display_name"": ""Example Person"",
591+
""status"": ""needs_action""
592+
}
593+
],
594+
""created"": ""2014-09-01T08:00:01Z"",
595+
""updated"": ""2014-09-01T09:24:16Z"",
596+
""options"": {
597+
""delete"": true,
598+
""update"": true,
599+
""change_participation_status"": true
600+
},
601+
""meeting_url"": ""https://meet.example.com/ABCD1234""
602+
}
603+
]
604+
}"));
605+
606+
var events = this.Client.GetEvents();
607+
608+
CollectionAssert.AreEqual(
609+
new List<Event>
610+
{
611+
new Event
612+
{
613+
CalendarId = "cal_U9uuErStTG@EAAAB_IsAsykA2DBTWqQTf-f0kJw",
614+
EventUid = "evt_external_54008b1a4a41730f8d5c6037",
615+
Summary = "Company Retreat",
616+
Description = "Escape to the country",
617+
Start = new EventTime(new Date(2014, 9, 6), "Etc/UTC"),
618+
End = new EventTime(new Date(2014, 9, 8), "Etc/UTC"),
619+
Location = null,
620+
Deleted = false,
621+
Recurring = true,
622+
SeriesIdentifier = "identifier",
623+
ParticipationStatus = AttendeeStatus.NeedsAction,
624+
Transparency = Transparency.Opaque,
625+
ExtendedTransparency = ExtendedTransparency.WorkingElsewhere,
626+
EventStatus = EventStatus.Confirmed,
627+
Categories = new string[] { },
628+
Created = new DateTime(2014, 9, 1, 8, 0, 1, DateTimeKind.Utc),
629+
Updated = new DateTime(2014, 9, 1, 9, 24, 16, DateTimeKind.Utc),
630+
Attendees = new[]
631+
{
632+
new Attendee
633+
{
634+
Email = "[email protected]",
635+
DisplayName = "Example Person",
636+
Status = AttendeeStatus.NeedsAction,
637+
},
638+
},
639+
Options = new EventOptions()
640+
{
641+
Delete = true,
642+
Update = true,
643+
ChangeParticipationStatus = true,
644+
},
645+
MeetingUrl = "https://meet.example.com/ABCD1234",
646+
},
647+
},
648+
events);
649+
}
650+
557651
[Test]
558652
public void CanGetEventWithOldAuditTimes()
559653
{

test/Cronofy.Test/CronofyAccountClientTests/UpsertEvent.cs

+47
Original file line numberDiff line numberDiff line change
@@ -860,5 +860,52 @@ public void CanUpsertRemovingSubscriptions()
860860

861861
this.Client.UpsertEvent(CalendarId, builder);
862862
}
863+
864+
[Test]
865+
public void CanUpsertEventWithExtendedTransparency()
866+
{
867+
const string eventId = "qTtZdczOccgaPncGJaCiLg";
868+
const string summary = "Board meeting";
869+
const string description = "Discuss plans for the next quarter";
870+
const string startTimeString = "2014-08-05 15:30:00Z";
871+
const string endTimeString = "2014-08-05 17:00:00Z";
872+
const string locationDescription = "Board room";
873+
const string extendedTransparency = ExtendedTransparency.OutOfOffice;
874+
875+
this.Http.Stub(
876+
HttpPost
877+
.Url("https://api.cronofy.com/v1/calendars/" + CalendarId + "/events")
878+
.RequestHeader("Authorization", "Bearer " + AccessToken)
879+
.RequestHeader("Content-Type", "application/json; charset=utf-8")
880+
.RequestBodyFormat(
881+
"{{\"event_id\":\"{0}\"," +
882+
"\"extended_transparency\":\"{1}\"," +
883+
"\"summary\":\"{2}\"," +
884+
"\"description\":\"{3}\"," +
885+
"\"start\":{{\"time\":\"{4}\",\"tzid\":\"Etc/UTC\"}}," +
886+
"\"end\":{{\"time\":\"{5}\",\"tzid\":\"Etc/UTC\"}}," +
887+
"\"location\":{{\"description\":\"{6}\"}}" +
888+
"}}",
889+
eventId,
890+
extendedTransparency,
891+
summary,
892+
description,
893+
startTimeString,
894+
endTimeString,
895+
locationDescription)
896+
.ResponseCode(202));
897+
898+
var builder = new UpsertEventRequestBuilder()
899+
.EventId(eventId)
900+
.Summary(summary)
901+
.Description(description)
902+
.Start(new DateTime(2014, 8, 5, 15, 30, 0, DateTimeKind.Utc))
903+
.End(new DateTime(2014, 8, 5, 17, 0, 0, DateTimeKind.Utc))
904+
.Location(locationDescription)
905+
.ExtendedTransparency(extendedTransparency);
906+
907+
this.Client.UpsertEvent(CalendarId, builder);
908+
}
909+
863910
}
864911
}

0 commit comments

Comments
 (0)