Inbox Example

{
  "configurations": {
    "deviceType": "RJS",
    "ctxId": "dashboard",
    "params": {
      "payload": {
        "GET_INSIGHTS": {
          "ok": true,
          "protocolVersion": "2.6",
          "requestChannel": "VANILLA_QA",
          "requestType": "getInsights",
          "requestId": "NLjFSETDjW7-K35x",
          "status": "200",
          "statusMessage": "ok",
          "insights": [],
          "numberOfInsights": 8,
          "unreadMessages": 4,
          "numberOfUnreadInsights": 4
        }
      },
      "userId": "B_1012"
    },
    "selectorString": "#root",
    "widgetType": "inbox"
  },
  "assets": {
    "baseUrl": "https://client-vanilla-assets.s3.amazonaws.com/product-react-assets/assets/",
    "useRemoteAssets": false
  },
  "internationalization": {
    "language": "en"
  }
}
func getPayloadForType(type: String, requestType: String, navParams: NSMutableDictionary?) {
        let serverUrl = NetworkManager.shared.getEngageServerUrl()
        let requestType = requestType
        let requestBodyParams = NSMutableDictionary.init()
        guard let constants = NetworkManager.shared.constants else { return }
 
        requestBodyParams.setValue(requestType, forKey: "type")
        requestBodyParams.setValue("dashboard", forKey: Personetics.PDBctxId)
        requestBodyParams.setValue(constants.protocolVersion, forKey: "protocolVersion")
        requestBodyParams.setValue(constants.appLanguage, forKey: "lang")
        let requestHeaders = NetworkManager.shared.getOptionalReqHeaders()
        NetworkManager.shared.doPostMessage(serverUrl: serverUrl, reqHttpBoday: requestBodyParams,
                                            reqHeaders: requestHeaders, requestType: requestType, onSuccess: { [weak self] result in
            if let payload = result as? String {
                switch type {
                case "story-widget":
                    self?.startStoryWidget(payload: BankUtility.stringToJsonObject(dataString: payload))
                case "recap":
                    self?.startRecapWidget(payload: BankUtility.stringToJsonObject(dataString: payload))
                case "inbox":
                    self?.startInboxWidget(payload: BankUtility.stringToJsonObject(dataString: payload))
                case "hub":
                    self?.startHubWidget(payload: BankUtility.stringToJsonObject(dataString: payload))
                case "singleTeaser":
                    self?.startSingleTeaserWidget(payload: BankUtility.stringToJsonObject(dataString: payload))
                case "singleTrackerTeaser":
                    self?.startSingleTrackerTeaserWidget(payload: BankUtility.stringToJsonObject(dataString: payload))
                case "trackersDashboard":
                    self?.startTrackersDashboardWidget(payload: BankUtility.stringToJsonObject(dataString: payload))
                case "carousel":
                    self?.startCarouselWidget(payload: BankUtility.stringToJsonObject(dataString: payload))
                case "manage-budgets":
                    if let addNavParams = navParams {
                        self?.startBudgetManageWidget(payload: BankUtility
                            .stringToJsonObject(dataString: payload), navParams: addNavParams)
                    } else {
                        self?.startBudgetManageWidget(payload: BankUtility
                            .stringToJsonObject(dataString: payload), navParams: nil)
                    }
                case "subscription-dashboard":
                    if let addNavParams = navParams {
                        self?.startSubscriptionDashboardWidget(payload: BankUtility
                            .stringToJsonObject(dataString: payload), navParams: addNavParams)
                    } else {
                        self?.startSubscriptionDashboardWidget(payload: BankUtility
                            .stringToJsonObject(dataString: payload), navParams: nil)
                    }
                case "actOnboarding":
                    if let addNavParams = navParams{
                        self?.startOnboardingWidget(payload: BankUtility.stringToJsonObject(dataString: payload), navParams: addNavParams)
                    }else{
                        self?.startOnboardingWidget(payload: BankUtility.stringToJsonObject(dataString: payload), navParams:nil)
                    }
                case "actManagement":
                    if let addNavParams = navParams{
                        self?.startManagementWidget(payload: BankUtility.stringToJsonObject(dataString: payload), navParams: addNavParams)
                    }else{
                        self?.startManagementWidget(payload: BankUtility.stringToJsonObject(dataString: payload), navParams:nil)
                    }
                default:
                    break
                }
            } else {
            }
        }, onError: {result in
            print("Get Payload \(requestType) Response ****Failed****: \(String(describing: result)))")
        })
    }