Exemple #1
0
        /// <summary>
        /// Sets the event details of the request.
        /// </summary>
        /// <param name="upsertEventRequest">
        /// The event details for the request, must not be null.
        /// </param>
        /// <returns>
        /// A reference to the <see cref="RealTimeSchedulingRequestBuilder"/>.
        /// </returns>
        public RealTimeSchedulingRequestBuilder UpsertEventRequest(UpsertEventRequest upsertEventRequest)
        {
            Preconditions.NotNull("event", upsertEventRequest);

            this.upsertEventRequestBuilder = Builder.Wrap(upsertEventRequest);

            return(this);
        }
Exemple #2
0
        /// <summary>
        /// Sets the event details of the request.
        /// </summary>
        /// <param name="upsertEventRequest">
        /// The event details for the request, must not be null.
        /// </param>
        /// <returns>
        /// A reference to the <see cref="AddToCalendarRequestBuilder"/>.
        /// </returns>
        public AddToCalendarRequestBuilder UpsertEventRequest(UpsertEventRequest upsertEventRequest)
        {
            Preconditions.NotNull("event", upsertEventRequest);

            this.upsertEventRequestBuilder = Builder.Wrap(upsertEventRequest);

            return(this);
        }
Exemple #3
0
        /// <summary>
        /// Sets the event on the builder.
        /// </summary>
        /// <returns>
        /// A reference to the <see cref="SequenceRequestBuilder"/>.
        /// </returns>
        /// <exception cref="ArgumentException">
        /// Thrown if <paramref name="eventRequest"/> is <code>null</code>.
        /// </exception>
        /// <param name="eventRequest">Event request.</param>
        public SequenceRequestBuilder Event(UpsertEventRequest eventRequest)
        {
            Preconditions.NotNull("eventRequest", eventRequest);

            this.eventRequest = eventRequest;

            return(this);
        }
Exemple #4
0
        public AddToCalendar()
        {
            this.client = new CronofyOAuthClient(clientId, clientSecret);
            this.http   = new StubHttpClient();

            client.HttpClient = http;

            this.upsertEventRequest = new UpsertEventRequestBuilder()
                                      .EventId(eventId)
                                      .Summary(summary)
                                      .Start(start)
                                      .End(end)
                                      .Build();
        }
        /// <inheritdoc/>
        public void UpsertEvent(string calendarId, UpsertEventRequest eventRequest)
        {
            Preconditions.NotEmpty("calendarId", calendarId);
            Preconditions.NotNull("eventRequest", eventRequest);

            var request = new HttpRequest();

            request.Method = "POST";
            request.Url    = string.Format(this.UrlProvider.ManagedEventUrlFormat, calendarId);
            request.AddOAuthAuthorization(this.AccessToken);
            request.SetJsonBody(eventRequest);

            this.HttpClient.GetValidResponse(request);
        }
Exemple #6
0
        public void SetUp()
        {
            this.client = new CronofyOAuthClient(clientId, clientSecret);
            this.http   = new StubHttpClient();

            client.HttpClient = http;

            this.upsertEventRequestWithoutStartAndEnd = new UpsertEventRequestBuilder()
                                                        .EventId(eventId)
                                                        .Summary(summary)
                                                        .Build();

            this.availabilityRequest = new AvailabilityRequestBuilder()
                                       .AddParticipantGroup(new ParticipantGroupBuilder().AddMember(sub))
                                       .AddAvailablePeriod(start, end)
                                       .RequiredDuration(60)
                                       .Build();
        }
        /// <inheritdoc/>
        public void UpsertEvent(string calendarId, UpsertEventRequest eventRequest)
        {
            Preconditions.NotEmpty("calendarId", calendarId);
            Preconditions.NotNull("eventRequest", eventRequest);

            var request = new HttpRequest();

            request.Method = "POST";
            request.Url    = string.Format(ManagedEventUrlFormat, calendarId);
            request.AddOAuthAuthorization(this.accessToken);
            request.SetJsonBody(eventRequest);

            var response = this.HttpClient.GetResponse(request);

            if (response.Code != 202)
            {
                // TODO More useful exceptions for validation errors
                throw new CronofyException("Request failed");
            }
        }
Exemple #8
0
        /// <summary>
        /// Add an event upsert to the batch.
        /// </summary>
        /// <param name="calendarId">
        /// The ID of the calendar the event should be upserted to, must not be
        /// empty.
        /// </param>
        /// <param name="eventRequest">
        /// The builder from which to create a <see cref="UpsertEventRequest"/>
        /// entry, must not be null.
        /// </param>
        /// <exception cref="ArgumentException">
        /// Thrown if <paramref name="calendarId"/> is empty or if
        /// <paramref name="eventRequest"/> is null.
        /// </exception>
        /// <returns>
        /// A reference to the modified builder.
        /// </returns>
        public BatchRequestBuilder UpsertEvent(string calendarId, UpsertEventRequest eventRequest)
        {
            Preconditions.NotNull("eventRequest", eventRequest);

            return this.UpsertEvent(calendarId, Builder.Wrap(eventRequest));
        }