//------------------------------------------------------------------------------ // // This code was generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. // // Changes to this file may cause incorrect behavior and will be lost when // the code is regenerated. // //------------------------------------------------------------------------------ #nullable enable namespace LukeHagar.PlexAPI.SDK { using LukeHagar.PlexAPI.SDK.Hooks; using LukeHagar.PlexAPI.SDK.Models.Components; using LukeHagar.PlexAPI.SDK.Models.Errors; using LukeHagar.PlexAPI.SDK.Models.Requests; using LukeHagar.PlexAPI.SDK.Utils; using LukeHagar.PlexAPI.SDK.Utils.Retries; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; /// /// The actual content of the media provider /// public interface IContent { /// /// Get items in a collection /// /// /// Get items in a collection. Note if this collection contains more than 100 items, paging must be used. /// /// Task GetCollectionItemsAsync(GetCollectionItemsRequest request); /// /// Get a metadata item /// /// /// Get one or more metadata items. /// /// Task GetMetadataItemAsync(GetMetadataItemRequest request); /// /// Set section albums /// /// /// Get all albums in a music section /// /// Task GetAlbumsAsync(GetAlbumsRequest request); /// /// Get items in the section /// /// /// Get the items in a section, potentially filtering them /// /// Task ListContentAsync(ListContentRequest request); /// /// Set section leaves /// /// /// Get all leaves in a section (such as episodes in a show section) /// /// Task GetAllLeavesAsync(GetAllLeavesRequest request); /// /// Set section artwork /// /// /// Get artwork for a library section /// /// Task GetArtsAsync(GetArtsRequest request); /// /// Set section categories /// /// /// Get categories in a library section /// /// Task GetCategoriesAsync(GetCategoriesRequest request); /// /// Set section clusters /// /// /// Get clusters in a library section (typically for photos) /// /// Task GetClusterAsync(GetClusterRequest request); /// /// Similar tracks to transition from one to another /// /// /// Get a list of audio tracks starting at one and ending at another which are similar across the path /// /// Task GetSonicPathAsync(GetSonicPathRequest request); /// /// Get all folder locations /// /// /// Get all folder locations of the media in a section /// /// Task GetFoldersAsync(GetFoldersRequest request); /// /// Set section moments /// /// /// Get moments in a library section (typically for photos) /// /// Task ListMomentsAsync(ListMomentsRequest request); /// /// The nearest audio tracks /// /// /// Get the nearest audio tracks to a particular analysis /// /// Task GetSonicallySimilarAsync(GetSonicallySimilarRequest request); /// /// Get a collection's image /// /// /// Get an image for the collection based on the items within /// /// Task GetCollectionImageAsync(GetCollectionImageRequest request); } /// /// The actual content of the media provider /// public class Content: IContent { public SDKConfig SDKConfiguration { get; private set; } private const string _language = "csharp"; private const string _sdkVersion = "0.19.0"; private const string _sdkGenVersion = "2.743.2"; private const string _openapiDocVersion = "1.1.1"; public Content(SDKConfig config) { SDKConfiguration = config; } public async Task GetCollectionItemsAsync(GetCollectionItemsRequest request) { if (request == null) { request = new GetCollectionItemsRequest(); } request.Accepts ??= SDKConfiguration.Accepts; request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier; request.Product ??= SDKConfiguration.Product; request.Version ??= SDKConfiguration.Version; request.Platform ??= SDKConfiguration.Platform; request.PlatformVersion ??= SDKConfiguration.PlatformVersion; request.Device ??= SDKConfiguration.Device; request.Model ??= SDKConfiguration.Model; request.DeviceVendor ??= SDKConfiguration.DeviceVendor; request.DeviceName ??= SDKConfiguration.DeviceName; request.Marketplace ??= SDKConfiguration.Marketplace; string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl(); var urlString = URLBuilder.Build(baseUrl, "/library/collections/{collectionId}/items", request); var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString); httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent); HeaderSerializer.PopulateHeaders(ref httpRequest, request); if (SDKConfiguration.SecuritySource != null) { httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest); } var hookCtx = new HookContext(SDKConfiguration, baseUrl, "getCollectionItems", null, SDKConfiguration.SecuritySource); httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest); HttpResponseMessage httpResponse; try { httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest); int _statusCode = (int)httpResponse.StatusCode; if (_statusCode == 404 || _statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null); if (_httpResponse != null) { httpResponse = _httpResponse; } } } catch (Exception error) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error); if (_httpResponse != null) { httpResponse = _httpResponse; } else { throw; } } httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse); var contentType = httpResponse.Content.Headers.ContentType?.MediaType; int responseStatusCode = (int)httpResponse.StatusCode; if(responseStatusCode == 200) { if(Utilities.IsContentTypeMatch("application/json", contentType)) { var httpResponseBody = await httpResponse.Content.ReadAsStringAsync(); MediaContainerWithMetadata obj; try { obj = ResponseBodyDeserializer.DeserializeNotNull(httpResponseBody, NullValueHandling.Ignore); } catch (Exception ex) { throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithMetadata.", httpResponse, httpResponseBody, ex); } var response = new GetCollectionItemsResponse() { StatusCode = responseStatusCode, ContentType = contentType, RawResponse = httpResponse }; response.MediaContainerWithMetadata = obj; return response; } throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode == 404 || responseStatusCode >= 400 && responseStatusCode < 500) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 500 && responseStatusCode < 600) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } public async Task GetMetadataItemAsync(GetMetadataItemRequest request) { if (request == null) { request = new GetMetadataItemRequest(); } request.Accepts ??= SDKConfiguration.Accepts; request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier; request.Product ??= SDKConfiguration.Product; request.Version ??= SDKConfiguration.Version; request.Platform ??= SDKConfiguration.Platform; request.PlatformVersion ??= SDKConfiguration.PlatformVersion; request.Device ??= SDKConfiguration.Device; request.Model ??= SDKConfiguration.Model; request.DeviceVendor ??= SDKConfiguration.DeviceVendor; request.DeviceName ??= SDKConfiguration.DeviceName; request.Marketplace ??= SDKConfiguration.Marketplace; string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl(); var urlString = URLBuilder.Build(baseUrl, "/library/metadata/{ids}", request); var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString); httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent); HeaderSerializer.PopulateHeaders(ref httpRequest, request); if (SDKConfiguration.SecuritySource != null) { httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest); } var hookCtx = new HookContext(SDKConfiguration, baseUrl, "getMetadataItem", null, SDKConfiguration.SecuritySource); httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest); HttpResponseMessage httpResponse; try { httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest); int _statusCode = (int)httpResponse.StatusCode; if (_statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null); if (_httpResponse != null) { httpResponse = _httpResponse; } } } catch (Exception error) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error); if (_httpResponse != null) { httpResponse = _httpResponse; } else { throw; } } httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse); var contentType = httpResponse.Content.Headers.ContentType?.MediaType; int responseStatusCode = (int)httpResponse.StatusCode; if(responseStatusCode == 200) { if(Utilities.IsContentTypeMatch("application/json", contentType)) { var httpResponseBody = await httpResponse.Content.ReadAsStringAsync(); MediaContainerWithMetadata obj; try { obj = ResponseBodyDeserializer.DeserializeNotNull(httpResponseBody, NullValueHandling.Ignore); } catch (Exception ex) { throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithMetadata.", httpResponse, httpResponseBody, ex); } var response = new GetMetadataItemResponse() { StatusCode = responseStatusCode, ContentType = contentType, RawResponse = httpResponse }; response.MediaContainerWithMetadata = obj; return response; } throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 400 && responseStatusCode < 500) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 500 && responseStatusCode < 600) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } public async Task GetAlbumsAsync(GetAlbumsRequest request) { if (request == null) { request = new GetAlbumsRequest(); } request.Accepts ??= SDKConfiguration.Accepts; request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier; request.Product ??= SDKConfiguration.Product; request.Version ??= SDKConfiguration.Version; request.Platform ??= SDKConfiguration.Platform; request.PlatformVersion ??= SDKConfiguration.PlatformVersion; request.Device ??= SDKConfiguration.Device; request.Model ??= SDKConfiguration.Model; request.DeviceVendor ??= SDKConfiguration.DeviceVendor; request.DeviceName ??= SDKConfiguration.DeviceName; request.Marketplace ??= SDKConfiguration.Marketplace; string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl(); var urlString = URLBuilder.Build(baseUrl, "/library/sections/{sectionId}/albums", request); var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString); httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent); HeaderSerializer.PopulateHeaders(ref httpRequest, request); if (SDKConfiguration.SecuritySource != null) { httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest); } var hookCtx = new HookContext(SDKConfiguration, baseUrl, "getAlbums", null, SDKConfiguration.SecuritySource); httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest); HttpResponseMessage httpResponse; try { httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest); int _statusCode = (int)httpResponse.StatusCode; if (_statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null); if (_httpResponse != null) { httpResponse = _httpResponse; } } } catch (Exception error) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error); if (_httpResponse != null) { httpResponse = _httpResponse; } else { throw; } } httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse); var contentType = httpResponse.Content.Headers.ContentType?.MediaType; int responseStatusCode = (int)httpResponse.StatusCode; if(responseStatusCode == 200) { if(Utilities.IsContentTypeMatch("application/json", contentType)) { var httpResponseBody = await httpResponse.Content.ReadAsStringAsync(); MediaContainerWithMetadata obj; try { obj = ResponseBodyDeserializer.DeserializeNotNull(httpResponseBody, NullValueHandling.Ignore); } catch (Exception ex) { throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithMetadata.", httpResponse, httpResponseBody, ex); } var response = new GetAlbumsResponse() { StatusCode = responseStatusCode, ContentType = contentType, RawResponse = httpResponse }; response.MediaContainerWithMetadata = obj; return response; } throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 400 && responseStatusCode < 500) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 500 && responseStatusCode < 600) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } public async Task ListContentAsync(ListContentRequest request) { if (request == null) { request = new ListContentRequest(); } request.Accepts ??= SDKConfiguration.Accepts; request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier; request.Product ??= SDKConfiguration.Product; request.Version ??= SDKConfiguration.Version; request.Platform ??= SDKConfiguration.Platform; request.PlatformVersion ??= SDKConfiguration.PlatformVersion; request.Device ??= SDKConfiguration.Device; request.Model ??= SDKConfiguration.Model; request.DeviceVendor ??= SDKConfiguration.DeviceVendor; request.DeviceName ??= SDKConfiguration.DeviceName; request.Marketplace ??= SDKConfiguration.Marketplace; string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl(); var urlString = URLBuilder.Build(baseUrl, "/library/sections/{sectionId}/all", request); var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString); httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent); HeaderSerializer.PopulateHeaders(ref httpRequest, request); if (SDKConfiguration.SecuritySource != null) { httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest); } var hookCtx = new HookContext(SDKConfiguration, baseUrl, "listContent", null, SDKConfiguration.SecuritySource); httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest); HttpResponseMessage httpResponse; try { httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest); int _statusCode = (int)httpResponse.StatusCode; if (_statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null); if (_httpResponse != null) { httpResponse = _httpResponse; } } } catch (Exception error) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error); if (_httpResponse != null) { httpResponse = _httpResponse; } else { throw; } } httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse); var contentType = httpResponse.Content.Headers.ContentType?.MediaType; int responseStatusCode = (int)httpResponse.StatusCode; if(responseStatusCode == 200) { if(Utilities.IsContentTypeMatch("application/json", contentType)) { var httpResponseBody = await httpResponse.Content.ReadAsStringAsync(); MediaContainerWithMetadata obj; try { obj = ResponseBodyDeserializer.DeserializeNotNull(httpResponseBody, NullValueHandling.Ignore); } catch (Exception ex) { throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithMetadata.", httpResponse, httpResponseBody, ex); } var response = new ListContentResponse() { StatusCode = responseStatusCode, ContentType = contentType, RawResponse = httpResponse }; response.MediaContainerWithMetadata = obj; return response; } throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 400 && responseStatusCode < 500) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 500 && responseStatusCode < 600) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } public async Task GetAllLeavesAsync(GetAllLeavesRequest request) { if (request == null) { request = new GetAllLeavesRequest(); } request.Accepts ??= SDKConfiguration.Accepts; request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier; request.Product ??= SDKConfiguration.Product; request.Version ??= SDKConfiguration.Version; request.Platform ??= SDKConfiguration.Platform; request.PlatformVersion ??= SDKConfiguration.PlatformVersion; request.Device ??= SDKConfiguration.Device; request.Model ??= SDKConfiguration.Model; request.DeviceVendor ??= SDKConfiguration.DeviceVendor; request.DeviceName ??= SDKConfiguration.DeviceName; request.Marketplace ??= SDKConfiguration.Marketplace; string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl(); var urlString = URLBuilder.Build(baseUrl, "/library/sections/{sectionId}/allLeaves", request); var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString); httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent); HeaderSerializer.PopulateHeaders(ref httpRequest, request); if (SDKConfiguration.SecuritySource != null) { httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest); } var hookCtx = new HookContext(SDKConfiguration, baseUrl, "getAllLeaves", null, SDKConfiguration.SecuritySource); httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest); HttpResponseMessage httpResponse; try { httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest); int _statusCode = (int)httpResponse.StatusCode; if (_statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null); if (_httpResponse != null) { httpResponse = _httpResponse; } } } catch (Exception error) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error); if (_httpResponse != null) { httpResponse = _httpResponse; } else { throw; } } httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse); var contentType = httpResponse.Content.Headers.ContentType?.MediaType; int responseStatusCode = (int)httpResponse.StatusCode; if(responseStatusCode == 200) { if(Utilities.IsContentTypeMatch("application/json", contentType)) { var httpResponseBody = await httpResponse.Content.ReadAsStringAsync(); MediaContainerWithMetadata obj; try { obj = ResponseBodyDeserializer.DeserializeNotNull(httpResponseBody, NullValueHandling.Ignore); } catch (Exception ex) { throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithMetadata.", httpResponse, httpResponseBody, ex); } var response = new GetAllLeavesResponse() { StatusCode = responseStatusCode, ContentType = contentType, RawResponse = httpResponse }; response.MediaContainerWithMetadata = obj; return response; } throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 400 && responseStatusCode < 500) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 500 && responseStatusCode < 600) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } public async Task GetArtsAsync(GetArtsRequest request) { if (request == null) { request = new GetArtsRequest(); } request.Accepts ??= SDKConfiguration.Accepts; request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier; request.Product ??= SDKConfiguration.Product; request.Version ??= SDKConfiguration.Version; request.Platform ??= SDKConfiguration.Platform; request.PlatformVersion ??= SDKConfiguration.PlatformVersion; request.Device ??= SDKConfiguration.Device; request.Model ??= SDKConfiguration.Model; request.DeviceVendor ??= SDKConfiguration.DeviceVendor; request.DeviceName ??= SDKConfiguration.DeviceName; request.Marketplace ??= SDKConfiguration.Marketplace; string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl(); var urlString = URLBuilder.Build(baseUrl, "/library/sections/{sectionId}/arts", request); var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString); httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent); HeaderSerializer.PopulateHeaders(ref httpRequest, request); if (SDKConfiguration.SecuritySource != null) { httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest); } var hookCtx = new HookContext(SDKConfiguration, baseUrl, "getArts", null, SDKConfiguration.SecuritySource); httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest); HttpResponseMessage httpResponse; try { httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest); int _statusCode = (int)httpResponse.StatusCode; if (_statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null); if (_httpResponse != null) { httpResponse = _httpResponse; } } } catch (Exception error) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error); if (_httpResponse != null) { httpResponse = _httpResponse; } else { throw; } } httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse); var contentType = httpResponse.Content.Headers.ContentType?.MediaType; int responseStatusCode = (int)httpResponse.StatusCode; if(responseStatusCode == 200) { if(Utilities.IsContentTypeMatch("application/json", contentType)) { var httpResponseBody = await httpResponse.Content.ReadAsStringAsync(); MediaContainerWithArtwork obj; try { obj = ResponseBodyDeserializer.DeserializeNotNull(httpResponseBody, NullValueHandling.Ignore); } catch (Exception ex) { throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithArtwork.", httpResponse, httpResponseBody, ex); } var response = new GetArtsResponse() { StatusCode = responseStatusCode, ContentType = contentType, RawResponse = httpResponse }; response.MediaContainerWithArtwork = obj; return response; } throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 400 && responseStatusCode < 500) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 500 && responseStatusCode < 600) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } public async Task GetCategoriesAsync(GetCategoriesRequest request) { if (request == null) { request = new GetCategoriesRequest(); } request.Accepts ??= SDKConfiguration.Accepts; request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier; request.Product ??= SDKConfiguration.Product; request.Version ??= SDKConfiguration.Version; request.Platform ??= SDKConfiguration.Platform; request.PlatformVersion ??= SDKConfiguration.PlatformVersion; request.Device ??= SDKConfiguration.Device; request.Model ??= SDKConfiguration.Model; request.DeviceVendor ??= SDKConfiguration.DeviceVendor; request.DeviceName ??= SDKConfiguration.DeviceName; request.Marketplace ??= SDKConfiguration.Marketplace; string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl(); var urlString = URLBuilder.Build(baseUrl, "/library/sections/{sectionId}/categories", request); var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString); httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent); HeaderSerializer.PopulateHeaders(ref httpRequest, request); if (SDKConfiguration.SecuritySource != null) { httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest); } var hookCtx = new HookContext(SDKConfiguration, baseUrl, "getCategories", null, SDKConfiguration.SecuritySource); httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest); HttpResponseMessage httpResponse; try { httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest); int _statusCode = (int)httpResponse.StatusCode; if (_statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null); if (_httpResponse != null) { httpResponse = _httpResponse; } } } catch (Exception error) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error); if (_httpResponse != null) { httpResponse = _httpResponse; } else { throw; } } httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse); var contentType = httpResponse.Content.Headers.ContentType?.MediaType; int responseStatusCode = (int)httpResponse.StatusCode; if(responseStatusCode == 200) { if(Utilities.IsContentTypeMatch("application/json", contentType)) { var httpResponseBody = await httpResponse.Content.ReadAsStringAsync(); MediaContainerWithArtwork obj; try { obj = ResponseBodyDeserializer.DeserializeNotNull(httpResponseBody, NullValueHandling.Ignore); } catch (Exception ex) { throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithArtwork.", httpResponse, httpResponseBody, ex); } var response = new GetCategoriesResponse() { StatusCode = responseStatusCode, ContentType = contentType, RawResponse = httpResponse }; response.MediaContainerWithArtwork = obj; return response; } throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 400 && responseStatusCode < 500) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 500 && responseStatusCode < 600) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } public async Task GetClusterAsync(GetClusterRequest request) { if (request == null) { request = new GetClusterRequest(); } request.Accepts ??= SDKConfiguration.Accepts; request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier; request.Product ??= SDKConfiguration.Product; request.Version ??= SDKConfiguration.Version; request.Platform ??= SDKConfiguration.Platform; request.PlatformVersion ??= SDKConfiguration.PlatformVersion; request.Device ??= SDKConfiguration.Device; request.Model ??= SDKConfiguration.Model; request.DeviceVendor ??= SDKConfiguration.DeviceVendor; request.DeviceName ??= SDKConfiguration.DeviceName; request.Marketplace ??= SDKConfiguration.Marketplace; string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl(); var urlString = URLBuilder.Build(baseUrl, "/library/sections/{sectionId}/cluster", request); var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString); httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent); HeaderSerializer.PopulateHeaders(ref httpRequest, request); if (SDKConfiguration.SecuritySource != null) { httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest); } var hookCtx = new HookContext(SDKConfiguration, baseUrl, "getCluster", null, SDKConfiguration.SecuritySource); httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest); HttpResponseMessage httpResponse; try { httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest); int _statusCode = (int)httpResponse.StatusCode; if (_statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null); if (_httpResponse != null) { httpResponse = _httpResponse; } } } catch (Exception error) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error); if (_httpResponse != null) { httpResponse = _httpResponse; } else { throw; } } httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse); var contentType = httpResponse.Content.Headers.ContentType?.MediaType; int responseStatusCode = (int)httpResponse.StatusCode; if(responseStatusCode == 200) { if(Utilities.IsContentTypeMatch("application/json", contentType)) { var httpResponseBody = await httpResponse.Content.ReadAsStringAsync(); MediaContainerWithArtwork obj; try { obj = ResponseBodyDeserializer.DeserializeNotNull(httpResponseBody, NullValueHandling.Ignore); } catch (Exception ex) { throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithArtwork.", httpResponse, httpResponseBody, ex); } var response = new GetClusterResponse() { StatusCode = responseStatusCode, ContentType = contentType, RawResponse = httpResponse }; response.MediaContainerWithArtwork = obj; return response; } throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 400 && responseStatusCode < 500) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 500 && responseStatusCode < 600) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } public async Task GetSonicPathAsync(GetSonicPathRequest request) { if (request == null) { request = new GetSonicPathRequest(); } request.Accepts ??= SDKConfiguration.Accepts; request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier; request.Product ??= SDKConfiguration.Product; request.Version ??= SDKConfiguration.Version; request.Platform ??= SDKConfiguration.Platform; request.PlatformVersion ??= SDKConfiguration.PlatformVersion; request.Device ??= SDKConfiguration.Device; request.Model ??= SDKConfiguration.Model; request.DeviceVendor ??= SDKConfiguration.DeviceVendor; request.DeviceName ??= SDKConfiguration.DeviceName; request.Marketplace ??= SDKConfiguration.Marketplace; string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl(); var urlString = URLBuilder.Build(baseUrl, "/library/sections/{sectionId}/computePath", request); var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString); httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent); HeaderSerializer.PopulateHeaders(ref httpRequest, request); if (SDKConfiguration.SecuritySource != null) { httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest); } var hookCtx = new HookContext(SDKConfiguration, baseUrl, "getSonicPath", null, SDKConfiguration.SecuritySource); httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest); HttpResponseMessage httpResponse; try { httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest); int _statusCode = (int)httpResponse.StatusCode; if (_statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null); if (_httpResponse != null) { httpResponse = _httpResponse; } } } catch (Exception error) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error); if (_httpResponse != null) { httpResponse = _httpResponse; } else { throw; } } httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse); var contentType = httpResponse.Content.Headers.ContentType?.MediaType; int responseStatusCode = (int)httpResponse.StatusCode; if(responseStatusCode == 200) { if(Utilities.IsContentTypeMatch("application/json", contentType)) { var httpResponseBody = await httpResponse.Content.ReadAsStringAsync(); MediaContainerWithMetadata obj; try { obj = ResponseBodyDeserializer.DeserializeNotNull(httpResponseBody, NullValueHandling.Ignore); } catch (Exception ex) { throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithMetadata.", httpResponse, httpResponseBody, ex); } var response = new GetSonicPathResponse() { StatusCode = responseStatusCode, ContentType = contentType, RawResponse = httpResponse }; response.MediaContainerWithMetadata = obj; return response; } throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 400 && responseStatusCode < 500) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 500 && responseStatusCode < 600) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } public async Task GetFoldersAsync(GetFoldersRequest request) { if (request == null) { request = new GetFoldersRequest(); } request.Accepts ??= SDKConfiguration.Accepts; request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier; request.Product ??= SDKConfiguration.Product; request.Version ??= SDKConfiguration.Version; request.Platform ??= SDKConfiguration.Platform; request.PlatformVersion ??= SDKConfiguration.PlatformVersion; request.Device ??= SDKConfiguration.Device; request.Model ??= SDKConfiguration.Model; request.DeviceVendor ??= SDKConfiguration.DeviceVendor; request.DeviceName ??= SDKConfiguration.DeviceName; request.Marketplace ??= SDKConfiguration.Marketplace; string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl(); var urlString = URLBuilder.Build(baseUrl, "/library/sections/{sectionId}/location", request); var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString); httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent); HeaderSerializer.PopulateHeaders(ref httpRequest, request); if (SDKConfiguration.SecuritySource != null) { httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest); } var hookCtx = new HookContext(SDKConfiguration, baseUrl, "getFolders", null, SDKConfiguration.SecuritySource); httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest); HttpResponseMessage httpResponse; try { httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest); int _statusCode = (int)httpResponse.StatusCode; if (_statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null); if (_httpResponse != null) { httpResponse = _httpResponse; } } } catch (Exception error) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error); if (_httpResponse != null) { httpResponse = _httpResponse; } else { throw; } } httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse); var contentType = httpResponse.Content.Headers.ContentType?.MediaType; int responseStatusCode = (int)httpResponse.StatusCode; if(responseStatusCode == 200) { if(Utilities.IsContentTypeMatch("application/json", contentType)) { var httpResponseBody = await httpResponse.Content.ReadAsStringAsync(); GetFoldersResponseBody obj; try { obj = ResponseBodyDeserializer.DeserializeNotNull(httpResponseBody, NullValueHandling.Ignore); } catch (Exception ex) { throw new ResponseValidationException("Failed to deserialize response body into GetFoldersResponseBody.", httpResponse, httpResponseBody, ex); } var response = new GetFoldersResponse() { StatusCode = responseStatusCode, ContentType = contentType, RawResponse = httpResponse }; response.Object = obj; return response; } throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 400 && responseStatusCode < 500) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 500 && responseStatusCode < 600) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } public async Task ListMomentsAsync(ListMomentsRequest request) { if (request == null) { request = new ListMomentsRequest(); } request.Accepts ??= SDKConfiguration.Accepts; request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier; request.Product ??= SDKConfiguration.Product; request.Version ??= SDKConfiguration.Version; request.Platform ??= SDKConfiguration.Platform; request.PlatformVersion ??= SDKConfiguration.PlatformVersion; request.Device ??= SDKConfiguration.Device; request.Model ??= SDKConfiguration.Model; request.DeviceVendor ??= SDKConfiguration.DeviceVendor; request.DeviceName ??= SDKConfiguration.DeviceName; request.Marketplace ??= SDKConfiguration.Marketplace; string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl(); var urlString = URLBuilder.Build(baseUrl, "/library/sections/{sectionId}/moment", request); var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString); httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent); HeaderSerializer.PopulateHeaders(ref httpRequest, request); if (SDKConfiguration.SecuritySource != null) { httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest); } var hookCtx = new HookContext(SDKConfiguration, baseUrl, "listMoments", null, SDKConfiguration.SecuritySource); httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest); HttpResponseMessage httpResponse; try { httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest); int _statusCode = (int)httpResponse.StatusCode; if (_statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null); if (_httpResponse != null) { httpResponse = _httpResponse; } } } catch (Exception error) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error); if (_httpResponse != null) { httpResponse = _httpResponse; } else { throw; } } httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse); var contentType = httpResponse.Content.Headers.ContentType?.MediaType; int responseStatusCode = (int)httpResponse.StatusCode; if(responseStatusCode == 200) { if(Utilities.IsContentTypeMatch("application/json", contentType)) { var httpResponseBody = await httpResponse.Content.ReadAsStringAsync(); MediaContainerWithArtwork obj; try { obj = ResponseBodyDeserializer.DeserializeNotNull(httpResponseBody, NullValueHandling.Ignore); } catch (Exception ex) { throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithArtwork.", httpResponse, httpResponseBody, ex); } var response = new ListMomentsResponse() { StatusCode = responseStatusCode, ContentType = contentType, RawResponse = httpResponse }; response.MediaContainerWithArtwork = obj; return response; } throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 400 && responseStatusCode < 500) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 500 && responseStatusCode < 600) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } public async Task GetSonicallySimilarAsync(GetSonicallySimilarRequest request) { if (request == null) { request = new GetSonicallySimilarRequest(); } request.Accepts ??= SDKConfiguration.Accepts; request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier; request.Product ??= SDKConfiguration.Product; request.Version ??= SDKConfiguration.Version; request.Platform ??= SDKConfiguration.Platform; request.PlatformVersion ??= SDKConfiguration.PlatformVersion; request.Device ??= SDKConfiguration.Device; request.Model ??= SDKConfiguration.Model; request.DeviceVendor ??= SDKConfiguration.DeviceVendor; request.DeviceName ??= SDKConfiguration.DeviceName; request.Marketplace ??= SDKConfiguration.Marketplace; string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl(); var urlString = URLBuilder.Build(baseUrl, "/library/sections/{sectionId}/nearest", request); var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString); httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent); HeaderSerializer.PopulateHeaders(ref httpRequest, request); if (SDKConfiguration.SecuritySource != null) { httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest); } var hookCtx = new HookContext(SDKConfiguration, baseUrl, "getSonicallySimilar", null, SDKConfiguration.SecuritySource); httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest); HttpResponseMessage httpResponse; try { httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest); int _statusCode = (int)httpResponse.StatusCode; if (_statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null); if (_httpResponse != null) { httpResponse = _httpResponse; } } } catch (Exception error) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error); if (_httpResponse != null) { httpResponse = _httpResponse; } else { throw; } } httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse); var contentType = httpResponse.Content.Headers.ContentType?.MediaType; int responseStatusCode = (int)httpResponse.StatusCode; if(responseStatusCode == 200) { if(Utilities.IsContentTypeMatch("application/json", contentType)) { var httpResponseBody = await httpResponse.Content.ReadAsStringAsync(); MediaContainerWithMetadata obj; try { obj = ResponseBodyDeserializer.DeserializeNotNull(httpResponseBody, NullValueHandling.Ignore); } catch (Exception ex) { throw new ResponseValidationException("Failed to deserialize response body into MediaContainerWithMetadata.", httpResponse, httpResponseBody, ex); } var response = new GetSonicallySimilarResponse() { StatusCode = responseStatusCode, ContentType = contentType, RawResponse = httpResponse }; response.MediaContainerWithMetadata = obj; return response; } throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 400 && responseStatusCode < 500) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 500 && responseStatusCode < 600) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } public async Task GetCollectionImageAsync(GetCollectionImageRequest request) { if (request == null) { request = new GetCollectionImageRequest(); } request.Accepts ??= SDKConfiguration.Accepts; request.ClientIdentifier ??= SDKConfiguration.ClientIdentifier; request.Product ??= SDKConfiguration.Product; request.Version ??= SDKConfiguration.Version; request.Platform ??= SDKConfiguration.Platform; request.PlatformVersion ??= SDKConfiguration.PlatformVersion; request.Device ??= SDKConfiguration.Device; request.Model ??= SDKConfiguration.Model; request.DeviceVendor ??= SDKConfiguration.DeviceVendor; request.DeviceName ??= SDKConfiguration.DeviceName; request.Marketplace ??= SDKConfiguration.Marketplace; string baseUrl = this.SDKConfiguration.GetTemplatedServerUrl(); var urlString = URLBuilder.Build(baseUrl, "/library/collections/{collectionId}/composite/{updatedAt}", request); var httpRequest = new HttpRequestMessage(HttpMethod.Get, urlString); httpRequest.Headers.Add("user-agent", SDKConfiguration.UserAgent); HeaderSerializer.PopulateHeaders(ref httpRequest, request); if (SDKConfiguration.SecuritySource != null) { httpRequest = new SecurityMetadata(SDKConfiguration.SecuritySource).Apply(httpRequest); } var hookCtx = new HookContext(SDKConfiguration, baseUrl, "getCollectionImage", null, SDKConfiguration.SecuritySource); httpRequest = await this.SDKConfiguration.Hooks.BeforeRequestAsync(new BeforeRequestContext(hookCtx), httpRequest); HttpResponseMessage httpResponse; try { httpResponse = await SDKConfiguration.Client.SendAsync(httpRequest); int _statusCode = (int)httpResponse.StatusCode; if (_statusCode == 404 || _statusCode >= 400 && _statusCode < 500 || _statusCode >= 500 && _statusCode < 600) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), httpResponse, null); if (_httpResponse != null) { httpResponse = _httpResponse; } } } catch (Exception error) { var _httpResponse = await this.SDKConfiguration.Hooks.AfterErrorAsync(new AfterErrorContext(hookCtx), null, error); if (_httpResponse != null) { httpResponse = _httpResponse; } else { throw; } } httpResponse = await this.SDKConfiguration.Hooks.AfterSuccessAsync(new AfterSuccessContext(hookCtx), httpResponse); var contentType = httpResponse.Content.Headers.ContentType?.MediaType; int responseStatusCode = (int)httpResponse.StatusCode; if(responseStatusCode == 200) { if(Utilities.IsContentTypeMatch("image/jpeg", contentType)) { var response = new GetCollectionImageResponse() { StatusCode = responseStatusCode, ContentType = contentType, RawResponse = httpResponse }; response.Bytes = await httpResponse.Content.ReadAsByteArrayAsync(); return response; } throw new Models.Errors.SDKException("Unknown content type received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode == 404 || responseStatusCode >= 400 && responseStatusCode < 500) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } else if(responseStatusCode >= 500 && responseStatusCode < 600) { throw new Models.Errors.SDKException("API error occurred", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } throw new Models.Errors.SDKException("Unknown status code received", httpResponse, await httpResponse.Content.ReadAsStringAsync()); } } }