Create buyerv1.0.0 · JSON Schema
Creates a Buyer profile for the authenticated customer from the supplied address.
1. Register a Buyer Shipping Profile
An authenticated customer creates their Buyer profile with a shipping address before placing their first order.
Payload details
street: Required street address line.city: Required city name.province: Required province or state name.
Example payload
{ "street": "42 Nguyen Hue Blvd", "city": "Ho Chi Minh City", "province": "Ho Chi Minh"}Using this example
Returns 201 Created with the created Buyer JSON payload and Location header, persisted idempotently for the x-request-id key.
using BookWorm.Chassis.Utilities.Configurations;using BookWorm.Constants.Aspire;using Refit;
public interface IOrderApiClient{ [Post("/api/v1/buyers")] Task<BuyerResponse> CreateBuyerAsync( [Body] CreateBuyerRequest request, [Header("x-request-id")] Guid requestId, CancellationToken cancellationToken = default );}
public sealed record CreateBuyerRequest(string Street, string City, string Province);
// DI registration following BookWorm.Chassis Refit patternbuilder.Services .AddRefitGeneratedClient<IOrderApiClient>(settings, Services.Ordering) .ConfigureHttpClient(client => client.BaseAddress = new($"https+http://{Services.Ordering}")) .ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler { PooledConnectionLifetime = TimeSpan.FromMinutes(5) } );
// Typed invocationvar buyer = await orderApiClient.CreateBuyerAsync( new("42 Nguyen Hue Blvd", "Ho Chi Minh City", "Ho Chi Minh"), Guid.CreateVersion7(), cancellationToken);import buyersApiClient from "@workspace/api-client/ordering/buyers";import useCreateBuyer from "@workspace/api-hooks/ordering/buyers/useCreateBuyer";
// 1. Direct @workspace/api-client (Axios) call (sets x-request-id automatically)const buyer = await buyersApiClient.create({ street: "42 Nguyen Hue Blvd", city: "Ho Chi Minh City", province: "Ho Chi Minh",});
// 2. React / TanStack Query hook (@workspace/api-hooks)const { mutate: createBuyer, isPending } = useCreateBuyer({ onSuccess: (created) => { console.log(`Created buyer ${created.id}`); },});
createBuyer({ street: "42 Nguyen Hue Blvd", city: "Ho Chi Minh City", province: "Ho Chi Minh",});1{
2 "$schema": "https://json-schema.org/draft/2020-12/schema",
3 "title": "CreateBuyerCommand",
4 "description": "Address fields required to create a Buyer profile.",
5 "type": "object",
6 "required": ["street", "city", "province"],
7 "properties": {
8 "street": {
9 "type": "string"
10 },
11 "city": {
12 "type": "string"
13 },
14 "province": {
15 "type": "string"
16 }
17 }
18}
19