Edit Order Notification Big Query Code¶
Bigquery Customer Notification Gateway¶
-
class
bigquery.bigquery_customer_notification_gateway.BigQueryCustomerNotificationGateway(client, application_dependencies)[source]¶ -
__init__(client, application_dependencies)[source]¶ Class to manage the big query executions for edit order notifications Sets the client variable for use within the class
- Parameters
client (google.cloud.bigquery.client.Client) – Initialised Bigquery Client Object
application_dependencies (util.application_dependencies.ApplicationDependencies) – Application dependency object used for DI
-
get_all_customers_that_have_deliveries_tomorrow()[source]¶ Method to get the json object from BigQuery and load it into memory as json object
- Returns
All returned data from the BigQuery table (orderid and retailerCustomerid) in a list
- Return type
list
Example
json list returned example:
[{'orderId': '1937251515984', 'retailerCustomerId': '1005971340'}, {'orderId': '1937251515984', 'retailerCustomerId': '1005971340'}, {'orderId': '1608541365787', 'retailerCustomerId': '1001022062'}, {'orderId': '1943775911778', 'retailerCustomerId': '1002105834'}]
- Raises
BigQueryError – If the client experiences an error when calling Google BigQuery
BigQueryNoItemsFoundError – If the request to BigQuery returns no items
-
Bigquery Edit Order Report Gateway¶
-
class
bigquery.bigquery_edit_order_report_gateway.BigQueryEditOrderReportGateway(client, application_dependencies)[source]¶ -
__init__(client, application_dependencies)[source]¶ Class to manage the big query executions for edit order notifications Sets the client variable for use within the class
- Parameters
client (google.cloud.bigquery.client.Client) – Initialised Bigquery Client Object
application_dependencies (util.application_dependencies.ApplicationDependencies) – Application dependency obj
-
post_report_of_notifications(report_of_notification_process)[source]¶ This method will send the report generated from the notification process to bigquery
- Parameters
report_of_notification_process (list) – List of dicts, where keys must match the table schema fields
- Returns
True if the transaction completed successfully in and was added to big query
- Return type
bool
- Raises
BigQueryTableNotFoundError – If the report table name could not be found using big query client
BigQueryRowsNotSentError – If the rows to add into the notification report big query table were not inserted
Examples
Example report_of_notification_process arg:
[{"OrderId": "123456789", "RetailerCustomerId": "12345", "Sms": True, "Email": True, "NotificationStatus": "Successfully sent communications", "Timestamp": "2020-02-03 13:50:53"}, {"OrderId": "246835791", "RetailerCustomerId": "24680", "Sms": False, "Email": True, "NotificationStatus": "Failed to send SMS", "Timestamp": "2020-02-03 13:50:59"}]
-