from enum import Enum

# 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"

# Sandbox configuration
SANDBOX_REGIONS = ['NA_SANDBOX', 'EU_SANDBOX', 'FE_SANDBOX']
NA_SANDBOX_REGION_CODE = "NA_SANDBOX"
SP_API_NA_SANDBOX_ENDPOINT = "https://sandbox.sellingpartnerapi-na.amazon.com"
EU_SANDBOX_REGION_CODE = "EU_SANDBOX"
SP_API_EU_SANDBOX_ENDPOINT = "https://sandbox.sellingpartnerapi-eu.amazon.com"
FE_SANDBOX_REGION_CODE = "FE_SANDBOX"
SP_API_FE_SANDBOX_ENDPOINT = "https://sandbox.sellingpartnerapi-fe.amazon.com"


# Region to Endpoint mapping
VALID_SP_API_REGION_CONFIG = {
    NA_REGION_CODE: SP_API_NA_ENDPOINT,
    NA_SANDBOX_REGION_CODE: SP_API_NA_SANDBOX_ENDPOINT,
    EU_REGION_CODE: SP_API_EU_ENDPOINT,
    EU_SANDBOX_REGION_CODE: SP_API_EU_SANDBOX_ENDPOINT,
    FE_REGION_CODE: SP_API_FE_ENDPOINT,
    FE_SANDBOX_REGION_CODE: SP_API_FE_SANDBOX_ENDPOINT
}

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


# Lambda Environment Variables
SP_API_APP_CREDENTIALS_SECRET_ARN_ENV_VARIABLE = "SP_API_APP_CREDENTIALS_SECRET_ARN"
SELLER_ITEMS_TABLE_NAME_ENV_VARIABLE = "SELLER_ITEMS_TABLE_NAME"


# Generic Lambda Input Parameters
REGION_CODE_KEY_NAME = "RegionCode"
REFRESH_TOKEN_KEY_NAME = "RefreshToken"


# State Machine Attributes
STATE_MACHINE_ARN_ENV_VARIABLE = "STATE_MACHINE_ARN"
STATE_MACHINE_KEY_REFRESH_TOKEN = "refreshToken"
STATE_MACHINE_KEY_REGION_CODE = "regionCode"
STATE_MACHINE_KEY_ASIN = "asin"
STATE_MACHINE_KEY_CREDENTIALS = "credentials"
STATE_MACHINE_KEY_OFFER_TYPE = "offerChangeType"
STATE_MACHINE_KEY_BUY_BOX = "buyBox"
STATE_MACHINE_KEY_BUY_BOX_CONDITION = "condition"
STATE_MACHINE_KEY_BUY_BOX_PRICE = "price"
STATE_MACHINE_KEY_SELLER = "seller"
STATE_MACHINE_KEY_SELLER_ID = "sellerId"
STATE_MACHINE_KEY_OFFERS = "offers"
STATE_MACHINE_KEY_SHIPPING_PRICE = "shippingPrice"
STATE_MACHINE_KEY_LISTING_PRICE = "listingPrice"
STATE_MACHINE_KEY_IS_BUY_BOX_WINNER = "isBuyBoxWinner"
STATE_MACHINE_KEY_MARKETPLACE_ID = "marketplaceId"
STATE_MACHINE_KEY_IS_FULFILLED_BY_AMAZON = "isFulfilledByAmazon"
STATE_MACHINE_KEY_COMPETITIVE_PRICE = "competitivePriceThreshold"
STATE_MACHINE_KEY_REFERENCE_PRICE = "referencePrice"
STATE_MACHINE_KEY_AVERAGE_SELLING_PRICE = "averageSellingPrice"
STATE_MACHINE_KEY_SELLER_OFFER = "sellerOffer"


# AWS Attributes
AWS_STEP_FUNCTIONS_CLIENT_NAME = "stepfunctions"
AWS_STEP_FUNCTIONS_ARN_NAME = "executionArn"
REFRESH_TOKEN_ARN_ENV_VARIABLE = "REFRESH_TOKEN"
REGION_CODE_ARN_ENV_VARIABLE = "REGION_CODE"
SQS_QUEUE_ARN_ENV_VARIABLE = "SQS_QUEUE_ARN"
SECRETS_MANAGER_CLIENT_NAME = "secretsmanager"


# Notifications Configurations
NOTIFICATION_TYPE_AOC = "ANY_OFFER_CHANGED"
NOTIFICATION_TYPE_PH = "PRICING_HEALTH"
LWA_NOTIFICATIONS_SCOPE = "sellingpartnerapi::notifications"


# Notification Attributes
NOTIFICATION_KEY_NOTIFICATION_TYPE = "notificationType"
NOTIFICATION_KEY_OFFER_CHANGE_TYPE = "OfferChangeType"
NOTIFICATION_KEY_OFFER_CHANGE_TRIGGER = "OfferChangeTrigger"
NOTIFICATION_KEY_ASIN = "ASIN"
NOTIFICATION_KEY_MARKETPLACE_ID = "MarketplaceId"
NOTIFICATION_KEY_SUMMARY = "Summary"
NOTIFICATION_KEY_BUY_BOX_PRICES = "BuyBoxPrices"
NOTIFICATION_BUY_BOX_PRICES_ITEM = 0
NOTIFICATION_KEY_ITEM_CONDITION = "Condition"
NOTIFICATION_KEY_LANDED_PRICE = "LandedPrice"
NOTIFICATION_KEY_OFFERS = "Offers"
NOTIFICATION_KEY_SELLER_ID = "SellerId"
NOTIFICATION_KEY_LISTING_PRICE = "ListingPrice"
NOTIFICATION_KEY_SHIPPING_PRICE = "Shipping"
NOTIFICATION_KEY_IS_BUY_BOX_WINNER = "IsBuyBoxWinner"
NOTIFICATION_KEY_IS_FULFILLED_BY_AMAZON = "IsFulfilledByAmazon"


# PRICING_HEALTH Attributes
NOTIFICATION_KEY_PH_OFFER_CHANGE_TRIGGER = "offerChangeTrigger"
NOTIFICATION_KEY_PH_ASIN = "asin"
NOTIFICATION_KEY_PH_MARKETPLACE_ID = "marketplaceId"
NOTIFICATION_KEY_PH_SUMMARY = "summary"
NOTIFICATION_KEY_PH_BUY_BOX_PRICES = "buyBoxPrices"
NOTIFICATION_BUY_PH_BOX_PRICES_ITEM = 0
NOTIFICATION_KEY_PH_ITEM_CONDITION = "itemCondition"
NOTIFICATION_KEY_PH_CONDITION = "condition"
NOTIFICATION_KEY_PH_LANDED_PRICE = "landedPrice"
NOTIFICATION_KEY_PH_MERCHANT_OFFER = "merchantOffer"
NOTIFICATION_KEY_PH_SELLER_ID = "sellerId"
NOTIFICATION_KEY_PH_LISTING_PRICE = "listingPrice"
NOTIFICATION_KEY_PH_SHIPPING_PRICE = "shipping"
NOTIFICATION_KEY_PH_REFERENCE_PRICE = "referencePrice"
NOTIFICATION_KEY_PH_AVERAGE_SELLING_PRICE = "averageSellingPrice"
NOTIFICATION_KEY_PH_COMPETITIVE_PRICE_THRESHOLD = "competitivePriceThreshold"
NOTIFICATION_KEY_PH_RETAIL_OFFER_PRICE = "retailOfferPrice"
NOTIFICATION_KEY_PH_MSRP_PRICE = "msrpPrice"
NOTIFICATION_KEY_PH_FULFILLMENT_TYPE = "fulfillmentType"
NOTIFICATION_KEY_PH_MFN_TYPE = "MFN"


# API Type
LISTINGS_API_TYPE = "listings"
PRICING_API_TYPE = "pricing"
NOTIFICATIONS_API_TYPE = "notifications"


# DynamoDB Attributes
SELLER_TABLE_HASH_KEY_NAME = "SKU"
AWS_DYNAMO_DB_CLIENT_KEY_NAME = "dynamodb"
SELLER_TABLE_NAME_ENV_VARIABLE = "SELLER_ITEMS_TABLE_NAME"
SELLER_TABLE_ASIN_KEY_NAME = "ASIN"
SELLER_TABLE_CONDITION_KEY_NAME = "Condition"
SELLER_TABLE_MARKETPLACE_KEY_NAME = "MarketplaceId"
SELLER_TABLE_SELLER_ID_KEY_NAME = "SellerId"
SELLER_TABLE_IS_FULFILLED_BY_AMAZON_KEY_NAME = "IsFulfilledByAmazon"
SELLER_TABLE_THRESHOLD_KEY_NAME = "MinThreshold"
SELLER_TABLE_PRICE_CHANGE_RULE_KEY_NAME = "PriceChangeRule"
SELLER_TABLE_PRICE_CHANGE_AMOUNT_KEY_NAME = "PriceChangeRuleAmount"
SELLER_TABLE_USE_COMPETITIVE_PRICE = "UseCompetitivePrice"


# Price Change Enum Value
class PriceChangeRule(Enum):
    PERCENTAGE = "PERCENTAGE"
    FIXED = "FIXED"
