-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathAddressesApi.cs
More file actions
162 lines (138 loc) · 13.4 KB
/
Copy pathAddressesApi.cs
File metadata and controls
162 lines (138 loc) · 13.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// <auto-generated />
// DO NOT MODIFY THIS FILE
// Changes can be made in a corresponding partial file, or by changing
// the template in <root>/generation/templates and generating the class again.
using ShipEngineSDK.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Mime;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
namespace ShipEngineSDK;
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
public partial interface IShipEngine
{
/// <summary>
/// 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.
/// </summary>
/// <exception cref="System.ArgumentNullException">Thrown when required argument is null</exception>
/// <exception cref="ShipEngineSDK.ShipEngineException">Thrown when fails to make API call</exception>
/// <param name="parseAddressRequestBody">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. </param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task of ShipEngineResponse (ParseAddressResponseBody)</returns>
Task<ShipEngineResponse<ParseAddressResponseBody>> ParseAddress(ParseAddressRequestBody parseAddressRequestBody, CancellationToken cancellationToken = default);
/// <summary>
/// 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.
/// </summary>
/// <exception cref="System.ArgumentNullException">Thrown when required argument is null</exception>
/// <exception cref="ShipEngineSDK.ShipEngineException">Thrown when fails to make API call</exception>
/// <param name="methodClient">HttpClient to use for the request</param>
/// <param name="parseAddressRequestBody">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. </param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task of ShipEngineResponse (ParseAddressResponseBody)</returns>
Task<ShipEngineResponse<ParseAddressResponseBody>> ParseAddress(HttpClient methodClient, ParseAddressRequestBody parseAddressRequestBody, CancellationToken cancellationToken = default);
/// <summary>
/// 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.
/// </summary>
/// <exception cref="System.ArgumentNullException">Thrown when required argument is null</exception>
/// <exception cref="ShipEngineSDK.ShipEngineException">Thrown when fails to make API call</exception>
/// <param name="addressToValidate"></param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task of ShipEngineResponse (List<AddressValidationResult>)</returns>
Task<ShipEngineResponse<List<AddressValidationResult>>> ValidateAddress(List<AddressToValidate> addressToValidate, CancellationToken cancellationToken = default);
/// <summary>
/// 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.
/// </summary>
/// <exception cref="System.ArgumentNullException">Thrown when required argument is null</exception>
/// <exception cref="ShipEngineSDK.ShipEngineException">Thrown when fails to make API call</exception>
/// <param name="methodClient">HttpClient to use for the request</param>
/// <param name="addressToValidate"></param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task of ShipEngineResponse (List<AddressValidationResult>)</returns>
Task<ShipEngineResponse<List<AddressValidationResult>>> ValidateAddress(HttpClient methodClient, List<AddressToValidate> addressToValidate, CancellationToken cancellationToken = default);
}
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
public partial class ShipEngine
{
/// <summary>
/// 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.
/// </summary>
/// <exception cref="System.ArgumentNullException">Thrown when required argument is null</exception>
/// <exception cref="ShipEngineSDK.ShipEngineException">Thrown when fails to make API call</exception>
/// <param name="parseAddressRequestBody">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. </param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task of ShipEngineResponse (ParseAddressResponseBody)</returns>
public Task<ShipEngineResponse<ParseAddressResponseBody>> ParseAddress(ParseAddressRequestBody parseAddressRequestBody, CancellationToken cancellationToken = default)
{
return ParseAddress(_client, parseAddressRequestBody, cancellationToken);
}
/// <summary>
/// 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.
/// </summary>
/// <exception cref="System.ArgumentNullException">Thrown when required argument is null</exception>
/// <exception cref="ShipEngineSDK.ShipEngineException">Thrown when fails to make API call</exception>
/// <param name="methodClient">HttpClient to use for the request</param>
/// <param name="parseAddressRequestBody">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. </param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task of ShipEngineResponse (ParseAddressResponseBody)</returns>
public async Task<ShipEngineResponse<ParseAddressResponseBody>> ParseAddress(HttpClient methodClient, ParseAddressRequestBody parseAddressRequestBody, CancellationToken cancellationToken = default)
{
// verify the required parameter 'parseAddressRequestBody' is set
if (parseAddressRequestBody == null)
{
throw new ArgumentNullException(nameof(parseAddressRequestBody));
}
RequestOptions requestOptions = new("/v1/addresses/recognize");
requestOptions.Data = JsonSerializer.Serialize(parseAddressRequestBody, JsonSerializerOptions);
requestOptions.Operation = "AddressesApi.ParseAddress";
var (data, response) = await GetHttpResponse<ParseAddressResponseBody>(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<ParseAddressResponseBody>(data, response.StatusCode, headers);
}
/// <summary>
/// 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.
/// </summary>
/// <exception cref="System.ArgumentNullException">Thrown when required argument is null</exception>
/// <exception cref="ShipEngineSDK.ShipEngineException">Thrown when fails to make API call</exception>
/// <param name="addressToValidate"></param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task of ShipEngineResponse (List<AddressValidationResult>)</returns>
public Task<ShipEngineResponse<List<AddressValidationResult>>> ValidateAddress(List<AddressToValidate> addressToValidate, CancellationToken cancellationToken = default)
{
return ValidateAddress(_client, addressToValidate, cancellationToken);
}
/// <summary>
/// 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.
/// </summary>
/// <exception cref="System.ArgumentNullException">Thrown when required argument is null</exception>
/// <exception cref="ShipEngineSDK.ShipEngineException">Thrown when fails to make API call</exception>
/// <param name="methodClient">HttpClient to use for the request</param>
/// <param name="addressToValidate"></param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns>Task of ShipEngineResponse (List<AddressValidationResult>)</returns>
public async Task<ShipEngineResponse<List<AddressValidationResult>>> ValidateAddress(HttpClient methodClient, List<AddressToValidate> addressToValidate, CancellationToken cancellationToken = default)
{
// verify the required parameter 'addressToValidate' is set
if (addressToValidate == null)
{
throw new ArgumentNullException(nameof(addressToValidate));
}
RequestOptions requestOptions = new("/v1/addresses/validate");
requestOptions.Data = JsonSerializer.Serialize(addressToValidate, JsonSerializerOptions);
requestOptions.Operation = "AddressesApi.ValidateAddress";
var (data, response) = await GetHttpResponse<List<AddressValidationResult>>(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<List<AddressValidationResult>>(data, response.StatusCode, headers);
}
}