-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAddressBookClient.cs
More file actions
34 lines (30 loc) · 1.25 KB
/
AddressBookClient.cs
File metadata and controls
34 lines (30 loc) · 1.25 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
using TypedRest.Endpoints;
using TypedRest.Endpoints.Generic;
using TypedRest.Serializers;
namespace AddressBook;
/// <summary>
/// Provides a type-safe client for the Address Book REST API.
/// </summary>
public class AddressBookClient : EntryEndpoint, IAddressBookClient
{
/// <summary>
/// Creates a new Address Book Client.
/// </summary>
/// <param name="uri">The base URI of the Address Book API.</param>
public AddressBookClient(Uri uri)
: base(uri, serializer: new SystemTextJsonSerializer())
{}
/// <summary>
/// Creates a new Address Book Client using a custom <see cref="HttpClient"/>. This is usually used for testing.
/// </summary>
/// <param name="httpClient">The HTTP client used to communicate with the remote element.</param>
/// <param name="uri">The base URI of the Address Book API.</param>
public AddressBookClient(HttpClient httpClient, Uri uri)
: base(httpClient, uri, serializer: new SystemTextJsonSerializer())
{}
/// <summary>
/// A collection of contacts in an address book.
/// </summary>
public ICollectionEndpoint<Contact, ContactElementEndpoint> Contacts
=> new CollectionEndpoint<Contact, ContactElementEndpoint>(this, relativeUri: "contacts");
}