Queries
BaseQuery
- class q2_cores.CorePro.queries.base_query.CoreProBaseQuery(logger, url_path, verb, body=None, mock_response=None, mock_error_code=None)[source]
Bases:
BaseQuery
Generic call builder for CorePro as per the docs: https://docs.corepro.io/api/overview
- Parameters:
logger (
Logger
) – Reference to calling request’s logger (self.logger in your extension)url_path (
str
) – URL according to CorePro docs (/customer/get/id for instance)
- Verb:
GET, POST, PUT, etc.
- Body:
(Optional) JSON payload
- Mock_response:
(Optional) The response to emulate what CorePro would respond with
- Mock_error_code:
(Optional) If provided, will return an error state for the mock
- build()[source]
build Build passthru string
Builds the adapter passthru xml string. For POST passthru requests, request body is json serialized and dumped as PassThru element content. Expected PassThru format: POST: <PassThru urlpath=”/rest/path” method=”POST”>{ “json”:”body” }</PassThru> GET: <PassThru urlpath=”/rest/path” method=”GET”/>
- Return type:
str
- Returns:
Passthru xml string
- mock_response()[source]
When run in DEBUG mode, the SDK will intercept calls before they go to HQ’s AdapterPassThru endpoint.
In these cases, the response will be whatever is returned from this function.
- async execute_no_bridge(base_url, api_key, api_secret, debug=True)[source]
Unlike most cores, CorePro does not need a Q2Bridge as a translation layer. To use the Bridge variant, look at .execute
- simulate_hq_response(result_str)[source]
The rest of the SDK framework expects an HQ shaped response. This coerces the raw response from CorePro into an HQ shape.
- async execute(hq_credentials=None, debug=True, zone_context=None)[source]
Call Core with self.raw_query and save the response in self.core_response. If in debug mode, return mocked response instead of actually calling the core.
- Parameters:
hq_credentials (
Optional
[HqCredentials
]) – If provided, uses an existing HQ Sessiondebug (
bool
) – Return a mocked response
ErrorCodes
All CorePro error codes we know about
GetCustomerByEmailQuery
- class q2_cores.CorePro.queries.get_customer_by_email_query.GetCustomerByEmailQuery(logger, customer_email)[source]
Bases:
CoreProBaseQuery
GET /customer/getByEmail/{customer_email}
Generic call builder for CorePro as per the docs: https://docs.corepro.io/api/overview
- Parameters:
logger (
Logger
) – Reference to calling request’s logger (self.logger in your extension)url_path – URL according to CorePro docs (/customer/get/id for instance)
- Verb:
GET, POST, PUT, etc.
- Body:
(Optional) JSON payload
- Mock_response:
(Optional) The response to emulate what CorePro would respond with
- Mock_error_code:
(Optional) If provided, will return an error state for the mock
GetCustomerQuery
- class q2_cores.CorePro.queries.get_customer_query.GetCustomerQuery(logger, customer_id)[source]
Bases:
CoreProBaseQuery
GET /customer/get/{customer_id}
Generic call builder for CorePro as per the docs: https://docs.corepro.io/api/overview
- Parameters:
logger (
Logger
) – Reference to calling request’s logger (self.logger in your extension)url_path – URL according to CorePro docs (/customer/get/id for instance)
- Verb:
GET, POST, PUT, etc.
- Body:
(Optional) JSON payload
- Mock_response:
(Optional) The response to emulate what CorePro would respond with
- Mock_error_code:
(Optional) If provided, will return an error state for the mock
MockResponses
UpdateDemographicInfoQuery
- class q2_cores.CorePro.queries.update_demographic_info_query.UpdateDemographicInfoQuery(logger, customer_id, demographic_info)[source]
Bases:
CoreProBaseQuery
POST /customer/update
Generic call builder for CorePro as per the docs: https://docs.corepro.io/api/overview
- Parameters:
logger (
Logger
) – Reference to calling request’s logger (self.logger in your extension)url_path – URL according to CorePro docs (/customer/get/id for instance)
- Verb:
GET, POST, PUT, etc.
- Body:
(Optional) JSON payload
- Mock_response:
(Optional) The response to emulate what CorePro would respond with
- Mock_error_code:
(Optional) If provided, will return an error state for the mock