3 min read
Ocapi
Poq.Sfcc.Ocapi
namespace provides Contracts, Clients and Extensions that allow quick usage of SFCC OCAPI Shop API with support of customizations.
Contracts
Contracts can be found in namespace Poq.Sfcc.Ocapi.Contract
. The contracts provided cover most of the relevant OCAPI Shop Rest API. Customizations in Sfcc are handled by extending provided Contract classes and using descendants with provided Clients. Detail reference and usage of all available classes and fields could be found in OCAPI documentation
Clients
Each Client covers a Resources available in OCAPI Shop API and can be used to call OCAPI Shop API. Interfaces for client are available in namespace Poq.Sfcc.Ocapi.Interfaces
List of Available Clients
BasketClient
CategoryClient
CustomerClient
OrderClient
ProductResourceClient
ProductSearchClient
PromotionsClient
SessionsClient
StoresClient
SearchSuggestionClient
All clients implement strict interfaces that could be found in
Poq.Sfcc.Ocapi.Interfaces
Supporting Different locales
Client services use the default locale that has been defined in configuration for all requests that are sent to OCAPI.
new ProductsSearchClient(s.GetRequiredService<IHttpClientFactory>(), new SfccConfiguration(){ BaseUrl = "your_sfcc_instance_base", ClientId = "your_client_id", Locale = "locale_to_use_with_all_requests_to_ocapi"});
ClientExtensions
Client Extensions build on top of available clients implementations adding handy features to speed up development with OCAPI.
Coverage
The following endpoints available in Sfcc OCAPI API are covered in Sfcc SDK Clients.
Shop Baskets (Shop API 24.5)
Create new basket /baskets (POST)
Get basket /baskets/{basket_id} (GET)
Update basket /baskets/{basket_id} (PATCH)
Remove a basket /baskets/{basket_id} (DELETE)
Add new items to basket /baskets/{basket_id}/items (POST)
Update item in basket /baskets/{basket_id}/items/{item_id} (PATCH)
Remove item from basket /baskets/{basket_id}/items/{item_id} (DELETE)
Create shipment /baskets/{basket_id}/shipments (POST)
Update shipment /baskets/{basket_id}/shipments/{shipment_id} (PATCH)
Delete shipment /baskets/{basket_id}/shipments/{shipment_id} (DELETE)
Set billing address baskets/{basket_id}/billing_address (PUT)
Add coupon to basket /baskets/{basket_id}/coupons (POST)
Remove coupon /baskets/{basket_id}/coupons/{coupon_item_id} (DELETE)
Add gift certificate /baskets/{basket_id}/gift_certificate_items (POST)
Remove gift certificate /baskets/{basket_id}/gift_certificate_items/{gift_certificate_item_id} (DELETE)
Update gift certificate /baskets/{basket_id}/gift_certificate_items/{gift_certificate_item_id} (PATCH)
Set shipping method /baskets/{basket_id}/shipments/{shipment_id}/shipping_method (PUT)
Get shipping methods /baskets/{basket_id}/shipments/{shipment_id}/shipping_methods (GET)
Add payment instrument /baskets/{basket_id}/payment_instruments (POST)
Update payment instrument /baskets/{basket_id}/payment_instruments/{payment_instrument_id} (PATCH)
Delete payment instrument /baskets/{basket_id}/payment_instruments/{payment_instrument_id} (DELETE)
Get payment methods /baskets/{basket_id}/payment_methods (GET)
Update basket customer /baskets/{basket_id}/customer (PUT)
Categories resource Categories resource (Shop API 24.5)
Customer resource Customers resource (Shop API 24.5)
Get customer /customers/{customer_id}
Register customer /customers
Update customer /customers/{customer_id}
Invalidate JWT /customers/auth (DELETE)
Obtain JWT /customers/auth (POST) - Types: credentials, guest, session, refresh
Retrieve customer basket /customers/{customer_id}/baskets (GET)
Get customer addresses /customers/{customer_id}/addresses (GET)
Get customer address /customers/{customer_id}/addresses/{address_name}(GET)
Create customer address /customers/{customer_id}/addresses (POST)
Update customer address /customers/{customer_id}/addresses/{address_name} (POST)
Delete customer address /customers/{customer_id}/addresses/{address_name} (DELETE)
Get payment instruments /customers/{customer_id}/payment_instruments (GET)
Add payment instrument /customers/{customer_id}/payment_instruments (POST)
Delete payment instrument /customers/{customer_id}/payment_instruments/{payment_instrument_id} (DELETE)
Get customer product lists /customers/{customer_id}/product_lists (GET)
Get customer product list /customers/{customer_id}/product_lists/{list_id} (GET)
Update customer product list /customers/{customer_id}/product_lists/{list_id} (GET)
Delete customer product list /customers/{customer_id}/product_lists/{list_id} (DELETE)
Create customer product list /customers/{customer_id}/product_lists (GET)
Get product list items /customers/{customer_id}/product_lists/{list_id}/items (GET)
Add item to customer product list /customers/{customer_id}/product_lists/{list_id}/items (POST)
Get item from product list /customers/{customer_id}/product_lists/{list_id}/items/{item_id} (GET)
Delete item from product list /customers/{customer_id}/product_lists/{list_id}/items/{item_id} (DELETE)
Update item in product list /customers/{customer_id}/product_lists/{list_id}/items/{item_id} (PATCH)
Get Customer orders /customers/{customer_id}/orders (GET)
Password reset /customers/password_reset (POST)
Update customer password /customers/{customer_id}/password (PUT)
Orders resource Orders resource (Shop API 24.5)
Submit an order from basket /orders (POST)
Get payment methods /orders/{order_no}/payment_methods (GET)
Delete payment instrument /orders/{order_no}/payment_instruments/{payment_instrument_id} (DELETE)
Update payment instrument /orders/{order_no}/payment_instruments/{payment_instrument_id}?skip_authorization={Boolean} (PATCH)
Add payment instrument /orders/{order_no}/payment_instruments?skip_authorization={Boolean} (POST)
Products resource Products resource (Shop API 24.5)
Get products /products/({id},...,{id}) (GET)
Get product /products/{id} (GET)
Get product availability /products/{id}/availability (GET)
ProductSearch resource ProductSearch resource (Shop API 24.5)
Sessions resource Sessions resource (Shop API 24.5)
Promotions resource Promotions resource (Shop API 24.5)
Get promotions by filter criteria /promotions (GET)
Stores resource Stores resource (Shop API 24.5)
Get nearest stores /stores (GET)
Get multiple stores by ids /stores/({id},...,{id}) (GET)
Get store /stores/{id} (GET)