from typing import Dict, Set

# Region configuration
NA_REGION_CODE = "NA"
SP_API_NA_ENDPOINT = "https://sellingpartnerapi-na.amazon.com"
EU_REGION_CODE = "EU"
SP_API_EU_ENDPOINT = "https://sellingpartnerapi-eu.amazon.com"
FE_REGION_CODE = "FE"
SP_API_FE_ENDPOINT = "https://sellingpartnerapi-fe.amazon.com"


# Region to Endpoint mapping
VALID_SP_API_REGION_CONFIG = {
    NA_REGION_CODE: SP_API_NA_ENDPOINT,
    EU_REGION_CODE: SP_API_EU_ENDPOINT,
    FE_REGION_CODE: SP_API_FE_ENDPOINT,
}


# Login With Amazon Configuration
LWA_ENDPOINT = "https://api.amazon.com/auth/o2/token"
SECRETS_MANAGER_KEY_NAME = "secretsmanager"

# Notifications Configuration
NOTIFICATION_TYPE_ORDER_CHANGE = "ORDER_CHANGE"
NOTIFICATION_LEVEL_ORDER_LEVEL = "OrderLevel"
SHIPPING_FULFILLMENT_CODE = "MFN"
NOTIFICATION_PROCESSING_STATUS_UNSHIPPED = "Unshipped"
NOTIFICATION_PROCESSING_STATUS_ALL: Set[str] = {"Unshipped"}

# SHIPPING Constants
SHIPPING_ORDER_KEY_NAME = "Order"

# Lambda Environment Variables
IAM_USER_CREDENTIALS_SECRET_ARN_ENV_VARIABLE = "IAM_USER_CREDENTIALS_SECRET_ARN"
SP_API_APP_CREDENTIALS_SECRET_ARN_ENV_VARIABLE = "SP_API_APP_CREDENTIALS_SECRET_ARN"
ROLE_ARN_ENV_VARIABLE = "ROLE_ARN"
SHIP_FROM_EMAIL_ENV_VARIABLE = "SHIP_FROM_EMAIL"
INVENTORY_TABLE_NAME_ENV_VARIABLE = "INVENTORY_TABLE_NAME"
SHIPMENTS_TABLE_NAME_ENV_VARIABLE = "SHIPMENTS_TABLE_NAME"
SHIPMENT_FILTER_TYPE_ENV_VARIABLE = "SHIPMENT_FILTER_TYPE"
LABELS_S3_BUCKET_NAME_ENV_VARIABLE = "LABELS_S3_BUCKET_NAME"
REFRESH_TOKEN_ARN_ENV_VARIABLE = "REFRESH_TOKEN"
REGION_CODE_ARN_ENV_VARIABLE = "REGION_CODE"
SQS_QUEUE_ARN_ENV_VARIABLE = "SQS_QUEUE_ARN"
ONE_CLICK_SHIPMENT_ENV_VARIABLE = "ONE_CLICK_SHIPMENT"

# Generic Lambda Input Parameters
REGION_CODE_KEY_NAME = "RegionCode"
REFRESH_TOKEN_KEY_NAME = "RefreshToken"
MARKETPLACE_ID_KEY_NAME = "MarketplaceId"
ONE_CLICK_SHIPMENT_KEY_NAME = "OneClickShipment"

# API Type
SHIPPING_API_TYPE = "shipping"
ORDERS_API_TYPE = "orders"
NOTIFICATIONS_API_TYPE = "notifications"

# Notification Constants
NOTIFICATION_TYPE_KEY_NAME = "NotificationType"
NOTIFICATION_LEVEL_KEY_NAME = "NotificationLevel"
NOTIFICATION_NAME_KEY_NAME = "OrderChangeNotification"
NOTIFICATION_FFM_TYPE_KEY_NAME = "FulfillmentType"
NOTIFICATION_ORDER_STATUS_KEY_NAME = "OrderStatus"
NOTIFICATION_ORDER_ID_KEY_NAME = "OrderId"
NOTIFICATION_AMZ_ORDER_ID_KEY_NAME = "AmazonOrderId"
NOTIFICATION_PAYLOAD_KEY_NAME = "Payload"
NOTIFICATION_SUMMARY_KEY_NAME = "Summary"
NOTIFICATION_MESSAGE_KEY_NAME = "Records"
NOTIFICATION_BODY_KEY_NAME = "body"

# State Machine Constants
STATE_MACHINE_ARN_ENV_VARIABLE = "STATE_MACHINE_ARN"
STATE_MACHINE_ORDER_ID_KEY_NAME = "orderId"
STATE_MACHINE_REFRESH_TOKEN_KEY_NAME = "refreshToken"
STATE_MACHINE_REGION_CODE_KEY_NAME = "regionCode"
STATE_MACHINE_ONE_CLICK_SHIPMENT_KEY_NAME = "oneClickShipment"
STATE_MACHINE_KEY_CREDENTIALS = "credentials"
STATE_MACHINE_SHIPMENT_ID_KEY_NAME = "shipmentId"
STATE_MACHINE_TRACKING_ID_KEY_NAME = "trackingId"
STATE_MACHINE_CARRIER_ID_KEY_NAME = "carrierId"

# Label Format Constants
LABEL_FORMAT_KEY_NAME = "labelFormat"
LABEL_DIMENSIONS_KEY_NAME = "dimensions"
LABEL_FILE_CONTENTS_KEY_NAME = "fileContents"
LABEL_NAME_KEY = "label"

# Lambda Utils
SHIPMENT_FILTER_TYPE_CHEAPEST = "CHEAPEST"
SHIPMENT_FILTER_TYPE_FASTEST = "FASTEST"
SHIPPING_SERVICE_LIST_KEY_NAME = "shippingServiceList"
LAMBDA_SHIPMENT_ID_KEY_NAME = "ShipmentId"
LAMBDA_TRACKING_ID_KEY_NAME = "TrackingId"
LAMBDA_CARRIER_ID_KEY_NAME = "CarrierId"

CONTENT_TYPE_METADATA_MAP: Dict[str, str] = {
    "PNG": "image/png",
    "PDF": "image/pdf",
    "ZPL": "image/zpl"
}

CONTENT_TYPE_KEY_NAME = "ContentType"
LWA_NOTIFICATIONS_SCOPE = "sellingpartnerapi::notifications"

# AWS Attributes
AWS_DYNAMO_DB_CLIENT_KEY_NAME = "dynamodb"
AWS_STEP_FUNCTIONS_CLIENT_KEY_NAME = "stepfunctions"
AWS_STEP_FUNCTIONS_ARN_KEY_NAME = "executionArn"
AWS_S3_CLIENT_KEY_NAME = "s3"
AWS_S3_BUCKET_KEY_NAME = "Bucket"
AWS_S3_KEY_NAME = "Key"
AWS_SNS_CLIENT_KEY_NAME = "sns"
AWS_SIGNATURE_VERSION = "s3v4"

# DynamoDB Attributes
INVENTORY_TABLE_HASH_KEY_NAME = "SKU"
INVENTORY_TABLE_STOCK_ATTRIBUTE_NAME = "Stock"
INVENTORY_TABLE_WEIGHT_VALUE_ATTRIBUTE_NAME = "WeightValue"
INVENTORY_TABLE_WEIGHT_UNIT_ATTRIBUTE_NAME = "WeightUnit"
INVENTORY_TABLE_LENGTH_ATTRIBUTE_NAME = "Length"
INVENTORY_TABLE_WIDTH_ATTRIBUTE_NAME = "Width"
INVENTORY_TABLE_HEIGHT_ATTRIBUTE_NAME = "Height"
INVENTORY_TABLE_SIZE_UNIT_ATTRIBUTE_NAME = "SizeUnit"

SHIPMENTS_TABLE_HASH_KEY_NAME = "OrderId"
SHIPMENTS_TABLE_SHIPMENT_ID_ATTRIBUTE_NAME = "ShipmentId"
SHIPMENTS_TABLE_TRACKING_ID_ATTRIBUTE_NAME = "TrackingId"
SHIPMENTS_TABLE_CARRIER_ID_ATTRIBUTE_NAME = "CarrierId"
