99import asyncio
1010import os
1111
12- # TODO: Uncomment after implementation
13- # from rencom import AsyncRencomClient
12+ from rencom import AsyncRencomClient
1413
1514
1615async def main ():
@@ -20,42 +19,39 @@ async def main():
2019 print ("Error: RENCOM_API_KEY environment variable not set" )
2120 return
2221
23- # TODO: Uncomment after implementation
24- # async with AsyncRencomClient(api_key=api_key) as client:
25- # # Search for retail merchants with checkout capability
26- # print("Searching for retail merchants...")
27- # merchants = await client.ucp.merchants.search(
28- # capabilities=["dev.ucp.shopping.checkout"],
29- # industry="retail",
30- # limit=5
31- # )
32- #
33- # print(f"\nFound {len(merchants.results)} merchants:")
34- # for merchant in merchants.results:
35- # print(f"\n{merchant.name} ({merchant.domain})")
36- # print(f" Industry: {merchant.industry}")
37- # print(f" Region: {merchant.region}")
38- # print(f" Capabilities: {', '.join(merchant.capabilities)}")
39- #
40- # # Search for products
41- # print("\n\nSearching for laptops under $1500...")
42- # products = await client.ucp.products.search(
43- # "laptop",
44- # price_max=150000, # $1500 in cents
45- # category="electronics",
46- # condition="new",
47- # limit=10
48- # )
49- #
50- # print(f"\nFound {len(products.results)} products:")
51- # for product in products.results:
52- # price = product.price_cents / 100
53- # print(f"\n{product.name}")
54- # print(f" Price: ${price:.2f}")
55- # print(f" Merchant: {product.merchant_domain}")
56- # print(f" Brand: {product.brand}")
57-
58- print ("TODO: Implement after client is ready" )
22+ async with AsyncRencomClient (api_key = api_key ) as client :
23+ # Search for retail merchants with checkout capability
24+ print ("Searching for retail merchants..." )
25+ merchants = await client .ucp .merchants .search (
26+ capabilities = ["dev.ucp.shopping.checkout" ], industry = "retail" , limit = 5
27+ )
28+
29+ print (f"\n Found { merchants .total } merchants (showing { len (merchants .merchants )} ):" )
30+ for merchant in merchants .merchants :
31+ print (f"\n { merchant .name } ({ merchant .domain } )" )
32+ print (f" Industry: { merchant .industry } " )
33+ print (f" Region: { merchant .region } " )
34+ print (f" Capabilities: { ', ' .join (merchant .capabilities )} " )
35+
36+ # Search for products
37+ print ("\n \n Searching for laptops under $1500..." )
38+ products = await client .ucp .products .search (
39+ "laptop" ,
40+ price_max = 150000 , # $1500 in cents
41+ category = "electronics" ,
42+ condition = "new" ,
43+ limit = 10 ,
44+ )
45+
46+ print (f"\n Found { products .total } products (showing { len (products .products )} ):" )
47+ for product in products .products :
48+ if product .price :
49+ price = product .price .amount / 100
50+ print (f"\n { product .title } " )
51+ print (f" Price: ${ price :.2f} " )
52+ print (f" Merchant: { product .merchant_domain } " )
53+ if product .brand :
54+ print (f" Brand: { product .brand } " )
5955
6056
6157if __name__ == "__main__" :
0 commit comments