1
1
namespace Cronofy
2
2
{
3
3
using System ;
4
+ using System . Collections . Generic ;
4
5
using Cronofy . Requests ;
5
6
6
7
/// <summary>
@@ -18,6 +19,16 @@ public sealed class AddToCalendarRequestBuilder : IBuilder<AddToCalendarRequest>
18
19
/// </summary>
19
20
private IBuilder < UpsertEventRequest > upsertEventRequestBuilder ;
20
21
22
+ /// <summary>
23
+ /// The availability details builder for the request.
24
+ /// </summary>
25
+ private IBuilder < AvailabilityRequest > availabilityRequestBuilder ;
26
+
27
+ /// <summary>
28
+ /// The target calendars builder for the request.
29
+ /// </summary>
30
+ private IList < AddToCalendarRequest . TargetCalendar > targetCalendars ;
31
+
21
32
/// <summary>
22
33
/// Sets the OAuth details of the request.
23
34
/// </summary>
@@ -31,7 +42,7 @@ public sealed class AddToCalendarRequestBuilder : IBuilder<AddToCalendarRequest>
31
42
/// A reference to the <see cref="AddToCalendarRequestBuilder"/>.
32
43
/// </returns>
33
44
/// <exception cref="ArgumentException">
34
- /// Thrown if <paramref name="redirectUrl "/> or <paramref name="scope"/> are empty.
45
+ /// Thrown if <paramref name="redirectUri "/> or <paramref name="scope"/> are empty.
35
46
/// </exception>
36
47
public AddToCalendarRequestBuilder OAuthDetails ( string redirectUri , string scope )
37
48
{
@@ -54,7 +65,7 @@ public AddToCalendarRequestBuilder OAuthDetails(string redirectUri, string scope
54
65
/// A reference to the <see cref="AddToCalendarRequestBuilder"/>.
55
66
/// </returns>
56
67
/// <exception cref="ArgumentException">
57
- /// Thrown if <paramref name="redirectUrl "/> or <paramref name="scope"/> are empty.
68
+ /// Thrown if <paramref name="redirectUri "/> or <paramref name="scope"/> are empty.
58
69
/// </exception>
59
70
public AddToCalendarRequestBuilder OAuthDetails ( string redirectUri , string scope , string state )
60
71
{
@@ -130,14 +141,105 @@ public AddToCalendarRequestBuilder UpsertEventRequest(UpsertEventRequest upsertE
130
141
return this ;
131
142
}
132
143
144
+ /// <summary>
145
+ /// Sets the availability details of the request.
146
+ /// </summary>
147
+ /// <param name="availabilityRequestBuilder">
148
+ /// The availability details builder for the request, must not be null.
149
+ /// </param>
150
+ /// <returns>
151
+ /// A reference to the <see cref="AddToCalendarRequestBuilder"/>
152
+ /// </returns>
153
+ public AddToCalendarRequestBuilder AvailabilityRequestBuilder ( IBuilder < AvailabilityRequest > availabilityRequestBuilder )
154
+ {
155
+ Preconditions . NotNull ( "availabilityRequestBuilder" , availabilityRequestBuilder ) ;
156
+
157
+ this . availabilityRequestBuilder = availabilityRequestBuilder ;
158
+
159
+ return this ;
160
+ }
161
+
162
+ /// <summary>
163
+ /// Sets the availability details of the request.
164
+ /// </summary>
165
+ /// <param name="availabilityRequest">
166
+ /// The event details for the request, must not be null.
167
+ /// </param>
168
+ /// <returns>
169
+ /// A reference to the <see cref="AddToCalendarRequestBuilder"/>.
170
+ /// </returns>
171
+ public AddToCalendarRequestBuilder AvailabilityRequest ( AvailabilityRequest availabilityRequest )
172
+ {
173
+ Preconditions . NotNull ( "availability" , availabilityRequest ) ;
174
+
175
+ this . availabilityRequestBuilder = Builder . Wrap ( availabilityRequest ) ;
176
+
177
+ return this ;
178
+ }
179
+
180
+ /// <summary>
181
+ /// Adds a target calendar to the request.
182
+ /// </summary>
183
+ /// <param name="sub">
184
+ /// The sub for the target calendar.
185
+ /// </param>
186
+ /// <param name="calendarId">
187
+ /// The target calendar's id.
188
+ /// </param>
189
+ /// <returns>
190
+ /// A reference to the <see cref="AddToCalendarRequestBuilder"/>.
191
+ /// </returns>
192
+ public AddToCalendarRequestBuilder AddTargetCalendar ( string sub , string calendarId )
193
+ {
194
+ Preconditions . NotBlank ( "sub" , sub ) ;
195
+ Preconditions . NotBlank ( "calendarId" , calendarId ) ;
196
+
197
+ if ( this . targetCalendars == null )
198
+ {
199
+ this . targetCalendars = new List < AddToCalendarRequest . TargetCalendar > ( ) ;
200
+ }
201
+
202
+ this . targetCalendars . Add ( new AddToCalendarRequest . TargetCalendar
203
+ {
204
+ Sub = sub ,
205
+ CalendarId = calendarId
206
+ } ) ;
207
+
208
+ return this ;
209
+ }
210
+
211
+ /// <summary>
212
+ /// Sets the target calendar details of the request.
213
+ /// </summary>
214
+ /// <param name="targetCalendars">
215
+ /// The target calendars.
216
+ /// </param>
217
+ /// <returns>
218
+ /// A reference to the <see cref="AddToCalendarRequestBuilder"/>.
219
+ /// </returns>
220
+ public AddToCalendarRequestBuilder TargetCalendars ( IList < AddToCalendarRequest . TargetCalendar > targetCalendars )
221
+ {
222
+ this . targetCalendars = targetCalendars ;
223
+
224
+ return this ;
225
+ }
226
+
133
227
/// <inheritdoc />
134
228
public AddToCalendarRequest Build ( )
135
229
{
136
- return new AddToCalendarRequest
230
+ var request = new AddToCalendarRequest
137
231
{
138
232
OAuth = this . oauthBuilder . Build ( ) ,
139
233
Event = this . upsertEventRequestBuilder . Build ( ) ,
234
+ TargetCalendars = this . targetCalendars ,
140
235
} ;
236
+
237
+ if ( this . availabilityRequestBuilder != null )
238
+ {
239
+ request . Availability = this . availabilityRequestBuilder . Build ( ) ;
240
+ }
241
+
242
+ return request ;
141
243
}
142
244
}
143
245
}
0 commit comments