//
//  APIEndPoints.swift
//  WOKA
//
//  Created by MacBook Pro on 06/05/24.
//

import Foundation

// enum to check envirnments
enum EnvironmentCheck{
    case staging
    case production
}

struct APIEndPoints {
    
    // Private init to prevent external initialization
    private init() {}
    
    struct BaseURL {
        static let staging = "https://wokaland.com/secret-panel-10102023/hidden-admin-portal-20092023/api/"
        static let production = ""
        
        static let appUrl = "https://apps.apple.com/in/app/woka/id6465305185"
    }
    
    struct StaticURLs{
        //    var masilaUrl = "https://content.jwplatform.com/videos/Iygt11AD-Ysj2G4DQ.mp4"
            static let masilaUrl = "https://cdn.jwplayer.com/manifests/Iygt11AD.m3u8"
            static let live_streaming = makeURL(path: "live_streaming")
    }
    
    struct Auth {
        static let check_exist_email = makeURL(path: "check_exist_email")
        
        /*
         Login User
         */
        static let login = makeURL(path: "login")
        static let login_proceed = makeURL(path: "login_proceed")
        static let guest_login = makeURL(path: "guest_login")
        
        
        static let user_email_verification = makeURL(path: "user_email_verification")
        static let validate_otp = makeURL(path: "validate_otp")
        static let interest_topic_listing = makeURL(path: "interest_topic_listing")
        static let check_exist_username = makeURL(path: "check_exist_username")
        static let avatar_listing = makeURL(path: "avatar_listing")
        static let child_registration = makeURL(path: "child_registration")
        static let get_linked_child = makeURL(path: "get_linked_child")
        
        /*
         Password forgot api's
         */
        static let forgot_password_send_otp = makeURL(path: "forgot_password_send_otp")
        static let forgot_password_verify_otp = makeURL(path: "forgot_password_verify_otp")
        static let update_password = makeURL(path: "update_password")
        
        /*
         UserData
         */
        static let get_user_data = makeURL(path: "get_user_data")
        
        /*
         Get username
         */
        static let forgot_username = makeURL(path: "forgot_username")
        
        /*
         
         */
        static let version_history = makeURL(path: "version_history")
    }
    
    struct SideBarNav{
        static let faq_listing = makeURL(path: "faq_listing")        
        static let user_queries_store = makeURL(path: "user_queries_store")        
        static let guest_queries_store = makeURL(path: "guest_queries_store")        
        static let update_profile = makeURL(path: "update_profile")        
        static let user_logout = makeURL(path: "user_logout")        
        static let user_deactivate_account = makeURL(path: "user_deactivate_account")        
        static let order_listing = makeURL(path: "order_listing")        
        static let order_status_track = makeURL(path: "order_status_track")        
    }
    
    struct Home{
        static let blogs = makeURL(path: "blogs")
        static let song_listing = makeURL(path: "song_listing")
        static let get_user_notifications = makeURL(path: "get_user_notifications")
        static let favourite_listing = makeURL(path: "v2/favourite_listing")
        
        //Post Like Unlike
        static let post_like = makeURL(path: "post_like")
        static let post_unlike = makeURL(path: "post_unlike")
        
        // Favourite
        static let favourite_remove = makeURL(path: "favourite_remove")
        static let favourite_add = makeURL(path: "favourite_add")
    }
    
    struct WebSeries{
        static let continue_watching = makeURL(path: "continue_watching")
        static let watch_show_listing = makeURL(path: "watch_show_listing")
        static let category_listing = makeURL(path: "category_listing")        
        static let season_listing = makeURL(path: "season_listing")        
        static let episode_listing = makeURL(path: "episode_listing")        
        static let teaser_listing = makeURL(path: "teaser_listing")        
    }
    
    struct AudioBooks{
        static let listen_audio_listing = makeURL(path: "listen_audio_listing")
    }
    
    struct Games{
        static let game_listing = makeURL(path: "game_listing")
        static let get_token_to_auth_player = makeURL(path: "get_token_to_auth_player")
    }
    
    struct Karaoke{
        static let sing_karaoke_listing = makeURL(path: "sing_karaoke_listing")
    }
    
    struct Shop{
        static let super_category_listing = makeURL(path: "super_category_listing")
        static let category_listing = makeURL(path: "category_listing")
        static let sub_category_listing = makeURL(path: "sub_category_listing")
        static let shop_product_listing = makeURL(path: "shop_product_listing")
        static let shop_product_listing_v2 = makeURL(path: "v2/shop_product_listing")
        static let shop_product_view = makeURL(path: "shop_product_view")
    }

    struct Cart{
        static let cart_listing = makeURL(path: "cart_listing")
        static let remove_cart = makeURL(path: "remove_cart")
        static let coupon_listing = makeURL(path: "coupon_listing")
        static let applied_coupon_discount = makeURL(path: "applied_coupon_discount")
        static let create_new_order = makeURL(path: "create_new_order")
        static let add_cart = makeURL(path: "add_cart")
    }
    
    struct Address{
        static let parent_address_listing = makeURL(path: "parent_address_listing")
        static let add_parent_address = makeURL(path: "add_parent_address")
//        static let pincode_serviceability_check_edd = makeURL(path: "pincode_serviceability_check_edd")
        static let pincode_serviceability_check_edd = makeURL(path: "v2/pincode_serviceability_check_edd")
    }
    
    // Other endpoint categories...
    struct Links {
        static let privacyPolicy = "https://www.wokaland.com/privacy-policy/"
        static let termsAndCondition = "https://www.wokaland.com/terms/"
        // Other links...
    }
    
    struct Analytics{
        static let user_clicks = makeURL(path: "v2/user_clicks")
        static let user_video_view = makeURL(path: "user_video_view")
        static let get_ad_data = makeURL(path: "get_ad_data")
        static let update_ad_count = makeURL(path: "update_ad_count")
    }
    
    // Helper method to construct full URL from base URL and path
    private static func makeURL(path: String) -> URL {
        guard let baseURL = baseURLForCurrentEnvironment() else {
            fatalError("Base URL not configured for current environment")
        }
        return baseURL.appendingPathComponent(path)
    }
    
    // Helper method to get base URL based on current environment
    private static func baseURLForCurrentEnvironment() -> URL? {
        // Determine environment (e.g., staging, production) and return appropriate base URL
        return URL(string: BaseURL.staging)
    }
}
