From a41db2843fd489a199abda1830322cdbe327656c Mon Sep 17 00:00:00 2001 From: Jigar-f Date: Mon, 20 Nov 2023 18:09:30 +0530 Subject: [PATCH] Fetch user id for first time user. --- internalsdk/session_model.go | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/internalsdk/session_model.go b/internalsdk/session_model.go index b623baa30..a19a81aec 100644 --- a/internalsdk/session_model.go +++ b/internalsdk/session_model.go @@ -294,37 +294,31 @@ func (m *SessionModel) initSessionModel(opts *SessionModelOpts) error { if err != nil { return err } - userIdStr := fmt.Sprintf("%d", userId) countryCode, err := m.GetCountryCode() if err != nil { return err } + //Get all the Plans + userIdStr := fmt.Sprintf("%d", userId) + if userId == 0 { + tempUserId, err := m.GetUserID() + if err != nil { + return err + } + userIdStr = fmt.Sprintf("%d", tempUserId) + } - // Run Plans in background - // go func() { - // data, err := apimodels.PlansV3(opts.DeviceID, userIdStr, lang, toekns, countryCode) - // if err != nil { - // log.Errorf("Error while Plans v3 request:", err) // Optional: log the error - // return - // } - // log.Debugf("Plans Response", data) - // }() - - // //Get all the Plans - - //Know Issue - //When use install app first time - // Plans API is failing err = getPlansV3(m.baseModel, opts.DeviceID, userIdStr, lang, token, countryCode) if err != nil { log.Debugf("Plans V3 error: %v", err) return err } - return nil } func getPlansV3(m *baseModel, deviceId string, userId string, lang string, token string, countyCode string) error { + // + log.Debugf("Request data deviceID %v userId %v lang %v token %v countyCode %v", deviceId, userId, lang, token, countyCode) plans, err := apimodels.PlansV3(deviceId, userId, lang, token, countyCode) if err != nil { log.Debugf("Plans V3 error: %v", err)