@@ -54,7 +54,7 @@ def __init__(
5454 self ,
5555 get_orders : GetOrders ,
5656 get_order : GetOrder ,
57- get_order_statuses : GetOrderStatuses , # type: ignore
57+ get_order_statuses : GetOrderStatuses | None = None , # type: ignore
5858 get_opportunity_search_records : GetOpportunitySearchRecords | None = None ,
5959 get_opportunity_search_record : GetOpportunitySearchRecord | None = None ,
6060 get_opportunity_search_record_statuses : GetOpportunitySearchRecordStatuses | None = None ,
@@ -67,18 +67,14 @@ def __init__(
6767 ) -> None :
6868 super ().__init__ (* args , ** kwargs )
6969
70- api_conformances = API_CONFORMANCE .all ()
71- for conformance in conformances :
72- if conformance not in api_conformances :
73- raise ValueError (f"{ conformance } is not a valid API conformance" )
70+ _conformances = set (conformances )
7471
7572 self ._get_orders = get_orders
7673 self ._get_order = get_order
77- self ._get_order_statuses = get_order_statuses
74+ self .__get_order_statuses = get_order_statuses
7875 self .__get_opportunity_search_records = get_opportunity_search_records
7976 self .__get_opportunity_search_record = get_opportunity_search_record
8077 self .__get_opportunity_search_record_statuses = get_opportunity_search_record_statuses
81- self .conformances = conformances
8278 self .name = name
8379 self .openapi_endpoint_name = openapi_endpoint_name
8480 self .docs_endpoint_name = docs_endpoint_name
@@ -132,15 +128,18 @@ def __init__(
132128 tags = ["Orders" ],
133129 )
134130
135- self .add_api_route (
136- "/orders/{order_id}/statuses" ,
137- self .get_order_statuses ,
138- methods = ["GET" ],
139- name = f"{ self .name } :{ LIST_ORDER_STATUSES } " ,
140- tags = ["Orders" ],
141- )
131+ if self .get_order_statuses is not None :
132+ _conformances .add (API_CONFORMANCE .order_statuses )
133+ self .add_api_route (
134+ "/orders/{order_id}/statuses" ,
135+ self .get_order_statuses ,
136+ methods = ["GET" ],
137+ name = f"{ self .name } :{ LIST_ORDER_STATUSES } " ,
138+ tags = ["Orders" ],
139+ )
142140
143- if API_CONFORMANCE .searches_opportunity in conformances :
141+ if self .supports_async_opportunity_search :
142+ _conformances .add (API_CONFORMANCE .searches_opportunity )
144143 self .add_api_route (
145144 "/searches/opportunities" ,
146145 self .get_opportunity_search_records ,
@@ -159,7 +158,8 @@ def __init__(
159158 tags = ["Opportunities" ],
160159 )
161160
162- if API_CONFORMANCE .searches_opportunity_statuses in conformances :
161+ if self .__get_opportunity_search_record_statuses is not None :
162+ _conformances .add (API_CONFORMANCE .searches_opportunity_statuses )
163163 self .add_api_route (
164164 "/searches/opportunities/{search_record_id}/statuses" ,
165165 self .get_opportunity_search_record_statuses ,
@@ -169,6 +169,8 @@ def __init__(
169169 tags = ["Opportunities" ],
170170 )
171171
172+ self .conformances = list (_conformances )
173+
172174 def get_root (self , request : Request ) -> RootResponse :
173175 links = [
174176 Link (
@@ -466,6 +468,12 @@ def opportunity_search_record_self_link(
466468 type = TYPE_JSON ,
467469 )
468470
471+ @property
472+ def _get_order_statuses (self ) -> GetOrderStatuses : # type: ignore
473+ if not self .__get_order_statuses :
474+ raise AttributeError ("Root router does not support order status history" )
475+ return self .__get_order_statuses
476+
469477 @property
470478 def _get_opportunity_search_records (self ) -> GetOpportunitySearchRecords :
471479 if not self .__get_opportunity_search_records :
@@ -481,13 +489,9 @@ def _get_opportunity_search_record(self) -> GetOpportunitySearchRecord:
481489 @property
482490 def _get_opportunity_search_record_statuses (self ) -> GetOpportunitySearchRecordStatuses :
483491 if not self .__get_opportunity_search_record_statuses :
484- raise AttributeError ("Root router does not support async opportunity search" )
492+ raise AttributeError ("Root router does not support async opportunity search status history " )
485493 return self .__get_opportunity_search_record_statuses
486494
487495 @property
488496 def supports_async_opportunity_search (self ) -> bool :
489- return (
490- API_CONFORMANCE .searches_opportunity in self .conformances
491- and self ._get_opportunity_search_records is not None
492- and self ._get_opportunity_search_record is not None
493- )
497+ return self .__get_opportunity_search_records is not None and self .__get_opportunity_search_record is not None
0 commit comments