/// <summary> /// Initializes a new instance of the <see cref="DeliveryClient"/> class for the unpublished content of the specified project. /// </summary> /// <param name="projectId">The identifier of the Kentico Cloud project.</param> /// <param name="previewApiKey">The Preview API key.</param> public DeliveryClient(string projectId, string previewApiKey) { if (projectId == null) { throw new ArgumentNullException(nameof(projectId), "Kentico Cloud project identifier is not specified."); } if (projectId == string.Empty) { throw new ArgumentException("Kentico Cloud project identifier is not specified.", nameof(projectId)); } if (projectId.Length > PROJECT_ID_MAX_LENGTH) { throw new ArgumentException($"The specified Kentico cloud project identifier ({projectId}) is too long. Haven't you accidentally passed the Preview API key instead of the project identifier?", nameof(projectId)); } if (previewApiKey == null) { throw new ArgumentNullException(nameof(projectId), "The Preview API key is not specified."); } if (previewApiKey == string.Empty) { throw new ArgumentException("The Preview API key is not specified.", nameof(projectId)); } _urlBuilder = new DeliveryEndpointUrlBuilder(projectId, previewApiKey); _httpClient = new HttpClient(); _httpClient.DefaultRequestHeaders.Add("Authorization", string.Format("Bearer {0}", previewApiKey)); }
/// <summary> /// Initializes a new instance of the <see cref="DeliveryClient"/> class for the published content of the specified project. /// </summary> /// <param name="projectId">The identifier of the Kentico Cloud project.</param> public DeliveryClient(string projectId) { if (projectId == null) { throw new ArgumentNullException(nameof(projectId), "Kentico Cloud project identifier is not specified."); } if (projectId == string.Empty) { throw new ArgumentException("Kentico Cloud project identifier is not specified.", nameof(projectId)); } if (projectId.Length > PROJECT_ID_MAX_LENGTH) { throw new ArgumentException($"The specified Kentico cloud project identifier ({projectId}) is too long. Haven't you accidentally passed the Preview API key instead of the project identifier?", nameof(projectId)); } _urlBuilder = new DeliveryEndpointUrlBuilder(projectId); _httpClient = new HttpClient(); }