cc-py-commons 0.5.34__tar.gz → 0.5.36__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/PKG-INFO +1 -1
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/config/c4_account_settings.py +1 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/config/env.py +3 -0
- cc_py_commons-0.5.36/cc_py_commons/config/web_socket_action.py +3 -0
- cc_py_commons-0.5.36/cc_py_commons/services/web_socket/send_notification.py +38 -0
- cc_py_commons-0.5.36/cc_py_commons/tests/test_web_socket_send_notification.py +39 -0
- cc_py_commons-0.5.36/cc_py_commons/utils/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons.egg-info/PKG-INFO +1 -1
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons.egg-info/SOURCES.txt +4 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/setup.py +1 -1
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/README.md +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/bids/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/bids/bid.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/bids/bid_history.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/bids/bid_history_schema.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/bids/bid_schema.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/carriers/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/carriers/account_carrier_map.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/carriers/account_carrier_map_schema.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/carriers/carrier.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/carriers/carrier_schema.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/carriers/contact.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/carriers/contact_schema.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/config/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/config/mcleod_load_fields.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/config/pc_miler_config.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/db/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/db/connection.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/geolocate.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/lanes/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/lanes/carrier_lane.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/lanes/carrier_lane_schema.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/lanes/lane.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/lanes/lane_schema.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/loads/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/loads/equipment.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/loads/equipment_schema.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/loads/equipment_types.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/loads/freighthub_contact.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/loads/freighthub_contact_schema.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/loads/load.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/loads/load_schema.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/loads/load_status.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/loads/location.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/loads/location_schema.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/loads/map_load_response.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/quotes/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/quotes/quote.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/quotes/quote_schema.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/quotes/quote_status.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/rfp/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/rfp/create_table.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/rfp/rfp_status.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/rfp/truck_lane_search_mapper.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/schemas/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/schemas/camel_case_schema.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/analytics/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/analytics/analytics_event.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/accept_bid.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/cancel_bid.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/constants.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/counter_bid.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/decline_bid.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/get_bid_by_amazon_order_id.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/get_quote.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/get_quote_by_load_id.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/list_bids.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/list_quotes.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/update_bid.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/c4/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/c4/amazon_session_token.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/c4/constants.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/c4/get_account.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/c4/get_account_settings.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/c4/get_integration.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/c4/get_users_for_account.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/c4/refresh_amazon_token.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/carrier_hub/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/carrier_hub/get_carrier.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/carrier_hub/list_carriers.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/carrier_hub/list_contacts.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/carrier_hub/update_contact.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/freight_hub/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/freight_hub/post_freight_hub_load.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/mercury/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/mercury/create_account_folder.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/mercury/db/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/mercury/db/delete_table.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/mercury/get_client.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/mercury/get_green_screens_lane_price.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/mercury/get_import_stat.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/mercury/get_lane_price.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/mercury/list_clients.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/mercury/post_import_stat.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/mercury/update_import_stat.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/slack/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/slack/send_slack_message.py +0 -0
- {cc_py_commons-0.5.34/cc_py_commons/sns → cc_py_commons-0.5.36/cc_py_commons/services/web_socket}/__init__.py +0 -0
- {cc_py_commons-0.5.34/cc_py_commons/sns/booking_agent → cc_py_commons-0.5.36/cc_py_commons/sns}/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/sns/book_load_notification.py +0 -0
- {cc_py_commons-0.5.34/cc_py_commons/sqs → cc_py_commons-0.5.36/cc_py_commons/sns/booking_agent}/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/sns/booking_agent/bid_counter_failure_notification.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/sns/booking_agent/constants.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/sns/booking_agent/send_sns_notification.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/sns/booking_assistant_flow_notification.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/sns/import_movements_notification.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/sns/parsed_carrier_notification.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/sns/sns_service.py +0 -0
- {cc_py_commons-0.5.34/cc_py_commons/tests → cc_py_commons-0.5.36/cc_py_commons/sqs}/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/sqs/booking_assistant_cancel_quote_notification.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/sqs/booking_assistant_flow_event.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/sqs/sqs_service.py +0 -0
- {cc_py_commons-0.5.34/cc_py_commons/transactions → cc_py_commons-0.5.36/cc_py_commons/tests}/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/tests/test_case_conversion.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/tests/test_lambda_utils.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/tests/test_map_transaction.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/tests/test_temperature_utils.py +0 -0
- {cc_py_commons-0.5.34/cc_py_commons/utils → cc_py_commons-0.5.36/cc_py_commons/transactions}/__init__.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/transactions/equipment_clas_schema.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/transactions/equipment_class.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/transactions/equipment_mapping.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/transactions/equipment_mapping_schema.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/transactions/map_transaction.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/transactions/transaction.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/transactions/transaction_schema.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/utils/bulk_lane_price_result_utils.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/utils/case_conversion.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/utils/datadog_logger.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/utils/datetimes.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/utils/dimension_utils.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/utils/geocode_location.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/utils/get_delivery_date.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/utils/json_logger.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/utils/lambda_utils.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/utils/local_file.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/utils/logger.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/utils/logger_v2.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/utils/pc_miler_utils.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/utils/price_utils.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/utils/redis.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/utils/s3_file.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/utils/temperature_utils.py +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons.egg-info/dependency_links.txt +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons.egg-info/requires.txt +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons.egg-info/top_level.txt +0 -0
- {cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/setup.cfg +0 -0
@@ -4,3 +4,4 @@ class C4AccountSettings:
|
|
4
4
|
SEARCH_TRUCK_ORIGIN_DEADHEAD_LIMIT = 'SEARCH_TRUCK_ORIGIN_DEADHEAD_LIMIT'
|
5
5
|
SEARCH_TRUCK_DESTINATION_DEADHEAD_LIMIT = 'SEARCH_TRUCK_DESTINATION_DEADHEAD_LIMIT'
|
6
6
|
SEARCH_TRUCK_RESULTS_COUNT = 'SEARCH_TRUCK_RESULTS_COUNT'
|
7
|
+
INCLUDE_DISPATCHER_IN_BOOK_NOW_OFFER = 'INCLUDE_DISPATCHER_IN_BOOK_NOW_OFFER'
|
@@ -60,6 +60,8 @@ class Config(object):
|
|
60
60
|
HERMES_SNS_ARN = 'arn:aws:sns:us-west-1:791608169866:hermes-sns-test'
|
61
61
|
C4_ACCOUNTS_BUCKET = 'c4-accounts-test'
|
62
62
|
ANALYTICS_SNS_ARN = 'arn:aws:sns:us-west-1:791608169866:analytics-test'
|
63
|
+
WEB_SOCKET_SNS_TOPIC_ARN = 'arn:aws:sns:us-west-1:791608169866:websocket-dev'
|
64
|
+
WEB_SOCKET_AUTH_TOKEN = os.getenv('WEB_SOCKET_AUTH_TOKEN')
|
63
65
|
|
64
66
|
# Database
|
65
67
|
DB_USERNAME = os.getenv('DB_USERNAME')
|
@@ -119,6 +121,7 @@ class ProductionConfig(Config):
|
|
119
121
|
HERMES_SNS_ARN = 'arn:aws:sns:us-west-1:791608169866:hermes-sns-prod'
|
120
122
|
C4_ACCOUNTS_BUCKET = 'c4-accounts-prod'
|
121
123
|
ANALYTICS_SNS_ARN ='arn:aws:sns:us-west-1:791608169866:analytics-prod'
|
124
|
+
WEB_SOCKET_SNS_TOPIC_ARN = 'arn:aws:sns:us-west-1:791608169866:websocket-prod'
|
122
125
|
|
123
126
|
config_options = {
|
124
127
|
'local': LocalConfig,
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import json
|
2
|
+
import traceback
|
3
|
+
|
4
|
+
from cc_py_commons.config.env import app_config
|
5
|
+
from cc_py_commons.config.web_socket_action import WebSocketAction
|
6
|
+
from cc_py_commons.sns.sns_service import SnsService
|
7
|
+
from cc_py_commons.utils import json_logger
|
8
|
+
|
9
|
+
|
10
|
+
def execute(action, user_id, account_id, payload):
|
11
|
+
if not action or not account_id or not payload:
|
12
|
+
json_logger.warning(account_id, 'Missing required parameters')
|
13
|
+
return None
|
14
|
+
valid_actions = [WebSocketAction.BROADCAST_TO_USER, WebSocketAction.BROADCAST_TO_ACCOUNT]
|
15
|
+
if action not in valid_actions:
|
16
|
+
json_logger.warning(account_id, f'Invalid action. Should be one of {valid_actions}')
|
17
|
+
return None
|
18
|
+
web_socket_auth_token = app_config.WEB_SOCKET_AUTH_TOKEN
|
19
|
+
if not web_socket_auth_token:
|
20
|
+
json_logger.warning(account_id, 'Missing WEB_SOCKET_AUTH_TOKEN')
|
21
|
+
return None
|
22
|
+
try:
|
23
|
+
message = {
|
24
|
+
'authKey': web_socket_auth_token,
|
25
|
+
'action': action,
|
26
|
+
'userId': user_id,
|
27
|
+
'accountId': account_id,
|
28
|
+
'payload': payload
|
29
|
+
}
|
30
|
+
sns_service = SnsService()
|
31
|
+
sns_service.send(app_config.WEB_SOCKET_SNS_TOPIC_ARN, 'web-socket-message', json.dumps(message))
|
32
|
+
successful_message = 'Successfully sent the notification'
|
33
|
+
json_logger.info(account_id, successful_message)
|
34
|
+
return successful_message
|
35
|
+
except Exception as e:
|
36
|
+
json_logger.error(account_id, 'Failed to send web socket notification', error=str(e),
|
37
|
+
stacktrace=traceback.format_exc())
|
38
|
+
return None
|
@@ -0,0 +1,39 @@
|
|
1
|
+
from unittest import TestCase
|
2
|
+
from unittest.mock import patch
|
3
|
+
|
4
|
+
from cc_py_commons.config.web_socket_action import WebSocketAction
|
5
|
+
from cc_py_commons.services.web_socket import send_notification
|
6
|
+
from cc_py_commons.sns.sns_service import SnsService
|
7
|
+
|
8
|
+
|
9
|
+
@patch.object(SnsService, 'send')
|
10
|
+
class TestSendNotification(TestCase):
|
11
|
+
|
12
|
+
def test_when_required_parameters_are_missing(self, sns_service_send):
|
13
|
+
result = send_notification.execute(WebSocketAction.BROADCAST_TO_ACCOUNT,
|
14
|
+
None, None, {'message': 'test'})
|
15
|
+
|
16
|
+
self.assertIsNone(result)
|
17
|
+
sns_service_send.assert_not_called()
|
18
|
+
|
19
|
+
def test_invalid_action(self, sns_service_send):
|
20
|
+
result = send_notification.execute('INVALID_ACTION',
|
21
|
+
None, 1234, {'message': 'test'})
|
22
|
+
|
23
|
+
self.assertIsNone(result)
|
24
|
+
sns_service_send.assert_not_called()
|
25
|
+
|
26
|
+
def test_when_web_socket_token_is_missing(self, sns_service_send):
|
27
|
+
result = send_notification.execute(WebSocketAction.BROADCAST_TO_ACCOUNT,
|
28
|
+
None, 1234, {'message': 'test'})
|
29
|
+
|
30
|
+
self.assertIsNone(result)
|
31
|
+
sns_service_send.assert_not_called()
|
32
|
+
|
33
|
+
@patch('cc_py_commons.config.env.app_config.WEB_SOCKET_AUTH_TOKEN', 'TOKEN')
|
34
|
+
def test_valid_request(self, sns_service_send):
|
35
|
+
result = send_notification.execute(WebSocketAction.BROADCAST_TO_ACCOUNT,
|
36
|
+
None, 1234, {'message': 'test'})
|
37
|
+
|
38
|
+
self.assertIsNotNone(result)
|
39
|
+
sns_service_send.assert_called_once()
|
File without changes
|
@@ -24,6 +24,7 @@ cc_py_commons/config/c4_account_settings.py
|
|
24
24
|
cc_py_commons/config/env.py
|
25
25
|
cc_py_commons/config/mcleod_load_fields.py
|
26
26
|
cc_py_commons/config/pc_miler_config.py
|
27
|
+
cc_py_commons/config/web_socket_action.py
|
27
28
|
cc_py_commons/db/__init__.py
|
28
29
|
cc_py_commons/db/connection.py
|
29
30
|
cc_py_commons/lanes/__init__.py
|
@@ -96,6 +97,8 @@ cc_py_commons/services/mercury/db/__init__.py
|
|
96
97
|
cc_py_commons/services/mercury/db/delete_table.py
|
97
98
|
cc_py_commons/services/slack/__init__.py
|
98
99
|
cc_py_commons/services/slack/send_slack_message.py
|
100
|
+
cc_py_commons/services/web_socket/__init__.py
|
101
|
+
cc_py_commons/services/web_socket/send_notification.py
|
99
102
|
cc_py_commons/sns/__init__.py
|
100
103
|
cc_py_commons/sns/book_load_notification.py
|
101
104
|
cc_py_commons/sns/booking_assistant_flow_notification.py
|
@@ -115,6 +118,7 @@ cc_py_commons/tests/test_case_conversion.py
|
|
115
118
|
cc_py_commons/tests/test_lambda_utils.py
|
116
119
|
cc_py_commons/tests/test_map_transaction.py
|
117
120
|
cc_py_commons/tests/test_temperature_utils.py
|
121
|
+
cc_py_commons/tests/test_web_socket_send_notification.py
|
118
122
|
cc_py_commons/transactions/__init__.py
|
119
123
|
cc_py_commons/transactions/equipment_clas_schema.py
|
120
124
|
cc_py_commons/transactions/equipment_class.py
|
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
|
|
3
3
|
setup(
|
4
4
|
name='cc_py_commons',
|
5
5
|
description='Common code for microservices',
|
6
|
-
version='0.5.
|
6
|
+
version='0.5.36',
|
7
7
|
url='https://github.com/Cargo-Chief/py-commons',
|
8
8
|
author='CargoChief',
|
9
9
|
author_email='engineering@cargochief.com',
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/carriers/account_carrier_map_schema.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/loads/freighthub_contact_schema.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/analytics/analytics_event.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/__init__.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/accept_bid.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/cancel_bid.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/constants.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/counter_bid.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/decline_bid.py
RENAMED
File without changes
|
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/get_quote.py
RENAMED
File without changes
|
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/list_bids.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/list_quotes.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/booking_agent/update_bid.py
RENAMED
File without changes
|
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/c4/amazon_session_token.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/c4/get_account_settings.py
RENAMED
File without changes
|
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/c4/get_users_for_account.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/c4/refresh_amazon_token.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/carrier_hub/__init__.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/carrier_hub/get_carrier.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/carrier_hub/list_carriers.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/carrier_hub/list_contacts.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/carrier_hub/update_contact.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/freight_hub/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/mercury/db/delete_table.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/mercury/get_import_stat.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/mercury/get_lane_price.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/mercury/list_clients.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/mercury/post_import_stat.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/mercury/update_import_stat.py
RENAMED
File without changes
|
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/services/slack/send_slack_message.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/sns/import_movements_notification.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/sns/parsed_carrier_notification.py
RENAMED
File without changes
|
File without changes
|
{cc_py_commons-0.5.34/cc_py_commons/tests → cc_py_commons-0.5.36/cc_py_commons/sqs}/__init__.py
RENAMED
File without changes
|
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/sqs/booking_assistant_flow_event.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/transactions/equipment_clas_schema.py
RENAMED
File without changes
|
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/transactions/equipment_mapping.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/transactions/equipment_mapping_schema.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/transactions/transaction_schema.py
RENAMED
File without changes
|
{cc_py_commons-0.5.34 → cc_py_commons-0.5.36}/cc_py_commons/utils/bulk_lane_price_result_utils.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|