Transforms requests and responses between UCP and ACP protocol formats.
Internal Format
Bazaar uses UCP as its internal/canonical format. Handlers always receive and return data in UCP format. This module transforms ACP requests into UCP format before they reach the handler, and transforms UCP responses back to ACP format before sending to ACP clients.
ACP Request → transform_request/2 → Handler (UCP) → transform_response/2 → ACP Response
UCP Request → Handler (UCP) → UCP Response (no transformation)Transformations
This module handles:
- Address fields (street_address ↔ line_one, etc.)
- Status values (incomplete ↔ not_ready_for_payment, etc.)
- Item/line_item structure differences
Address Field Mappings
| UCP (internal) | ACP |
|---|---|
street_address | line_one |
extended_address | line_two |
address_locality | city |
address_region | state |
address_country | country |
postal_code | postal_code (unchanged) |
Item Mappings
| UCP (internal) | ACP |
|---|---|
items | line_items |
sku | product.id |
name | product.name |
price | base_amount |
Summary
Functions
Transforms address fields between UCP and ACP formats.
Transforms an incoming request from ACP format to internal (UCP) format.
Transforms an outgoing response from internal (UCP) format to protocol format.
Functions
Transforms address fields between UCP and ACP formats.
Direction
:acp_to_ucp- Transforms ACP fields (line_one, city) to UCP fields (street_address, address_locality):ucp_to_acp- Transforms UCP fields to ACP fields
@spec transform_request(map(), Bazaar.Protocol.t()) :: {:ok, map()}
Transforms an incoming request from ACP format to internal (UCP) format.
For :ucp protocol, returns the request unchanged.
For :acp protocol, transforms address fields and line_items.
@spec transform_response(map(), Bazaar.Protocol.t()) :: {:ok, map()}
Transforms an outgoing response from internal (UCP) format to protocol format.
For :ucp protocol, returns the response unchanged.
For :acp protocol, transforms status, address fields, and items.