---
# System prepended metadata

title: CLE Tech debt tickets

---

# CLE Tech debt tickets

* Enable view's Preview to make UI development faster by injecting required dummy dependencies.
* CartNCheckoutServices - 
    * CartItemRequest needs to refactor, this is getting used to generate request object on type and that needs to untangled
    ```
    private func getURLandMethodFrom(
        request: CartItemAPIRequestModel,
        configAPI: CartAPIConfigModel) throws ->
    (urlString: String, method: DSGCore.Method, includeBotman: Bool) {
        var method = Method.get
        var urlString = configAPI.baseURL
        var includeBotman = false

        switch request.operation {
        case .get:
            urlString += configAPI.get
        case .add:
            guard let skuId = request.skuID else {
                throw CartAPIError.dataNil
            }
            urlString += String(format: configAPI.add, skuId)
            method = .put
            includeBotman = true
        case .update:
            guard let skuId = request.skuID, let quantity = request.quantity else {
                throw CartAPIError.dataNil
            }
            urlString += String(format: configAPI.edit, skuId, quantity)
            method = .post
        case .delete:
            guard let skuId = request.skuID else {
                throw CartAPIError.dataNil
            }
            urlString += String(format: configAPI.delete, skuId)
            method = .delete
        case .postOrderSummary:
            urlString += configAPI.orderSummary
            method = .post
            includeBotman = true
        case .getOrderSummary:
            guard let checkoutKey = request.checkoutKey else {
                throw CartAPIError.dataNil
            }
            urlString += String(format: configAPI.checkoutOrderSummary, checkoutKey)
            method = .get
            includeBotman = true
        case .getCheckout:
            guard let checkoutKey = request.checkoutKey else {
                throw CartAPIError.dataNil
            }
            urlString += String(format: configAPI.checkout, checkoutKey)
            method = .get
            includeBotman = true
        case .shippingInformation:
            guard let checkoutKey = request.checkoutKey else {
                throw CartAPIError.dataNil
            }
            urlString += String(format: configAPI.shippingInformation, checkoutKey)
            method = .put
            includeBotman = true
        case .deliveryMode:
            guard let checkoutKey = request.checkoutKey else {
                throw CartAPIError.dataNil
            }
            urlString += String(format: configAPI.setDeliveryMode, checkoutKey)
            method = .put
            includeBotman = true
        case .accertify:
            guard let checkoutKey = request.checkoutKey else {
                throw CartAPIError.dataNil
            }
            urlString = String(format: configAPI.accertify + checkoutKey)
            method = .put
        case .postCheckout:
            guard let checkoutKey = request.checkoutKey else {
                throw CartAPIError.dataNil
            }
            urlString += String(format: configAPI.checkout, checkoutKey)
            method = .post
            includeBotman = true
        case .placeOrder:
            guard let checkoutKey = request.checkoutKey else {
                throw CartAPIError.dataNil
            }
            urlString += String(format: configAPI.paymentPreprocessor, checkoutKey)
            method = .put
            includeBotman = true
        case .orderConfirmation:
            guard let checkoutKey = request.checkoutKey else {
                throw CartAPIError.dataNil
            }
            urlString += String(format: configAPI.orderConfirmation, checkoutKey)
            method = .get
        case .deliverySpeedInformation:
            urlString += configAPI.deliverySpeedInformation
        case .shippingRestriction:
            urlString += configAPI.shippingRestriction
		case .storeInfo:
			guard let storeId = request.storeId else {
                throw CartAPIError.dataNil
            }
			urlString = String(format: configAPI.storeInfo, storeId)
		case .updateSTH:
			 guard let skuId = request.skuID else {
				throw CartAPIError.dataNil
			}
			urlString += String(format: configAPI.updateSTH, skuId)
			method = .post
            includeBotman = true
		case .updateBOPIS:
			guard let skuId = request.skuID, let bopis = request.bopis, let storeId = request.storeId else {
				throw CartAPIError.dataNil
			}
			urlString += String(format: configAPI.updateBopis, skuId, bopis, storeId)
			method = .post
            includeBotman = true
		case .updateBOPL:
			guard let skuId = request.skuID, let bopl = request.bopl, let storeId = request.storeId else {
					throw CartAPIError.dataNil
				}
			urlString += String(format: configAPI.updateBopl, skuId, bopl, storeId)
			method = .post
			includeBotman = true
		case .inventory:
			guard let skuId = request.skuID, let storeId = request.storeId else {
				throw CartAPIError.dataNil
			}
			urlString = String(format: configAPI.inventory, storeId, skuId)
			method = .get
        default:
            throw APIError.invalidUrl
        }
        return (urlString, method, includeBotman)
    }
    ```
    
    We need to create separate request stucture for each type to make it clean and common part can be abstracted.
    
* Mostly we wire all of our api response model's upto view, we need to start introducing Domain object and wire from viewModel to view only
    * Cloud -> API-Response-Model -> ViewModel/Domain Object -> View(consume domain object)

* Move all Cart Request builder models to CartNCheckoutServices Module
* Reorganize the Cart module folder structure with established agreed pattern View/ViewModels/Services/Models/Common 
* Most of places we doesn't use repository pattern to fetch data either from remote or local, Start implementing repository for fetching remote data and make viewModel's light weight this way viewModel will ask to repository to give data and that data will be processed for logic. below are the list of feature's we can target
    * All Cart Api's
    * All Account APi's
    * All Shop APi's
    * All Homr Api's
    * All Certona Api's
    * All Sneaker Api's

* Our project has 322 ViewModifier's in 129 files, We need to find common one or make more common and centralize them in DSGCore to reduce duplicated viewmodifier's and to stop keep growing them for new feature's. 
   ![](https://i.imgur.com/HpjB6Ce.jpg)
   
* Advanced Async/await networking layer. 
* Move MedalliaInitialization/FirebaseInitialization/MoveInitialization/AccountsHandlerInitialization/AccertifyInitialization to DSGCore under 3rd party folder.
* Clean Assets.xcassets for unused color assets

* Analyze Store list types - Initial requirement had mystore to be different and store selected on plp,pdp,cart to be different. But later changed whenever selecting any store mystore also will be updated.
 Need to remove plpstore 
 Reference ticket : https://jira.dcsg.com/browse/CMT-6548

```/// Store List Type
public enum StoreListType {
    /// set store list type
    case setStore
    /// select store list type
    case selectStore
    /// PLP store list type
    case plpStore
}
```

* Shop
    * ShopLandingView has a body length of over 200 lines. We can reduce this and simplify the structure by:
        * Extracting subviews
        * Extract modifiers to clean up call sites

    * ProductListViewModel has ~70 properties. We can group some of these into objects by responsibility to declutter the viewModel (spike). 
        ![](https://i.imgur.com/kKfBF9H.png)

    * HomrUtilityCarouselView
        * move NavigationLink inside of UtilityCarouselRowView
        ![](https://i.imgur.com/DHkLMoN.png)


* CartNCheckout - 
    * Convert below services to repository to get data
        * CheckoutPlaceOrderService
        * CheckoutPromotionViewModelService
        * CheckOutDeliverySpeedViewService
        * CheckoutPickupPersonService
        * CheckoutViewModelService
        * CheckoutGiftingService
        * CheckOutCalculateEstimatedPointsService
        * CheckOutSavedPaymentsService

* CheckOutViewModel - CheckOutViewModel.swift
    * Untangle the nested viewModels within it and use directly in View's where it's needed to use it. below is the list of nested viewModels
        * @Published internal var loaderViewModel = CheckoutLoaderViewModel()
    @Published internal var contactInfoViewModel = CheckoutContactInfoViewModel()
    @Published internal var addressViewModel = CheckOutAddressViewModel()
    @Published internal var deliverySpeedViewModel = CheckOutDeliverySpeedViewModel()
    @Published internal var creditInfoViewModel = CheckOutCreditInfoViewModel()
    @Published internal var promoViewModel = CheckOutPromotionViewModel()
    @Published internal var nextButtonViewModel = CheckoutNextButtonViewModel()
    @Published internal var scoreCardViewModel = CheckOutScorecardRewardsViewModel()
    @Published internal var pickupPersonViewModel = CheckoutPickupPersonViewModel()
    @Published internal var giftingViewModel = CheckOutGiftingViewModel()
    @Published internal var giftMessageViewModel = CheckOutGiftMessageViewModel()
    
* CheckOutAddressViewModel - 
    Can we make common address validation and supporting billing/shipping/account address reusable viewmodel so we can remove all viewModel from account/shop/checkout/other places and just use it and make common logic.
    
* CartSubViewModel - 
    Models needs to move to model section and viewModels needs to separate out to its own files and few needs to convert to models.
    * CartItem
    * CartSummaryViewModel
    * CartRadioBtnInfoViewModel
    * CartStoreInfoViewModel

* Account
    * EditScoreCardViewModel
        * remove unused `validateWasCalled` property
        * unit test email verification logic to protect it from any accidental changes, causing a bug.

* Shop Folder Structure 

* Refactor Search View Model - 
1. Move Product Card, Category UI model to separate classes
2. Old image loader is used need to refactor image loader with reusable component or create a new one in DSG core
3. Remove unused code - internal func getTitle(type: SAYTType) -> String {
		switch type {
			case .suggestions:
				return "search_header_title_suggestions".localized
			case .categories:
				return "search_header_title_categories".localized
			case .brands:
				return "search_header_title_brands".localized
			default:
				return ""
		}
	}
4. Rename Search view model extension classes with proper naming. Current - SearchViewModelExtensions, SearchViewModel+Extension
