From 2cf0fa079961d95309561935e8dd579c86345222 Mon Sep 17 00:00:00 2001 From: Joshua Flanagan Date: Wed, 21 Aug 2024 21:08:34 -0500 Subject: [PATCH 1/2] Return the HTTP response status and headers Callers should have access to the response headers - specifically the x-shipengine-request-id. --- ShipEngineSDK/Api/AccountApi.cs | 140 ++++++------ ShipEngineSDK/Api/AddressesApi.cs | 48 ++-- ShipEngineSDK/Api/BatchesApi.cs | 232 ++++++++++---------- ShipEngineSDK/Api/CarrierAccountsApi.cs | 94 ++++---- ShipEngineSDK/Api/CarriersApi.cs | 163 +++++++------- ShipEngineSDK/Api/DownloadsApi.cs | 25 ++- ShipEngineSDK/Api/InsuranceApi.cs | 94 ++++---- ShipEngineSDK/Api/LabelsApi.cs | 209 +++++++++--------- ShipEngineSDK/Api/ManifestsApi.cs | 94 ++++---- ShipEngineSDK/Api/PackagePickupsApi.cs | 94 ++++---- ShipEngineSDK/Api/PackageTypesApi.cs | 117 +++++----- ShipEngineSDK/Api/RatesApi.cs | 94 ++++---- ShipEngineSDK/Api/ServicePointsApi.cs | 48 ++-- ShipEngineSDK/Api/ShipmentsApi.cs | 278 ++++++++++++------------ ShipEngineSDK/Api/TagsApi.cs | 94 ++++---- ShipEngineSDK/Api/TokensApi.cs | 25 ++- ShipEngineSDK/Api/TrackingApi.cs | 71 +++--- ShipEngineSDK/Api/WarehousesApi.cs | 140 ++++++------ ShipEngineSDK/Api/WebhooksApi.cs | 117 +++++----- ShipEngineSDK/ShipEngineClient.cs | 10 +- ShipEngineSDK/ShipEngineResponse.cs | 18 ++ generation/templates/api.mustache | 25 ++- 22 files changed, 1174 insertions(+), 1056 deletions(-) create mode 100644 ShipEngineSDK/ShipEngineResponse.cs diff --git a/ShipEngineSDK/Api/AccountApi.cs b/ShipEngineSDK/Api/AccountApi.cs index d252b388..cdff8ea1 100644 --- a/ShipEngineSDK/Api/AccountApi.cs +++ b/ShipEngineSDK/Api/AccountApi.cs @@ -31,8 +31,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetAccountSettingsImagesResponseBody) - Task CreateAccountImage(CreateAccountSettingsImageRequestBody createAccountSettingsImageRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetAccountSettingsImagesResponseBody) + Task> CreateAccountImage(CreateAccountSettingsImageRequestBody createAccountSettingsImageRequestBody, CancellationToken cancellationToken = default); /// /// Create an Account Image Create an Account Image @@ -42,8 +42,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetAccountSettingsImagesResponseBody) - Task CreateAccountImage(HttpClient methodClient, CreateAccountSettingsImageRequestBody createAccountSettingsImageRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetAccountSettingsImagesResponseBody) + Task> CreateAccountImage(HttpClient methodClient, CreateAccountSettingsImageRequestBody createAccountSettingsImageRequestBody, CancellationToken cancellationToken = default); /// /// Delete Account Image By Id Delete Account Image By Id @@ -52,8 +52,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Label Image Id /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task DeleteAccountImageById(string labelImageId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> DeleteAccountImageById(string labelImageId, CancellationToken cancellationToken = default); /// /// Delete Account Image By Id Delete Account Image By Id @@ -63,8 +63,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Label Image Id /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task DeleteAccountImageById(HttpClient methodClient, string labelImageId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> DeleteAccountImageById(HttpClient methodClient, string labelImageId, CancellationToken cancellationToken = default); /// /// Get Account Image By ID Retrieve information for an account image. @@ -73,8 +73,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Label Image Id /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetAccountSettingsImagesResponseBody) - Task GetAccountSettingsImagesById(string labelImageId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetAccountSettingsImagesResponseBody) + Task> GetAccountSettingsImagesById(string labelImageId, CancellationToken cancellationToken = default); /// /// Get Account Image By ID Retrieve information for an account image. @@ -84,8 +84,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Label Image Id /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetAccountSettingsImagesResponseBody) - Task GetAccountSettingsImagesById(HttpClient methodClient, string labelImageId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetAccountSettingsImagesResponseBody) + Task> GetAccountSettingsImagesById(HttpClient methodClient, string labelImageId, CancellationToken cancellationToken = default); /// /// List Account Images List all account images for the ShipEngine account @@ -93,8 +93,8 @@ public partial interface IShipEngine /// Thrown when required argument is null /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListAccountSettingsImagesResponseBody) - Task ListAccountImages(CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListAccountSettingsImagesResponseBody) + Task> ListAccountImages(CancellationToken cancellationToken = default); /// /// List Account Images List all account images for the ShipEngine account @@ -103,8 +103,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// HttpClient to use for the request /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListAccountSettingsImagesResponseBody) - Task ListAccountImages(HttpClient methodClient, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListAccountSettingsImagesResponseBody) + Task> ListAccountImages(HttpClient methodClient, CancellationToken cancellationToken = default); /// /// List Account Settings List all account settings for the ShipEngine account @@ -112,8 +112,8 @@ public partial interface IShipEngine /// Thrown when required argument is null /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetAccountSettingsResponseBody) - Task ListAccountSettings(CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetAccountSettingsResponseBody) + Task> ListAccountSettings(CancellationToken cancellationToken = default); /// /// List Account Settings List all account settings for the ShipEngine account @@ -122,8 +122,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// HttpClient to use for the request /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetAccountSettingsResponseBody) - Task ListAccountSettings(HttpClient methodClient, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetAccountSettingsResponseBody) + Task> ListAccountSettings(HttpClient methodClient, CancellationToken cancellationToken = default); /// /// Update Account Image By ID Update information for an account image. @@ -133,8 +133,8 @@ public partial interface IShipEngine /// /// Label Image Id /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task UpdateAccountSettingsImagesById(UpdateAccountSettingsImageRequestBody updateAccountSettingsImageRequestBody, string labelImageId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> UpdateAccountSettingsImagesById(UpdateAccountSettingsImageRequestBody updateAccountSettingsImageRequestBody, string labelImageId, CancellationToken cancellationToken = default); /// /// Update Account Image By ID Update information for an account image. @@ -145,8 +145,8 @@ public partial interface IShipEngine /// /// Label Image Id /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task UpdateAccountSettingsImagesById(HttpClient methodClient, UpdateAccountSettingsImageRequestBody updateAccountSettingsImageRequestBody, string labelImageId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> UpdateAccountSettingsImagesById(HttpClient methodClient, UpdateAccountSettingsImageRequestBody updateAccountSettingsImageRequestBody, string labelImageId, CancellationToken cancellationToken = default); } @@ -162,8 +162,8 @@ public partial class ShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetAccountSettingsImagesResponseBody) - public Task CreateAccountImage(CreateAccountSettingsImageRequestBody createAccountSettingsImageRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetAccountSettingsImagesResponseBody) + public Task> CreateAccountImage(CreateAccountSettingsImageRequestBody createAccountSettingsImageRequestBody, CancellationToken cancellationToken = default) { return CreateAccountImage(_client, createAccountSettingsImageRequestBody, cancellationToken); } @@ -176,8 +176,8 @@ public Task CreateAccountImage(CreateAccou /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetAccountSettingsImagesResponseBody) - public async Task CreateAccountImage(HttpClient methodClient, CreateAccountSettingsImageRequestBody createAccountSettingsImageRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetAccountSettingsImagesResponseBody) + public async Task> CreateAccountImage(HttpClient methodClient, CreateAccountSettingsImageRequestBody createAccountSettingsImageRequestBody, CancellationToken cancellationToken = default) { // verify the required parameter 'createAccountSettingsImageRequestBody' is set if (createAccountSettingsImageRequestBody == null) @@ -192,9 +192,10 @@ public async Task CreateAccountImage(HttpC requestOptions.Operation = "AccountApi.CreateAccountImage"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -204,8 +205,8 @@ public async Task CreateAccountImage(HttpC /// Thrown when fails to make API call /// Label Image Id /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task DeleteAccountImageById(string labelImageId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> DeleteAccountImageById(string labelImageId, CancellationToken cancellationToken = default) { return DeleteAccountImageById(_client, labelImageId, cancellationToken); } @@ -218,8 +219,8 @@ public Task DeleteAccountImageById(string labelImageId, CancellationToke /// HttpClient to use for the request /// Label Image Id /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task DeleteAccountImageById(HttpClient methodClient, string labelImageId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> DeleteAccountImageById(HttpClient methodClient, string labelImageId, CancellationToken cancellationToken = default) { // verify the required parameter 'labelImageId' is set if (labelImageId == null) @@ -234,9 +235,10 @@ public async Task DeleteAccountImageById(HttpClient methodClient, string requestOptions.Operation = "AccountApi.DeleteAccountImageById"; - var result = await SendHttpRequestAsync(HttpMethods.Delete, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -246,8 +248,8 @@ public async Task DeleteAccountImageById(HttpClient methodClient, string /// Thrown when fails to make API call /// Label Image Id /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetAccountSettingsImagesResponseBody) - public Task GetAccountSettingsImagesById(string labelImageId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetAccountSettingsImagesResponseBody) + public Task> GetAccountSettingsImagesById(string labelImageId, CancellationToken cancellationToken = default) { return GetAccountSettingsImagesById(_client, labelImageId, cancellationToken); } @@ -260,8 +262,8 @@ public Task GetAccountSettingsImagesById(s /// HttpClient to use for the request /// Label Image Id /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetAccountSettingsImagesResponseBody) - public async Task GetAccountSettingsImagesById(HttpClient methodClient, string labelImageId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetAccountSettingsImagesResponseBody) + public async Task> GetAccountSettingsImagesById(HttpClient methodClient, string labelImageId, CancellationToken cancellationToken = default) { // verify the required parameter 'labelImageId' is set if (labelImageId == null) @@ -276,9 +278,10 @@ public async Task GetAccountSettingsImages requestOptions.Operation = "AccountApi.GetAccountSettingsImagesById"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -287,8 +290,8 @@ public async Task GetAccountSettingsImages /// Thrown when required argument is null /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListAccountSettingsImagesResponseBody) - public Task ListAccountImages(CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListAccountSettingsImagesResponseBody) + public Task> ListAccountImages(CancellationToken cancellationToken = default) { return ListAccountImages(_client, cancellationToken); } @@ -300,8 +303,8 @@ public Task ListAccountImages(Cancellatio /// Thrown when fails to make API call /// HttpClient to use for the request /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListAccountSettingsImagesResponseBody) - public async Task ListAccountImages(HttpClient methodClient, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListAccountSettingsImagesResponseBody) + public async Task> ListAccountImages(HttpClient methodClient, CancellationToken cancellationToken = default) { RequestOptions requestOptions = new("/v1/account/settings/images"); @@ -309,9 +312,10 @@ public async Task ListAccountImages(HttpC requestOptions.Operation = "AccountApi.ListAccountImages"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -320,8 +324,8 @@ public async Task ListAccountImages(HttpC /// Thrown when required argument is null /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetAccountSettingsResponseBody) - public Task ListAccountSettings(CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetAccountSettingsResponseBody) + public Task> ListAccountSettings(CancellationToken cancellationToken = default) { return ListAccountSettings(_client, cancellationToken); } @@ -333,8 +337,8 @@ public Task ListAccountSettings(CancellationToke /// Thrown when fails to make API call /// HttpClient to use for the request /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetAccountSettingsResponseBody) - public async Task ListAccountSettings(HttpClient methodClient, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetAccountSettingsResponseBody) + public async Task> ListAccountSettings(HttpClient methodClient, CancellationToken cancellationToken = default) { RequestOptions requestOptions = new("/v1/account/settings"); @@ -342,9 +346,10 @@ public async Task ListAccountSettings(HttpClient requestOptions.Operation = "AccountApi.ListAccountSettings"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -355,8 +360,8 @@ public async Task ListAccountSettings(HttpClient /// /// Label Image Id /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task UpdateAccountSettingsImagesById(UpdateAccountSettingsImageRequestBody updateAccountSettingsImageRequestBody, string labelImageId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> UpdateAccountSettingsImagesById(UpdateAccountSettingsImageRequestBody updateAccountSettingsImageRequestBody, string labelImageId, CancellationToken cancellationToken = default) { return UpdateAccountSettingsImagesById(_client, updateAccountSettingsImageRequestBody, labelImageId, cancellationToken); } @@ -370,8 +375,8 @@ public Task UpdateAccountSettingsImagesById(UpdateAccountSettingsImageRe /// /// Label Image Id /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task UpdateAccountSettingsImagesById(HttpClient methodClient, UpdateAccountSettingsImageRequestBody updateAccountSettingsImageRequestBody, string labelImageId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> UpdateAccountSettingsImagesById(HttpClient methodClient, UpdateAccountSettingsImageRequestBody updateAccountSettingsImageRequestBody, string labelImageId, CancellationToken cancellationToken = default) { // verify the required parameter 'updateAccountSettingsImageRequestBody' is set if (updateAccountSettingsImageRequestBody == null) @@ -393,9 +398,10 @@ public async Task UpdateAccountSettingsImagesById(HttpClient methodClien requestOptions.Operation = "AccountApi.UpdateAccountSettingsImagesById"; - var result = await SendHttpRequestAsync(HttpMethods.Put, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } -} \ No newline at end of file +} diff --git a/ShipEngineSDK/Api/AddressesApi.cs b/ShipEngineSDK/Api/AddressesApi.cs index 28dd3ad1..3613e3e6 100644 --- a/ShipEngineSDK/Api/AddressesApi.cs +++ b/ShipEngineSDK/Api/AddressesApi.cs @@ -31,8 +31,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// The only required field is `text`, which is the text to be parsed. You can optionally also provide an `address` containing already-known values. For example, you may already know the recipient's name, city, and country, and only want to parse the street address into separate lines. /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ParseAddressResponseBody) - Task ParseAddress(ParseAddressRequestBody parseAddressRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ParseAddressResponseBody) + Task> ParseAddress(ParseAddressRequestBody parseAddressRequestBody, CancellationToken cancellationToken = default); /// /// Parse an address The address-recognition API makes it easy for you to extract address data from unstructured text, including the recipient name, line 1, line 2, city, postal code, and more. Data often enters your system as unstructured text (for example: emails, SMS messages, support tickets, or other documents). ShipEngine's address-recognition API helps you extract meaningful, structured data from this unstructured text. The parsed address data is returned in the same structure that's used for other ShipEngine APIs, such as address validation, rate quotes, and shipping labels. > **Note:** Address recognition is currently supported for the United States, Canada, Australia, New Zealand, the United Kingdom, and Ireland. @@ -42,8 +42,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// The only required field is `text`, which is the text to be parsed. You can optionally also provide an `address` containing already-known values. For example, you may already know the recipient's name, city, and country, and only want to parse the street address into separate lines. /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ParseAddressResponseBody) - Task ParseAddress(HttpClient methodClient, ParseAddressRequestBody parseAddressRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ParseAddressResponseBody) + Task> ParseAddress(HttpClient methodClient, ParseAddressRequestBody parseAddressRequestBody, CancellationToken cancellationToken = default); /// /// Validate An Address Address validation ensures accurate addresses and can lead to reduced shipping costs by preventing address correction surcharges. ShipEngine cross references multiple databases to validate addresses and identify potential deliverability issues. @@ -52,8 +52,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<AddressValidationResult>) - Task> ValidateAddress(List addressToValidate, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (List<AddressValidationResult>) + Task>> ValidateAddress(List addressToValidate, CancellationToken cancellationToken = default); /// /// Validate An Address Address validation ensures accurate addresses and can lead to reduced shipping costs by preventing address correction surcharges. ShipEngine cross references multiple databases to validate addresses and identify potential deliverability issues. @@ -63,8 +63,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<AddressValidationResult>) - Task> ValidateAddress(HttpClient methodClient, List addressToValidate, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (List<AddressValidationResult>) + Task>> ValidateAddress(HttpClient methodClient, List addressToValidate, CancellationToken cancellationToken = default); } @@ -80,8 +80,8 @@ public partial class ShipEngine /// Thrown when fails to make API call /// The only required field is `text`, which is the text to be parsed. You can optionally also provide an `address` containing already-known values. For example, you may already know the recipient's name, city, and country, and only want to parse the street address into separate lines. /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ParseAddressResponseBody) - public Task ParseAddress(ParseAddressRequestBody parseAddressRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ParseAddressResponseBody) + public Task> ParseAddress(ParseAddressRequestBody parseAddressRequestBody, CancellationToken cancellationToken = default) { return ParseAddress(_client, parseAddressRequestBody, cancellationToken); } @@ -94,8 +94,8 @@ public Task ParseAddress(ParseAddressRequestBody parse /// HttpClient to use for the request /// The only required field is `text`, which is the text to be parsed. You can optionally also provide an `address` containing already-known values. For example, you may already know the recipient's name, city, and country, and only want to parse the street address into separate lines. /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ParseAddressResponseBody) - public async Task ParseAddress(HttpClient methodClient, ParseAddressRequestBody parseAddressRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ParseAddressResponseBody) + public async Task> ParseAddress(HttpClient methodClient, ParseAddressRequestBody parseAddressRequestBody, CancellationToken cancellationToken = default) { // verify the required parameter 'parseAddressRequestBody' is set if (parseAddressRequestBody == null) @@ -110,9 +110,10 @@ public async Task ParseAddress(HttpClient methodClient requestOptions.Operation = "AddressesApi.ParseAddress"; - var result = await SendHttpRequestAsync(HttpMethods.Put, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -122,8 +123,8 @@ public async Task ParseAddress(HttpClient methodClient /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<AddressValidationResult>) - public Task> ValidateAddress(List addressToValidate, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (List<AddressValidationResult>) + public Task>> ValidateAddress(List addressToValidate, CancellationToken cancellationToken = default) { return ValidateAddress(_client, addressToValidate, cancellationToken); } @@ -136,8 +137,8 @@ public Task> ValidateAddress(ListHttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<AddressValidationResult>) - public async Task> ValidateAddress(HttpClient methodClient, List addressToValidate, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (List<AddressValidationResult>) + public async Task>> ValidateAddress(HttpClient methodClient, List addressToValidate, CancellationToken cancellationToken = default) { // verify the required parameter 'addressToValidate' is set if (addressToValidate == null) @@ -152,9 +153,10 @@ public async Task> ValidateAddress(HttpClient meth requestOptions.Operation = "AddressesApi.ValidateAddress"; - var result = await SendHttpRequestAsync>(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse>(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse>(data, response.StatusCode, headers); } -} \ No newline at end of file +} diff --git a/ShipEngineSDK/Api/BatchesApi.cs b/ShipEngineSDK/Api/BatchesApi.cs index e388d35a..2fd17cc2 100644 --- a/ShipEngineSDK/Api/BatchesApi.cs +++ b/ShipEngineSDK/Api/BatchesApi.cs @@ -32,8 +32,8 @@ public partial interface IShipEngine /// /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task AddToBatch(AddToBatchRequestBody addToBatchRequestBody, string batchId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> AddToBatch(AddToBatchRequestBody addToBatchRequestBody, string batchId, CancellationToken cancellationToken = default); /// /// Add to a Batch Add a Shipment or Rate to a Batch @@ -44,8 +44,8 @@ public partial interface IShipEngine /// /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task AddToBatch(HttpClient methodClient, AddToBatchRequestBody addToBatchRequestBody, string batchId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> AddToBatch(HttpClient methodClient, AddToBatchRequestBody addToBatchRequestBody, string batchId, CancellationToken cancellationToken = default); /// /// Create A Batch Create a Batch @@ -54,8 +54,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateBatchResponseBody) - Task CreateBatch(CreateBatchRequest createBatchRequest, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateBatchResponseBody) + Task> CreateBatch(CreateBatchRequest createBatchRequest, CancellationToken cancellationToken = default); /// /// Create A Batch Create a Batch @@ -65,8 +65,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateBatchResponseBody) - Task CreateBatch(HttpClient methodClient, CreateBatchRequest createBatchRequest, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateBatchResponseBody) + Task> CreateBatch(HttpClient methodClient, CreateBatchRequest createBatchRequest, CancellationToken cancellationToken = default); /// /// Delete Batch By Id Delete Batch By Id @@ -75,8 +75,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task DeleteBatch(string batchId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> DeleteBatch(string batchId, CancellationToken cancellationToken = default); /// /// Delete Batch By Id Delete Batch By Id @@ -86,8 +86,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task DeleteBatch(HttpClient methodClient, string batchId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> DeleteBatch(HttpClient methodClient, string batchId, CancellationToken cancellationToken = default); /// /// Get Batch By External ID Get Batch By External ID @@ -96,8 +96,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetBatchByExternalIdResponseBody) - Task GetBatchByExternalId(string externalBatchId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetBatchByExternalIdResponseBody) + Task> GetBatchByExternalId(string externalBatchId, CancellationToken cancellationToken = default); /// /// Get Batch By External ID Get Batch By External ID @@ -107,8 +107,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetBatchByExternalIdResponseBody) - Task GetBatchByExternalId(HttpClient methodClient, string externalBatchId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetBatchByExternalIdResponseBody) + Task> GetBatchByExternalId(HttpClient methodClient, string externalBatchId, CancellationToken cancellationToken = default); /// /// Get Batch By ID Get Batch By ID @@ -117,8 +117,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetBatchByIdResponseBody) - Task GetBatchById(string batchId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetBatchByIdResponseBody) + Task> GetBatchById(string batchId, CancellationToken cancellationToken = default); /// /// Get Batch By ID Get Batch By ID @@ -128,8 +128,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetBatchByIdResponseBody) - Task GetBatchById(HttpClient methodClient, string batchId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetBatchByIdResponseBody) + Task> GetBatchById(HttpClient methodClient, string batchId, CancellationToken cancellationToken = default); /// /// Get Batch Errors Error handling in batches are handled differently than in a single synchronous request. You must retrieve the status of your batch by [getting a batch](https://www.shipengine.com/docs/reference/get-batch-by-id/) and getting an overview of the statuses or you can list errors directly here below to get detailed information about the errors. @@ -140,8 +140,8 @@ public partial interface IShipEngine /// (optional) /// Return a specific page of results. Defaults to the first page. If set to a number that's greater than the number of pages of results, an empty page is returned. (optional, default to 1) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListBatchErrorsResponseBody) - Task ListBatchErrors(string batchId, int? pagesize, int? page, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListBatchErrorsResponseBody) + Task> ListBatchErrors(string batchId, int? pagesize, int? page, CancellationToken cancellationToken = default); /// /// Get Batch Errors Error handling in batches are handled differently than in a single synchronous request. You must retrieve the status of your batch by [getting a batch](https://www.shipengine.com/docs/reference/get-batch-by-id/) and getting an overview of the statuses or you can list errors directly here below to get detailed information about the errors. @@ -153,8 +153,8 @@ public partial interface IShipEngine /// (optional) /// Return a specific page of results. Defaults to the first page. If set to a number that's greater than the number of pages of results, an empty page is returned. (optional, default to 1) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListBatchErrorsResponseBody) - Task ListBatchErrors(HttpClient methodClient, string batchId, int? pagesize, int? page, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListBatchErrorsResponseBody) + Task> ListBatchErrors(HttpClient methodClient, string batchId, int? pagesize, int? page, CancellationToken cancellationToken = default); /// /// List Batches List Batches associated with your Shipengine account @@ -168,8 +168,8 @@ public partial interface IShipEngine /// Return a specific page of results. Defaults to the first page. If set to a number that's greater than the number of pages of results, an empty page is returned. (optional, default to 1) /// The number of results to return per response. (optional, default to 25) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListBatchesResponseBody) - Task ListBatches(BatchStatus? status, BatchesSortBy? sortBy, SortDir? sortDir, string? batchNumber, int? page, int? pageSize, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListBatchesResponseBody) + Task> ListBatches(BatchStatus? status, BatchesSortBy? sortBy, SortDir? sortDir, string? batchNumber, int? page, int? pageSize, CancellationToken cancellationToken = default); /// /// List Batches List Batches associated with your Shipengine account @@ -184,8 +184,8 @@ public partial interface IShipEngine /// Return a specific page of results. Defaults to the first page. If set to a number that's greater than the number of pages of results, an empty page is returned. (optional, default to 1) /// The number of results to return per response. (optional, default to 25) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListBatchesResponseBody) - Task ListBatches(HttpClient methodClient, BatchStatus? status, BatchesSortBy? sortBy, SortDir? sortDir, string? batchNumber, int? page, int? pageSize, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListBatchesResponseBody) + Task> ListBatches(HttpClient methodClient, BatchStatus? status, BatchesSortBy? sortBy, SortDir? sortDir, string? batchNumber, int? page, int? pageSize, CancellationToken cancellationToken = default); /// /// Process Batch ID Labels Process Batch ID Labels @@ -195,8 +195,8 @@ public partial interface IShipEngine /// /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task ProcessBatch(ProcessBatchRequestBody processBatchRequestBody, string batchId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> ProcessBatch(ProcessBatchRequestBody processBatchRequestBody, string batchId, CancellationToken cancellationToken = default); /// /// Process Batch ID Labels Process Batch ID Labels @@ -207,8 +207,8 @@ public partial interface IShipEngine /// /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task ProcessBatch(HttpClient methodClient, ProcessBatchRequestBody processBatchRequestBody, string batchId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> ProcessBatch(HttpClient methodClient, ProcessBatchRequestBody processBatchRequestBody, string batchId, CancellationToken cancellationToken = default); /// /// Remove From Batch Remove a shipment or rate from a batch @@ -218,8 +218,8 @@ public partial interface IShipEngine /// /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task RemoveFromBatch(RemoveFromBatchRequestBody removeFromBatchRequestBody, string batchId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> RemoveFromBatch(RemoveFromBatchRequestBody removeFromBatchRequestBody, string batchId, CancellationToken cancellationToken = default); /// /// Remove From Batch Remove a shipment or rate from a batch @@ -230,8 +230,8 @@ public partial interface IShipEngine /// /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task RemoveFromBatch(HttpClient methodClient, RemoveFromBatchRequestBody removeFromBatchRequestBody, string batchId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> RemoveFromBatch(HttpClient methodClient, RemoveFromBatchRequestBody removeFromBatchRequestBody, string batchId, CancellationToken cancellationToken = default); /// /// Update Batch By Id Update Batch By Id @@ -240,8 +240,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task UpdateBatch(string batchId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> UpdateBatch(string batchId, CancellationToken cancellationToken = default); /// /// Update Batch By Id Update Batch By Id @@ -251,8 +251,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task UpdateBatch(HttpClient methodClient, string batchId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> UpdateBatch(HttpClient methodClient, string batchId, CancellationToken cancellationToken = default); } @@ -269,8 +269,8 @@ public partial class ShipEngine /// /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task AddToBatch(AddToBatchRequestBody addToBatchRequestBody, string batchId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> AddToBatch(AddToBatchRequestBody addToBatchRequestBody, string batchId, CancellationToken cancellationToken = default) { return AddToBatch(_client, addToBatchRequestBody, batchId, cancellationToken); } @@ -284,8 +284,8 @@ public Task AddToBatch(AddToBatchRequestBody addToBatchRequestBody, stri /// /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task AddToBatch(HttpClient methodClient, AddToBatchRequestBody addToBatchRequestBody, string batchId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> AddToBatch(HttpClient methodClient, AddToBatchRequestBody addToBatchRequestBody, string batchId, CancellationToken cancellationToken = default) { // verify the required parameter 'addToBatchRequestBody' is set if (addToBatchRequestBody == null) @@ -307,9 +307,10 @@ public async Task AddToBatch(HttpClient methodClient, AddToBatchRequestB requestOptions.Operation = "BatchesApi.AddToBatch"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -319,8 +320,8 @@ public async Task AddToBatch(HttpClient methodClient, AddToBatchRequestB /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateBatchResponseBody) - public Task CreateBatch(CreateBatchRequest createBatchRequest, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateBatchResponseBody) + public Task> CreateBatch(CreateBatchRequest createBatchRequest, CancellationToken cancellationToken = default) { return CreateBatch(_client, createBatchRequest, cancellationToken); } @@ -333,8 +334,8 @@ public Task CreateBatch(CreateBatchRequest createBatchR /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateBatchResponseBody) - public async Task CreateBatch(HttpClient methodClient, CreateBatchRequest createBatchRequest, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateBatchResponseBody) + public async Task> CreateBatch(HttpClient methodClient, CreateBatchRequest createBatchRequest, CancellationToken cancellationToken = default) { // verify the required parameter 'createBatchRequest' is set if (createBatchRequest == null) @@ -349,9 +350,10 @@ public async Task CreateBatch(HttpClient methodClient, requestOptions.Operation = "BatchesApi.CreateBatch"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -361,8 +363,8 @@ public async Task CreateBatch(HttpClient methodClient, /// Thrown when fails to make API call /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task DeleteBatch(string batchId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> DeleteBatch(string batchId, CancellationToken cancellationToken = default) { return DeleteBatch(_client, batchId, cancellationToken); } @@ -375,8 +377,8 @@ public Task DeleteBatch(string batchId, CancellationToken cancellationTo /// HttpClient to use for the request /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task DeleteBatch(HttpClient methodClient, string batchId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> DeleteBatch(HttpClient methodClient, string batchId, CancellationToken cancellationToken = default) { // verify the required parameter 'batchId' is set if (batchId == null) @@ -391,9 +393,10 @@ public async Task DeleteBatch(HttpClient methodClient, string batchId, C requestOptions.Operation = "BatchesApi.DeleteBatch"; - var result = await SendHttpRequestAsync(HttpMethods.Delete, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -403,8 +406,8 @@ public async Task DeleteBatch(HttpClient methodClient, string batchId, C /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetBatchByExternalIdResponseBody) - public Task GetBatchByExternalId(string externalBatchId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetBatchByExternalIdResponseBody) + public Task> GetBatchByExternalId(string externalBatchId, CancellationToken cancellationToken = default) { return GetBatchByExternalId(_client, externalBatchId, cancellationToken); } @@ -417,8 +420,8 @@ public Task GetBatchByExternalId(string extern /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetBatchByExternalIdResponseBody) - public async Task GetBatchByExternalId(HttpClient methodClient, string externalBatchId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetBatchByExternalIdResponseBody) + public async Task> GetBatchByExternalId(HttpClient methodClient, string externalBatchId, CancellationToken cancellationToken = default) { // verify the required parameter 'externalBatchId' is set if (externalBatchId == null) @@ -433,9 +436,10 @@ public async Task GetBatchByExternalId(HttpCli requestOptions.Operation = "BatchesApi.GetBatchByExternalId"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -445,8 +449,8 @@ public async Task GetBatchByExternalId(HttpCli /// Thrown when fails to make API call /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetBatchByIdResponseBody) - public Task GetBatchById(string batchId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetBatchByIdResponseBody) + public Task> GetBatchById(string batchId, CancellationToken cancellationToken = default) { return GetBatchById(_client, batchId, cancellationToken); } @@ -459,8 +463,8 @@ public Task GetBatchById(string batchId, CancellationT /// HttpClient to use for the request /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetBatchByIdResponseBody) - public async Task GetBatchById(HttpClient methodClient, string batchId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetBatchByIdResponseBody) + public async Task> GetBatchById(HttpClient methodClient, string batchId, CancellationToken cancellationToken = default) { // verify the required parameter 'batchId' is set if (batchId == null) @@ -475,9 +479,10 @@ public async Task GetBatchById(HttpClient methodClient requestOptions.Operation = "BatchesApi.GetBatchById"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -489,8 +494,8 @@ public async Task GetBatchById(HttpClient methodClient /// (optional) /// Return a specific page of results. Defaults to the first page. If set to a number that's greater than the number of pages of results, an empty page is returned. (optional, default to 1) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListBatchErrorsResponseBody) - public Task ListBatchErrors(string batchId, int? pagesize = default, int? page = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListBatchErrorsResponseBody) + public Task> ListBatchErrors(string batchId, int? pagesize = default, int? page = default, CancellationToken cancellationToken = default) { return ListBatchErrors(_client, batchId, pagesize, page, cancellationToken); } @@ -505,8 +510,8 @@ public Task ListBatchErrors(string batchId, int? pa /// (optional) /// Return a specific page of results. Defaults to the first page. If set to a number that's greater than the number of pages of results, an empty page is returned. (optional, default to 1) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListBatchErrorsResponseBody) - public async Task ListBatchErrors(HttpClient methodClient, string batchId, int? pagesize = default, int? page = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListBatchErrorsResponseBody) + public async Task> ListBatchErrors(HttpClient methodClient, string batchId, int? pagesize = default, int? page = default, CancellationToken cancellationToken = default) { // verify the required parameter 'batchId' is set if (batchId == null) @@ -529,9 +534,10 @@ public async Task ListBatchErrors(HttpClient method requestOptions.Operation = "BatchesApi.ListBatchErrors"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -546,8 +552,8 @@ public async Task ListBatchErrors(HttpClient method /// Return a specific page of results. Defaults to the first page. If set to a number that's greater than the number of pages of results, an empty page is returned. (optional, default to 1) /// The number of results to return per response. (optional, default to 25) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListBatchesResponseBody) - public Task ListBatches(BatchStatus? status = default, BatchesSortBy? sortBy = default, SortDir? sortDir = default, string? batchNumber = default, int? page = default, int? pageSize = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListBatchesResponseBody) + public Task> ListBatches(BatchStatus? status = default, BatchesSortBy? sortBy = default, SortDir? sortDir = default, string? batchNumber = default, int? page = default, int? pageSize = default, CancellationToken cancellationToken = default) { return ListBatches(_client, status, sortBy, sortDir, batchNumber, page, pageSize, cancellationToken); } @@ -565,8 +571,8 @@ public Task ListBatches(BatchStatus? status = default, /// Return a specific page of results. Defaults to the first page. If set to a number that's greater than the number of pages of results, an empty page is returned. (optional, default to 1) /// The number of results to return per response. (optional, default to 25) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListBatchesResponseBody) - public async Task ListBatches(HttpClient methodClient, BatchStatus? status = default, BatchesSortBy? sortBy = default, SortDir? sortDir = default, string? batchNumber = default, int? page = default, int? pageSize = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListBatchesResponseBody) + public async Task> ListBatches(HttpClient methodClient, BatchStatus? status = default, BatchesSortBy? sortBy = default, SortDir? sortDir = default, string? batchNumber = default, int? page = default, int? pageSize = default, CancellationToken cancellationToken = default) { RequestOptions requestOptions = new("/v1/batches"); @@ -598,9 +604,10 @@ public async Task ListBatches(HttpClient methodClient, requestOptions.Operation = "BatchesApi.ListBatches"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -611,8 +618,8 @@ public async Task ListBatches(HttpClient methodClient, /// /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task ProcessBatch(ProcessBatchRequestBody processBatchRequestBody, string batchId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> ProcessBatch(ProcessBatchRequestBody processBatchRequestBody, string batchId, CancellationToken cancellationToken = default) { return ProcessBatch(_client, processBatchRequestBody, batchId, cancellationToken); } @@ -626,8 +633,8 @@ public Task ProcessBatch(ProcessBatchRequestBody processBatchRequestBody /// /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task ProcessBatch(HttpClient methodClient, ProcessBatchRequestBody processBatchRequestBody, string batchId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> ProcessBatch(HttpClient methodClient, ProcessBatchRequestBody processBatchRequestBody, string batchId, CancellationToken cancellationToken = default) { // verify the required parameter 'processBatchRequestBody' is set if (processBatchRequestBody == null) @@ -649,9 +656,10 @@ public async Task ProcessBatch(HttpClient methodClient, ProcessBatchRequ requestOptions.Operation = "BatchesApi.ProcessBatch"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -662,8 +670,8 @@ public async Task ProcessBatch(HttpClient methodClient, ProcessBatchRequ /// /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task RemoveFromBatch(RemoveFromBatchRequestBody removeFromBatchRequestBody, string batchId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> RemoveFromBatch(RemoveFromBatchRequestBody removeFromBatchRequestBody, string batchId, CancellationToken cancellationToken = default) { return RemoveFromBatch(_client, removeFromBatchRequestBody, batchId, cancellationToken); } @@ -677,8 +685,8 @@ public Task RemoveFromBatch(RemoveFromBatchRequestBody removeFromBatchRe /// /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task RemoveFromBatch(HttpClient methodClient, RemoveFromBatchRequestBody removeFromBatchRequestBody, string batchId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> RemoveFromBatch(HttpClient methodClient, RemoveFromBatchRequestBody removeFromBatchRequestBody, string batchId, CancellationToken cancellationToken = default) { // verify the required parameter 'removeFromBatchRequestBody' is set if (removeFromBatchRequestBody == null) @@ -700,9 +708,10 @@ public async Task RemoveFromBatch(HttpClient methodClient, RemoveFromBat requestOptions.Operation = "BatchesApi.RemoveFromBatch"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -712,8 +721,8 @@ public async Task RemoveFromBatch(HttpClient methodClient, RemoveFromBat /// Thrown when fails to make API call /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task UpdateBatch(string batchId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> UpdateBatch(string batchId, CancellationToken cancellationToken = default) { return UpdateBatch(_client, batchId, cancellationToken); } @@ -726,8 +735,8 @@ public Task UpdateBatch(string batchId, CancellationToken cancellationTo /// HttpClient to use for the request /// Batch ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task UpdateBatch(HttpClient methodClient, string batchId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> UpdateBatch(HttpClient methodClient, string batchId, CancellationToken cancellationToken = default) { // verify the required parameter 'batchId' is set if (batchId == null) @@ -742,9 +751,10 @@ public async Task UpdateBatch(HttpClient methodClient, string batchId, C requestOptions.Operation = "BatchesApi.UpdateBatch"; - var result = await SendHttpRequestAsync(HttpMethods.Put, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } -} \ No newline at end of file +} diff --git a/ShipEngineSDK/Api/CarrierAccountsApi.cs b/ShipEngineSDK/Api/CarrierAccountsApi.cs index d3cf8cde..fa4261dd 100644 --- a/ShipEngineSDK/Api/CarrierAccountsApi.cs +++ b/ShipEngineSDK/Api/CarrierAccountsApi.cs @@ -32,8 +32,8 @@ public partial interface IShipEngine /// The carrier name, such as `stamps_com`, `ups`, `fedex`, or `dhl_express`. /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ConnectCarrierResponseBody) - Task ConnectCarrier(CarrierName carrierName, ConnectCarrierRequestBody connectCarrierRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ConnectCarrierResponseBody) + Task> ConnectCarrier(CarrierName carrierName, ConnectCarrierRequestBody connectCarrierRequestBody, CancellationToken cancellationToken = default); /// /// Connect a carrier account Connect a carrier account @@ -44,8 +44,8 @@ public partial interface IShipEngine /// The carrier name, such as `stamps_com`, `ups`, `fedex`, or `dhl_express`. /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ConnectCarrierResponseBody) - Task ConnectCarrier(HttpClient methodClient, CarrierName carrierName, ConnectCarrierRequestBody connectCarrierRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ConnectCarrierResponseBody) + Task> ConnectCarrier(HttpClient methodClient, CarrierName carrierName, ConnectCarrierRequestBody connectCarrierRequestBody, CancellationToken cancellationToken = default); /// /// Disconnect a carrier Disconnect a carrier @@ -55,8 +55,8 @@ public partial interface IShipEngine /// The carrier name, such as `stamps_com`, `ups`, `fedex`, or `dhl_express`. /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task DisconnectCarrier(CarrierName carrierName, string carrierId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> DisconnectCarrier(CarrierName carrierName, string carrierId, CancellationToken cancellationToken = default); /// /// Disconnect a carrier Disconnect a carrier @@ -67,8 +67,8 @@ public partial interface IShipEngine /// The carrier name, such as `stamps_com`, `ups`, `fedex`, or `dhl_express`. /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task DisconnectCarrier(HttpClient methodClient, CarrierName carrierName, string carrierId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> DisconnectCarrier(HttpClient methodClient, CarrierName carrierName, string carrierId, CancellationToken cancellationToken = default); /// /// Get carrier settings Get carrier settings @@ -78,8 +78,8 @@ public partial interface IShipEngine /// The carrier name, such as `ups`, `fedex`, or `dhl_express`. /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetCarrierSettingsResponseBody) - Task GetCarrierSettings(CarrierNameWithSettings carrierName, string carrierId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetCarrierSettingsResponseBody) + Task> GetCarrierSettings(CarrierNameWithSettings carrierName, string carrierId, CancellationToken cancellationToken = default); /// /// Get carrier settings Get carrier settings @@ -90,8 +90,8 @@ public partial interface IShipEngine /// The carrier name, such as `ups`, `fedex`, or `dhl_express`. /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetCarrierSettingsResponseBody) - Task GetCarrierSettings(HttpClient methodClient, CarrierNameWithSettings carrierName, string carrierId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetCarrierSettingsResponseBody) + Task> GetCarrierSettings(HttpClient methodClient, CarrierNameWithSettings carrierName, string carrierId, CancellationToken cancellationToken = default); /// /// Update carrier settings Update carrier settings @@ -102,8 +102,8 @@ public partial interface IShipEngine /// /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task UpdateCarrierSettings(CarrierNameWithSettings carrierName, UpdateCarrierSettingsRequestBody updateCarrierSettingsRequestBody, string carrierId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> UpdateCarrierSettings(CarrierNameWithSettings carrierName, UpdateCarrierSettingsRequestBody updateCarrierSettingsRequestBody, string carrierId, CancellationToken cancellationToken = default); /// /// Update carrier settings Update carrier settings @@ -115,8 +115,8 @@ public partial interface IShipEngine /// /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task UpdateCarrierSettings(HttpClient methodClient, CarrierNameWithSettings carrierName, UpdateCarrierSettingsRequestBody updateCarrierSettingsRequestBody, string carrierId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> UpdateCarrierSettings(HttpClient methodClient, CarrierNameWithSettings carrierName, UpdateCarrierSettingsRequestBody updateCarrierSettingsRequestBody, string carrierId, CancellationToken cancellationToken = default); } @@ -133,8 +133,8 @@ public partial class ShipEngine /// The carrier name, such as `stamps_com`, `ups`, `fedex`, or `dhl_express`. /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ConnectCarrierResponseBody) - public Task ConnectCarrier(CarrierName carrierName, ConnectCarrierRequestBody connectCarrierRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ConnectCarrierResponseBody) + public Task> ConnectCarrier(CarrierName carrierName, ConnectCarrierRequestBody connectCarrierRequestBody, CancellationToken cancellationToken = default) { return ConnectCarrier(_client, carrierName, connectCarrierRequestBody, cancellationToken); } @@ -148,8 +148,8 @@ public Task ConnectCarrier(CarrierName carrierName, /// The carrier name, such as `stamps_com`, `ups`, `fedex`, or `dhl_express`. /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ConnectCarrierResponseBody) - public async Task ConnectCarrier(HttpClient methodClient, CarrierName carrierName, ConnectCarrierRequestBody connectCarrierRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ConnectCarrierResponseBody) + public async Task> ConnectCarrier(HttpClient methodClient, CarrierName carrierName, ConnectCarrierRequestBody connectCarrierRequestBody, CancellationToken cancellationToken = default) { // verify the required parameter 'carrierName' is set if (carrierName == null) @@ -171,9 +171,10 @@ public async Task ConnectCarrier(HttpClient methodCl requestOptions.Operation = "CarrierAccountsApi.ConnectCarrier"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -184,8 +185,8 @@ public async Task ConnectCarrier(HttpClient methodCl /// The carrier name, such as `stamps_com`, `ups`, `fedex`, or `dhl_express`. /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task DisconnectCarrier(CarrierName carrierName, string carrierId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> DisconnectCarrier(CarrierName carrierName, string carrierId, CancellationToken cancellationToken = default) { return DisconnectCarrier(_client, carrierName, carrierId, cancellationToken); } @@ -199,8 +200,8 @@ public Task DisconnectCarrier(CarrierName carrierName, string carrierId, /// The carrier name, such as `stamps_com`, `ups`, `fedex`, or `dhl_express`. /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task DisconnectCarrier(HttpClient methodClient, CarrierName carrierName, string carrierId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> DisconnectCarrier(HttpClient methodClient, CarrierName carrierName, string carrierId, CancellationToken cancellationToken = default) { // verify the required parameter 'carrierName' is set if (carrierName == null) @@ -222,9 +223,10 @@ public async Task DisconnectCarrier(HttpClient methodClient, CarrierName requestOptions.Operation = "CarrierAccountsApi.DisconnectCarrier"; - var result = await SendHttpRequestAsync(HttpMethods.Delete, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -235,8 +237,8 @@ public async Task DisconnectCarrier(HttpClient methodClient, CarrierName /// The carrier name, such as `ups`, `fedex`, or `dhl_express`. /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetCarrierSettingsResponseBody) - public Task GetCarrierSettings(CarrierNameWithSettings carrierName, string carrierId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetCarrierSettingsResponseBody) + public Task> GetCarrierSettings(CarrierNameWithSettings carrierName, string carrierId, CancellationToken cancellationToken = default) { return GetCarrierSettings(_client, carrierName, carrierId, cancellationToken); } @@ -250,8 +252,8 @@ public Task GetCarrierSettings(CarrierNameWithSe /// The carrier name, such as `ups`, `fedex`, or `dhl_express`. /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetCarrierSettingsResponseBody) - public async Task GetCarrierSettings(HttpClient methodClient, CarrierNameWithSettings carrierName, string carrierId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetCarrierSettingsResponseBody) + public async Task> GetCarrierSettings(HttpClient methodClient, CarrierNameWithSettings carrierName, string carrierId, CancellationToken cancellationToken = default) { // verify the required parameter 'carrierName' is set if (carrierName == null) @@ -273,9 +275,10 @@ public async Task GetCarrierSettings(HttpClient requestOptions.Operation = "CarrierAccountsApi.GetCarrierSettings"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -287,8 +290,8 @@ public async Task GetCarrierSettings(HttpClient /// /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task UpdateCarrierSettings(CarrierNameWithSettings carrierName, UpdateCarrierSettingsRequestBody updateCarrierSettingsRequestBody, string carrierId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> UpdateCarrierSettings(CarrierNameWithSettings carrierName, UpdateCarrierSettingsRequestBody updateCarrierSettingsRequestBody, string carrierId, CancellationToken cancellationToken = default) { return UpdateCarrierSettings(_client, carrierName, updateCarrierSettingsRequestBody, carrierId, cancellationToken); } @@ -303,8 +306,8 @@ public Task UpdateCarrierSettings(CarrierNameWithSettings carrierName, U /// /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task UpdateCarrierSettings(HttpClient methodClient, CarrierNameWithSettings carrierName, UpdateCarrierSettingsRequestBody updateCarrierSettingsRequestBody, string carrierId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> UpdateCarrierSettings(HttpClient methodClient, CarrierNameWithSettings carrierName, UpdateCarrierSettingsRequestBody updateCarrierSettingsRequestBody, string carrierId, CancellationToken cancellationToken = default) { // verify the required parameter 'carrierName' is set if (carrierName == null) @@ -333,9 +336,10 @@ public async Task UpdateCarrierSettings(HttpClient methodClient, Carrier requestOptions.Operation = "CarrierAccountsApi.UpdateCarrierSettings"; - var result = await SendHttpRequestAsync(HttpMethods.Put, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } -} \ No newline at end of file +} diff --git a/ShipEngineSDK/Api/CarriersApi.cs b/ShipEngineSDK/Api/CarriersApi.cs index 51a144d2..e752d264 100644 --- a/ShipEngineSDK/Api/CarriersApi.cs +++ b/ShipEngineSDK/Api/CarriersApi.cs @@ -32,8 +32,8 @@ public partial interface IShipEngine /// /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (AddFundsToCarrierResponseBody) - Task AddFundsToCarrier(AddFundsToCarrierRequestBody addFundsToCarrierRequestBody, string carrierId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (AddFundsToCarrierResponseBody) + Task> AddFundsToCarrier(AddFundsToCarrierRequestBody addFundsToCarrierRequestBody, string carrierId, CancellationToken cancellationToken = default); /// /// Add Funds To Carrier Add Funds To A Carrier @@ -44,8 +44,8 @@ public partial interface IShipEngine /// /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (AddFundsToCarrierResponseBody) - Task AddFundsToCarrier(HttpClient methodClient, AddFundsToCarrierRequestBody addFundsToCarrierRequestBody, string carrierId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (AddFundsToCarrierResponseBody) + Task> AddFundsToCarrier(HttpClient methodClient, AddFundsToCarrierRequestBody addFundsToCarrierRequestBody, string carrierId, CancellationToken cancellationToken = default); /// /// Disconnect Carrier by ID Disconnect a Carrier of the given ID from the account @@ -54,8 +54,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task DisconnectCarrierById(string carrierId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> DisconnectCarrierById(string carrierId, CancellationToken cancellationToken = default); /// /// Disconnect Carrier by ID Disconnect a Carrier of the given ID from the account @@ -65,8 +65,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task DisconnectCarrierById(HttpClient methodClient, string carrierId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> DisconnectCarrierById(HttpClient methodClient, string carrierId, CancellationToken cancellationToken = default); /// /// Get Carrier By ID Retrive carrier info by ID @@ -75,8 +75,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetCarrierByIdResponseBody) - Task GetCarrierById(string carrierId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetCarrierByIdResponseBody) + Task> GetCarrierById(string carrierId, CancellationToken cancellationToken = default); /// /// Get Carrier By ID Retrive carrier info by ID @@ -86,8 +86,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetCarrierByIdResponseBody) - Task GetCarrierById(HttpClient methodClient, string carrierId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetCarrierByIdResponseBody) + Task> GetCarrierById(HttpClient methodClient, string carrierId, CancellationToken cancellationToken = default); /// /// Get Carrier Options Get a list of the options available for the carrier @@ -96,8 +96,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetCarrierOptionsResponseBody) - Task GetCarrierOptions(string carrierId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetCarrierOptionsResponseBody) + Task> GetCarrierOptions(string carrierId, CancellationToken cancellationToken = default); /// /// Get Carrier Options Get a list of the options available for the carrier @@ -107,8 +107,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetCarrierOptionsResponseBody) - Task GetCarrierOptions(HttpClient methodClient, string carrierId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetCarrierOptionsResponseBody) + Task> GetCarrierOptions(HttpClient methodClient, string carrierId, CancellationToken cancellationToken = default); /// /// List Carrier Package Types List the package types associated with the carrier @@ -117,8 +117,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListCarrierPackageTypesResponseBody) - Task ListCarrierPackageTypes(string carrierId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListCarrierPackageTypesResponseBody) + Task> ListCarrierPackageTypes(string carrierId, CancellationToken cancellationToken = default); /// /// List Carrier Package Types List the package types associated with the carrier @@ -128,8 +128,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListCarrierPackageTypesResponseBody) - Task ListCarrierPackageTypes(HttpClient methodClient, string carrierId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListCarrierPackageTypesResponseBody) + Task> ListCarrierPackageTypes(HttpClient methodClient, string carrierId, CancellationToken cancellationToken = default); /// /// List Carrier Services List the services associated with the carrier ID @@ -138,8 +138,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListCarrierServicesResponseBody) - Task ListCarrierServices(string carrierId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListCarrierServicesResponseBody) + Task> ListCarrierServices(string carrierId, CancellationToken cancellationToken = default); /// /// List Carrier Services List the services associated with the carrier ID @@ -149,8 +149,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListCarrierServicesResponseBody) - Task ListCarrierServices(HttpClient methodClient, string carrierId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListCarrierServicesResponseBody) + Task> ListCarrierServices(HttpClient methodClient, string carrierId, CancellationToken cancellationToken = default); /// /// List Carriers List all carriers that have been added to this account @@ -158,8 +158,8 @@ public partial interface IShipEngine /// Thrown when required argument is null /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetCarriersResponseBody) - Task ListCarriers(CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetCarriersResponseBody) + Task> ListCarriers(CancellationToken cancellationToken = default); /// /// List Carriers List all carriers that have been added to this account @@ -168,8 +168,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// HttpClient to use for the request /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetCarriersResponseBody) - Task ListCarriers(HttpClient methodClient, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetCarriersResponseBody) + Task> ListCarriers(HttpClient methodClient, CancellationToken cancellationToken = default); } @@ -186,8 +186,8 @@ public partial class ShipEngine /// /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (AddFundsToCarrierResponseBody) - public Task AddFundsToCarrier(AddFundsToCarrierRequestBody addFundsToCarrierRequestBody, string carrierId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (AddFundsToCarrierResponseBody) + public Task> AddFundsToCarrier(AddFundsToCarrierRequestBody addFundsToCarrierRequestBody, string carrierId, CancellationToken cancellationToken = default) { return AddFundsToCarrier(_client, addFundsToCarrierRequestBody, carrierId, cancellationToken); } @@ -201,8 +201,8 @@ public Task AddFundsToCarrier(AddFundsToCarrierRe /// /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (AddFundsToCarrierResponseBody) - public async Task AddFundsToCarrier(HttpClient methodClient, AddFundsToCarrierRequestBody addFundsToCarrierRequestBody, string carrierId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (AddFundsToCarrierResponseBody) + public async Task> AddFundsToCarrier(HttpClient methodClient, AddFundsToCarrierRequestBody addFundsToCarrierRequestBody, string carrierId, CancellationToken cancellationToken = default) { // verify the required parameter 'addFundsToCarrierRequestBody' is set if (addFundsToCarrierRequestBody == null) @@ -224,9 +224,10 @@ public async Task AddFundsToCarrier(HttpClient me requestOptions.Operation = "CarriersApi.AddFundsToCarrier"; - var result = await SendHttpRequestAsync(HttpMethods.Put, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -236,8 +237,8 @@ public async Task AddFundsToCarrier(HttpClient me /// Thrown when fails to make API call /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task DisconnectCarrierById(string carrierId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> DisconnectCarrierById(string carrierId, CancellationToken cancellationToken = default) { return DisconnectCarrierById(_client, carrierId, cancellationToken); } @@ -250,8 +251,8 @@ public Task DisconnectCarrierById(string carrierId, CancellationToken ca /// HttpClient to use for the request /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task DisconnectCarrierById(HttpClient methodClient, string carrierId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> DisconnectCarrierById(HttpClient methodClient, string carrierId, CancellationToken cancellationToken = default) { // verify the required parameter 'carrierId' is set if (carrierId == null) @@ -266,9 +267,10 @@ public async Task DisconnectCarrierById(HttpClient methodClient, string requestOptions.Operation = "CarriersApi.DisconnectCarrierById"; - var result = await SendHttpRequestAsync(HttpMethods.Delete, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -278,8 +280,8 @@ public async Task DisconnectCarrierById(HttpClient methodClient, string /// Thrown when fails to make API call /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetCarrierByIdResponseBody) - public Task GetCarrierById(string carrierId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetCarrierByIdResponseBody) + public Task> GetCarrierById(string carrierId, CancellationToken cancellationToken = default) { return GetCarrierById(_client, carrierId, cancellationToken); } @@ -292,8 +294,8 @@ public Task GetCarrierById(string carrierId, Cancell /// HttpClient to use for the request /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetCarrierByIdResponseBody) - public async Task GetCarrierById(HttpClient methodClient, string carrierId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetCarrierByIdResponseBody) + public async Task> GetCarrierById(HttpClient methodClient, string carrierId, CancellationToken cancellationToken = default) { // verify the required parameter 'carrierId' is set if (carrierId == null) @@ -308,9 +310,10 @@ public async Task GetCarrierById(HttpClient methodCl requestOptions.Operation = "CarriersApi.GetCarrierById"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -320,8 +323,8 @@ public async Task GetCarrierById(HttpClient methodCl /// Thrown when fails to make API call /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetCarrierOptionsResponseBody) - public Task GetCarrierOptions(string carrierId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetCarrierOptionsResponseBody) + public Task> GetCarrierOptions(string carrierId, CancellationToken cancellationToken = default) { return GetCarrierOptions(_client, carrierId, cancellationToken); } @@ -334,8 +337,8 @@ public Task GetCarrierOptions(string carrierId, C /// HttpClient to use for the request /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetCarrierOptionsResponseBody) - public async Task GetCarrierOptions(HttpClient methodClient, string carrierId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetCarrierOptionsResponseBody) + public async Task> GetCarrierOptions(HttpClient methodClient, string carrierId, CancellationToken cancellationToken = default) { // verify the required parameter 'carrierId' is set if (carrierId == null) @@ -350,9 +353,10 @@ public async Task GetCarrierOptions(HttpClient me requestOptions.Operation = "CarriersApi.GetCarrierOptions"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -362,8 +366,8 @@ public async Task GetCarrierOptions(HttpClient me /// Thrown when fails to make API call /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListCarrierPackageTypesResponseBody) - public Task ListCarrierPackageTypes(string carrierId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListCarrierPackageTypesResponseBody) + public Task> ListCarrierPackageTypes(string carrierId, CancellationToken cancellationToken = default) { return ListCarrierPackageTypes(_client, carrierId, cancellationToken); } @@ -376,8 +380,8 @@ public Task ListCarrierPackageTypes(string /// HttpClient to use for the request /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListCarrierPackageTypesResponseBody) - public async Task ListCarrierPackageTypes(HttpClient methodClient, string carrierId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListCarrierPackageTypesResponseBody) + public async Task> ListCarrierPackageTypes(HttpClient methodClient, string carrierId, CancellationToken cancellationToken = default) { // verify the required parameter 'carrierId' is set if (carrierId == null) @@ -392,9 +396,10 @@ public async Task ListCarrierPackageTypes(H requestOptions.Operation = "CarriersApi.ListCarrierPackageTypes"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -404,8 +409,8 @@ public async Task ListCarrierPackageTypes(H /// Thrown when fails to make API call /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListCarrierServicesResponseBody) - public Task ListCarrierServices(string carrierId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListCarrierServicesResponseBody) + public Task> ListCarrierServices(string carrierId, CancellationToken cancellationToken = default) { return ListCarrierServices(_client, carrierId, cancellationToken); } @@ -418,8 +423,8 @@ public Task ListCarrierServices(string carrierI /// HttpClient to use for the request /// Carrier ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListCarrierServicesResponseBody) - public async Task ListCarrierServices(HttpClient methodClient, string carrierId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListCarrierServicesResponseBody) + public async Task> ListCarrierServices(HttpClient methodClient, string carrierId, CancellationToken cancellationToken = default) { // verify the required parameter 'carrierId' is set if (carrierId == null) @@ -434,9 +439,10 @@ public async Task ListCarrierServices(HttpClien requestOptions.Operation = "CarriersApi.ListCarrierServices"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -445,8 +451,8 @@ public async Task ListCarrierServices(HttpClien /// Thrown when required argument is null /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetCarriersResponseBody) - public Task ListCarriers(CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetCarriersResponseBody) + public Task> ListCarriers(CancellationToken cancellationToken = default) { return ListCarriers(_client, cancellationToken); } @@ -458,8 +464,8 @@ public Task ListCarriers(CancellationToken cancellation /// Thrown when fails to make API call /// HttpClient to use for the request /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetCarriersResponseBody) - public async Task ListCarriers(HttpClient methodClient, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetCarriersResponseBody) + public async Task> ListCarriers(HttpClient methodClient, CancellationToken cancellationToken = default) { RequestOptions requestOptions = new("/v1/carriers"); @@ -467,9 +473,10 @@ public async Task ListCarriers(HttpClient methodClient, requestOptions.Operation = "CarriersApi.ListCarriers"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } -} \ No newline at end of file +} diff --git a/ShipEngineSDK/Api/DownloadsApi.cs b/ShipEngineSDK/Api/DownloadsApi.cs index 6a2d6e3b..8a5b59f6 100644 --- a/ShipEngineSDK/Api/DownloadsApi.cs +++ b/ShipEngineSDK/Api/DownloadsApi.cs @@ -35,8 +35,8 @@ public partial interface IShipEngine /// (optional) /// (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (System.IO.Stream) - Task DownloadFile(string subdir, string filename, string dir, int? rotation, string? download, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (System.IO.Stream) + Task> DownloadFile(string subdir, string filename, string dir, int? rotation, string? download, CancellationToken cancellationToken = default); /// /// Download File Get File @@ -50,8 +50,8 @@ public partial interface IShipEngine /// (optional) /// (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (System.IO.Stream) - Task DownloadFile(HttpClient methodClient, string subdir, string filename, string dir, int? rotation, string? download, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (System.IO.Stream) + Task> DownloadFile(HttpClient methodClient, string subdir, string filename, string dir, int? rotation, string? download, CancellationToken cancellationToken = default); } @@ -71,8 +71,8 @@ public partial class ShipEngine /// (optional) /// (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (System.IO.Stream) - public Task DownloadFile(string subdir, string filename, string dir, int? rotation = default, string? download = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (System.IO.Stream) + public Task> DownloadFile(string subdir, string filename, string dir, int? rotation = default, string? download = default, CancellationToken cancellationToken = default) { return DownloadFile(_client, subdir, filename, dir, rotation, download, cancellationToken); } @@ -89,8 +89,8 @@ public partial class ShipEngine /// (optional) /// (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (System.IO.Stream) - public async Task DownloadFile(HttpClient methodClient, string subdir, string filename, string dir, int? rotation = default, string? download = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (System.IO.Stream) + public async Task> DownloadFile(HttpClient methodClient, string subdir, string filename, string dir, int? rotation = default, string? download = default, CancellationToken cancellationToken = default) { // verify the required parameter 'subdir' is set if (subdir == null) @@ -127,9 +127,10 @@ public partial class ShipEngine requestOptions.Operation = "DownloadsApi.DownloadFile"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } -} \ No newline at end of file +} diff --git a/ShipEngineSDK/Api/InsuranceApi.cs b/ShipEngineSDK/Api/InsuranceApi.cs index 307b2ab0..e6ca29d8 100644 --- a/ShipEngineSDK/Api/InsuranceApi.cs +++ b/ShipEngineSDK/Api/InsuranceApi.cs @@ -31,8 +31,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (AddFundsToInsuranceResponseBody) - Task AddFundsToInsurance(AddFundsToInsuranceRequestBody addFundsToInsuranceRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (AddFundsToInsuranceResponseBody) + Task> AddFundsToInsurance(AddFundsToInsuranceRequestBody addFundsToInsuranceRequestBody, CancellationToken cancellationToken = default); /// /// Add Funds To Insurance You may need to auto fund your account from time to time. For example, if you don't normally ship items over $100, and may want to add funds to insurance rather than keeping the account funded. @@ -42,8 +42,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (AddFundsToInsuranceResponseBody) - Task AddFundsToInsurance(HttpClient methodClient, AddFundsToInsuranceRequestBody addFundsToInsuranceRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (AddFundsToInsuranceResponseBody) + Task> AddFundsToInsurance(HttpClient methodClient, AddFundsToInsuranceRequestBody addFundsToInsuranceRequestBody, CancellationToken cancellationToken = default); /// /// Connect a Shipsurance Account Connect a Shipsurance Account @@ -52,8 +52,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (Object) - Task ConnectInsurer(ConnectInsurerRequestBody connectInsurerRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (Object) + Task> ConnectInsurer(ConnectInsurerRequestBody connectInsurerRequestBody, CancellationToken cancellationToken = default); /// /// Connect a Shipsurance Account Connect a Shipsurance Account @@ -63,8 +63,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (Object) - Task ConnectInsurer(HttpClient methodClient, ConnectInsurerRequestBody connectInsurerRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (Object) + Task> ConnectInsurer(HttpClient methodClient, ConnectInsurerRequestBody connectInsurerRequestBody, CancellationToken cancellationToken = default); /// /// Disconnect a Shipsurance Account Disconnect a Shipsurance Account @@ -72,8 +72,8 @@ public partial interface IShipEngine /// Thrown when required argument is null /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of ApiResponse (Object) - Task DisconnectInsurer(CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (Object) + Task> DisconnectInsurer(CancellationToken cancellationToken = default); /// /// Disconnect a Shipsurance Account Disconnect a Shipsurance Account @@ -82,8 +82,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// HttpClient to use for the request /// Cancellation Token to cancel the request. - /// Task of ApiResponse (Object) - Task DisconnectInsurer(HttpClient methodClient, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (Object) + Task> DisconnectInsurer(HttpClient methodClient, CancellationToken cancellationToken = default); /// /// Get Insurance Funds Balance Retrieve the balance of your Shipsurance account. @@ -91,8 +91,8 @@ public partial interface IShipEngine /// Thrown when required argument is null /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetInsuranceBalanceResponseBody) - Task GetInsuranceBalance(CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetInsuranceBalanceResponseBody) + Task> GetInsuranceBalance(CancellationToken cancellationToken = default); /// /// Get Insurance Funds Balance Retrieve the balance of your Shipsurance account. @@ -101,8 +101,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// HttpClient to use for the request /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetInsuranceBalanceResponseBody) - Task GetInsuranceBalance(HttpClient methodClient, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetInsuranceBalanceResponseBody) + Task> GetInsuranceBalance(HttpClient methodClient, CancellationToken cancellationToken = default); } @@ -118,8 +118,8 @@ public partial class ShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (AddFundsToInsuranceResponseBody) - public Task AddFundsToInsurance(AddFundsToInsuranceRequestBody addFundsToInsuranceRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (AddFundsToInsuranceResponseBody) + public Task> AddFundsToInsurance(AddFundsToInsuranceRequestBody addFundsToInsuranceRequestBody, CancellationToken cancellationToken = default) { return AddFundsToInsurance(_client, addFundsToInsuranceRequestBody, cancellationToken); } @@ -132,8 +132,8 @@ public Task AddFundsToInsurance(AddFundsToInsur /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (AddFundsToInsuranceResponseBody) - public async Task AddFundsToInsurance(HttpClient methodClient, AddFundsToInsuranceRequestBody addFundsToInsuranceRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (AddFundsToInsuranceResponseBody) + public async Task> AddFundsToInsurance(HttpClient methodClient, AddFundsToInsuranceRequestBody addFundsToInsuranceRequestBody, CancellationToken cancellationToken = default) { // verify the required parameter 'addFundsToInsuranceRequestBody' is set if (addFundsToInsuranceRequestBody == null) @@ -148,9 +148,10 @@ public async Task AddFundsToInsurance(HttpClien requestOptions.Operation = "InsuranceApi.AddFundsToInsurance"; - var result = await SendHttpRequestAsync(HttpMethods.Patch, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Patch, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -160,8 +161,8 @@ public async Task AddFundsToInsurance(HttpClien /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (Object) - public Task ConnectInsurer(ConnectInsurerRequestBody connectInsurerRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (Object) + public Task> ConnectInsurer(ConnectInsurerRequestBody connectInsurerRequestBody, CancellationToken cancellationToken = default) { return ConnectInsurer(_client, connectInsurerRequestBody, cancellationToken); } @@ -174,8 +175,8 @@ public Task ConnectInsurer(ConnectInsurerRequestBody connectInsurerReque /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (Object) - public async Task ConnectInsurer(HttpClient methodClient, ConnectInsurerRequestBody connectInsurerRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (Object) + public async Task> ConnectInsurer(HttpClient methodClient, ConnectInsurerRequestBody connectInsurerRequestBody, CancellationToken cancellationToken = default) { // verify the required parameter 'connectInsurerRequestBody' is set if (connectInsurerRequestBody == null) @@ -190,9 +191,10 @@ public async Task ConnectInsurer(HttpClient methodClient, ConnectInsurer requestOptions.Operation = "InsuranceApi.ConnectInsurer"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -201,8 +203,8 @@ public async Task ConnectInsurer(HttpClient methodClient, ConnectInsurer /// Thrown when required argument is null /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of ApiResponse (Object) - public Task DisconnectInsurer(CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (Object) + public Task> DisconnectInsurer(CancellationToken cancellationToken = default) { return DisconnectInsurer(_client, cancellationToken); } @@ -214,8 +216,8 @@ public Task DisconnectInsurer(CancellationToken cancellationToken = defa /// Thrown when fails to make API call /// HttpClient to use for the request /// Cancellation Token to cancel the request. - /// Task of ApiResponse (Object) - public async Task DisconnectInsurer(HttpClient methodClient, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (Object) + public async Task> DisconnectInsurer(HttpClient methodClient, CancellationToken cancellationToken = default) { RequestOptions requestOptions = new("/v1/connections/insurance/shipsurance"); @@ -223,9 +225,10 @@ public async Task DisconnectInsurer(HttpClient methodClient, Cancellatio requestOptions.Operation = "InsuranceApi.DisconnectInsurer"; - var result = await SendHttpRequestAsync(HttpMethods.Delete, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -234,8 +237,8 @@ public async Task DisconnectInsurer(HttpClient methodClient, Cancellatio /// Thrown when required argument is null /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetInsuranceBalanceResponseBody) - public Task GetInsuranceBalance(CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetInsuranceBalanceResponseBody) + public Task> GetInsuranceBalance(CancellationToken cancellationToken = default) { return GetInsuranceBalance(_client, cancellationToken); } @@ -247,8 +250,8 @@ public Task GetInsuranceBalance(CancellationTok /// Thrown when fails to make API call /// HttpClient to use for the request /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetInsuranceBalanceResponseBody) - public async Task GetInsuranceBalance(HttpClient methodClient, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetInsuranceBalanceResponseBody) + public async Task> GetInsuranceBalance(HttpClient methodClient, CancellationToken cancellationToken = default) { RequestOptions requestOptions = new("/v1/insurance/shipsurance/balance"); @@ -256,9 +259,10 @@ public async Task GetInsuranceBalance(HttpClien requestOptions.Operation = "InsuranceApi.GetInsuranceBalance"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } -} \ No newline at end of file +} diff --git a/ShipEngineSDK/Api/LabelsApi.cs b/ShipEngineSDK/Api/LabelsApi.cs index 6717e400..743f0bd3 100644 --- a/ShipEngineSDK/Api/LabelsApi.cs +++ b/ShipEngineSDK/Api/LabelsApi.cs @@ -31,8 +31,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateLabelResponseBody) - Task CreateLabel(CreateLabelRequestBody createLabelRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateLabelResponseBody) + Task> CreateLabel(CreateLabelRequestBody createLabelRequestBody, CancellationToken cancellationToken = default); /// /// Purchase Label Purchase and print a label for shipment @@ -42,8 +42,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateLabelResponseBody) - Task CreateLabel(HttpClient methodClient, CreateLabelRequestBody createLabelRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateLabelResponseBody) + Task> CreateLabel(HttpClient methodClient, CreateLabelRequestBody createLabelRequestBody, CancellationToken cancellationToken = default); /// /// Purchase Label with Rate ID When retrieving rates for shipments using the `/rates` endpoint, the returned information contains a `rate_id` property that can be used to generate a label without having to refill in the shipment information repeatedly. @@ -53,8 +53,8 @@ public partial interface IShipEngine /// /// Rate ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateLabelFromRateResponseBody) - Task CreateLabelFromRate(CreateLabelFromRateRequestBody createLabelFromRateRequestBody, string rateId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateLabelFromRateResponseBody) + Task> CreateLabelFromRate(CreateLabelFromRateRequestBody createLabelFromRateRequestBody, string rateId, CancellationToken cancellationToken = default); /// /// Purchase Label with Rate ID When retrieving rates for shipments using the `/rates` endpoint, the returned information contains a `rate_id` property that can be used to generate a label without having to refill in the shipment information repeatedly. @@ -65,8 +65,8 @@ public partial interface IShipEngine /// /// Rate ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateLabelFromRateResponseBody) - Task CreateLabelFromRate(HttpClient methodClient, CreateLabelFromRateRequestBody createLabelFromRateRequestBody, string rateId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateLabelFromRateResponseBody) + Task> CreateLabelFromRate(HttpClient methodClient, CreateLabelFromRateRequestBody createLabelFromRateRequestBody, string rateId, CancellationToken cancellationToken = default); /// /// Purchase Label with Shipment ID Purchase a label using a shipment ID that has already been created with the desired address and package info. @@ -76,8 +76,8 @@ public partial interface IShipEngine /// /// Shipment ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateLabelFromShipmentResponseBody) - Task CreateLabelFromShipment(CreateLabelFromShipmentRequestBody createLabelFromShipmentRequestBody, string shipmentId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateLabelFromShipmentResponseBody) + Task> CreateLabelFromShipment(CreateLabelFromShipmentRequestBody createLabelFromShipmentRequestBody, string shipmentId, CancellationToken cancellationToken = default); /// /// Purchase Label with Shipment ID Purchase a label using a shipment ID that has already been created with the desired address and package info. @@ -88,8 +88,8 @@ public partial interface IShipEngine /// /// Shipment ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateLabelFromShipmentResponseBody) - Task CreateLabelFromShipment(HttpClient methodClient, CreateLabelFromShipmentRequestBody createLabelFromShipmentRequestBody, string shipmentId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateLabelFromShipmentResponseBody) + Task> CreateLabelFromShipment(HttpClient methodClient, CreateLabelFromShipmentRequestBody createLabelFromShipmentRequestBody, string shipmentId, CancellationToken cancellationToken = default); /// /// Create a return label Create a return label @@ -99,8 +99,8 @@ public partial interface IShipEngine /// /// Label ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateReturnLabelResponseBody) - Task CreateReturnLabel(CreateReturnLabelRequestBody createReturnLabelRequestBody, string labelId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateReturnLabelResponseBody) + Task> CreateReturnLabel(CreateReturnLabelRequestBody createReturnLabelRequestBody, string labelId, CancellationToken cancellationToken = default); /// /// Create a return label Create a return label @@ -111,8 +111,8 @@ public partial interface IShipEngine /// /// Label ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateReturnLabelResponseBody) - Task CreateReturnLabel(HttpClient methodClient, CreateReturnLabelRequestBody createReturnLabelRequestBody, string labelId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateReturnLabelResponseBody) + Task> CreateReturnLabel(HttpClient methodClient, CreateReturnLabelRequestBody createReturnLabelRequestBody, string labelId, CancellationToken cancellationToken = default); /// /// Get Label By External Shipment ID Find a label by using the external shipment id that was used during label creation @@ -122,8 +122,8 @@ public partial interface IShipEngine /// /// (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetLabelByExternalShipmentIdResponseBody) - Task GetLabelByExternalShipmentId(string externalShipmentId, LabelDownloadType? labelDownloadType, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetLabelByExternalShipmentIdResponseBody) + Task> GetLabelByExternalShipmentId(string externalShipmentId, LabelDownloadType? labelDownloadType, CancellationToken cancellationToken = default); /// /// Get Label By External Shipment ID Find a label by using the external shipment id that was used during label creation @@ -134,8 +134,8 @@ public partial interface IShipEngine /// /// (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetLabelByExternalShipmentIdResponseBody) - Task GetLabelByExternalShipmentId(HttpClient methodClient, string externalShipmentId, LabelDownloadType? labelDownloadType, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetLabelByExternalShipmentIdResponseBody) + Task> GetLabelByExternalShipmentId(HttpClient methodClient, string externalShipmentId, LabelDownloadType? labelDownloadType, CancellationToken cancellationToken = default); /// /// Get Label By ID Retrieve information for individual labels. @@ -145,8 +145,8 @@ public partial interface IShipEngine /// Label ID /// (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetLabelByIdResponseBody) - Task GetLabelById(string labelId, LabelDownloadType? labelDownloadType, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetLabelByIdResponseBody) + Task> GetLabelById(string labelId, LabelDownloadType? labelDownloadType, CancellationToken cancellationToken = default); /// /// Get Label By ID Retrieve information for individual labels. @@ -157,8 +157,8 @@ public partial interface IShipEngine /// Label ID /// (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetLabelByIdResponseBody) - Task GetLabelById(HttpClient methodClient, string labelId, LabelDownloadType? labelDownloadType, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetLabelByIdResponseBody) + Task> GetLabelById(HttpClient methodClient, string labelId, LabelDownloadType? labelDownloadType, CancellationToken cancellationToken = default); /// /// Get Label Tracking Information Retrieve the label's tracking information @@ -167,8 +167,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Label ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetTrackingLogFromLabelResponseBody) - Task GetTrackingLogFromLabel(string labelId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetTrackingLogFromLabelResponseBody) + Task> GetTrackingLogFromLabel(string labelId, CancellationToken cancellationToken = default); /// /// Get Label Tracking Information Retrieve the label's tracking information @@ -178,8 +178,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Label ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetTrackingLogFromLabelResponseBody) - Task GetTrackingLogFromLabel(HttpClient methodClient, string labelId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetTrackingLogFromLabelResponseBody) + Task> GetTrackingLogFromLabel(HttpClient methodClient, string labelId, CancellationToken cancellationToken = default); /// /// List labels This endpoint returns a list of labels that you've [created](https://www.shipengine.com/docs/labels/create-a-label/). You can optionally filter the results as well as control their sort order and the number of results returned at a time. By default, all labels are returned, 25 at a time, starting with the most recently created ones. You can combine multiple filter options to narrow-down the results. For example, if you only want to get your UPS labels for your east coast warehouse you could query by both `warehouse_id` and `carrier_id` @@ -201,8 +201,8 @@ public partial interface IShipEngine /// The number of results to return per response. (optional, default to 25) /// Controls which field the query is sorted by. (optional, default to created_at) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListLabelsResponseBody) - Task ListLabels(DateTimeOffset? createdAtStart, DateTimeOffset? createdAtEnd, LabelStatus? labelStatus, SortDir? sortDir, string? serviceCode, string? carrierId, string? trackingNumber, string? batchId, string? rateId, string? shipmentId, string? warehouseId, int? page, int? pageSize, string? sortBy, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListLabelsResponseBody) + Task> ListLabels(DateTimeOffset? createdAtStart, DateTimeOffset? createdAtEnd, LabelStatus? labelStatus, SortDir? sortDir, string? serviceCode, string? carrierId, string? trackingNumber, string? batchId, string? rateId, string? shipmentId, string? warehouseId, int? page, int? pageSize, string? sortBy, CancellationToken cancellationToken = default); /// /// List labels This endpoint returns a list of labels that you've [created](https://www.shipengine.com/docs/labels/create-a-label/). You can optionally filter the results as well as control their sort order and the number of results returned at a time. By default, all labels are returned, 25 at a time, starting with the most recently created ones. You can combine multiple filter options to narrow-down the results. For example, if you only want to get your UPS labels for your east coast warehouse you could query by both `warehouse_id` and `carrier_id` @@ -225,8 +225,8 @@ public partial interface IShipEngine /// The number of results to return per response. (optional, default to 25) /// Controls which field the query is sorted by. (optional, default to created_at) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListLabelsResponseBody) - Task ListLabels(HttpClient methodClient, DateTimeOffset? createdAtStart, DateTimeOffset? createdAtEnd, LabelStatus? labelStatus, SortDir? sortDir, string? serviceCode, string? carrierId, string? trackingNumber, string? batchId, string? rateId, string? shipmentId, string? warehouseId, int? page, int? pageSize, string? sortBy, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListLabelsResponseBody) + Task> ListLabels(HttpClient methodClient, DateTimeOffset? createdAtStart, DateTimeOffset? createdAtEnd, LabelStatus? labelStatus, SortDir? sortDir, string? serviceCode, string? carrierId, string? trackingNumber, string? batchId, string? rateId, string? shipmentId, string? warehouseId, int? page, int? pageSize, string? sortBy, CancellationToken cancellationToken = default); /// /// Void a Label By ID Void a label by ID to get a refund. @@ -235,8 +235,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Label ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (VoidLabelResponseBody) - Task VoidLabel(string labelId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (VoidLabelResponseBody) + Task> VoidLabel(string labelId, CancellationToken cancellationToken = default); /// /// Void a Label By ID Void a label by ID to get a refund. @@ -246,8 +246,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Label ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (VoidLabelResponseBody) - Task VoidLabel(HttpClient methodClient, string labelId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (VoidLabelResponseBody) + Task> VoidLabel(HttpClient methodClient, string labelId, CancellationToken cancellationToken = default); } @@ -263,8 +263,8 @@ public partial class ShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateLabelResponseBody) - public Task CreateLabel(CreateLabelRequestBody createLabelRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateLabelResponseBody) + public Task> CreateLabel(CreateLabelRequestBody createLabelRequestBody, CancellationToken cancellationToken = default) { return CreateLabel(_client, createLabelRequestBody, cancellationToken); } @@ -277,8 +277,8 @@ public Task CreateLabel(CreateLabelRequestBody createLa /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateLabelResponseBody) - public async Task CreateLabel(HttpClient methodClient, CreateLabelRequestBody createLabelRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateLabelResponseBody) + public async Task> CreateLabel(HttpClient methodClient, CreateLabelRequestBody createLabelRequestBody, CancellationToken cancellationToken = default) { // verify the required parameter 'createLabelRequestBody' is set if (createLabelRequestBody == null) @@ -293,9 +293,10 @@ public async Task CreateLabel(HttpClient methodClient, requestOptions.Operation = "LabelsApi.CreateLabel"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -306,8 +307,8 @@ public async Task CreateLabel(HttpClient methodClient, /// /// Rate ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateLabelFromRateResponseBody) - public Task CreateLabelFromRate(CreateLabelFromRateRequestBody createLabelFromRateRequestBody, string rateId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateLabelFromRateResponseBody) + public Task> CreateLabelFromRate(CreateLabelFromRateRequestBody createLabelFromRateRequestBody, string rateId, CancellationToken cancellationToken = default) { return CreateLabelFromRate(_client, createLabelFromRateRequestBody, rateId, cancellationToken); } @@ -321,8 +322,8 @@ public Task CreateLabelFromRate(CreateLabelFrom /// /// Rate ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateLabelFromRateResponseBody) - public async Task CreateLabelFromRate(HttpClient methodClient, CreateLabelFromRateRequestBody createLabelFromRateRequestBody, string rateId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateLabelFromRateResponseBody) + public async Task> CreateLabelFromRate(HttpClient methodClient, CreateLabelFromRateRequestBody createLabelFromRateRequestBody, string rateId, CancellationToken cancellationToken = default) { // verify the required parameter 'createLabelFromRateRequestBody' is set if (createLabelFromRateRequestBody == null) @@ -344,9 +345,10 @@ public async Task CreateLabelFromRate(HttpClien requestOptions.Operation = "LabelsApi.CreateLabelFromRate"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -357,8 +359,8 @@ public async Task CreateLabelFromRate(HttpClien /// /// Shipment ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateLabelFromShipmentResponseBody) - public Task CreateLabelFromShipment(CreateLabelFromShipmentRequestBody createLabelFromShipmentRequestBody, string shipmentId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateLabelFromShipmentResponseBody) + public Task> CreateLabelFromShipment(CreateLabelFromShipmentRequestBody createLabelFromShipmentRequestBody, string shipmentId, CancellationToken cancellationToken = default) { return CreateLabelFromShipment(_client, createLabelFromShipmentRequestBody, shipmentId, cancellationToken); } @@ -372,8 +374,8 @@ public Task CreateLabelFromShipment(CreateL /// /// Shipment ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateLabelFromShipmentResponseBody) - public async Task CreateLabelFromShipment(HttpClient methodClient, CreateLabelFromShipmentRequestBody createLabelFromShipmentRequestBody, string shipmentId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateLabelFromShipmentResponseBody) + public async Task> CreateLabelFromShipment(HttpClient methodClient, CreateLabelFromShipmentRequestBody createLabelFromShipmentRequestBody, string shipmentId, CancellationToken cancellationToken = default) { // verify the required parameter 'createLabelFromShipmentRequestBody' is set if (createLabelFromShipmentRequestBody == null) @@ -395,9 +397,10 @@ public async Task CreateLabelFromShipment(H requestOptions.Operation = "LabelsApi.CreateLabelFromShipment"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -408,8 +411,8 @@ public async Task CreateLabelFromShipment(H /// /// Label ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateReturnLabelResponseBody) - public Task CreateReturnLabel(CreateReturnLabelRequestBody createReturnLabelRequestBody, string labelId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateReturnLabelResponseBody) + public Task> CreateReturnLabel(CreateReturnLabelRequestBody createReturnLabelRequestBody, string labelId, CancellationToken cancellationToken = default) { return CreateReturnLabel(_client, createReturnLabelRequestBody, labelId, cancellationToken); } @@ -423,8 +426,8 @@ public Task CreateReturnLabel(CreateReturnLabelRe /// /// Label ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateReturnLabelResponseBody) - public async Task CreateReturnLabel(HttpClient methodClient, CreateReturnLabelRequestBody createReturnLabelRequestBody, string labelId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateReturnLabelResponseBody) + public async Task> CreateReturnLabel(HttpClient methodClient, CreateReturnLabelRequestBody createReturnLabelRequestBody, string labelId, CancellationToken cancellationToken = default) { // verify the required parameter 'createReturnLabelRequestBody' is set if (createReturnLabelRequestBody == null) @@ -446,9 +449,10 @@ public async Task CreateReturnLabel(HttpClient me requestOptions.Operation = "LabelsApi.CreateReturnLabel"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -459,8 +463,8 @@ public async Task CreateReturnLabel(HttpClient me /// /// (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetLabelByExternalShipmentIdResponseBody) - public Task GetLabelByExternalShipmentId(string externalShipmentId, LabelDownloadType? labelDownloadType = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetLabelByExternalShipmentIdResponseBody) + public Task> GetLabelByExternalShipmentId(string externalShipmentId, LabelDownloadType? labelDownloadType = default, CancellationToken cancellationToken = default) { return GetLabelByExternalShipmentId(_client, externalShipmentId, labelDownloadType, cancellationToken); } @@ -474,8 +478,8 @@ public Task GetLabelByExternalShipment /// /// (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetLabelByExternalShipmentIdResponseBody) - public async Task GetLabelByExternalShipmentId(HttpClient methodClient, string externalShipmentId, LabelDownloadType? labelDownloadType = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetLabelByExternalShipmentIdResponseBody) + public async Task> GetLabelByExternalShipmentId(HttpClient methodClient, string externalShipmentId, LabelDownloadType? labelDownloadType = default, CancellationToken cancellationToken = default) { // verify the required parameter 'externalShipmentId' is set if (externalShipmentId == null) @@ -494,9 +498,10 @@ public async Task GetLabelByExternalSh requestOptions.Operation = "LabelsApi.GetLabelByExternalShipmentId"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -507,8 +512,8 @@ public async Task GetLabelByExternalSh /// Label ID /// (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetLabelByIdResponseBody) - public Task GetLabelById(string labelId, LabelDownloadType? labelDownloadType = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetLabelByIdResponseBody) + public Task> GetLabelById(string labelId, LabelDownloadType? labelDownloadType = default, CancellationToken cancellationToken = default) { return GetLabelById(_client, labelId, labelDownloadType, cancellationToken); } @@ -522,8 +527,8 @@ public Task GetLabelById(string labelId, LabelDownload /// Label ID /// (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetLabelByIdResponseBody) - public async Task GetLabelById(HttpClient methodClient, string labelId, LabelDownloadType? labelDownloadType = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetLabelByIdResponseBody) + public async Task> GetLabelById(HttpClient methodClient, string labelId, LabelDownloadType? labelDownloadType = default, CancellationToken cancellationToken = default) { // verify the required parameter 'labelId' is set if (labelId == null) @@ -542,9 +547,10 @@ public async Task GetLabelById(HttpClient methodClient requestOptions.Operation = "LabelsApi.GetLabelById"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -554,8 +560,8 @@ public async Task GetLabelById(HttpClient methodClient /// Thrown when fails to make API call /// Label ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetTrackingLogFromLabelResponseBody) - public Task GetTrackingLogFromLabel(string labelId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetTrackingLogFromLabelResponseBody) + public Task> GetTrackingLogFromLabel(string labelId, CancellationToken cancellationToken = default) { return GetTrackingLogFromLabel(_client, labelId, cancellationToken); } @@ -568,8 +574,8 @@ public Task GetTrackingLogFromLabel(string /// HttpClient to use for the request /// Label ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetTrackingLogFromLabelResponseBody) - public async Task GetTrackingLogFromLabel(HttpClient methodClient, string labelId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetTrackingLogFromLabelResponseBody) + public async Task> GetTrackingLogFromLabel(HttpClient methodClient, string labelId, CancellationToken cancellationToken = default) { // verify the required parameter 'labelId' is set if (labelId == null) @@ -584,9 +590,10 @@ public async Task GetTrackingLogFromLabel(H requestOptions.Operation = "LabelsApi.GetTrackingLogFromLabel"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -609,8 +616,8 @@ public async Task GetTrackingLogFromLabel(H /// The number of results to return per response. (optional, default to 25) /// Controls which field the query is sorted by. (optional, default to created_at) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListLabelsResponseBody) - public Task ListLabels(DateTimeOffset? createdAtStart = default, DateTimeOffset? createdAtEnd = default, LabelStatus? labelStatus = default, SortDir? sortDir = default, string? serviceCode = default, string? carrierId = default, string? trackingNumber = default, string? batchId = default, string? rateId = default, string? shipmentId = default, string? warehouseId = default, int? page = default, int? pageSize = default, string? sortBy = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListLabelsResponseBody) + public Task> ListLabels(DateTimeOffset? createdAtStart = default, DateTimeOffset? createdAtEnd = default, LabelStatus? labelStatus = default, SortDir? sortDir = default, string? serviceCode = default, string? carrierId = default, string? trackingNumber = default, string? batchId = default, string? rateId = default, string? shipmentId = default, string? warehouseId = default, int? page = default, int? pageSize = default, string? sortBy = default, CancellationToken cancellationToken = default) { return ListLabels(_client, createdAtStart, createdAtEnd, labelStatus, sortDir, serviceCode, carrierId, trackingNumber, batchId, rateId, shipmentId, warehouseId, page, pageSize, sortBy, cancellationToken); } @@ -636,8 +643,8 @@ public Task ListLabels(DateTimeOffset? createdAtStart = /// The number of results to return per response. (optional, default to 25) /// Controls which field the query is sorted by. (optional, default to created_at) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListLabelsResponseBody) - public async Task ListLabels(HttpClient methodClient, DateTimeOffset? createdAtStart = default, DateTimeOffset? createdAtEnd = default, LabelStatus? labelStatus = default, SortDir? sortDir = default, string? serviceCode = default, string? carrierId = default, string? trackingNumber = default, string? batchId = default, string? rateId = default, string? shipmentId = default, string? warehouseId = default, int? page = default, int? pageSize = default, string? sortBy = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListLabelsResponseBody) + public async Task> ListLabels(HttpClient methodClient, DateTimeOffset? createdAtStart = default, DateTimeOffset? createdAtEnd = default, LabelStatus? labelStatus = default, SortDir? sortDir = default, string? serviceCode = default, string? carrierId = default, string? trackingNumber = default, string? batchId = default, string? rateId = default, string? shipmentId = default, string? warehouseId = default, int? page = default, int? pageSize = default, string? sortBy = default, CancellationToken cancellationToken = default) { RequestOptions requestOptions = new("/v1/labels"); @@ -701,9 +708,10 @@ public async Task ListLabels(HttpClient methodClient, Da requestOptions.Operation = "LabelsApi.ListLabels"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -713,8 +721,8 @@ public async Task ListLabels(HttpClient methodClient, Da /// Thrown when fails to make API call /// Label ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (VoidLabelResponseBody) - public Task VoidLabel(string labelId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (VoidLabelResponseBody) + public Task> VoidLabel(string labelId, CancellationToken cancellationToken = default) { return VoidLabel(_client, labelId, cancellationToken); } @@ -727,8 +735,8 @@ public Task VoidLabel(string labelId, CancellationToken c /// HttpClient to use for the request /// Label ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (VoidLabelResponseBody) - public async Task VoidLabel(HttpClient methodClient, string labelId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (VoidLabelResponseBody) + public async Task> VoidLabel(HttpClient methodClient, string labelId, CancellationToken cancellationToken = default) { // verify the required parameter 'labelId' is set if (labelId == null) @@ -743,9 +751,10 @@ public async Task VoidLabel(HttpClient methodClient, stri requestOptions.Operation = "LabelsApi.VoidLabel"; - var result = await SendHttpRequestAsync(HttpMethods.Put, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } -} \ No newline at end of file +} diff --git a/ShipEngineSDK/Api/ManifestsApi.cs b/ShipEngineSDK/Api/ManifestsApi.cs index 8cd04cad..cab14483 100644 --- a/ShipEngineSDK/Api/ManifestsApi.cs +++ b/ShipEngineSDK/Api/ManifestsApi.cs @@ -31,8 +31,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateManifestResponseBody) - Task CreateManifest(CreateManifestRequestBody createManifestRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateManifestResponseBody) + Task> CreateManifest(CreateManifestRequestBody createManifestRequestBody, CancellationToken cancellationToken = default); /// /// Create Manifest Each ShipEngine manifest is created for a specific warehouse, so you'll need to provide the warehouse_id rather than the ship_from address. You can create a warehouse for each location that you want to create manifests for. @@ -42,8 +42,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateManifestResponseBody) - Task CreateManifest(HttpClient methodClient, CreateManifestRequestBody createManifestRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateManifestResponseBody) + Task> CreateManifest(HttpClient methodClient, CreateManifestRequestBody createManifestRequestBody, CancellationToken cancellationToken = default); /// /// Get Manifest By Id Get Manifest By Id @@ -52,8 +52,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// The Manifest Id /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetManifestByIdResponseBody) - Task GetManifestById(string manifestId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetManifestByIdResponseBody) + Task> GetManifestById(string manifestId, CancellationToken cancellationToken = default); /// /// Get Manifest By Id Get Manifest By Id @@ -63,8 +63,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// The Manifest Id /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetManifestByIdResponseBody) - Task GetManifestById(HttpClient methodClient, string manifestId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetManifestByIdResponseBody) + Task> GetManifestById(HttpClient methodClient, string manifestId, CancellationToken cancellationToken = default); /// /// Get Manifest Request By Id Get Manifest Request By Id @@ -73,8 +73,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// The Manifest Request Id /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateManifestResponseBody) - Task GetManifestRequestById(string manifestRequestId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateManifestResponseBody) + Task> GetManifestRequestById(string manifestRequestId, CancellationToken cancellationToken = default); /// /// Get Manifest Request By Id Get Manifest Request By Id @@ -84,8 +84,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// The Manifest Request Id /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateManifestResponseBody) - Task GetManifestRequestById(HttpClient methodClient, string manifestRequestId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateManifestResponseBody) + Task> GetManifestRequestById(HttpClient methodClient, string manifestRequestId, CancellationToken cancellationToken = default); /// /// List Manifests Similar to querying shipments, we allow you to query manifests since there will likely be a large number over a long period of time. @@ -102,8 +102,8 @@ public partial interface IShipEngine /// Return a specific page of results. Defaults to the first page. If set to a number that's greater than the number of pages of results, an empty page is returned. (optional, default to 1) /// The number of results to return per response. (optional, default to 25) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListManifestsResponseBody) - Task ListManifests(DateTimeOffset? shipDateStart, DateTimeOffset? shipDateEnd, DateTimeOffset? createdAtStart, DateTimeOffset? createdAtEnd, List? labelIds, string? warehouseId, string? carrierId, int? page, int? pageSize, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListManifestsResponseBody) + Task> ListManifests(DateTimeOffset? shipDateStart, DateTimeOffset? shipDateEnd, DateTimeOffset? createdAtStart, DateTimeOffset? createdAtEnd, List? labelIds, string? warehouseId, string? carrierId, int? page, int? pageSize, CancellationToken cancellationToken = default); /// /// List Manifests Similar to querying shipments, we allow you to query manifests since there will likely be a large number over a long period of time. @@ -121,8 +121,8 @@ public partial interface IShipEngine /// Return a specific page of results. Defaults to the first page. If set to a number that's greater than the number of pages of results, an empty page is returned. (optional, default to 1) /// The number of results to return per response. (optional, default to 25) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListManifestsResponseBody) - Task ListManifests(HttpClient methodClient, DateTimeOffset? shipDateStart, DateTimeOffset? shipDateEnd, DateTimeOffset? createdAtStart, DateTimeOffset? createdAtEnd, List? labelIds, string? warehouseId, string? carrierId, int? page, int? pageSize, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListManifestsResponseBody) + Task> ListManifests(HttpClient methodClient, DateTimeOffset? shipDateStart, DateTimeOffset? shipDateEnd, DateTimeOffset? createdAtStart, DateTimeOffset? createdAtEnd, List? labelIds, string? warehouseId, string? carrierId, int? page, int? pageSize, CancellationToken cancellationToken = default); } @@ -138,8 +138,8 @@ public partial class ShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateManifestResponseBody) - public Task CreateManifest(CreateManifestRequestBody createManifestRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateManifestResponseBody) + public Task> CreateManifest(CreateManifestRequestBody createManifestRequestBody, CancellationToken cancellationToken = default) { return CreateManifest(_client, createManifestRequestBody, cancellationToken); } @@ -152,8 +152,8 @@ public Task CreateManifest(CreateManifestRequestBody /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateManifestResponseBody) - public async Task CreateManifest(HttpClient methodClient, CreateManifestRequestBody createManifestRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateManifestResponseBody) + public async Task> CreateManifest(HttpClient methodClient, CreateManifestRequestBody createManifestRequestBody, CancellationToken cancellationToken = default) { // verify the required parameter 'createManifestRequestBody' is set if (createManifestRequestBody == null) @@ -168,9 +168,10 @@ public async Task CreateManifest(HttpClient methodCl requestOptions.Operation = "ManifestsApi.CreateManifest"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -180,8 +181,8 @@ public async Task CreateManifest(HttpClient methodCl /// Thrown when fails to make API call /// The Manifest Id /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetManifestByIdResponseBody) - public Task GetManifestById(string manifestId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetManifestByIdResponseBody) + public Task> GetManifestById(string manifestId, CancellationToken cancellationToken = default) { return GetManifestById(_client, manifestId, cancellationToken); } @@ -194,8 +195,8 @@ public Task GetManifestById(string manifestId, Canc /// HttpClient to use for the request /// The Manifest Id /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetManifestByIdResponseBody) - public async Task GetManifestById(HttpClient methodClient, string manifestId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetManifestByIdResponseBody) + public async Task> GetManifestById(HttpClient methodClient, string manifestId, CancellationToken cancellationToken = default) { // verify the required parameter 'manifestId' is set if (manifestId == null) @@ -210,9 +211,10 @@ public async Task GetManifestById(HttpClient method requestOptions.Operation = "ManifestsApi.GetManifestById"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -222,8 +224,8 @@ public async Task GetManifestById(HttpClient method /// Thrown when fails to make API call /// The Manifest Request Id /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateManifestResponseBody) - public Task GetManifestRequestById(string manifestRequestId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateManifestResponseBody) + public Task> GetManifestRequestById(string manifestRequestId, CancellationToken cancellationToken = default) { return GetManifestRequestById(_client, manifestRequestId, cancellationToken); } @@ -236,8 +238,8 @@ public Task GetManifestRequestById(string manifestRe /// HttpClient to use for the request /// The Manifest Request Id /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateManifestResponseBody) - public async Task GetManifestRequestById(HttpClient methodClient, string manifestRequestId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateManifestResponseBody) + public async Task> GetManifestRequestById(HttpClient methodClient, string manifestRequestId, CancellationToken cancellationToken = default) { // verify the required parameter 'manifestRequestId' is set if (manifestRequestId == null) @@ -252,9 +254,10 @@ public async Task GetManifestRequestById(HttpClient requestOptions.Operation = "ManifestsApi.GetManifestRequestById"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -272,8 +275,8 @@ public async Task GetManifestRequestById(HttpClient /// Return a specific page of results. Defaults to the first page. If set to a number that's greater than the number of pages of results, an empty page is returned. (optional, default to 1) /// The number of results to return per response. (optional, default to 25) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListManifestsResponseBody) - public Task ListManifests(DateTimeOffset? shipDateStart = default, DateTimeOffset? shipDateEnd = default, DateTimeOffset? createdAtStart = default, DateTimeOffset? createdAtEnd = default, List? labelIds = default, string? warehouseId = default, string? carrierId = default, int? page = default, int? pageSize = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListManifestsResponseBody) + public Task> ListManifests(DateTimeOffset? shipDateStart = default, DateTimeOffset? shipDateEnd = default, DateTimeOffset? createdAtStart = default, DateTimeOffset? createdAtEnd = default, List? labelIds = default, string? warehouseId = default, string? carrierId = default, int? page = default, int? pageSize = default, CancellationToken cancellationToken = default) { return ListManifests(_client, shipDateStart, shipDateEnd, createdAtStart, createdAtEnd, labelIds, warehouseId, carrierId, page, pageSize, cancellationToken); } @@ -294,8 +297,8 @@ public Task ListManifests(DateTimeOffset? shipDateSta /// Return a specific page of results. Defaults to the first page. If set to a number that's greater than the number of pages of results, an empty page is returned. (optional, default to 1) /// The number of results to return per response. (optional, default to 25) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListManifestsResponseBody) - public async Task ListManifests(HttpClient methodClient, DateTimeOffset? shipDateStart = default, DateTimeOffset? shipDateEnd = default, DateTimeOffset? createdAtStart = default, DateTimeOffset? createdAtEnd = default, List? labelIds = default, string? warehouseId = default, string? carrierId = default, int? page = default, int? pageSize = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListManifestsResponseBody) + public async Task> ListManifests(HttpClient methodClient, DateTimeOffset? shipDateStart = default, DateTimeOffset? shipDateEnd = default, DateTimeOffset? createdAtStart = default, DateTimeOffset? createdAtEnd = default, List? labelIds = default, string? warehouseId = default, string? carrierId = default, int? page = default, int? pageSize = default, CancellationToken cancellationToken = default) { RequestOptions requestOptions = new("/v1/manifests"); @@ -339,9 +342,10 @@ public async Task ListManifests(HttpClient methodClie requestOptions.Operation = "ManifestsApi.ListManifests"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } -} \ No newline at end of file +} diff --git a/ShipEngineSDK/Api/PackagePickupsApi.cs b/ShipEngineSDK/Api/PackagePickupsApi.cs index ecb7af04..3faba26d 100644 --- a/ShipEngineSDK/Api/PackagePickupsApi.cs +++ b/ShipEngineSDK/Api/PackagePickupsApi.cs @@ -31,8 +31,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (DeletePickupByIdResponseBody) - Task DeleteScheduledPickup(string pickupId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (DeletePickupByIdResponseBody) + Task> DeleteScheduledPickup(string pickupId, CancellationToken cancellationToken = default); /// /// Delete a Scheduled Pickup Delete a previously-scheduled pickup by ID @@ -42,8 +42,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (DeletePickupByIdResponseBody) - Task DeleteScheduledPickup(HttpClient methodClient, string pickupId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (DeletePickupByIdResponseBody) + Task> DeleteScheduledPickup(HttpClient methodClient, string pickupId, CancellationToken cancellationToken = default); /// /// Get Pickup By ID Get Pickup By ID @@ -52,8 +52,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetPickupByIdResponseBody) - Task GetPickupById(string pickupId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetPickupByIdResponseBody) + Task> GetPickupById(string pickupId, CancellationToken cancellationToken = default); /// /// Get Pickup By ID Get Pickup By ID @@ -63,8 +63,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetPickupByIdResponseBody) - Task GetPickupById(HttpClient methodClient, string pickupId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetPickupByIdResponseBody) + Task> GetPickupById(HttpClient methodClient, string pickupId, CancellationToken cancellationToken = default); /// /// List Scheduled Pickups List all pickups that have been scheduled for this carrier @@ -78,8 +78,8 @@ public partial interface IShipEngine /// Return a specific page of results. Defaults to the first page. If set to a number that's greater than the number of pages of results, an empty page is returned. (optional, default to 1) /// The number of results to return per response. (optional, default to 25) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetPickupsResponseBody) - Task ListScheduledPickups(DateTimeOffset? createdAtStart, DateTimeOffset? createdAtEnd, string? carrierId, string? warehouseId, int? page, int? pageSize, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetPickupsResponseBody) + Task> ListScheduledPickups(DateTimeOffset? createdAtStart, DateTimeOffset? createdAtEnd, string? carrierId, string? warehouseId, int? page, int? pageSize, CancellationToken cancellationToken = default); /// /// List Scheduled Pickups List all pickups that have been scheduled for this carrier @@ -94,8 +94,8 @@ public partial interface IShipEngine /// Return a specific page of results. Defaults to the first page. If set to a number that's greater than the number of pages of results, an empty page is returned. (optional, default to 1) /// The number of results to return per response. (optional, default to 25) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetPickupsResponseBody) - Task ListScheduledPickups(HttpClient methodClient, DateTimeOffset? createdAtStart, DateTimeOffset? createdAtEnd, string? carrierId, string? warehouseId, int? page, int? pageSize, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetPickupsResponseBody) + Task> ListScheduledPickups(HttpClient methodClient, DateTimeOffset? createdAtStart, DateTimeOffset? createdAtEnd, string? carrierId, string? warehouseId, int? page, int? pageSize, CancellationToken cancellationToken = default); /// /// Schedule a Pickup Schedule a package pickup with a carrier @@ -104,8 +104,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (SchedulePickupResponseBody) - Task SchedulePickup(SchedulePickupRequestBody schedulePickupRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (SchedulePickupResponseBody) + Task> SchedulePickup(SchedulePickupRequestBody schedulePickupRequestBody, CancellationToken cancellationToken = default); /// /// Schedule a Pickup Schedule a package pickup with a carrier @@ -115,8 +115,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (SchedulePickupResponseBody) - Task SchedulePickup(HttpClient methodClient, SchedulePickupRequestBody schedulePickupRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (SchedulePickupResponseBody) + Task> SchedulePickup(HttpClient methodClient, SchedulePickupRequestBody schedulePickupRequestBody, CancellationToken cancellationToken = default); } @@ -132,8 +132,8 @@ public partial class ShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (DeletePickupByIdResponseBody) - public Task DeleteScheduledPickup(string pickupId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (DeletePickupByIdResponseBody) + public Task> DeleteScheduledPickup(string pickupId, CancellationToken cancellationToken = default) { return DeleteScheduledPickup(_client, pickupId, cancellationToken); } @@ -146,8 +146,8 @@ public Task DeleteScheduledPickup(string pickupId, /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (DeletePickupByIdResponseBody) - public async Task DeleteScheduledPickup(HttpClient methodClient, string pickupId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (DeletePickupByIdResponseBody) + public async Task> DeleteScheduledPickup(HttpClient methodClient, string pickupId, CancellationToken cancellationToken = default) { // verify the required parameter 'pickupId' is set if (pickupId == null) @@ -162,9 +162,10 @@ public async Task DeleteScheduledPickup(HttpClient requestOptions.Operation = "PackagePickupsApi.DeleteScheduledPickup"; - var result = await SendHttpRequestAsync(HttpMethods.Delete, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -174,8 +175,8 @@ public async Task DeleteScheduledPickup(HttpClient /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetPickupByIdResponseBody) - public Task GetPickupById(string pickupId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetPickupByIdResponseBody) + public Task> GetPickupById(string pickupId, CancellationToken cancellationToken = default) { return GetPickupById(_client, pickupId, cancellationToken); } @@ -188,8 +189,8 @@ public Task GetPickupById(string pickupId, Cancellati /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetPickupByIdResponseBody) - public async Task GetPickupById(HttpClient methodClient, string pickupId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetPickupByIdResponseBody) + public async Task> GetPickupById(HttpClient methodClient, string pickupId, CancellationToken cancellationToken = default) { // verify the required parameter 'pickupId' is set if (pickupId == null) @@ -204,9 +205,10 @@ public async Task GetPickupById(HttpClient methodClie requestOptions.Operation = "PackagePickupsApi.GetPickupById"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -221,8 +223,8 @@ public async Task GetPickupById(HttpClient methodClie /// Return a specific page of results. Defaults to the first page. If set to a number that's greater than the number of pages of results, an empty page is returned. (optional, default to 1) /// The number of results to return per response. (optional, default to 25) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetPickupsResponseBody) - public Task ListScheduledPickups(DateTimeOffset? createdAtStart = default, DateTimeOffset? createdAtEnd = default, string? carrierId = default, string? warehouseId = default, int? page = default, int? pageSize = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetPickupsResponseBody) + public Task> ListScheduledPickups(DateTimeOffset? createdAtStart = default, DateTimeOffset? createdAtEnd = default, string? carrierId = default, string? warehouseId = default, int? page = default, int? pageSize = default, CancellationToken cancellationToken = default) { return ListScheduledPickups(_client, createdAtStart, createdAtEnd, carrierId, warehouseId, page, pageSize, cancellationToken); } @@ -240,8 +242,8 @@ public Task ListScheduledPickups(DateTimeOffset? created /// Return a specific page of results. Defaults to the first page. If set to a number that's greater than the number of pages of results, an empty page is returned. (optional, default to 1) /// The number of results to return per response. (optional, default to 25) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetPickupsResponseBody) - public async Task ListScheduledPickups(HttpClient methodClient, DateTimeOffset? createdAtStart = default, DateTimeOffset? createdAtEnd = default, string? carrierId = default, string? warehouseId = default, int? page = default, int? pageSize = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetPickupsResponseBody) + public async Task> ListScheduledPickups(HttpClient methodClient, DateTimeOffset? createdAtStart = default, DateTimeOffset? createdAtEnd = default, string? carrierId = default, string? warehouseId = default, int? page = default, int? pageSize = default, CancellationToken cancellationToken = default) { RequestOptions requestOptions = new("/v1/pickups"); @@ -273,9 +275,10 @@ public async Task ListScheduledPickups(HttpClient method requestOptions.Operation = "PackagePickupsApi.ListScheduledPickups"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -285,8 +288,8 @@ public async Task ListScheduledPickups(HttpClient method /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (SchedulePickupResponseBody) - public Task SchedulePickup(SchedulePickupRequestBody schedulePickupRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (SchedulePickupResponseBody) + public Task> SchedulePickup(SchedulePickupRequestBody schedulePickupRequestBody, CancellationToken cancellationToken = default) { return SchedulePickup(_client, schedulePickupRequestBody, cancellationToken); } @@ -299,8 +302,8 @@ public Task SchedulePickup(SchedulePickupRequestBody /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (SchedulePickupResponseBody) - public async Task SchedulePickup(HttpClient methodClient, SchedulePickupRequestBody schedulePickupRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (SchedulePickupResponseBody) + public async Task> SchedulePickup(HttpClient methodClient, SchedulePickupRequestBody schedulePickupRequestBody, CancellationToken cancellationToken = default) { // verify the required parameter 'schedulePickupRequestBody' is set if (schedulePickupRequestBody == null) @@ -315,9 +318,10 @@ public async Task SchedulePickup(HttpClient methodCl requestOptions.Operation = "PackagePickupsApi.SchedulePickup"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } -} \ No newline at end of file +} diff --git a/ShipEngineSDK/Api/PackageTypesApi.cs b/ShipEngineSDK/Api/PackageTypesApi.cs index 77cb2586..04b8b545 100644 --- a/ShipEngineSDK/Api/PackageTypesApi.cs +++ b/ShipEngineSDK/Api/PackageTypesApi.cs @@ -31,8 +31,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreatePackageTypeResponseBody) - Task CreatePackageType(CreatePackageTypeRequestBody createPackageTypeRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreatePackageTypeResponseBody) + Task> CreatePackageType(CreatePackageTypeRequestBody createPackageTypeRequestBody, CancellationToken cancellationToken = default); /// /// Create Custom Package Type Create a custom package type to better assist in getting accurate rate estimates @@ -42,8 +42,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreatePackageTypeResponseBody) - Task CreatePackageType(HttpClient methodClient, CreatePackageTypeRequestBody createPackageTypeRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreatePackageTypeResponseBody) + Task> CreatePackageType(HttpClient methodClient, CreatePackageTypeRequestBody createPackageTypeRequestBody, CancellationToken cancellationToken = default); /// /// Delete A Custom Package By ID Delete a custom package using the ID @@ -52,8 +52,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Package ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task DeletePackageType(string packageId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> DeletePackageType(string packageId, CancellationToken cancellationToken = default); /// /// Delete A Custom Package By ID Delete a custom package using the ID @@ -63,8 +63,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Package ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task DeletePackageType(HttpClient methodClient, string packageId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> DeletePackageType(HttpClient methodClient, string packageId, CancellationToken cancellationToken = default); /// /// Get Custom Package Type By ID Get Custom Package Type by ID @@ -73,8 +73,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Package ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetPackageTypeByIdResponseBody) - Task GetPackageTypeById(string packageId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetPackageTypeByIdResponseBody) + Task> GetPackageTypeById(string packageId, CancellationToken cancellationToken = default); /// /// Get Custom Package Type By ID Get Custom Package Type by ID @@ -84,8 +84,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Package ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetPackageTypeByIdResponseBody) - Task GetPackageTypeById(HttpClient methodClient, string packageId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetPackageTypeByIdResponseBody) + Task> GetPackageTypeById(HttpClient methodClient, string packageId, CancellationToken cancellationToken = default); /// /// List Custom Package Types List the custom package types associated with the account @@ -93,8 +93,8 @@ public partial interface IShipEngine /// Thrown when required argument is null /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListPackageTypesResponseBody) - Task ListPackageTypes(CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListPackageTypesResponseBody) + Task> ListPackageTypes(CancellationToken cancellationToken = default); /// /// List Custom Package Types List the custom package types associated with the account @@ -103,8 +103,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// HttpClient to use for the request /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListPackageTypesResponseBody) - Task ListPackageTypes(HttpClient methodClient, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListPackageTypesResponseBody) + Task> ListPackageTypes(HttpClient methodClient, CancellationToken cancellationToken = default); /// /// Update Custom Package Type By ID Update the custom package type object by ID @@ -114,8 +114,8 @@ public partial interface IShipEngine /// /// Package ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task UpdatePackageType(UpdatePackageTypeRequestBody updatePackageTypeRequestBody, string packageId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> UpdatePackageType(UpdatePackageTypeRequestBody updatePackageTypeRequestBody, string packageId, CancellationToken cancellationToken = default); /// /// Update Custom Package Type By ID Update the custom package type object by ID @@ -126,8 +126,8 @@ public partial interface IShipEngine /// /// Package ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task UpdatePackageType(HttpClient methodClient, UpdatePackageTypeRequestBody updatePackageTypeRequestBody, string packageId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> UpdatePackageType(HttpClient methodClient, UpdatePackageTypeRequestBody updatePackageTypeRequestBody, string packageId, CancellationToken cancellationToken = default); } @@ -143,8 +143,8 @@ public partial class ShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreatePackageTypeResponseBody) - public Task CreatePackageType(CreatePackageTypeRequestBody createPackageTypeRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreatePackageTypeResponseBody) + public Task> CreatePackageType(CreatePackageTypeRequestBody createPackageTypeRequestBody, CancellationToken cancellationToken = default) { return CreatePackageType(_client, createPackageTypeRequestBody, cancellationToken); } @@ -157,8 +157,8 @@ public Task CreatePackageType(CreatePackageTypeRe /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreatePackageTypeResponseBody) - public async Task CreatePackageType(HttpClient methodClient, CreatePackageTypeRequestBody createPackageTypeRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreatePackageTypeResponseBody) + public async Task> CreatePackageType(HttpClient methodClient, CreatePackageTypeRequestBody createPackageTypeRequestBody, CancellationToken cancellationToken = default) { // verify the required parameter 'createPackageTypeRequestBody' is set if (createPackageTypeRequestBody == null) @@ -173,9 +173,10 @@ public async Task CreatePackageType(HttpClient me requestOptions.Operation = "PackageTypesApi.CreatePackageType"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -185,8 +186,8 @@ public async Task CreatePackageType(HttpClient me /// Thrown when fails to make API call /// Package ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task DeletePackageType(string packageId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> DeletePackageType(string packageId, CancellationToken cancellationToken = default) { return DeletePackageType(_client, packageId, cancellationToken); } @@ -199,8 +200,8 @@ public Task DeletePackageType(string packageId, CancellationToken cancel /// HttpClient to use for the request /// Package ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task DeletePackageType(HttpClient methodClient, string packageId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> DeletePackageType(HttpClient methodClient, string packageId, CancellationToken cancellationToken = default) { // verify the required parameter 'packageId' is set if (packageId == null) @@ -215,9 +216,10 @@ public async Task DeletePackageType(HttpClient methodClient, string pack requestOptions.Operation = "PackageTypesApi.DeletePackageType"; - var result = await SendHttpRequestAsync(HttpMethods.Delete, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -227,8 +229,8 @@ public async Task DeletePackageType(HttpClient methodClient, string pack /// Thrown when fails to make API call /// Package ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetPackageTypeByIdResponseBody) - public Task GetPackageTypeById(string packageId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetPackageTypeByIdResponseBody) + public Task> GetPackageTypeById(string packageId, CancellationToken cancellationToken = default) { return GetPackageTypeById(_client, packageId, cancellationToken); } @@ -241,8 +243,8 @@ public Task GetPackageTypeById(string packageId, /// HttpClient to use for the request /// Package ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetPackageTypeByIdResponseBody) - public async Task GetPackageTypeById(HttpClient methodClient, string packageId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetPackageTypeByIdResponseBody) + public async Task> GetPackageTypeById(HttpClient methodClient, string packageId, CancellationToken cancellationToken = default) { // verify the required parameter 'packageId' is set if (packageId == null) @@ -257,9 +259,10 @@ public async Task GetPackageTypeById(HttpClient requestOptions.Operation = "PackageTypesApi.GetPackageTypeById"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -268,8 +271,8 @@ public async Task GetPackageTypeById(HttpClient /// Thrown when required argument is null /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListPackageTypesResponseBody) - public Task ListPackageTypes(CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListPackageTypesResponseBody) + public Task> ListPackageTypes(CancellationToken cancellationToken = default) { return ListPackageTypes(_client, cancellationToken); } @@ -281,8 +284,8 @@ public Task ListPackageTypes(CancellationToken can /// Thrown when fails to make API call /// HttpClient to use for the request /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListPackageTypesResponseBody) - public async Task ListPackageTypes(HttpClient methodClient, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListPackageTypesResponseBody) + public async Task> ListPackageTypes(HttpClient methodClient, CancellationToken cancellationToken = default) { RequestOptions requestOptions = new("/v1/packages"); @@ -290,9 +293,10 @@ public async Task ListPackageTypes(HttpClient meth requestOptions.Operation = "PackageTypesApi.ListPackageTypes"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -303,8 +307,8 @@ public async Task ListPackageTypes(HttpClient meth /// /// Package ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task UpdatePackageType(UpdatePackageTypeRequestBody updatePackageTypeRequestBody, string packageId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> UpdatePackageType(UpdatePackageTypeRequestBody updatePackageTypeRequestBody, string packageId, CancellationToken cancellationToken = default) { return UpdatePackageType(_client, updatePackageTypeRequestBody, packageId, cancellationToken); } @@ -318,8 +322,8 @@ public Task UpdatePackageType(UpdatePackageTypeRequestBody updatePackage /// /// Package ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task UpdatePackageType(HttpClient methodClient, UpdatePackageTypeRequestBody updatePackageTypeRequestBody, string packageId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> UpdatePackageType(HttpClient methodClient, UpdatePackageTypeRequestBody updatePackageTypeRequestBody, string packageId, CancellationToken cancellationToken = default) { // verify the required parameter 'updatePackageTypeRequestBody' is set if (updatePackageTypeRequestBody == null) @@ -341,9 +345,10 @@ public async Task UpdatePackageType(HttpClient methodClient, UpdatePacka requestOptions.Operation = "PackageTypesApi.UpdatePackageType"; - var result = await SendHttpRequestAsync(HttpMethods.Put, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } -} \ No newline at end of file +} diff --git a/ShipEngineSDK/Api/RatesApi.cs b/ShipEngineSDK/Api/RatesApi.cs index 1dee183e..3e42723c 100644 --- a/ShipEngineSDK/Api/RatesApi.cs +++ b/ShipEngineSDK/Api/RatesApi.cs @@ -31,8 +31,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CalculateRatesResponseBody) - Task CalculateRates(CalculateRatesRequestBody calculateRatesRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CalculateRatesResponseBody) + Task> CalculateRates(CalculateRatesRequestBody calculateRatesRequestBody, CancellationToken cancellationToken = default); /// /// Get Shipping Rates It's not uncommon that you want to give your customer the choice between whether they want to ship the fastest, cheapest, or the most trusted route. Most companies don't solely ship things using a single shipping option; so we provide functionality to show you all your options! @@ -42,8 +42,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CalculateRatesResponseBody) - Task CalculateRates(HttpClient methodClient, CalculateRatesRequestBody calculateRatesRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CalculateRatesResponseBody) + Task> CalculateRates(HttpClient methodClient, CalculateRatesRequestBody calculateRatesRequestBody, CancellationToken cancellationToken = default); /// /// Get Bulk Rates Get Bulk Shipment Rates @@ -52,8 +52,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<BulkRate>) - Task> CompareBulkRates(CompareBulkRatesRequestBody compareBulkRatesRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (List<BulkRate>) + Task>> CompareBulkRates(CompareBulkRatesRequestBody compareBulkRatesRequestBody, CancellationToken cancellationToken = default); /// /// Get Bulk Rates Get Bulk Shipment Rates @@ -63,8 +63,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<BulkRate>) - Task> CompareBulkRates(HttpClient methodClient, CompareBulkRatesRequestBody compareBulkRatesRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (List<BulkRate>) + Task>> CompareBulkRates(HttpClient methodClient, CompareBulkRatesRequestBody compareBulkRatesRequestBody, CancellationToken cancellationToken = default); /// /// Estimate Rates Get Rate Estimates @@ -73,8 +73,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<RateEstimate>) - Task> EstimateRates(EstimateRatesRequestBody estimateRatesRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (List<RateEstimate>) + Task>> EstimateRates(EstimateRatesRequestBody estimateRatesRequestBody, CancellationToken cancellationToken = default); /// /// Estimate Rates Get Rate Estimates @@ -84,8 +84,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<RateEstimate>) - Task> EstimateRates(HttpClient methodClient, EstimateRatesRequestBody estimateRatesRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (List<RateEstimate>) + Task>> EstimateRates(HttpClient methodClient, EstimateRatesRequestBody estimateRatesRequestBody, CancellationToken cancellationToken = default); /// /// Get Rate By ID Retrieve a previously queried rate by its ID @@ -94,8 +94,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Rate ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetRateByIdResponseBody) - Task GetRateById(string rateId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetRateByIdResponseBody) + Task> GetRateById(string rateId, CancellationToken cancellationToken = default); /// /// Get Rate By ID Retrieve a previously queried rate by its ID @@ -105,8 +105,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Rate ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetRateByIdResponseBody) - Task GetRateById(HttpClient methodClient, string rateId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetRateByIdResponseBody) + Task> GetRateById(HttpClient methodClient, string rateId, CancellationToken cancellationToken = default); } @@ -122,8 +122,8 @@ public partial class ShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CalculateRatesResponseBody) - public Task CalculateRates(CalculateRatesRequestBody calculateRatesRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CalculateRatesResponseBody) + public Task> CalculateRates(CalculateRatesRequestBody calculateRatesRequestBody, CancellationToken cancellationToken = default) { return CalculateRates(_client, calculateRatesRequestBody, cancellationToken); } @@ -136,8 +136,8 @@ public Task CalculateRates(CalculateRatesRequestBody /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CalculateRatesResponseBody) - public async Task CalculateRates(HttpClient methodClient, CalculateRatesRequestBody calculateRatesRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CalculateRatesResponseBody) + public async Task> CalculateRates(HttpClient methodClient, CalculateRatesRequestBody calculateRatesRequestBody, CancellationToken cancellationToken = default) { // verify the required parameter 'calculateRatesRequestBody' is set if (calculateRatesRequestBody == null) @@ -152,9 +152,10 @@ public async Task CalculateRates(HttpClient methodCl requestOptions.Operation = "RatesApi.CalculateRates"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -164,8 +165,8 @@ public async Task CalculateRates(HttpClient methodCl /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<BulkRate>) - public Task> CompareBulkRates(CompareBulkRatesRequestBody compareBulkRatesRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (List<BulkRate>) + public Task>> CompareBulkRates(CompareBulkRatesRequestBody compareBulkRatesRequestBody, CancellationToken cancellationToken = default) { return CompareBulkRates(_client, compareBulkRatesRequestBody, cancellationToken); } @@ -178,8 +179,8 @@ public Task> CompareBulkRates(CompareBulkRatesRequestBody compare /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<BulkRate>) - public async Task> CompareBulkRates(HttpClient methodClient, CompareBulkRatesRequestBody compareBulkRatesRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (List<BulkRate>) + public async Task>> CompareBulkRates(HttpClient methodClient, CompareBulkRatesRequestBody compareBulkRatesRequestBody, CancellationToken cancellationToken = default) { // verify the required parameter 'compareBulkRatesRequestBody' is set if (compareBulkRatesRequestBody == null) @@ -194,9 +195,10 @@ public async Task> CompareBulkRates(HttpClient methodClient, Comp requestOptions.Operation = "RatesApi.CompareBulkRates"; - var result = await SendHttpRequestAsync>(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse>(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse>(data, response.StatusCode, headers); } /// @@ -206,8 +208,8 @@ public async Task> CompareBulkRates(HttpClient methodClient, Comp /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<RateEstimate>) - public Task> EstimateRates(EstimateRatesRequestBody estimateRatesRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (List<RateEstimate>) + public Task>> EstimateRates(EstimateRatesRequestBody estimateRatesRequestBody, CancellationToken cancellationToken = default) { return EstimateRates(_client, estimateRatesRequestBody, cancellationToken); } @@ -220,8 +222,8 @@ public Task> EstimateRates(EstimateRatesRequestBody estimateR /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<RateEstimate>) - public async Task> EstimateRates(HttpClient methodClient, EstimateRatesRequestBody estimateRatesRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (List<RateEstimate>) + public async Task>> EstimateRates(HttpClient methodClient, EstimateRatesRequestBody estimateRatesRequestBody, CancellationToken cancellationToken = default) { // verify the required parameter 'estimateRatesRequestBody' is set if (estimateRatesRequestBody == null) @@ -236,9 +238,10 @@ public async Task> EstimateRates(HttpClient methodClient, Est requestOptions.Operation = "RatesApi.EstimateRates"; - var result = await SendHttpRequestAsync>(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse>(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse>(data, response.StatusCode, headers); } /// @@ -248,8 +251,8 @@ public async Task> EstimateRates(HttpClient methodClient, Est /// Thrown when fails to make API call /// Rate ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetRateByIdResponseBody) - public Task GetRateById(string rateId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetRateByIdResponseBody) + public Task> GetRateById(string rateId, CancellationToken cancellationToken = default) { return GetRateById(_client, rateId, cancellationToken); } @@ -262,8 +265,8 @@ public Task GetRateById(string rateId, CancellationToke /// HttpClient to use for the request /// Rate ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetRateByIdResponseBody) - public async Task GetRateById(HttpClient methodClient, string rateId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetRateByIdResponseBody) + public async Task> GetRateById(HttpClient methodClient, string rateId, CancellationToken cancellationToken = default) { // verify the required parameter 'rateId' is set if (rateId == null) @@ -278,9 +281,10 @@ public async Task GetRateById(HttpClient methodClient, requestOptions.Operation = "RatesApi.GetRateById"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } -} \ No newline at end of file +} diff --git a/ShipEngineSDK/Api/ServicePointsApi.cs b/ShipEngineSDK/Api/ServicePointsApi.cs index 6b5dd6ae..f03d9afc 100644 --- a/ShipEngineSDK/Api/ServicePointsApi.cs +++ b/ShipEngineSDK/Api/ServicePointsApi.cs @@ -33,8 +33,8 @@ public partial interface IShipEngine /// A two-letter [ISO 3166-1 country code](https://en.wikipedia.org/wiki/ISO_3166-1) /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetServicePointByIdResponseBody) - Task ServicePointsGetById(string carrierCode, string countryCode, string servicePointId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetServicePointByIdResponseBody) + Task> ServicePointsGetById(string carrierCode, string countryCode, string servicePointId, CancellationToken cancellationToken = default); /// /// Get Service Point By ID Returns a carrier service point by using the service_point_id @@ -46,8 +46,8 @@ public partial interface IShipEngine /// A two-letter [ISO 3166-1 country code](https://en.wikipedia.org/wiki/ISO_3166-1) /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetServicePointByIdResponseBody) - Task ServicePointsGetById(HttpClient methodClient, string carrierCode, string countryCode, string servicePointId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetServicePointByIdResponseBody) + Task> ServicePointsGetById(HttpClient methodClient, string carrierCode, string countryCode, string servicePointId, CancellationToken cancellationToken = default); /// /// List Service Points List carrier service points by location @@ -56,8 +56,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListServicePointsResponseBody) - Task ServicePointsList(GetServicePointsRequest getServicePointsRequest, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListServicePointsResponseBody) + Task> ServicePointsList(GetServicePointsRequest getServicePointsRequest, CancellationToken cancellationToken = default); /// /// List Service Points List carrier service points by location @@ -67,8 +67,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListServicePointsResponseBody) - Task ServicePointsList(HttpClient methodClient, GetServicePointsRequest getServicePointsRequest, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListServicePointsResponseBody) + Task> ServicePointsList(HttpClient methodClient, GetServicePointsRequest getServicePointsRequest, CancellationToken cancellationToken = default); } @@ -86,8 +86,8 @@ public partial class ShipEngine /// A two-letter [ISO 3166-1 country code](https://en.wikipedia.org/wiki/ISO_3166-1) /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetServicePointByIdResponseBody) - public Task ServicePointsGetById(string carrierCode, string countryCode, string servicePointId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetServicePointByIdResponseBody) + public Task> ServicePointsGetById(string carrierCode, string countryCode, string servicePointId, CancellationToken cancellationToken = default) { return ServicePointsGetById(_client, carrierCode, countryCode, servicePointId, cancellationToken); } @@ -102,8 +102,8 @@ public Task ServicePointsGetById(string carrier /// A two-letter [ISO 3166-1 country code](https://en.wikipedia.org/wiki/ISO_3166-1) /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetServicePointByIdResponseBody) - public async Task ServicePointsGetById(HttpClient methodClient, string carrierCode, string countryCode, string servicePointId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetServicePointByIdResponseBody) + public async Task> ServicePointsGetById(HttpClient methodClient, string carrierCode, string countryCode, string servicePointId, CancellationToken cancellationToken = default) { // verify the required parameter 'carrierCode' is set if (carrierCode == null) @@ -132,9 +132,10 @@ public async Task ServicePointsGetById(HttpClie requestOptions.Operation = "ServicePointsApi.ServicePointsGetById"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -144,8 +145,8 @@ public async Task ServicePointsGetById(HttpClie /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListServicePointsResponseBody) - public Task ServicePointsList(GetServicePointsRequest getServicePointsRequest, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListServicePointsResponseBody) + public Task> ServicePointsList(GetServicePointsRequest getServicePointsRequest, CancellationToken cancellationToken = default) { return ServicePointsList(_client, getServicePointsRequest, cancellationToken); } @@ -158,8 +159,8 @@ public Task ServicePointsList(GetServicePointsReq /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListServicePointsResponseBody) - public async Task ServicePointsList(HttpClient methodClient, GetServicePointsRequest getServicePointsRequest, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListServicePointsResponseBody) + public async Task> ServicePointsList(HttpClient methodClient, GetServicePointsRequest getServicePointsRequest, CancellationToken cancellationToken = default) { // verify the required parameter 'getServicePointsRequest' is set if (getServicePointsRequest == null) @@ -174,9 +175,10 @@ public async Task ServicePointsList(HttpClient me requestOptions.Operation = "ServicePointsApi.ServicePointsList"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } -} \ No newline at end of file +} diff --git a/ShipEngineSDK/Api/ShipmentsApi.cs b/ShipEngineSDK/Api/ShipmentsApi.cs index cc40dfe1..bbf82cd9 100644 --- a/ShipEngineSDK/Api/ShipmentsApi.cs +++ b/ShipEngineSDK/Api/ShipmentsApi.cs @@ -31,8 +31,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Shipment ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task CancelShipments(string shipmentId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> CancelShipments(string shipmentId, CancellationToken cancellationToken = default); /// /// Cancel a Shipment Mark a shipment cancelled, if it is no longer needed or being used by your organized. Any label associated with the shipment needs to be voided first An example use case would be if a batch label creation job is going to run at a set time and only queries `pending` shipments. Marking a shipment as cancelled would remove it from this process @@ -42,8 +42,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Shipment ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task CancelShipments(HttpClient methodClient, string shipmentId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> CancelShipments(HttpClient methodClient, string shipmentId, CancellationToken cancellationToken = default); /// /// Create Shipments Create one or multiple shipments. @@ -52,8 +52,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateShipmentsResponseBody) - Task CreateShipments(CreateShipmentsRequestBody createShipmentsRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateShipmentsResponseBody) + Task> CreateShipments(CreateShipmentsRequestBody createShipmentsRequestBody, CancellationToken cancellationToken = default); /// /// Create Shipments Create one or multiple shipments. @@ -63,8 +63,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateShipmentsResponseBody) - Task CreateShipments(HttpClient methodClient, CreateShipmentsRequestBody createShipmentsRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateShipmentsResponseBody) + Task> CreateShipments(HttpClient methodClient, CreateShipmentsRequestBody createShipmentsRequestBody, CancellationToken cancellationToken = default); /// /// Get Shipment By External ID Query Shipments created using your own custom ID convention using this endpint @@ -73,8 +73,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetShipmentByExternalIdResponseBody) - Task GetShipmentByExternalId(string externalShipmentId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetShipmentByExternalIdResponseBody) + Task> GetShipmentByExternalId(string externalShipmentId, CancellationToken cancellationToken = default); /// /// Get Shipment By External ID Query Shipments created using your own custom ID convention using this endpint @@ -84,8 +84,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetShipmentByExternalIdResponseBody) - Task GetShipmentByExternalId(HttpClient methodClient, string externalShipmentId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetShipmentByExternalIdResponseBody) + Task> GetShipmentByExternalId(HttpClient methodClient, string externalShipmentId, CancellationToken cancellationToken = default); /// /// Get Shipment By ID Get an individual shipment based on its ID @@ -94,8 +94,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Shipment ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetShipmentByIdResponseBody) - Task GetShipmentById(string shipmentId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetShipmentByIdResponseBody) + Task> GetShipmentById(string shipmentId, CancellationToken cancellationToken = default); /// /// Get Shipment By ID Get an individual shipment based on its ID @@ -105,8 +105,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Shipment ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetShipmentByIdResponseBody) - Task GetShipmentById(HttpClient methodClient, string shipmentId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetShipmentByIdResponseBody) + Task> GetShipmentById(HttpClient methodClient, string shipmentId, CancellationToken cancellationToken = default); /// /// Get Shipment Rates Get Rates for the shipment information associated with the shipment ID @@ -116,8 +116,8 @@ public partial interface IShipEngine /// Shipment ID /// Used to create a filter for when a resource was created (ex. A shipment that was created after a certain time) (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListShipmentRatesResponseBody) - Task ListShipmentRates(string shipmentId, DateTimeOffset? createdAtStart, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListShipmentRatesResponseBody) + Task> ListShipmentRates(string shipmentId, DateTimeOffset? createdAtStart, CancellationToken cancellationToken = default); /// /// Get Shipment Rates Get Rates for the shipment information associated with the shipment ID @@ -128,8 +128,8 @@ public partial interface IShipEngine /// Shipment ID /// Used to create a filter for when a resource was created (ex. A shipment that was created after a certain time) (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListShipmentRatesResponseBody) - Task ListShipmentRates(HttpClient methodClient, string shipmentId, DateTimeOffset? createdAtStart, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListShipmentRatesResponseBody) + Task> ListShipmentRates(HttpClient methodClient, string shipmentId, DateTimeOffset? createdAtStart, CancellationToken cancellationToken = default); /// /// List Shipments Get list of Shipments @@ -149,8 +149,8 @@ public partial interface IShipEngine /// Return a specific page of results. Defaults to the first page. If set to a number that's greater than the number of pages of results, an empty page is returned. (optional, default to 1) /// The number of results to return per response. (optional, default to 25) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListShipmentsResponseBody) - Task ListShipments(DateTimeOffset? createdAtStart, DateTimeOffset? createdAtEnd, DateTimeOffset? modifiedAtStart, DateTimeOffset? modifiedAtEnd, ShipmentStatus? shipmentStatus, ShipmentsSortBy? sortBy, SortDir? sortDir, string? batchId, string? tag, string? salesOrderId, int? page, int? pageSize, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListShipmentsResponseBody) + Task> ListShipments(DateTimeOffset? createdAtStart, DateTimeOffset? createdAtEnd, DateTimeOffset? modifiedAtStart, DateTimeOffset? modifiedAtEnd, ShipmentStatus? shipmentStatus, ShipmentsSortBy? sortBy, SortDir? sortDir, string? batchId, string? tag, string? salesOrderId, int? page, int? pageSize, CancellationToken cancellationToken = default); /// /// List Shipments Get list of Shipments @@ -171,8 +171,8 @@ public partial interface IShipEngine /// Return a specific page of results. Defaults to the first page. If set to a number that's greater than the number of pages of results, an empty page is returned. (optional, default to 1) /// The number of results to return per response. (optional, default to 25) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListShipmentsResponseBody) - Task ListShipments(HttpClient methodClient, DateTimeOffset? createdAtStart, DateTimeOffset? createdAtEnd, DateTimeOffset? modifiedAtStart, DateTimeOffset? modifiedAtEnd, ShipmentStatus? shipmentStatus, ShipmentsSortBy? sortBy, SortDir? sortDir, string? batchId, string? tag, string? salesOrderId, int? page, int? pageSize, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListShipmentsResponseBody) + Task> ListShipments(HttpClient methodClient, DateTimeOffset? createdAtStart, DateTimeOffset? createdAtEnd, DateTimeOffset? modifiedAtStart, DateTimeOffset? modifiedAtEnd, ShipmentStatus? shipmentStatus, ShipmentsSortBy? sortBy, SortDir? sortDir, string? batchId, string? tag, string? salesOrderId, int? page, int? pageSize, CancellationToken cancellationToken = default); /// /// Parse shipping info The shipment-recognition API makes it easy for you to extract shipping data from unstructured text, including people's names, addresses, package weights and dimensions, insurance and delivery requirements, and more. Data often enters your system as unstructured text (for example: emails, SMS messages, support tickets, or other documents). ShipEngine's shipment-recognition API helps you extract meaningful, structured data from this unstructured text. The parsed shipment data is returned in the same structure that's used for other ShipEngine APIs, so you can easily use the parsed data to create a shipping label. > **Note:** Shipment recognition is currently supported for the United States, Canada, Australia, New Zealand, the United Kingdom, and Ireland. @@ -181,8 +181,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// The only required field is `text`, which is the text to be parsed. You can optionally also provide a `shipment` containing any already-known values. For example, you probably already know the `ship_from` address, and you may also already know what carrier and service you want to use. /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ParseShipmentResponseBody) - Task ParseShipment(ParseShipmentRequestBody parseShipmentRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ParseShipmentResponseBody) + Task> ParseShipment(ParseShipmentRequestBody parseShipmentRequestBody, CancellationToken cancellationToken = default); /// /// Parse shipping info The shipment-recognition API makes it easy for you to extract shipping data from unstructured text, including people's names, addresses, package weights and dimensions, insurance and delivery requirements, and more. Data often enters your system as unstructured text (for example: emails, SMS messages, support tickets, or other documents). ShipEngine's shipment-recognition API helps you extract meaningful, structured data from this unstructured text. The parsed shipment data is returned in the same structure that's used for other ShipEngine APIs, so you can easily use the parsed data to create a shipping label. > **Note:** Shipment recognition is currently supported for the United States, Canada, Australia, New Zealand, the United Kingdom, and Ireland. @@ -192,8 +192,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// The only required field is `text`, which is the text to be parsed. You can optionally also provide a `shipment` containing any already-known values. For example, you probably already know the `ship_from` address, and you may also already know what carrier and service you want to use. /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ParseShipmentResponseBody) - Task ParseShipment(HttpClient methodClient, ParseShipmentRequestBody parseShipmentRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ParseShipmentResponseBody) + Task> ParseShipment(HttpClient methodClient, ParseShipmentRequestBody parseShipmentRequestBody, CancellationToken cancellationToken = default); /// /// Get Shipment Tags Get Shipment tags based on its ID @@ -202,8 +202,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Shipment ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (TagShipmentResponseBody) - Task ShipmentsListTags(string shipmentId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (TagShipmentResponseBody) + Task> ShipmentsListTags(string shipmentId, CancellationToken cancellationToken = default); /// /// Get Shipment Tags Get Shipment tags based on its ID @@ -213,8 +213,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Shipment ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (TagShipmentResponseBody) - Task ShipmentsListTags(HttpClient methodClient, string shipmentId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (TagShipmentResponseBody) + Task> ShipmentsListTags(HttpClient methodClient, string shipmentId, CancellationToken cancellationToken = default); /// /// Update Shipments Tags Update Shipments Tags @@ -223,8 +223,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse - Task ShipmentsUpdateTags(UpdateShipmentsTagsRequestBody updateShipmentsTagsRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse + Task> ShipmentsUpdateTags(UpdateShipmentsTagsRequestBody updateShipmentsTagsRequestBody, CancellationToken cancellationToken = default); /// /// Update Shipments Tags Update Shipments Tags @@ -234,8 +234,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse - Task ShipmentsUpdateTags(HttpClient methodClient, UpdateShipmentsTagsRequestBody updateShipmentsTagsRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse + Task> ShipmentsUpdateTags(HttpClient methodClient, UpdateShipmentsTagsRequestBody updateShipmentsTagsRequestBody, CancellationToken cancellationToken = default); /// /// Add Tag to Shipment Add a tag to the shipment object @@ -245,8 +245,8 @@ public partial interface IShipEngine /// Shipment ID /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (TagShipmentResponseBody) - Task TagShipment(string shipmentId, string tagName, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (TagShipmentResponseBody) + Task> TagShipment(string shipmentId, string tagName, CancellationToken cancellationToken = default); /// /// Add Tag to Shipment Add a tag to the shipment object @@ -257,8 +257,8 @@ public partial interface IShipEngine /// Shipment ID /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (TagShipmentResponseBody) - Task TagShipment(HttpClient methodClient, string shipmentId, string tagName, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (TagShipmentResponseBody) + Task> TagShipment(HttpClient methodClient, string shipmentId, string tagName, CancellationToken cancellationToken = default); /// /// Remove Tag from Shipment Remove an existing tag from the Shipment object @@ -268,8 +268,8 @@ public partial interface IShipEngine /// Shipment ID /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task UntagShipment(string shipmentId, string tagName, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> UntagShipment(string shipmentId, string tagName, CancellationToken cancellationToken = default); /// /// Remove Tag from Shipment Remove an existing tag from the Shipment object @@ -280,8 +280,8 @@ public partial interface IShipEngine /// Shipment ID /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task UntagShipment(HttpClient methodClient, string shipmentId, string tagName, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> UntagShipment(HttpClient methodClient, string shipmentId, string tagName, CancellationToken cancellationToken = default); /// /// Update Shipment By ID Update a shipment object based on its ID @@ -291,8 +291,8 @@ public partial interface IShipEngine /// /// Shipment ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (UpdateShipmentResponseBody) - Task UpdateShipment(UpdateShipmentRequestBody updateShipmentRequestBody, string shipmentId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (UpdateShipmentResponseBody) + Task> UpdateShipment(UpdateShipmentRequestBody updateShipmentRequestBody, string shipmentId, CancellationToken cancellationToken = default); /// /// Update Shipment By ID Update a shipment object based on its ID @@ -303,8 +303,8 @@ public partial interface IShipEngine /// /// Shipment ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (UpdateShipmentResponseBody) - Task UpdateShipment(HttpClient methodClient, UpdateShipmentRequestBody updateShipmentRequestBody, string shipmentId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (UpdateShipmentResponseBody) + Task> UpdateShipment(HttpClient methodClient, UpdateShipmentRequestBody updateShipmentRequestBody, string shipmentId, CancellationToken cancellationToken = default); } @@ -320,8 +320,8 @@ public partial class ShipEngine /// Thrown when fails to make API call /// Shipment ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task CancelShipments(string shipmentId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> CancelShipments(string shipmentId, CancellationToken cancellationToken = default) { return CancelShipments(_client, shipmentId, cancellationToken); } @@ -334,8 +334,8 @@ public Task CancelShipments(string shipmentId, CancellationToken cancell /// HttpClient to use for the request /// Shipment ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task CancelShipments(HttpClient methodClient, string shipmentId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> CancelShipments(HttpClient methodClient, string shipmentId, CancellationToken cancellationToken = default) { // verify the required parameter 'shipmentId' is set if (shipmentId == null) @@ -350,9 +350,10 @@ public async Task CancelShipments(HttpClient methodClient, string shipme requestOptions.Operation = "ShipmentsApi.CancelShipments"; - var result = await SendHttpRequestAsync(HttpMethods.Put, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -362,8 +363,8 @@ public async Task CancelShipments(HttpClient methodClient, string shipme /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateShipmentsResponseBody) - public Task CreateShipments(CreateShipmentsRequestBody createShipmentsRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateShipmentsResponseBody) + public Task> CreateShipments(CreateShipmentsRequestBody createShipmentsRequestBody, CancellationToken cancellationToken = default) { return CreateShipments(_client, createShipmentsRequestBody, cancellationToken); } @@ -376,8 +377,8 @@ public Task CreateShipments(CreateShipmentsRequestB /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateShipmentsResponseBody) - public async Task CreateShipments(HttpClient methodClient, CreateShipmentsRequestBody createShipmentsRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateShipmentsResponseBody) + public async Task> CreateShipments(HttpClient methodClient, CreateShipmentsRequestBody createShipmentsRequestBody, CancellationToken cancellationToken = default) { // verify the required parameter 'createShipmentsRequestBody' is set if (createShipmentsRequestBody == null) @@ -392,9 +393,10 @@ public async Task CreateShipments(HttpClient method requestOptions.Operation = "ShipmentsApi.CreateShipments"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -404,8 +406,8 @@ public async Task CreateShipments(HttpClient method /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetShipmentByExternalIdResponseBody) - public Task GetShipmentByExternalId(string externalShipmentId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetShipmentByExternalIdResponseBody) + public Task> GetShipmentByExternalId(string externalShipmentId, CancellationToken cancellationToken = default) { return GetShipmentByExternalId(_client, externalShipmentId, cancellationToken); } @@ -418,8 +420,8 @@ public Task GetShipmentByExternalId(string /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetShipmentByExternalIdResponseBody) - public async Task GetShipmentByExternalId(HttpClient methodClient, string externalShipmentId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetShipmentByExternalIdResponseBody) + public async Task> GetShipmentByExternalId(HttpClient methodClient, string externalShipmentId, CancellationToken cancellationToken = default) { // verify the required parameter 'externalShipmentId' is set if (externalShipmentId == null) @@ -434,9 +436,10 @@ public async Task GetShipmentByExternalId(H requestOptions.Operation = "ShipmentsApi.GetShipmentByExternalId"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -446,8 +449,8 @@ public async Task GetShipmentByExternalId(H /// Thrown when fails to make API call /// Shipment ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetShipmentByIdResponseBody) - public Task GetShipmentById(string shipmentId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetShipmentByIdResponseBody) + public Task> GetShipmentById(string shipmentId, CancellationToken cancellationToken = default) { return GetShipmentById(_client, shipmentId, cancellationToken); } @@ -460,8 +463,8 @@ public Task GetShipmentById(string shipmentId, Canc /// HttpClient to use for the request /// Shipment ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetShipmentByIdResponseBody) - public async Task GetShipmentById(HttpClient methodClient, string shipmentId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetShipmentByIdResponseBody) + public async Task> GetShipmentById(HttpClient methodClient, string shipmentId, CancellationToken cancellationToken = default) { // verify the required parameter 'shipmentId' is set if (shipmentId == null) @@ -476,9 +479,10 @@ public async Task GetShipmentById(HttpClient method requestOptions.Operation = "ShipmentsApi.GetShipmentById"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -489,8 +493,8 @@ public async Task GetShipmentById(HttpClient method /// Shipment ID /// Used to create a filter for when a resource was created (ex. A shipment that was created after a certain time) (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListShipmentRatesResponseBody) - public Task ListShipmentRates(string shipmentId, DateTimeOffset? createdAtStart = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListShipmentRatesResponseBody) + public Task> ListShipmentRates(string shipmentId, DateTimeOffset? createdAtStart = default, CancellationToken cancellationToken = default) { return ListShipmentRates(_client, shipmentId, createdAtStart, cancellationToken); } @@ -504,8 +508,8 @@ public Task ListShipmentRates(string shipmentId, /// Shipment ID /// Used to create a filter for when a resource was created (ex. A shipment that was created after a certain time) (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListShipmentRatesResponseBody) - public async Task ListShipmentRates(HttpClient methodClient, string shipmentId, DateTimeOffset? createdAtStart = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListShipmentRatesResponseBody) + public async Task> ListShipmentRates(HttpClient methodClient, string shipmentId, DateTimeOffset? createdAtStart = default, CancellationToken cancellationToken = default) { // verify the required parameter 'shipmentId' is set if (shipmentId == null) @@ -524,9 +528,10 @@ public async Task ListShipmentRates(HttpClient me requestOptions.Operation = "ShipmentsApi.ListShipmentRates"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -547,8 +552,8 @@ public async Task ListShipmentRates(HttpClient me /// Return a specific page of results. Defaults to the first page. If set to a number that's greater than the number of pages of results, an empty page is returned. (optional, default to 1) /// The number of results to return per response. (optional, default to 25) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListShipmentsResponseBody) - public Task ListShipments(DateTimeOffset? createdAtStart = default, DateTimeOffset? createdAtEnd = default, DateTimeOffset? modifiedAtStart = default, DateTimeOffset? modifiedAtEnd = default, ShipmentStatus? shipmentStatus = default, ShipmentsSortBy? sortBy = default, SortDir? sortDir = default, string? batchId = default, string? tag = default, string? salesOrderId = default, int? page = default, int? pageSize = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListShipmentsResponseBody) + public Task> ListShipments(DateTimeOffset? createdAtStart = default, DateTimeOffset? createdAtEnd = default, DateTimeOffset? modifiedAtStart = default, DateTimeOffset? modifiedAtEnd = default, ShipmentStatus? shipmentStatus = default, ShipmentsSortBy? sortBy = default, SortDir? sortDir = default, string? batchId = default, string? tag = default, string? salesOrderId = default, int? page = default, int? pageSize = default, CancellationToken cancellationToken = default) { return ListShipments(_client, createdAtStart, createdAtEnd, modifiedAtStart, modifiedAtEnd, shipmentStatus, sortBy, sortDir, batchId, tag, salesOrderId, page, pageSize, cancellationToken); } @@ -572,8 +577,8 @@ public Task ListShipments(DateTimeOffset? createdAtSt /// Return a specific page of results. Defaults to the first page. If set to a number that's greater than the number of pages of results, an empty page is returned. (optional, default to 1) /// The number of results to return per response. (optional, default to 25) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListShipmentsResponseBody) - public async Task ListShipments(HttpClient methodClient, DateTimeOffset? createdAtStart = default, DateTimeOffset? createdAtEnd = default, DateTimeOffset? modifiedAtStart = default, DateTimeOffset? modifiedAtEnd = default, ShipmentStatus? shipmentStatus = default, ShipmentsSortBy? sortBy = default, SortDir? sortDir = default, string? batchId = default, string? tag = default, string? salesOrderId = default, int? page = default, int? pageSize = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListShipmentsResponseBody) + public async Task> ListShipments(HttpClient methodClient, DateTimeOffset? createdAtStart = default, DateTimeOffset? createdAtEnd = default, DateTimeOffset? modifiedAtStart = default, DateTimeOffset? modifiedAtEnd = default, ShipmentStatus? shipmentStatus = default, ShipmentsSortBy? sortBy = default, SortDir? sortDir = default, string? batchId = default, string? tag = default, string? salesOrderId = default, int? page = default, int? pageSize = default, CancellationToken cancellationToken = default) { RequestOptions requestOptions = new("/v1/shipments"); @@ -629,9 +634,10 @@ public async Task ListShipments(HttpClient methodClie requestOptions.Operation = "ShipmentsApi.ListShipments"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -641,8 +647,8 @@ public async Task ListShipments(HttpClient methodClie /// Thrown when fails to make API call /// The only required field is `text`, which is the text to be parsed. You can optionally also provide a `shipment` containing any already-known values. For example, you probably already know the `ship_from` address, and you may also already know what carrier and service you want to use. /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ParseShipmentResponseBody) - public Task ParseShipment(ParseShipmentRequestBody parseShipmentRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ParseShipmentResponseBody) + public Task> ParseShipment(ParseShipmentRequestBody parseShipmentRequestBody, CancellationToken cancellationToken = default) { return ParseShipment(_client, parseShipmentRequestBody, cancellationToken); } @@ -655,8 +661,8 @@ public Task ParseShipment(ParseShipmentRequestBody pa /// HttpClient to use for the request /// The only required field is `text`, which is the text to be parsed. You can optionally also provide a `shipment` containing any already-known values. For example, you probably already know the `ship_from` address, and you may also already know what carrier and service you want to use. /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ParseShipmentResponseBody) - public async Task ParseShipment(HttpClient methodClient, ParseShipmentRequestBody parseShipmentRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ParseShipmentResponseBody) + public async Task> ParseShipment(HttpClient methodClient, ParseShipmentRequestBody parseShipmentRequestBody, CancellationToken cancellationToken = default) { // verify the required parameter 'parseShipmentRequestBody' is set if (parseShipmentRequestBody == null) @@ -671,9 +677,10 @@ public async Task ParseShipment(HttpClient methodClie requestOptions.Operation = "ShipmentsApi.ParseShipment"; - var result = await SendHttpRequestAsync(HttpMethods.Put, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -683,8 +690,8 @@ public async Task ParseShipment(HttpClient methodClie /// Thrown when fails to make API call /// Shipment ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (TagShipmentResponseBody) - public Task ShipmentsListTags(string shipmentId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (TagShipmentResponseBody) + public Task> ShipmentsListTags(string shipmentId, CancellationToken cancellationToken = default) { return ShipmentsListTags(_client, shipmentId, cancellationToken); } @@ -697,8 +704,8 @@ public Task ShipmentsListTags(string shipmentId, Cancel /// HttpClient to use for the request /// Shipment ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (TagShipmentResponseBody) - public async Task ShipmentsListTags(HttpClient methodClient, string shipmentId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (TagShipmentResponseBody) + public async Task> ShipmentsListTags(HttpClient methodClient, string shipmentId, CancellationToken cancellationToken = default) { // verify the required parameter 'shipmentId' is set if (shipmentId == null) @@ -713,9 +720,10 @@ public async Task ShipmentsListTags(HttpClient methodCl requestOptions.Operation = "ShipmentsApi.ShipmentsListTags"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -725,8 +733,8 @@ public async Task ShipmentsListTags(HttpClient methodCl /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse - public Task ShipmentsUpdateTags(UpdateShipmentsTagsRequestBody updateShipmentsTagsRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse + public Task> ShipmentsUpdateTags(UpdateShipmentsTagsRequestBody updateShipmentsTagsRequestBody, CancellationToken cancellationToken = default) { return ShipmentsUpdateTags(_client, updateShipmentsTagsRequestBody, cancellationToken); } @@ -739,8 +747,8 @@ public Task ShipmentsUpdateTags(UpdateShipmentsTagsRequestBody updateShi /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse - public async Task ShipmentsUpdateTags(HttpClient methodClient, UpdateShipmentsTagsRequestBody updateShipmentsTagsRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse + public async Task> ShipmentsUpdateTags(HttpClient methodClient, UpdateShipmentsTagsRequestBody updateShipmentsTagsRequestBody, CancellationToken cancellationToken = default) { // verify the required parameter 'updateShipmentsTagsRequestBody' is set if (updateShipmentsTagsRequestBody == null) @@ -755,9 +763,10 @@ public async Task ShipmentsUpdateTags(HttpClient methodClient, UpdateShi requestOptions.Operation = "ShipmentsApi.ShipmentsUpdateTags"; - var result = await SendHttpRequestAsync(HttpMethods.Put, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -768,8 +777,8 @@ public async Task ShipmentsUpdateTags(HttpClient methodClient, UpdateShi /// Shipment ID /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (TagShipmentResponseBody) - public Task TagShipment(string shipmentId, string tagName, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (TagShipmentResponseBody) + public Task> TagShipment(string shipmentId, string tagName, CancellationToken cancellationToken = default) { return TagShipment(_client, shipmentId, tagName, cancellationToken); } @@ -783,8 +792,8 @@ public Task TagShipment(string shipmentId, string tagNa /// Shipment ID /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (TagShipmentResponseBody) - public async Task TagShipment(HttpClient methodClient, string shipmentId, string tagName, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (TagShipmentResponseBody) + public async Task> TagShipment(HttpClient methodClient, string shipmentId, string tagName, CancellationToken cancellationToken = default) { // verify the required parameter 'shipmentId' is set if (shipmentId == null) @@ -806,9 +815,10 @@ public async Task TagShipment(HttpClient methodClient, requestOptions.Operation = "ShipmentsApi.TagShipment"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -819,8 +829,8 @@ public async Task TagShipment(HttpClient methodClient, /// Shipment ID /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task UntagShipment(string shipmentId, string tagName, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> UntagShipment(string shipmentId, string tagName, CancellationToken cancellationToken = default) { return UntagShipment(_client, shipmentId, tagName, cancellationToken); } @@ -834,8 +844,8 @@ public Task UntagShipment(string shipmentId, string tagName, Cancellatio /// Shipment ID /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task UntagShipment(HttpClient methodClient, string shipmentId, string tagName, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> UntagShipment(HttpClient methodClient, string shipmentId, string tagName, CancellationToken cancellationToken = default) { // verify the required parameter 'shipmentId' is set if (shipmentId == null) @@ -857,9 +867,10 @@ public async Task UntagShipment(HttpClient methodClient, string shipment requestOptions.Operation = "ShipmentsApi.UntagShipment"; - var result = await SendHttpRequestAsync(HttpMethods.Delete, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -870,8 +881,8 @@ public async Task UntagShipment(HttpClient methodClient, string shipment /// /// Shipment ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (UpdateShipmentResponseBody) - public Task UpdateShipment(UpdateShipmentRequestBody updateShipmentRequestBody, string shipmentId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (UpdateShipmentResponseBody) + public Task> UpdateShipment(UpdateShipmentRequestBody updateShipmentRequestBody, string shipmentId, CancellationToken cancellationToken = default) { return UpdateShipment(_client, updateShipmentRequestBody, shipmentId, cancellationToken); } @@ -885,8 +896,8 @@ public Task UpdateShipment(UpdateShipmentRequestBody /// /// Shipment ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (UpdateShipmentResponseBody) - public async Task UpdateShipment(HttpClient methodClient, UpdateShipmentRequestBody updateShipmentRequestBody, string shipmentId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (UpdateShipmentResponseBody) + public async Task> UpdateShipment(HttpClient methodClient, UpdateShipmentRequestBody updateShipmentRequestBody, string shipmentId, CancellationToken cancellationToken = default) { // verify the required parameter 'updateShipmentRequestBody' is set if (updateShipmentRequestBody == null) @@ -908,9 +919,10 @@ public async Task UpdateShipment(HttpClient methodCl requestOptions.Operation = "ShipmentsApi.UpdateShipment"; - var result = await SendHttpRequestAsync(HttpMethods.Put, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } -} \ No newline at end of file +} diff --git a/ShipEngineSDK/Api/TagsApi.cs b/ShipEngineSDK/Api/TagsApi.cs index 94031585..5835c99b 100644 --- a/ShipEngineSDK/Api/TagsApi.cs +++ b/ShipEngineSDK/Api/TagsApi.cs @@ -31,8 +31,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateTagResponseBody) - Task CreateTag(string tagName, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateTagResponseBody) + Task> CreateTag(string tagName, CancellationToken cancellationToken = default); /// /// Create a New Tag Create a new Tag for customizing how you track your shipments @@ -42,8 +42,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateTagResponseBody) - Task CreateTag(HttpClient methodClient, string tagName, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateTagResponseBody) + Task> CreateTag(HttpClient methodClient, string tagName, CancellationToken cancellationToken = default); /// /// Delete Tag Delete a tag that is no longer needed @@ -52,8 +52,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task DeleteTag(string tagName, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> DeleteTag(string tagName, CancellationToken cancellationToken = default); /// /// Delete Tag Delete a tag that is no longer needed @@ -63,8 +63,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task DeleteTag(HttpClient methodClient, string tagName, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> DeleteTag(HttpClient methodClient, string tagName, CancellationToken cancellationToken = default); /// /// Get Tags Get a list of all tags associated with an account. @@ -72,8 +72,8 @@ public partial interface IShipEngine /// Thrown when required argument is null /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListTagsResponseBody) - Task ListTags(CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListTagsResponseBody) + Task> ListTags(CancellationToken cancellationToken = default); /// /// Get Tags Get a list of all tags associated with an account. @@ -82,8 +82,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// HttpClient to use for the request /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListTagsResponseBody) - Task ListTags(HttpClient methodClient, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListTagsResponseBody) + Task> ListTags(HttpClient methodClient, CancellationToken cancellationToken = default); /// /// Update Tag Name Change a tag name while still keeping the relevant shipments attached to it @@ -93,8 +93,8 @@ public partial interface IShipEngine /// /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task RenameTag(string tagName, string newTagName, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> RenameTag(string tagName, string newTagName, CancellationToken cancellationToken = default); /// /// Update Tag Name Change a tag name while still keeping the relevant shipments attached to it @@ -105,8 +105,8 @@ public partial interface IShipEngine /// /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task RenameTag(HttpClient methodClient, string tagName, string newTagName, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> RenameTag(HttpClient methodClient, string tagName, string newTagName, CancellationToken cancellationToken = default); } @@ -122,8 +122,8 @@ public partial class ShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateTagResponseBody) - public Task CreateTag(string tagName, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateTagResponseBody) + public Task> CreateTag(string tagName, CancellationToken cancellationToken = default) { return CreateTag(_client, tagName, cancellationToken); } @@ -136,8 +136,8 @@ public Task CreateTag(string tagName, CancellationToken c /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateTagResponseBody) - public async Task CreateTag(HttpClient methodClient, string tagName, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateTagResponseBody) + public async Task> CreateTag(HttpClient methodClient, string tagName, CancellationToken cancellationToken = default) { // verify the required parameter 'tagName' is set if (tagName == null) @@ -152,9 +152,10 @@ public async Task CreateTag(HttpClient methodClient, stri requestOptions.Operation = "TagsApi.CreateTag"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -164,8 +165,8 @@ public async Task CreateTag(HttpClient methodClient, stri /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task DeleteTag(string tagName, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> DeleteTag(string tagName, CancellationToken cancellationToken = default) { return DeleteTag(_client, tagName, cancellationToken); } @@ -178,8 +179,8 @@ public Task DeleteTag(string tagName, CancellationToken cancellationToke /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task DeleteTag(HttpClient methodClient, string tagName, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> DeleteTag(HttpClient methodClient, string tagName, CancellationToken cancellationToken = default) { // verify the required parameter 'tagName' is set if (tagName == null) @@ -194,9 +195,10 @@ public async Task DeleteTag(HttpClient methodClient, string tagName, Can requestOptions.Operation = "TagsApi.DeleteTag"; - var result = await SendHttpRequestAsync(HttpMethods.Delete, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -205,8 +207,8 @@ public async Task DeleteTag(HttpClient methodClient, string tagName, Can /// Thrown when required argument is null /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListTagsResponseBody) - public Task ListTags(CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListTagsResponseBody) + public Task> ListTags(CancellationToken cancellationToken = default) { return ListTags(_client, cancellationToken); } @@ -218,8 +220,8 @@ public Task ListTags(CancellationToken cancellationToken = /// Thrown when fails to make API call /// HttpClient to use for the request /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListTagsResponseBody) - public async Task ListTags(HttpClient methodClient, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListTagsResponseBody) + public async Task> ListTags(HttpClient methodClient, CancellationToken cancellationToken = default) { RequestOptions requestOptions = new("/v1/tags"); @@ -227,9 +229,10 @@ public async Task ListTags(HttpClient methodClient, Cancel requestOptions.Operation = "TagsApi.ListTags"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -240,8 +243,8 @@ public async Task ListTags(HttpClient methodClient, Cancel /// /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task RenameTag(string tagName, string newTagName, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> RenameTag(string tagName, string newTagName, CancellationToken cancellationToken = default) { return RenameTag(_client, tagName, newTagName, cancellationToken); } @@ -255,8 +258,8 @@ public Task RenameTag(string tagName, string newTagName, CancellationTok /// /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task RenameTag(HttpClient methodClient, string tagName, string newTagName, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> RenameTag(HttpClient methodClient, string tagName, string newTagName, CancellationToken cancellationToken = default) { // verify the required parameter 'tagName' is set if (tagName == null) @@ -278,9 +281,10 @@ public async Task RenameTag(HttpClient methodClient, string tagName, str requestOptions.Operation = "TagsApi.RenameTag"; - var result = await SendHttpRequestAsync(HttpMethods.Put, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } -} \ No newline at end of file +} diff --git a/ShipEngineSDK/Api/TokensApi.cs b/ShipEngineSDK/Api/TokensApi.cs index 679e4c92..f2190480 100644 --- a/ShipEngineSDK/Api/TokensApi.cs +++ b/ShipEngineSDK/Api/TokensApi.cs @@ -31,8 +31,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Include a redirect url to the application formatted with the ephemeral token. (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (TokensGetEphemeralTokenResponseBodyYaml) - Task TokensGetEphemeralToken(Redirect? redirect, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (TokensGetEphemeralTokenResponseBodyYaml) + Task> TokensGetEphemeralToken(Redirect? redirect, CancellationToken cancellationToken = default); /// /// Get Ephemeral Token This endpoint returns a token that can be passed to an application for authorized access. The lifetime of this token is 10 seconds. @@ -42,8 +42,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Include a redirect url to the application formatted with the ephemeral token. (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (TokensGetEphemeralTokenResponseBodyYaml) - Task TokensGetEphemeralToken(HttpClient methodClient, Redirect? redirect, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (TokensGetEphemeralTokenResponseBodyYaml) + Task> TokensGetEphemeralToken(HttpClient methodClient, Redirect? redirect, CancellationToken cancellationToken = default); } @@ -59,8 +59,8 @@ public partial class ShipEngine /// Thrown when fails to make API call /// Include a redirect url to the application formatted with the ephemeral token. (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (TokensGetEphemeralTokenResponseBodyYaml) - public Task TokensGetEphemeralToken(Redirect? redirect = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (TokensGetEphemeralTokenResponseBodyYaml) + public Task> TokensGetEphemeralToken(Redirect? redirect = default, CancellationToken cancellationToken = default) { return TokensGetEphemeralToken(_client, redirect, cancellationToken); } @@ -73,8 +73,8 @@ public Task TokensGetEphemeralToken(Red /// HttpClient to use for the request /// Include a redirect url to the application formatted with the ephemeral token. (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (TokensGetEphemeralTokenResponseBodyYaml) - public async Task TokensGetEphemeralToken(HttpClient methodClient, Redirect? redirect = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (TokensGetEphemeralTokenResponseBodyYaml) + public async Task> TokensGetEphemeralToken(HttpClient methodClient, Redirect? redirect = default, CancellationToken cancellationToken = default) { RequestOptions requestOptions = new("/v1/tokens/ephemeral"); @@ -86,9 +86,10 @@ public async Task TokensGetEphemeralTok requestOptions.Operation = "TokensApi.TokensGetEphemeralToken"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } -} \ No newline at end of file +} diff --git a/ShipEngineSDK/Api/TrackingApi.cs b/ShipEngineSDK/Api/TrackingApi.cs index 6e80832f..1ef72872 100644 --- a/ShipEngineSDK/Api/TrackingApi.cs +++ b/ShipEngineSDK/Api/TrackingApi.cs @@ -32,8 +32,8 @@ public partial interface IShipEngine /// A [shipping carrier](https://www.shipengine.com/docs/carriers/setup/), such as `fedex`, `dhl_express`, `stamps_com`, etc. (optional) /// The tracking number associated with a shipment (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetTrackingLogResponseBody) - Task GetTrackingLog(string? carrierCode, string? trackingNumber, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetTrackingLogResponseBody) + Task> GetTrackingLog(string? carrierCode, string? trackingNumber, CancellationToken cancellationToken = default); /// /// Get Tracking Information Retrieve package tracking information @@ -44,8 +44,8 @@ public partial interface IShipEngine /// A [shipping carrier](https://www.shipengine.com/docs/carriers/setup/), such as `fedex`, `dhl_express`, `stamps_com`, etc. (optional) /// The tracking number associated with a shipment (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetTrackingLogResponseBody) - Task GetTrackingLog(HttpClient methodClient, string? carrierCode, string? trackingNumber, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetTrackingLogResponseBody) + Task> GetTrackingLog(HttpClient methodClient, string? carrierCode, string? trackingNumber, CancellationToken cancellationToken = default); /// /// Start Tracking a Package Allows you to subscribe to tracking updates for a package. You specify the carrier_code and tracking_number of the package, and receive notifications via webhooks whenever the shipping status changes. @@ -55,8 +55,8 @@ public partial interface IShipEngine /// A [shipping carrier](https://www.shipengine.com/docs/carriers/setup/), such as `fedex`, `dhl_express`, `stamps_com`, etc. (optional) /// The tracking number associated with a shipment (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task StartTracking(string? carrierCode, string? trackingNumber, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> StartTracking(string? carrierCode, string? trackingNumber, CancellationToken cancellationToken = default); /// /// Start Tracking a Package Allows you to subscribe to tracking updates for a package. You specify the carrier_code and tracking_number of the package, and receive notifications via webhooks whenever the shipping status changes. @@ -67,8 +67,8 @@ public partial interface IShipEngine /// A [shipping carrier](https://www.shipengine.com/docs/carriers/setup/), such as `fedex`, `dhl_express`, `stamps_com`, etc. (optional) /// The tracking number associated with a shipment (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task StartTracking(HttpClient methodClient, string? carrierCode, string? trackingNumber, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> StartTracking(HttpClient methodClient, string? carrierCode, string? trackingNumber, CancellationToken cancellationToken = default); /// /// Stop Tracking a Package Unsubscribe from tracking updates for a package. @@ -78,8 +78,8 @@ public partial interface IShipEngine /// A [shipping carrier](https://www.shipengine.com/docs/carriers/setup/), such as `fedex`, `dhl_express`, `stamps_com`, etc. (optional) /// The tracking number associated with a shipment (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task StopTracking(string? carrierCode, string? trackingNumber, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> StopTracking(string? carrierCode, string? trackingNumber, CancellationToken cancellationToken = default); /// /// Stop Tracking a Package Unsubscribe from tracking updates for a package. @@ -90,8 +90,8 @@ public partial interface IShipEngine /// A [shipping carrier](https://www.shipengine.com/docs/carriers/setup/), such as `fedex`, `dhl_express`, `stamps_com`, etc. (optional) /// The tracking number associated with a shipment (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task StopTracking(HttpClient methodClient, string? carrierCode, string? trackingNumber, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> StopTracking(HttpClient methodClient, string? carrierCode, string? trackingNumber, CancellationToken cancellationToken = default); } @@ -108,8 +108,8 @@ public partial class ShipEngine /// A [shipping carrier](https://www.shipengine.com/docs/carriers/setup/), such as `fedex`, `dhl_express`, `stamps_com`, etc. (optional) /// The tracking number associated with a shipment (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetTrackingLogResponseBody) - public Task GetTrackingLog(string? carrierCode = default, string? trackingNumber = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetTrackingLogResponseBody) + public Task> GetTrackingLog(string? carrierCode = default, string? trackingNumber = default, CancellationToken cancellationToken = default) { return GetTrackingLog(_client, carrierCode, trackingNumber, cancellationToken); } @@ -123,8 +123,8 @@ public Task GetTrackingLog(string? carrierCode = def /// A [shipping carrier](https://www.shipengine.com/docs/carriers/setup/), such as `fedex`, `dhl_express`, `stamps_com`, etc. (optional) /// The tracking number associated with a shipment (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetTrackingLogResponseBody) - public async Task GetTrackingLog(HttpClient methodClient, string? carrierCode = default, string? trackingNumber = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetTrackingLogResponseBody) + public async Task> GetTrackingLog(HttpClient methodClient, string? carrierCode = default, string? trackingNumber = default, CancellationToken cancellationToken = default) { RequestOptions requestOptions = new("/v1/tracking"); @@ -140,9 +140,10 @@ public async Task GetTrackingLog(HttpClient methodCl requestOptions.Operation = "TrackingApi.GetTrackingLog"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -153,8 +154,8 @@ public async Task GetTrackingLog(HttpClient methodCl /// A [shipping carrier](https://www.shipengine.com/docs/carriers/setup/), such as `fedex`, `dhl_express`, `stamps_com`, etc. (optional) /// The tracking number associated with a shipment (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task StartTracking(string? carrierCode = default, string? trackingNumber = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> StartTracking(string? carrierCode = default, string? trackingNumber = default, CancellationToken cancellationToken = default) { return StartTracking(_client, carrierCode, trackingNumber, cancellationToken); } @@ -168,8 +169,8 @@ public Task StartTracking(string? carrierCode = default, string? trackin /// A [shipping carrier](https://www.shipengine.com/docs/carriers/setup/), such as `fedex`, `dhl_express`, `stamps_com`, etc. (optional) /// The tracking number associated with a shipment (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task StartTracking(HttpClient methodClient, string? carrierCode = default, string? trackingNumber = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> StartTracking(HttpClient methodClient, string? carrierCode = default, string? trackingNumber = default, CancellationToken cancellationToken = default) { RequestOptions requestOptions = new("/v1/tracking/start"); @@ -185,9 +186,10 @@ public async Task StartTracking(HttpClient methodClient, string? carrier requestOptions.Operation = "TrackingApi.StartTracking"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -198,8 +200,8 @@ public async Task StartTracking(HttpClient methodClient, string? carrier /// A [shipping carrier](https://www.shipengine.com/docs/carriers/setup/), such as `fedex`, `dhl_express`, `stamps_com`, etc. (optional) /// The tracking number associated with a shipment (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task StopTracking(string? carrierCode = default, string? trackingNumber = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> StopTracking(string? carrierCode = default, string? trackingNumber = default, CancellationToken cancellationToken = default) { return StopTracking(_client, carrierCode, trackingNumber, cancellationToken); } @@ -213,8 +215,8 @@ public Task StopTracking(string? carrierCode = default, string? tracking /// A [shipping carrier](https://www.shipengine.com/docs/carriers/setup/), such as `fedex`, `dhl_express`, `stamps_com`, etc. (optional) /// The tracking number associated with a shipment (optional) /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task StopTracking(HttpClient methodClient, string? carrierCode = default, string? trackingNumber = default, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> StopTracking(HttpClient methodClient, string? carrierCode = default, string? trackingNumber = default, CancellationToken cancellationToken = default) { RequestOptions requestOptions = new("/v1/tracking/stop"); @@ -230,9 +232,10 @@ public async Task StopTracking(HttpClient methodClient, string? carrierC requestOptions.Operation = "TrackingApi.StopTracking"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } -} \ No newline at end of file +} diff --git a/ShipEngineSDK/Api/WarehousesApi.cs b/ShipEngineSDK/Api/WarehousesApi.cs index e13d4502..267e6cf1 100644 --- a/ShipEngineSDK/Api/WarehousesApi.cs +++ b/ShipEngineSDK/Api/WarehousesApi.cs @@ -31,8 +31,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateWarehouseResponseBody) - Task CreateWarehouse(CreateWarehouseRequestBody createWarehouseRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateWarehouseResponseBody) + Task> CreateWarehouse(CreateWarehouseRequestBody createWarehouseRequestBody, CancellationToken cancellationToken = default); /// /// Create Warehouse Create a warehouse location that you can use to create shipping items by simply passing in the generated warehouse id. If the return address is not supplied in the request body then it is assumed that the origin address is the return address as well @@ -42,8 +42,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateWarehouseResponseBody) - Task CreateWarehouse(HttpClient methodClient, CreateWarehouseRequestBody createWarehouseRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateWarehouseResponseBody) + Task> CreateWarehouse(HttpClient methodClient, CreateWarehouseRequestBody createWarehouseRequestBody, CancellationToken cancellationToken = default); /// /// Delete Warehouse By ID Delete a warehouse by ID @@ -52,8 +52,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Warehouse ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task DeleteWarehouse(string warehouseId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> DeleteWarehouse(string warehouseId, CancellationToken cancellationToken = default); /// /// Delete Warehouse By ID Delete a warehouse by ID @@ -63,8 +63,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Warehouse ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task DeleteWarehouse(HttpClient methodClient, string warehouseId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> DeleteWarehouse(HttpClient methodClient, string warehouseId, CancellationToken cancellationToken = default); /// /// Get Warehouse By Id Retrieve warehouse data based on the warehouse ID @@ -73,8 +73,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Warehouse ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetWarehouseByIdResponseBody) - Task GetWarehouseById(string warehouseId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetWarehouseByIdResponseBody) + Task> GetWarehouseById(string warehouseId, CancellationToken cancellationToken = default); /// /// Get Warehouse By Id Retrieve warehouse data based on the warehouse ID @@ -84,8 +84,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Warehouse ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetWarehouseByIdResponseBody) - Task GetWarehouseById(HttpClient methodClient, string warehouseId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetWarehouseByIdResponseBody) + Task> GetWarehouseById(HttpClient methodClient, string warehouseId, CancellationToken cancellationToken = default); /// /// List Warehouses Retrieve a list of warehouses associated with this account. @@ -93,8 +93,8 @@ public partial interface IShipEngine /// Thrown when required argument is null /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListWarehousesResponseBody) - Task ListWarehouses(CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListWarehousesResponseBody) + Task> ListWarehouses(CancellationToken cancellationToken = default); /// /// List Warehouses Retrieve a list of warehouses associated with this account. @@ -103,8 +103,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// HttpClient to use for the request /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListWarehousesResponseBody) - Task ListWarehouses(HttpClient methodClient, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (ListWarehousesResponseBody) + Task> ListWarehouses(HttpClient methodClient, CancellationToken cancellationToken = default); /// /// Update Warehouse By Id Update Warehouse object information @@ -114,8 +114,8 @@ public partial interface IShipEngine /// /// Warehouse ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task UpdateWarehouse(UpdateWarehouseRequestBody updateWarehouseRequestBody, string warehouseId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> UpdateWarehouse(UpdateWarehouseRequestBody updateWarehouseRequestBody, string warehouseId, CancellationToken cancellationToken = default); /// /// Update Warehouse By Id Update Warehouse object information @@ -126,8 +126,8 @@ public partial interface IShipEngine /// /// Warehouse ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task UpdateWarehouse(HttpClient methodClient, UpdateWarehouseRequestBody updateWarehouseRequestBody, string warehouseId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> UpdateWarehouse(HttpClient methodClient, UpdateWarehouseRequestBody updateWarehouseRequestBody, string warehouseId, CancellationToken cancellationToken = default); /// /// Update Warehouse Settings Update Warehouse settings object information @@ -137,8 +137,8 @@ public partial interface IShipEngine /// /// Warehouse ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task UpdateWarehouseSettings(UpdateWarehouseSettingsRequestBody updateWarehouseSettingsRequestBody, string warehouseId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> UpdateWarehouseSettings(UpdateWarehouseSettingsRequestBody updateWarehouseSettingsRequestBody, string warehouseId, CancellationToken cancellationToken = default); /// /// Update Warehouse Settings Update Warehouse settings object information @@ -149,8 +149,8 @@ public partial interface IShipEngine /// /// Warehouse ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task UpdateWarehouseSettings(HttpClient methodClient, UpdateWarehouseSettingsRequestBody updateWarehouseSettingsRequestBody, string warehouseId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> UpdateWarehouseSettings(HttpClient methodClient, UpdateWarehouseSettingsRequestBody updateWarehouseSettingsRequestBody, string warehouseId, CancellationToken cancellationToken = default); } @@ -166,8 +166,8 @@ public partial class ShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateWarehouseResponseBody) - public Task CreateWarehouse(CreateWarehouseRequestBody createWarehouseRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateWarehouseResponseBody) + public Task> CreateWarehouse(CreateWarehouseRequestBody createWarehouseRequestBody, CancellationToken cancellationToken = default) { return CreateWarehouse(_client, createWarehouseRequestBody, cancellationToken); } @@ -180,8 +180,8 @@ public Task CreateWarehouse(CreateWarehouseRequestB /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateWarehouseResponseBody) - public async Task CreateWarehouse(HttpClient methodClient, CreateWarehouseRequestBody createWarehouseRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateWarehouseResponseBody) + public async Task> CreateWarehouse(HttpClient methodClient, CreateWarehouseRequestBody createWarehouseRequestBody, CancellationToken cancellationToken = default) { // verify the required parameter 'createWarehouseRequestBody' is set if (createWarehouseRequestBody == null) @@ -196,9 +196,10 @@ public async Task CreateWarehouse(HttpClient method requestOptions.Operation = "WarehousesApi.CreateWarehouse"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -208,8 +209,8 @@ public async Task CreateWarehouse(HttpClient method /// Thrown when fails to make API call /// Warehouse ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task DeleteWarehouse(string warehouseId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> DeleteWarehouse(string warehouseId, CancellationToken cancellationToken = default) { return DeleteWarehouse(_client, warehouseId, cancellationToken); } @@ -222,8 +223,8 @@ public Task DeleteWarehouse(string warehouseId, CancellationToken cancel /// HttpClient to use for the request /// Warehouse ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task DeleteWarehouse(HttpClient methodClient, string warehouseId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> DeleteWarehouse(HttpClient methodClient, string warehouseId, CancellationToken cancellationToken = default) { // verify the required parameter 'warehouseId' is set if (warehouseId == null) @@ -238,9 +239,10 @@ public async Task DeleteWarehouse(HttpClient methodClient, string wareho requestOptions.Operation = "WarehousesApi.DeleteWarehouse"; - var result = await SendHttpRequestAsync(HttpMethods.Delete, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -250,8 +252,8 @@ public async Task DeleteWarehouse(HttpClient methodClient, string wareho /// Thrown when fails to make API call /// Warehouse ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetWarehouseByIdResponseBody) - public Task GetWarehouseById(string warehouseId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetWarehouseByIdResponseBody) + public Task> GetWarehouseById(string warehouseId, CancellationToken cancellationToken = default) { return GetWarehouseById(_client, warehouseId, cancellationToken); } @@ -264,8 +266,8 @@ public Task GetWarehouseById(string warehouseId, C /// HttpClient to use for the request /// Warehouse ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetWarehouseByIdResponseBody) - public async Task GetWarehouseById(HttpClient methodClient, string warehouseId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetWarehouseByIdResponseBody) + public async Task> GetWarehouseById(HttpClient methodClient, string warehouseId, CancellationToken cancellationToken = default) { // verify the required parameter 'warehouseId' is set if (warehouseId == null) @@ -280,9 +282,10 @@ public async Task GetWarehouseById(HttpClient meth requestOptions.Operation = "WarehousesApi.GetWarehouseById"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -291,8 +294,8 @@ public async Task GetWarehouseById(HttpClient meth /// Thrown when required argument is null /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListWarehousesResponseBody) - public Task ListWarehouses(CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListWarehousesResponseBody) + public Task> ListWarehouses(CancellationToken cancellationToken = default) { return ListWarehouses(_client, cancellationToken); } @@ -304,8 +307,8 @@ public Task ListWarehouses(CancellationToken cancell /// Thrown when fails to make API call /// HttpClient to use for the request /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ListWarehousesResponseBody) - public async Task ListWarehouses(HttpClient methodClient, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (ListWarehousesResponseBody) + public async Task> ListWarehouses(HttpClient methodClient, CancellationToken cancellationToken = default) { RequestOptions requestOptions = new("/v1/warehouses"); @@ -313,9 +316,10 @@ public async Task ListWarehouses(HttpClient methodCl requestOptions.Operation = "WarehousesApi.ListWarehouses"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -326,8 +330,8 @@ public async Task ListWarehouses(HttpClient methodCl /// /// Warehouse ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task UpdateWarehouse(UpdateWarehouseRequestBody updateWarehouseRequestBody, string warehouseId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> UpdateWarehouse(UpdateWarehouseRequestBody updateWarehouseRequestBody, string warehouseId, CancellationToken cancellationToken = default) { return UpdateWarehouse(_client, updateWarehouseRequestBody, warehouseId, cancellationToken); } @@ -341,8 +345,8 @@ public Task UpdateWarehouse(UpdateWarehouseRequestBody updateWarehouseRe /// /// Warehouse ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task UpdateWarehouse(HttpClient methodClient, UpdateWarehouseRequestBody updateWarehouseRequestBody, string warehouseId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> UpdateWarehouse(HttpClient methodClient, UpdateWarehouseRequestBody updateWarehouseRequestBody, string warehouseId, CancellationToken cancellationToken = default) { // verify the required parameter 'updateWarehouseRequestBody' is set if (updateWarehouseRequestBody == null) @@ -364,9 +368,10 @@ public async Task UpdateWarehouse(HttpClient methodClient, UpdateWarehou requestOptions.Operation = "WarehousesApi.UpdateWarehouse"; - var result = await SendHttpRequestAsync(HttpMethods.Put, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -377,8 +382,8 @@ public async Task UpdateWarehouse(HttpClient methodClient, UpdateWarehou /// /// Warehouse ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task UpdateWarehouseSettings(UpdateWarehouseSettingsRequestBody updateWarehouseSettingsRequestBody, string warehouseId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> UpdateWarehouseSettings(UpdateWarehouseSettingsRequestBody updateWarehouseSettingsRequestBody, string warehouseId, CancellationToken cancellationToken = default) { return UpdateWarehouseSettings(_client, updateWarehouseSettingsRequestBody, warehouseId, cancellationToken); } @@ -392,8 +397,8 @@ public Task UpdateWarehouseSettings(UpdateWarehouseSettingsRequestBody u /// /// Warehouse ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task UpdateWarehouseSettings(HttpClient methodClient, UpdateWarehouseSettingsRequestBody updateWarehouseSettingsRequestBody, string warehouseId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> UpdateWarehouseSettings(HttpClient methodClient, UpdateWarehouseSettingsRequestBody updateWarehouseSettingsRequestBody, string warehouseId, CancellationToken cancellationToken = default) { // verify the required parameter 'updateWarehouseSettingsRequestBody' is set if (updateWarehouseSettingsRequestBody == null) @@ -415,9 +420,10 @@ public async Task UpdateWarehouseSettings(HttpClient methodClient, Updat requestOptions.Operation = "WarehousesApi.UpdateWarehouseSettings"; - var result = await SendHttpRequestAsync(HttpMethods.Put, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } -} \ No newline at end of file +} diff --git a/ShipEngineSDK/Api/WebhooksApi.cs b/ShipEngineSDK/Api/WebhooksApi.cs index 9c6c951d..d436b269 100644 --- a/ShipEngineSDK/Api/WebhooksApi.cs +++ b/ShipEngineSDK/Api/WebhooksApi.cs @@ -31,8 +31,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateWebhookResponseBody) - Task CreateWebhook(CreateWebhookRequestBody createWebhookRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateWebhookResponseBody) + Task> CreateWebhook(CreateWebhookRequestBody createWebhookRequestBody, CancellationToken cancellationToken = default); /// /// Create a Webhook Create a webook for specific events in the environment. @@ -42,8 +42,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateWebhookResponseBody) - Task CreateWebhook(HttpClient methodClient, CreateWebhookRequestBody createWebhookRequestBody, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (CreateWebhookResponseBody) + Task> CreateWebhook(HttpClient methodClient, CreateWebhookRequestBody createWebhookRequestBody, CancellationToken cancellationToken = default); /// /// Delete Webhook By ID Delete a webhook @@ -52,8 +52,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Webhook ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task DeleteWebhook(string webhookId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> DeleteWebhook(string webhookId, CancellationToken cancellationToken = default); /// /// Delete Webhook By ID Delete a webhook @@ -63,8 +63,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Webhook ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task DeleteWebhook(HttpClient methodClient, string webhookId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> DeleteWebhook(HttpClient methodClient, string webhookId, CancellationToken cancellationToken = default); /// /// Get Webhook By ID Retrieve individual webhook by an ID @@ -73,8 +73,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// Webhook ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetWebhookByIdResponseBody) - Task GetWebhookById(string webhookId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetWebhookByIdResponseBody) + Task> GetWebhookById(string webhookId, CancellationToken cancellationToken = default); /// /// Get Webhook By ID Retrieve individual webhook by an ID @@ -84,8 +84,8 @@ public partial interface IShipEngine /// HttpClient to use for the request /// Webhook ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetWebhookByIdResponseBody) - Task GetWebhookById(HttpClient methodClient, string webhookId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (GetWebhookByIdResponseBody) + Task> GetWebhookById(HttpClient methodClient, string webhookId, CancellationToken cancellationToken = default); /// /// List Webhooks List all webhooks currently enabled for the account. @@ -93,8 +93,8 @@ public partial interface IShipEngine /// Thrown when required argument is null /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<Webhook>) - Task> ListWebhooks(CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (List<Webhook>) + Task>> ListWebhooks(CancellationToken cancellationToken = default); /// /// List Webhooks List all webhooks currently enabled for the account. @@ -103,8 +103,8 @@ public partial interface IShipEngine /// Thrown when fails to make API call /// HttpClient to use for the request /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<Webhook>) - Task> ListWebhooks(HttpClient methodClient, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (List<Webhook>) + Task>> ListWebhooks(HttpClient methodClient, CancellationToken cancellationToken = default); /// /// Update a Webhook Update the webhook url property @@ -114,8 +114,8 @@ public partial interface IShipEngine /// /// Webhook ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task UpdateWebhook(UpdateWebhookRequestBody updateWebhookRequestBody, string webhookId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> UpdateWebhook(UpdateWebhookRequestBody updateWebhookRequestBody, string webhookId, CancellationToken cancellationToken = default); /// /// Update a Webhook Update the webhook url property @@ -126,8 +126,8 @@ public partial interface IShipEngine /// /// Webhook ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - Task UpdateWebhook(HttpClient methodClient, UpdateWebhookRequestBody updateWebhookRequestBody, string webhookId, CancellationToken cancellationToken = default); + /// Task of ShipEngineResponse (string) + Task> UpdateWebhook(HttpClient methodClient, UpdateWebhookRequestBody updateWebhookRequestBody, string webhookId, CancellationToken cancellationToken = default); } @@ -143,8 +143,8 @@ public partial class ShipEngine /// Thrown when fails to make API call /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateWebhookResponseBody) - public Task CreateWebhook(CreateWebhookRequestBody createWebhookRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateWebhookResponseBody) + public Task> CreateWebhook(CreateWebhookRequestBody createWebhookRequestBody, CancellationToken cancellationToken = default) { return CreateWebhook(_client, createWebhookRequestBody, cancellationToken); } @@ -157,8 +157,8 @@ public Task CreateWebhook(CreateWebhookRequestBody cr /// HttpClient to use for the request /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (CreateWebhookResponseBody) - public async Task CreateWebhook(HttpClient methodClient, CreateWebhookRequestBody createWebhookRequestBody, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (CreateWebhookResponseBody) + public async Task> CreateWebhook(HttpClient methodClient, CreateWebhookRequestBody createWebhookRequestBody, CancellationToken cancellationToken = default) { // verify the required parameter 'createWebhookRequestBody' is set if (createWebhookRequestBody == null) @@ -173,9 +173,10 @@ public async Task CreateWebhook(HttpClient methodClie requestOptions.Operation = "WebhooksApi.CreateWebhook"; - var result = await SendHttpRequestAsync(HttpMethods.Post, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -185,8 +186,8 @@ public async Task CreateWebhook(HttpClient methodClie /// Thrown when fails to make API call /// Webhook ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task DeleteWebhook(string webhookId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> DeleteWebhook(string webhookId, CancellationToken cancellationToken = default) { return DeleteWebhook(_client, webhookId, cancellationToken); } @@ -199,8 +200,8 @@ public Task DeleteWebhook(string webhookId, CancellationToken cancellati /// HttpClient to use for the request /// Webhook ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task DeleteWebhook(HttpClient methodClient, string webhookId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> DeleteWebhook(HttpClient methodClient, string webhookId, CancellationToken cancellationToken = default) { // verify the required parameter 'webhookId' is set if (webhookId == null) @@ -215,9 +216,10 @@ public async Task DeleteWebhook(HttpClient methodClient, string webhookI requestOptions.Operation = "WebhooksApi.DeleteWebhook"; - var result = await SendHttpRequestAsync(HttpMethods.Delete, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -227,8 +229,8 @@ public async Task DeleteWebhook(HttpClient methodClient, string webhookI /// Thrown when fails to make API call /// Webhook ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetWebhookByIdResponseBody) - public Task GetWebhookById(string webhookId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetWebhookByIdResponseBody) + public Task> GetWebhookById(string webhookId, CancellationToken cancellationToken = default) { return GetWebhookById(_client, webhookId, cancellationToken); } @@ -241,8 +243,8 @@ public Task GetWebhookById(string webhookId, Cancell /// HttpClient to use for the request /// Webhook ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (GetWebhookByIdResponseBody) - public async Task GetWebhookById(HttpClient methodClient, string webhookId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (GetWebhookByIdResponseBody) + public async Task> GetWebhookById(HttpClient methodClient, string webhookId, CancellationToken cancellationToken = default) { // verify the required parameter 'webhookId' is set if (webhookId == null) @@ -257,9 +259,10 @@ public async Task GetWebhookById(HttpClient methodCl requestOptions.Operation = "WebhooksApi.GetWebhookById"; - var result = await SendHttpRequestAsync(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } /// @@ -268,8 +271,8 @@ public async Task GetWebhookById(HttpClient methodCl /// Thrown when required argument is null /// Thrown when fails to make API call /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<Webhook>) - public Task> ListWebhooks(CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (List<Webhook>) + public Task>> ListWebhooks(CancellationToken cancellationToken = default) { return ListWebhooks(_client, cancellationToken); } @@ -281,8 +284,8 @@ public Task> ListWebhooks(CancellationToken cancellationToken = de /// Thrown when fails to make API call /// HttpClient to use for the request /// Cancellation Token to cancel the request. - /// Task of ApiResponse (List<Webhook>) - public async Task> ListWebhooks(HttpClient methodClient, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (List<Webhook>) + public async Task>> ListWebhooks(HttpClient methodClient, CancellationToken cancellationToken = default) { RequestOptions requestOptions = new("/v1/environment/webhooks"); @@ -290,9 +293,10 @@ public async Task> ListWebhooks(HttpClient methodClient, Cancellat requestOptions.Operation = "WebhooksApi.ListWebhooks"; - var result = await SendHttpRequestAsync>(HttpMethods.Get, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse>(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse>(data, response.StatusCode, headers); } /// @@ -303,8 +307,8 @@ public async Task> ListWebhooks(HttpClient methodClient, Cancellat /// /// Webhook ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public Task UpdateWebhook(UpdateWebhookRequestBody updateWebhookRequestBody, string webhookId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public Task> UpdateWebhook(UpdateWebhookRequestBody updateWebhookRequestBody, string webhookId, CancellationToken cancellationToken = default) { return UpdateWebhook(_client, updateWebhookRequestBody, webhookId, cancellationToken); } @@ -318,8 +322,8 @@ public Task UpdateWebhook(UpdateWebhookRequestBody updateWebhookRequestB /// /// Webhook ID /// Cancellation Token to cancel the request. - /// Task of ApiResponse (string) - public async Task UpdateWebhook(HttpClient methodClient, UpdateWebhookRequestBody updateWebhookRequestBody, string webhookId, CancellationToken cancellationToken = default) + /// Task of ShipEngineResponse (string) + public async Task> UpdateWebhook(HttpClient methodClient, UpdateWebhookRequestBody updateWebhookRequestBody, string webhookId, CancellationToken cancellationToken = default) { // verify the required parameter 'updateWebhookRequestBody' is set if (updateWebhookRequestBody == null) @@ -341,9 +345,10 @@ public async Task UpdateWebhook(HttpClient methodClient, UpdateWebhookRe requestOptions.Operation = "WebhooksApi.UpdateWebhook"; - var result = await SendHttpRequestAsync(HttpMethods.Put, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse(data, response.StatusCode, headers); } -} \ No newline at end of file +} diff --git a/ShipEngineSDK/ShipEngineClient.cs b/ShipEngineSDK/ShipEngineClient.cs index f69fb8a3..1194882e 100644 --- a/ShipEngineSDK/ShipEngineClient.cs +++ b/ShipEngineSDK/ShipEngineClient.cs @@ -225,6 +225,13 @@ public virtual Task SendHttpRequestAsync(HttpMethod method, string path, s /// Token that can be used to cancel the request /// public virtual async Task SendHttpRequestAsync(HttpMethod method, string path, string? jsonContent, HttpClient client, Config config, CancellationToken cancellationToken) + { + (T data, HttpResponseMessage message) = await GetHttpResponse(method, path, jsonContent, client, config, cancellationToken); + return data; + } + + public async Task<(T, HttpResponseMessage)> GetHttpResponse(HttpMethod method, string path, string? jsonContent, HttpClient client, Config config, + CancellationToken cancellationToken) { int retry = 0; @@ -239,8 +246,7 @@ public virtual async Task SendHttpRequestAsync(HttpMethod method, string p response = await client.SendAsync(request, cancellationToken); var deserializedResult = await DeserializedResultOrThrow(response); - - return deserializedResult; + return (deserializedResult, response); } catch (ShipEngineException e) { diff --git a/ShipEngineSDK/ShipEngineResponse.cs b/ShipEngineSDK/ShipEngineResponse.cs new file mode 100644 index 00000000..45c4e4d0 --- /dev/null +++ b/ShipEngineSDK/ShipEngineResponse.cs @@ -0,0 +1,18 @@ +namespace ShipEngineSDK; + +using System.Collections.Generic; +using System.Net; + +public class ShipEngineResponse +{ + private readonly T _data; + public HttpStatusCode HttpStatus { get; private init; } + public IDictionary Headers { get; private init; } + + public ShipEngineResponse(T data, HttpStatusCode httpStatus, Dictionary headers) + { + _data = data; + HttpStatus = httpStatus; + Headers = headers; + } +} \ No newline at end of file diff --git a/generation/templates/api.mustache b/generation/templates/api.mustache index 5403fd35..061319bf 100644 --- a/generation/templates/api.mustache +++ b/generation/templates/api.mustache @@ -33,11 +33,11 @@ namespace {{packageName}}; /// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}} {{/allParams}} /// Cancellation Token to cancel the request. - /// Task of ApiResponse{{#returnType}} ({{.}}){{/returnType}} + /// Task of ShipEngineResponse{{#returnType}} ({{.}}){{/returnType}} {{#isDeprecated}} [Obsolete] {{/isDeprecated}} - Task<{{{returnType}}}{{^returnType}}Object{{/returnType}}> {{operationId}}({{#allParams}}{{{dataType}}}{{^required}}?{{/required}} {{paramName}}, {{/allParams}}CancellationToken cancellationToken = default); + Task> {{operationId}}({{#allParams}}{{{dataType}}}{{^required}}?{{/required}} {{paramName}}, {{/allParams}}CancellationToken cancellationToken = default); /// /// {{summary}} {{notes}} @@ -49,11 +49,11 @@ namespace {{packageName}}; /// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}} {{/allParams}} /// Cancellation Token to cancel the request. - /// Task of ApiResponse{{#returnType}} ({{.}}){{/returnType}} + /// Task of ShipEngineResponse{{#returnType}} ({{.}}){{/returnType}} {{#isDeprecated}} [Obsolete] {{/isDeprecated}} - Task<{{{returnType}}}{{^returnType}}Object{{/returnType}}> {{operationId}}(HttpClient methodClient, {{#allParams}}{{{dataType}}}{{^required}}?{{/required}} {{paramName}}, {{/allParams}}CancellationToken cancellationToken = default); + Task> {{operationId}}(HttpClient methodClient, {{#allParams}}{{{dataType}}}{{^required}}?{{/required}} {{paramName}}, {{/allParams}}CancellationToken cancellationToken = default); {{/operation}} } @@ -73,11 +73,11 @@ namespace {{packageName}}; /// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}} {{/allParams}} /// Cancellation Token to cancel the request. - /// Task of ApiResponse{{#returnType}} ({{.}}){{/returnType}} + /// Task of ShipEngineResponse{{#returnType}} ({{.}}){{/returnType}} {{#isDeprecated}} [Obsolete] {{/isDeprecated}} - public Task<{{{returnType}}}{{^returnType}}Object{{/returnType}}> {{operationId}}({{#allParams}}{{{dataType}}}{{^required}}?{{/required}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default{{/optionalMethodArgument}}{{/required}}, {{/allParams}}CancellationToken cancellationToken = default) + public Task> {{operationId}}({{#allParams}}{{{dataType}}}{{^required}}?{{/required}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default{{/optionalMethodArgument}}{{/required}}, {{/allParams}}CancellationToken cancellationToken = default) { return {{operationId}}(_client, {{#allParams}}{{paramName}}, {{/allParams}}cancellationToken); } @@ -92,11 +92,11 @@ namespace {{packageName}}; /// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}} {{/allParams}} /// Cancellation Token to cancel the request. - /// Task of ApiResponse{{#returnType}} ({{.}}){{/returnType}} + /// Task of ShipEngineResponse{{#returnType}} ({{.}}){{/returnType}} {{#isDeprecated}} [Obsolete] {{/isDeprecated}} - public async Task<{{{returnType}}}{{^returnType}}Object{{/returnType}}> {{operationId}}(HttpClient methodClient, {{#allParams}}{{{dataType}}}{{^required}}?{{/required}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default{{/optionalMethodArgument}}{{/required}}, {{/allParams}}CancellationToken cancellationToken = default) + public async Task> {{operationId}}(HttpClient methodClient, {{#allParams}}{{{dataType}}}{{^required}}?{{/required}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default{{/optionalMethodArgument}}{{/required}}, {{/allParams}}CancellationToken cancellationToken = default) { {{#allParams}} {{#required}} @@ -238,10 +238,11 @@ namespace {{packageName}}; requestOptions.Operation = "{{classname}}.{{operationId}}"; - var result = await SendHttpRequestAsync<{{{returnType}}}{{^returnType}}Object{{/returnType}}>(HttpMethods.{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}}, requestOptions, methodClient, _config, cancellationToken); - - return result; + var (data, response) = await GetHttpResponse<{{{returnType}}}{{^returnType}}Object{{/returnType}}>(HttpMethods.{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}}, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); + var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), + StringComparer.InvariantCultureIgnoreCase); + return new ShipEngineResponse<{{{returnType}}}{{^returnType}}Object{{/returnType}}>(data, response.StatusCode, headers); } {{/operation}} -}{{/operations}} \ No newline at end of file +}{{/operations}} From 9de45551e7b2740b7fe0df0477baac9bf9130cdf Mon Sep 17 00:00:00 2001 From: Andrew Benz Date: Thu, 22 Aug 2024 12:21:28 -0500 Subject: [PATCH 2/2] Make data public and encapsulate header consolidation in response object --- .vscode/settings.json | 22 ++++++++- ShipEngineSDK/Api/AccountApi.cs | 30 +++---------- ShipEngineSDK/Api/AddressesApi.cs | 10 +---- ShipEngineSDK/Api/BatchesApi.cs | 50 +++++---------------- ShipEngineSDK/Api/CarrierAccountsApi.cs | 20 ++------- ShipEngineSDK/Api/CarriersApi.cs | 35 +++------------ ShipEngineSDK/Api/DownloadsApi.cs | 5 +-- ShipEngineSDK/Api/InsuranceApi.cs | 20 ++------- ShipEngineSDK/Api/LabelsApi.cs | 45 ++++--------------- ShipEngineSDK/Api/ManifestsApi.cs | 20 ++------- ShipEngineSDK/Api/PackagePickupsApi.cs | 20 ++------- ShipEngineSDK/Api/PackageTypesApi.cs | 25 +++-------- ShipEngineSDK/Api/RatesApi.cs | 20 ++------- ShipEngineSDK/Api/ServicePointsApi.cs | 10 +---- ShipEngineSDK/Api/ShipmentsApi.cs | 60 +++++-------------------- ShipEngineSDK/Api/TagsApi.cs | 20 ++------- ShipEngineSDK/Api/TokensApi.cs | 5 +-- ShipEngineSDK/Api/TrackingApi.cs | 15 ++----- ShipEngineSDK/Api/WarehousesApi.cs | 30 +++---------- ShipEngineSDK/Api/WebhooksApi.cs | 25 +++-------- ShipEngineSDK/ShipEngineClient.cs | 52 ++++++++++++--------- ShipEngineSDK/ShipEngineResponse.cs | 38 +++++++++++----- generation/templates/api.mustache | 5 +-- 23 files changed, 173 insertions(+), 409 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index ae17e7fa..8db1bcb7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,5 +3,25 @@ "omnisharp.useEditorFormattingSettings": false, "[csharp]": { "editor.defaultFormatter": "ms-dotnettools.csharp" - } + }, + "workbench.colorCustomizations": { + "activityBar.activeBackground": "#26b7e8", + "activityBar.background": "#26b7e8", + "activityBar.foreground": "#15202b", + "activityBar.inactiveForeground": "#15202b99", + "activityBarBadge.background": "#ca159c", + "activityBarBadge.foreground": "#e7e7e7", + "commandCenter.border": "#e7e7e799", + "sash.hoverBorder": "#26b7e8", + "statusBar.background": "#1599c6", + "statusBar.foreground": "#e7e7e7", + "statusBarItem.hoverBackground": "#26b7e8", + "statusBarItem.remoteBackground": "#1599c6", + "statusBarItem.remoteForeground": "#e7e7e7", + "titleBar.activeBackground": "#1599c6", + "titleBar.activeForeground": "#e7e7e7", + "titleBar.inactiveBackground": "#1599c699", + "titleBar.inactiveForeground": "#e7e7e799" + }, + "peacock.color": "#1599c6" } \ No newline at end of file diff --git a/ShipEngineSDK/Api/AccountApi.cs b/ShipEngineSDK/Api/AccountApi.cs index cdff8ea1..fa6136c8 100644 --- a/ShipEngineSDK/Api/AccountApi.cs +++ b/ShipEngineSDK/Api/AccountApi.cs @@ -192,10 +192,7 @@ public async Task> Crea requestOptions.Operation = "AccountApi.CreateAccountImage"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -235,10 +232,7 @@ public async Task> DeleteAccountImageById(HttpClient requestOptions.Operation = "AccountApi.DeleteAccountImageById"; - var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -278,10 +272,7 @@ public async Task> GetA requestOptions.Operation = "AccountApi.GetAccountSettingsImagesById"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -312,10 +303,7 @@ public async Task> Lis requestOptions.Operation = "AccountApi.ListAccountImages"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -346,10 +334,7 @@ public async Task> ListAccoun requestOptions.Operation = "AccountApi.ListAccountSettings"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -398,10 +383,7 @@ public async Task> UpdateAccountSettingsImagesById(Ht requestOptions.Operation = "AccountApi.UpdateAccountSettingsImagesById"; - var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } } diff --git a/ShipEngineSDK/Api/AddressesApi.cs b/ShipEngineSDK/Api/AddressesApi.cs index 3613e3e6..e4e00ba5 100644 --- a/ShipEngineSDK/Api/AddressesApi.cs +++ b/ShipEngineSDK/Api/AddressesApi.cs @@ -110,10 +110,7 @@ public async Task> ParseAddress(Htt requestOptions.Operation = "AddressesApi.ParseAddress"; - var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -153,10 +150,7 @@ public async Task>> ValidateAdd requestOptions.Operation = "AddressesApi.ValidateAddress"; - var (data, response) = await GetHttpResponse>(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse>(data, response.StatusCode, headers); + return await GetHttpResponse>(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } } diff --git a/ShipEngineSDK/Api/BatchesApi.cs b/ShipEngineSDK/Api/BatchesApi.cs index 2fd17cc2..329dbfee 100644 --- a/ShipEngineSDK/Api/BatchesApi.cs +++ b/ShipEngineSDK/Api/BatchesApi.cs @@ -307,10 +307,7 @@ public async Task> AddToBatch(HttpClient methodClient requestOptions.Operation = "BatchesApi.AddToBatch"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -350,10 +347,7 @@ public async Task> CreateBatch(HttpC requestOptions.Operation = "BatchesApi.CreateBatch"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -393,10 +387,7 @@ public async Task> DeleteBatch(HttpClient methodClien requestOptions.Operation = "BatchesApi.DeleteBatch"; - var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -436,10 +427,7 @@ public async Task> GetBatch requestOptions.Operation = "BatchesApi.GetBatchByExternalId"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -479,10 +467,7 @@ public async Task> GetBatchById(Htt requestOptions.Operation = "BatchesApi.GetBatchById"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -534,10 +519,7 @@ public async Task> ListBatchErro requestOptions.Operation = "BatchesApi.ListBatchErrors"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -604,10 +586,7 @@ public async Task> ListBatches(HttpC requestOptions.Operation = "BatchesApi.ListBatches"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -656,10 +635,7 @@ public async Task> ProcessBatch(HttpClient methodClie requestOptions.Operation = "BatchesApi.ProcessBatch"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -708,10 +684,7 @@ public async Task> RemoveFromBatch(HttpClient methodC requestOptions.Operation = "BatchesApi.RemoveFromBatch"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -751,10 +724,7 @@ public async Task> UpdateBatch(HttpClient methodClien requestOptions.Operation = "BatchesApi.UpdateBatch"; - var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } } diff --git a/ShipEngineSDK/Api/CarrierAccountsApi.cs b/ShipEngineSDK/Api/CarrierAccountsApi.cs index fa4261dd..3ae63440 100644 --- a/ShipEngineSDK/Api/CarrierAccountsApi.cs +++ b/ShipEngineSDK/Api/CarrierAccountsApi.cs @@ -171,10 +171,7 @@ public async Task> ConnectCarrier requestOptions.Operation = "CarrierAccountsApi.ConnectCarrier"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -223,10 +220,7 @@ public async Task> DisconnectCarrier(HttpClient metho requestOptions.Operation = "CarrierAccountsApi.DisconnectCarrier"; - var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -275,10 +269,7 @@ public async Task> GetCarrier requestOptions.Operation = "CarrierAccountsApi.GetCarrierSettings"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -336,10 +327,7 @@ public async Task> UpdateCarrierSettings(HttpClient m requestOptions.Operation = "CarrierAccountsApi.UpdateCarrierSettings"; - var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } } diff --git a/ShipEngineSDK/Api/CarriersApi.cs b/ShipEngineSDK/Api/CarriersApi.cs index e752d264..2b42e8e4 100644 --- a/ShipEngineSDK/Api/CarriersApi.cs +++ b/ShipEngineSDK/Api/CarriersApi.cs @@ -224,10 +224,7 @@ public async Task> AddFundsToC requestOptions.Operation = "CarriersApi.AddFundsToCarrier"; - var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -267,10 +264,7 @@ public async Task> DisconnectCarrierById(HttpClient m requestOptions.Operation = "CarriersApi.DisconnectCarrierById"; - var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -310,10 +304,7 @@ public async Task> GetCarrierById requestOptions.Operation = "CarriersApi.GetCarrierById"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -353,10 +344,7 @@ public async Task> GetCarrierO requestOptions.Operation = "CarriersApi.GetCarrierOptions"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -396,10 +384,7 @@ public async Task> ListC requestOptions.Operation = "CarriersApi.ListCarrierPackageTypes"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -439,10 +424,7 @@ public async Task> ListCarri requestOptions.Operation = "CarriersApi.ListCarrierServices"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -473,10 +455,7 @@ public async Task> ListCarriers(Http requestOptions.Operation = "CarriersApi.ListCarriers"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } } diff --git a/ShipEngineSDK/Api/DownloadsApi.cs b/ShipEngineSDK/Api/DownloadsApi.cs index 8a5b59f6..80736caf 100644 --- a/ShipEngineSDK/Api/DownloadsApi.cs +++ b/ShipEngineSDK/Api/DownloadsApi.cs @@ -127,10 +127,7 @@ public partial class ShipEngine requestOptions.Operation = "DownloadsApi.DownloadFile"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } } diff --git a/ShipEngineSDK/Api/InsuranceApi.cs b/ShipEngineSDK/Api/InsuranceApi.cs index e6ca29d8..149fad45 100644 --- a/ShipEngineSDK/Api/InsuranceApi.cs +++ b/ShipEngineSDK/Api/InsuranceApi.cs @@ -148,10 +148,7 @@ public async Task> AddFundsT requestOptions.Operation = "InsuranceApi.AddFundsToInsurance"; - var (data, response) = await GetHttpResponse(HttpMethods.Patch, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Patch, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -191,10 +188,7 @@ public async Task> ConnectInsurer(HttpClient methodCl requestOptions.Operation = "InsuranceApi.ConnectInsurer"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -225,10 +219,7 @@ public async Task> DisconnectInsurer(HttpClient metho requestOptions.Operation = "InsuranceApi.DisconnectInsurer"; - var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -259,10 +250,7 @@ public async Task> GetInsura requestOptions.Operation = "InsuranceApi.GetInsuranceBalance"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } } diff --git a/ShipEngineSDK/Api/LabelsApi.cs b/ShipEngineSDK/Api/LabelsApi.cs index 743f0bd3..b802dfa9 100644 --- a/ShipEngineSDK/Api/LabelsApi.cs +++ b/ShipEngineSDK/Api/LabelsApi.cs @@ -293,10 +293,7 @@ public async Task> CreateLabel(HttpC requestOptions.Operation = "LabelsApi.CreateLabel"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -345,10 +342,7 @@ public async Task> CreateLab requestOptions.Operation = "LabelsApi.CreateLabelFromRate"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -397,10 +391,7 @@ public async Task> Creat requestOptions.Operation = "LabelsApi.CreateLabelFromShipment"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -449,10 +440,7 @@ public async Task> CreateRetur requestOptions.Operation = "LabelsApi.CreateReturnLabel"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -498,10 +486,7 @@ public async Task> requestOptions.Operation = "LabelsApi.GetLabelByExternalShipmentId"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -547,10 +532,7 @@ public async Task> GetLabelById(Htt requestOptions.Operation = "LabelsApi.GetLabelById"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -590,10 +572,7 @@ public async Task> GetTr requestOptions.Operation = "LabelsApi.GetTrackingLogFromLabel"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -708,10 +687,7 @@ public async Task> ListLabels(HttpCli requestOptions.Operation = "LabelsApi.ListLabels"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -751,10 +727,7 @@ public async Task> VoidLabel(HttpClien requestOptions.Operation = "LabelsApi.VoidLabel"; - var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } } diff --git a/ShipEngineSDK/Api/ManifestsApi.cs b/ShipEngineSDK/Api/ManifestsApi.cs index cab14483..b784e0af 100644 --- a/ShipEngineSDK/Api/ManifestsApi.cs +++ b/ShipEngineSDK/Api/ManifestsApi.cs @@ -168,10 +168,7 @@ public async Task> CreateManifest requestOptions.Operation = "ManifestsApi.CreateManifest"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -211,10 +208,7 @@ public async Task> GetManifestBy requestOptions.Operation = "ManifestsApi.GetManifestById"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -254,10 +248,7 @@ public async Task> GetManifestReq requestOptions.Operation = "ManifestsApi.GetManifestRequestById"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -342,10 +333,7 @@ public async Task> ListManifests(H requestOptions.Operation = "ManifestsApi.ListManifests"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } } diff --git a/ShipEngineSDK/Api/PackagePickupsApi.cs b/ShipEngineSDK/Api/PackagePickupsApi.cs index 3faba26d..5b705381 100644 --- a/ShipEngineSDK/Api/PackagePickupsApi.cs +++ b/ShipEngineSDK/Api/PackagePickupsApi.cs @@ -162,10 +162,7 @@ public async Task> DeleteSchedu requestOptions.Operation = "PackagePickupsApi.DeleteScheduledPickup"; - var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -205,10 +202,7 @@ public async Task> GetPickupById(H requestOptions.Operation = "PackagePickupsApi.GetPickupById"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -275,10 +269,7 @@ public async Task> ListScheduledPicku requestOptions.Operation = "PackagePickupsApi.ListScheduledPickups"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -318,10 +309,7 @@ public async Task> SchedulePickup requestOptions.Operation = "PackagePickupsApi.SchedulePickup"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } } diff --git a/ShipEngineSDK/Api/PackageTypesApi.cs b/ShipEngineSDK/Api/PackageTypesApi.cs index 04b8b545..9c1881fd 100644 --- a/ShipEngineSDK/Api/PackageTypesApi.cs +++ b/ShipEngineSDK/Api/PackageTypesApi.cs @@ -173,10 +173,7 @@ public async Task> CreatePacka requestOptions.Operation = "PackageTypesApi.CreatePackageType"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -216,10 +213,7 @@ public async Task> DeletePackageType(HttpClient metho requestOptions.Operation = "PackageTypesApi.DeletePackageType"; - var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -259,10 +253,7 @@ public async Task> GetPackage requestOptions.Operation = "PackageTypesApi.GetPackageTypeById"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -293,10 +284,7 @@ public async Task> ListPackageT requestOptions.Operation = "PackageTypesApi.ListPackageTypes"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -345,10 +333,7 @@ public async Task> UpdatePackageType(HttpClient metho requestOptions.Operation = "PackageTypesApi.UpdatePackageType"; - var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } } diff --git a/ShipEngineSDK/Api/RatesApi.cs b/ShipEngineSDK/Api/RatesApi.cs index 3e42723c..96222278 100644 --- a/ShipEngineSDK/Api/RatesApi.cs +++ b/ShipEngineSDK/Api/RatesApi.cs @@ -152,10 +152,7 @@ public async Task> CalculateRates requestOptions.Operation = "RatesApi.CalculateRates"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -195,10 +192,7 @@ public async Task>> CompareBulkRates(HttpClien requestOptions.Operation = "RatesApi.CompareBulkRates"; - var (data, response) = await GetHttpResponse>(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse>(data, response.StatusCode, headers); + return await GetHttpResponse>(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -238,10 +232,7 @@ public async Task>> EstimateRates(HttpClie requestOptions.Operation = "RatesApi.EstimateRates"; - var (data, response) = await GetHttpResponse>(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse>(data, response.StatusCode, headers); + return await GetHttpResponse>(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -281,10 +272,7 @@ public async Task> GetRateById(HttpC requestOptions.Operation = "RatesApi.GetRateById"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } } diff --git a/ShipEngineSDK/Api/ServicePointsApi.cs b/ShipEngineSDK/Api/ServicePointsApi.cs index f03d9afc..0481a582 100644 --- a/ShipEngineSDK/Api/ServicePointsApi.cs +++ b/ShipEngineSDK/Api/ServicePointsApi.cs @@ -132,10 +132,7 @@ public async Task> ServicePo requestOptions.Operation = "ServicePointsApi.ServicePointsGetById"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -175,10 +172,7 @@ public async Task> ServicePoin requestOptions.Operation = "ServicePointsApi.ServicePointsList"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } } diff --git a/ShipEngineSDK/Api/ShipmentsApi.cs b/ShipEngineSDK/Api/ShipmentsApi.cs index bbf82cd9..29fe8b58 100644 --- a/ShipEngineSDK/Api/ShipmentsApi.cs +++ b/ShipEngineSDK/Api/ShipmentsApi.cs @@ -350,10 +350,7 @@ public async Task> CancelShipments(HttpClient methodC requestOptions.Operation = "ShipmentsApi.CancelShipments"; - var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -393,10 +390,7 @@ public async Task> CreateShipmen requestOptions.Operation = "ShipmentsApi.CreateShipments"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -436,10 +430,7 @@ public async Task> GetSh requestOptions.Operation = "ShipmentsApi.GetShipmentByExternalId"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -479,10 +470,7 @@ public async Task> GetShipmentBy requestOptions.Operation = "ShipmentsApi.GetShipmentById"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -528,10 +516,7 @@ public async Task> ListShipmen requestOptions.Operation = "ShipmentsApi.ListShipmentRates"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -634,10 +619,7 @@ public async Task> ListShipments(H requestOptions.Operation = "ShipmentsApi.ListShipments"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -677,10 +659,7 @@ public async Task> ParseShipment(H requestOptions.Operation = "ShipmentsApi.ParseShipment"; - var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -720,10 +699,7 @@ public async Task> ShipmentsListTags requestOptions.Operation = "ShipmentsApi.ShipmentsListTags"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -763,10 +739,7 @@ public async Task> ShipmentsUpdateTags(HttpClient met requestOptions.Operation = "ShipmentsApi.ShipmentsUpdateTags"; - var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -815,10 +788,7 @@ public async Task> TagShipment(HttpC requestOptions.Operation = "ShipmentsApi.TagShipment"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -867,10 +837,7 @@ public async Task> UntagShipment(HttpClient methodCli requestOptions.Operation = "ShipmentsApi.UntagShipment"; - var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -919,10 +886,7 @@ public async Task> UpdateShipment requestOptions.Operation = "ShipmentsApi.UpdateShipment"; - var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } } diff --git a/ShipEngineSDK/Api/TagsApi.cs b/ShipEngineSDK/Api/TagsApi.cs index 5835c99b..9140f9b6 100644 --- a/ShipEngineSDK/Api/TagsApi.cs +++ b/ShipEngineSDK/Api/TagsApi.cs @@ -152,10 +152,7 @@ public async Task> CreateTag(HttpClien requestOptions.Operation = "TagsApi.CreateTag"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -195,10 +192,7 @@ public async Task> DeleteTag(HttpClient methodClient, requestOptions.Operation = "TagsApi.DeleteTag"; - var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -229,10 +223,7 @@ public async Task> ListTags(HttpClient requestOptions.Operation = "TagsApi.ListTags"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -281,10 +272,7 @@ public async Task> RenameTag(HttpClient methodClient, requestOptions.Operation = "TagsApi.RenameTag"; - var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } } diff --git a/ShipEngineSDK/Api/TokensApi.cs b/ShipEngineSDK/Api/TokensApi.cs index f2190480..1e69f5e4 100644 --- a/ShipEngineSDK/Api/TokensApi.cs +++ b/ShipEngineSDK/Api/TokensApi.cs @@ -86,10 +86,7 @@ public async Task> T requestOptions.Operation = "TokensApi.TokensGetEphemeralToken"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } } diff --git a/ShipEngineSDK/Api/TrackingApi.cs b/ShipEngineSDK/Api/TrackingApi.cs index 1ef72872..45aadc47 100644 --- a/ShipEngineSDK/Api/TrackingApi.cs +++ b/ShipEngineSDK/Api/TrackingApi.cs @@ -140,10 +140,7 @@ public async Task> GetTrackingLog requestOptions.Operation = "TrackingApi.GetTrackingLog"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -186,10 +183,7 @@ public async Task> StartTracking(HttpClient methodCli requestOptions.Operation = "TrackingApi.StartTracking"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -232,10 +226,7 @@ public async Task> StopTracking(HttpClient methodClie requestOptions.Operation = "TrackingApi.StopTracking"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } } diff --git a/ShipEngineSDK/Api/WarehousesApi.cs b/ShipEngineSDK/Api/WarehousesApi.cs index 267e6cf1..4c0a8fcf 100644 --- a/ShipEngineSDK/Api/WarehousesApi.cs +++ b/ShipEngineSDK/Api/WarehousesApi.cs @@ -196,10 +196,7 @@ public async Task> CreateWarehou requestOptions.Operation = "WarehousesApi.CreateWarehouse"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -239,10 +236,7 @@ public async Task> DeleteWarehouse(HttpClient methodC requestOptions.Operation = "WarehousesApi.DeleteWarehouse"; - var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -282,10 +276,7 @@ public async Task> GetWarehouse requestOptions.Operation = "WarehousesApi.GetWarehouseById"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -316,10 +307,7 @@ public async Task> ListWarehouses requestOptions.Operation = "WarehousesApi.ListWarehouses"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -368,10 +356,7 @@ public async Task> UpdateWarehouse(HttpClient methodC requestOptions.Operation = "WarehousesApi.UpdateWarehouse"; - var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -420,10 +405,7 @@ public async Task> UpdateWarehouseSettings(HttpClient requestOptions.Operation = "WarehousesApi.UpdateWarehouseSettings"; - var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } } diff --git a/ShipEngineSDK/Api/WebhooksApi.cs b/ShipEngineSDK/Api/WebhooksApi.cs index d436b269..c44f041a 100644 --- a/ShipEngineSDK/Api/WebhooksApi.cs +++ b/ShipEngineSDK/Api/WebhooksApi.cs @@ -173,10 +173,7 @@ public async Task> CreateWebhook(H requestOptions.Operation = "WebhooksApi.CreateWebhook"; - var (data, response) = await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -216,10 +213,7 @@ public async Task> DeleteWebhook(HttpClient methodCli requestOptions.Operation = "WebhooksApi.DeleteWebhook"; - var (data, response) = await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Delete, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -259,10 +253,7 @@ public async Task> GetWebhookById requestOptions.Operation = "WebhooksApi.GetWebhookById"; - var (data, response) = await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -293,10 +284,7 @@ public async Task>> ListWebhooks(HttpClient met requestOptions.Operation = "WebhooksApi.ListWebhooks"; - var (data, response) = await GetHttpResponse>(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse>(data, response.StatusCode, headers); + return await GetHttpResponse>(HttpMethods.Get, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } /// @@ -345,10 +333,7 @@ public async Task> UpdateWebhook(HttpClient methodCli requestOptions.Operation = "WebhooksApi.UpdateWebhook"; - var (data, response) = await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse(data, response.StatusCode, headers); + return await GetHttpResponse(HttpMethods.Put, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } } diff --git a/ShipEngineSDK/ShipEngineClient.cs b/ShipEngineSDK/ShipEngineClient.cs index 1194882e..91abb608 100644 --- a/ShipEngineSDK/ShipEngineClient.cs +++ b/ShipEngineSDK/ShipEngineClient.cs @@ -187,11 +187,11 @@ private async Task DeserializedResultOrThrow(HttpResponseMessage response) /// Builds and sends an HTTP Request to the ShipEngine Client, has special logic for handling /// 429 rate limit exceeded errors and subsequent retry logic. /// - /// - /// + /// Type of data to return + /// Http method for the request /// Options for the request - /// - /// + /// Client to use for the request + /// Extra configuration for the request /// Token that can be used to cancel the request /// public virtual Task SendHttpRequestAsync(HttpMethod method, RequestOptions requestOptions, @@ -202,12 +202,12 @@ public virtual Task SendHttpRequestAsync(HttpMethod method, RequestOptions /// Builds and sends an HTTP Request to the ShipEngine Client, has special logic for handling /// 429 rate limit exceeded errors and subsequent retry logic. /// - /// - /// - /// - /// - /// - /// + /// Type of data to return + /// Http method for the request + /// Path of the request + /// Content to send to the server, already serialized to JSON + /// Client to use for the request + /// Extra configuration for the request /// public virtual Task SendHttpRequestAsync(HttpMethod method, string path, string? jsonContent, HttpClient client, Config config) => SendHttpRequestAsync(method, path, jsonContent, client, config, CancellationToken); @@ -216,21 +216,33 @@ public virtual Task SendHttpRequestAsync(HttpMethod method, string path, s /// Builds and sends an HTTP Request to the ShipEngine Client, has special logic for handling /// 429 rate limit exceeded errors and subsequent retry logic. /// - /// - /// - /// - /// - /// - /// + /// Type of data to return + /// Http method for the request + /// Path of the request + /// Content to send to the server, already serialized to JSON + /// Client to use for the request + /// Extra configuration for the request /// Token that can be used to cancel the request /// public virtual async Task SendHttpRequestAsync(HttpMethod method, string path, string? jsonContent, HttpClient client, Config config, CancellationToken cancellationToken) { - (T data, HttpResponseMessage message) = await GetHttpResponse(method, path, jsonContent, client, config, cancellationToken); - return data; + var response = await GetHttpResponse(method, path, jsonContent, client, config, cancellationToken); + return response.Data; } - public async Task<(T, HttpResponseMessage)> GetHttpResponse(HttpMethod method, string path, string? jsonContent, HttpClient client, Config config, + /// + /// Builds and sends an HTTP Request to the ShipEngine Client, has special logic for handling + /// 429 rate limit exceeded errors and subsequent retry logic. + /// + /// Type of data to return + /// Http method for the request + /// Path of the request + /// Content to send to the server, already serialized to JSON + /// Client to use for the request + /// Extra configuration for the request + /// Token that can be used to cancel the request + /// + public async Task> GetHttpResponse(HttpMethod method, string path, string? jsonContent, HttpClient client, Config config, CancellationToken cancellationToken) { int retry = 0; @@ -246,7 +258,7 @@ public virtual async Task SendHttpRequestAsync(HttpMethod method, string p response = await client.SendAsync(request, cancellationToken); var deserializedResult = await DeserializedResultOrThrow(response); - return (deserializedResult, response); + return new(deserializedResult, response); } catch (ShipEngineException e) { diff --git a/ShipEngineSDK/ShipEngineResponse.cs b/ShipEngineSDK/ShipEngineResponse.cs index 45c4e4d0..23ede6a4 100644 --- a/ShipEngineSDK/ShipEngineResponse.cs +++ b/ShipEngineSDK/ShipEngineResponse.cs @@ -1,18 +1,32 @@ -namespace ShipEngineSDK; - +using System; using System.Collections.Generic; +using System.Linq; using System.Net; +using System.Net.Http; -public class ShipEngineResponse +namespace ShipEngineSDK; + +/// +/// Response from ShipEngine API that includes the data, status code, and headers +/// +/// Type of data returned from the API +/// Deserialized data from the API +/// Response message from the server +public class ShipEngineResponse(T data, HttpResponseMessage message) { - private readonly T _data; - public HttpStatusCode HttpStatus { get; private init; } - public IDictionary Headers { get; private init; } + /// + /// Data returned from the API + /// + public T Data { get; } = data; + + /// + /// Status code of the response + /// + public HttpStatusCode HttpStatus { get; } = message.StatusCode; - public ShipEngineResponse(T data, HttpStatusCode httpStatus, Dictionary headers) - { - _data = data; - HttpStatus = httpStatus; - Headers = headers; - } + /// + /// Headers returned from the API + /// + public IDictionary Headers { get; } = message.Headers + .ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), StringComparer.InvariantCultureIgnoreCase); } \ No newline at end of file diff --git a/generation/templates/api.mustache b/generation/templates/api.mustache index 061319bf..3715e02d 100644 --- a/generation/templates/api.mustache +++ b/generation/templates/api.mustache @@ -238,10 +238,7 @@ namespace {{packageName}}; requestOptions.Operation = "{{classname}}.{{operationId}}"; - var (data, response) = await GetHttpResponse<{{{returnType}}}{{^returnType}}Object{{/returnType}}>(HttpMethods.{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}}, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(), - StringComparer.InvariantCultureIgnoreCase); - return new ShipEngineResponse<{{{returnType}}}{{^returnType}}Object{{/returnType}}>(data, response.StatusCode, headers); + return await GetHttpResponse<{{{returnType}}}{{^returnType}}Object{{/returnType}}>(HttpMethods.{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}}, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken); } {{/operation}}