3434from stapi_fastapi .models .shared import Link
3535from stapi_fastapi .responses import GeoJSONResponse
3636from stapi_fastapi .routers .product_router import ProductRouter
37+ from stapi_fastapi .routers .route_names import (
38+ CONFORMANCE ,
39+ GET_OPPORTUNITY_SEARCH_RECORD ,
40+ GET_ORDER ,
41+ LIST_OPPORTUNITY_SEARCH_RECORDS ,
42+ LIST_ORDER_STATUSES ,
43+ LIST_ORDERS ,
44+ LIST_PRODUCTS ,
45+ ROOT ,
46+ )
3747
3848logger = logging .getLogger (__name__ )
3949
@@ -84,31 +94,31 @@ def __init__(
8494 "/" ,
8595 self .get_root ,
8696 methods = ["GET" ],
87- name = f"{ self .name } :root " ,
97+ name = f"{ self .name } :{ ROOT } " ,
8898 tags = ["Root" ],
8999 )
90100
91101 self .add_api_route (
92102 "/conformance" ,
93103 self .get_conformance ,
94104 methods = ["GET" ],
95- name = f"{ self .name } :conformance " ,
105+ name = f"{ self .name } :{ CONFORMANCE } " ,
96106 tags = ["Conformance" ],
97107 )
98108
99109 self .add_api_route (
100110 "/products" ,
101111 self .get_products ,
102112 methods = ["GET" ],
103- name = f"{ self .name } :list-products " ,
113+ name = f"{ self .name } :{ LIST_PRODUCTS } " ,
104114 tags = ["Products" ],
105115 )
106116
107117 self .add_api_route (
108118 "/orders" ,
109119 self .get_orders ,
110120 methods = ["GET" ],
111- name = f"{ self .name } :list-orders " ,
121+ name = f"{ self .name } :{ LIST_ORDERS } " ,
112122 response_class = GeoJSONResponse ,
113123 tags = ["Orders" ],
114124 )
@@ -117,7 +127,7 @@ def __init__(
117127 "/orders/{order_id}" ,
118128 self .get_order ,
119129 methods = ["GET" ],
120- name = f"{ self .name } :get-order " ,
130+ name = f"{ self .name } :{ GET_ORDER } " ,
121131 response_class = GeoJSONResponse ,
122132 tags = ["Orders" ],
123133 )
@@ -126,7 +136,7 @@ def __init__(
126136 "/orders/{order_id}/statuses" ,
127137 self .get_order_statuses ,
128138 methods = ["GET" ],
129- name = f"{ self .name } :list-order-statuses " ,
139+ name = f"{ self .name } :{ LIST_ORDER_STATUSES } " ,
130140 tags = ["Orders" ],
131141 )
132142
@@ -135,7 +145,7 @@ def __init__(
135145 "/searches/opportunities" ,
136146 self .get_opportunity_search_records ,
137147 methods = ["GET" ],
138- name = f"{ self .name } :list-opportunity-search-records " ,
148+ name = f"{ self .name } :{ LIST_OPPORTUNITY_SEARCH_RECORDS } " ,
139149 summary = "List all Opportunity Search Records" ,
140150 tags = ["Opportunities" ],
141151 )
@@ -144,15 +154,15 @@ def __init__(
144154 "/searches/opportunities/{search_record_id}" ,
145155 self .get_opportunity_search_record ,
146156 methods = ["GET" ],
147- name = f"{ self .name } :get-opportunity-search-record " ,
157+ name = f"{ self .name } :{ GET_OPPORTUNITY_SEARCH_RECORD } " ,
148158 summary = "Get an Opportunity Search Record by ID" ,
149159 tags = ["Opportunities" ],
150160 )
151161
152162 def get_root (self , request : Request ) -> RootResponse :
153163 links = [
154164 Link (
155- href = str (request .url_for (f"{ self .name } :root " )),
165+ href = str (request .url_for (f"{ self .name } :{ ROOT } " )),
156166 rel = "self" ,
157167 type = TYPE_JSON ,
158168 ),
@@ -167,17 +177,17 @@ def get_root(self, request: Request) -> RootResponse:
167177 type = "text/html" ,
168178 ),
169179 Link (
170- href = str (request .url_for (f"{ self .name } :conformance " )),
180+ href = str (request .url_for (f"{ self .name } :{ CONFORMANCE } " )),
171181 rel = "conformance" ,
172182 type = TYPE_JSON ,
173183 ),
174184 Link (
175- href = str (request .url_for (f"{ self .name } :list-products " )),
185+ href = str (request .url_for (f"{ self .name } :{ LIST_PRODUCTS } " )),
176186 rel = "products" ,
177187 type = TYPE_JSON ,
178188 ),
179189 Link (
180- href = str (request .url_for (f"{ self .name } :list-orders " )),
190+ href = str (request .url_for (f"{ self .name } :{ LIST_ORDERS } " )),
181191 rel = "orders" ,
182192 type = TYPE_GEOJSON ,
183193 ),
@@ -187,7 +197,9 @@ def get_root(self, request: Request) -> RootResponse:
187197 links .append (
188198 Link (
189199 href = str (
190- request .url_for (f"{ self .name } :list-opportunity-search-records" )
200+ request .url_for (
201+ f"{ self .name } :{ LIST_OPPORTUNITY_SEARCH_RECORDS } "
202+ )
191203 ),
192204 rel = "opportunity-search-records" ,
193205 type = TYPE_JSON ,
@@ -220,7 +232,7 @@ def get_products(
220232 ids = self .product_ids [start :end ]
221233 links = [
222234 Link (
223- href = str (request .url_for (f"{ self .name } :list-products " )),
235+ href = str (request .url_for (f"{ self .name } :{ LIST_PRODUCTS } " )),
224236 rel = "self" ,
225237 type = TYPE_JSON ,
226238 ),
@@ -327,10 +339,10 @@ def add_product(self, product: Product, *args, **kwargs) -> None:
327339 self .product_ids = [* self .product_routers .keys ()]
328340
329341 def generate_order_href (self , request : Request , order_id : str ) -> URL :
330- return request .url_for (f"{ self .name } :get-order " , order_id = order_id )
342+ return request .url_for (f"{ self .name } :{ GET_ORDER } " , order_id = order_id )
331343
332344 def generate_order_statuses_href (self , request : Request , order_id : str ) -> URL :
333- return request .url_for (f"{ self .name } :list-order-statuses " , order_id = order_id )
345+ return request .url_for (f"{ self .name } :{ LIST_ORDER_STATUSES } " , order_id = order_id )
334346
335347 def order_links (self , order : Order , request : Request ) -> list [Link ]:
336348 return [
@@ -350,7 +362,7 @@ def order_statuses_link(self, request: Request, order_id: str):
350362 return Link (
351363 href = str (
352364 request .url_for (
353- f"{ self .name } :list-order-statuses " ,
365+ f"{ self .name } :{ LIST_ORDER_STATUSES } " ,
354366 order_id = order_id ,
355367 )
356368 ),
@@ -428,7 +440,7 @@ def generate_opportunity_search_record_href(
428440 self , request : Request , search_record_id : str
429441 ) -> URL :
430442 return request .url_for (
431- f"{ self .name } :get-opportunity-search-record " ,
443+ f"{ self .name } :{ GET_OPPORTUNITY_SEARCH_RECORD } " ,
432444 search_record_id = search_record_id ,
433445 )
434446
0 commit comments