public static async Task<Challenge> getChallengeQuestion(User user)
 {
     string route = !String.IsNullOrEmpty(user.id) ? APIRoutes.challengeQuestionWithUserIdRoute(user.id) :
                                                    APIRoutes.challengeQuestionWithExternalIdRoute(user.external_id);
     SMResponse m = await AsyncClient.get(route);
     return m == null ? null : m.challenge;
 }
        private static SMRequest ConstructSMRequest(User user)
        {
            SMRequest retVal = new SMRequest();
            retVal.user = user;

            return retVal;
        }
Beispiel #3
0
        public static async Task<User> createUser(string externalId, String email, UserGender gender, String dob, String ipAddress)
        {
            IPAddress address;
            if (!IPAddress.TryParse(ipAddress, out address))
            {
                Console.Write("UserFactory - Create User - Invalid IP - " + ipAddress);
                return null;
            }

            var myUser = new User
            {
                external_id = externalId,
                email = email,
                dob = dob,
                gender = gender.ToString("g"),
                ip = ipAddress

            };

            SMRequest createUserRequest = new SMRequest();
            createUserRequest.user = myUser;
            SMResponse m = await AsyncClient.post(APIRoutes.createUserRoute(), createUserRequest);
            if (m == null) return null;
            return m.user;
        }
 public static async Task<Challenge> postChallengeQuestion(User user, Challenge challenge, int offerId)
 {
     string route = !String.IsNullOrEmpty(user.id) ? APIRoutes.challengeAnswerSubmissionWithUserIdRoute(user.id, challenge.skillsTestQuestion.id, offerId) :
                                                     APIRoutes.challengeAnswerSubmissionWithExternalIdRoute(user.external_id, challenge.skillsTestQuestion.id, offerId);
     SMResponse m = await AsyncClient.post(route, ConstructSMRequest(challenge));
     return m == null ? null : m.challenge;
 }
        public static async Task<IList<ImageValidation>> getImages(User user)
        {
            string route = String.IsNullOrEmpty(user.id) ? APIRoutes.validateImageWithUserIdRoute(user.id) :
                                                           APIRoutes.validateImageWithExternalIdRoute(user.external_id);

            SMResponse m = await AsyncClient.get(route);

            //note that this is a list of imagevalidation objects
            return m == null ? null : m.imageValidations;
        }
        public static async Task<ImageValidation> validateImage(User user, ImageValidation img)
        {
            SMRequest imageValidationRequest = new SMRequest();
            imageValidationRequest.user = user;
            imageValidationRequest.imageValidation = img;

            string route = String.IsNullOrEmpty(user.id) ? APIRoutes.validateImageWithUserIdRoute(user.id) :
                                                           APIRoutes.validateImageWithExternalIdRoute(user.external_id);
           
            SMResponse m = await AsyncClient.post(route, imageValidationRequest);
            return m == null ? null : m.GetImageValidationModel();
        }
Beispiel #7
0
        public static async Task<User> updateUserProfileById(string id, Dictionary<string, string> meta)
        {
            var myUser = new User
            {
                user_profile = meta
            };

            SMRequest createUserRequest = new SMRequest();
            createUserRequest.user = myUser;
            SMResponse m = await AsyncClient.put(APIRoutes.updateUserWithId() + id, createUserRequest);
            if (m == null) return null;
            return m.GetUserResponseModel();
        }
Beispiel #8
0
        public static async Task<Verification> validateViaSMS(User user)
        {
            //sending only the data we need
            User tempUser = new User();
            tempUser.id = user.id;
            tempUser.phoneNumber = user.phoneNumber;
            tempUser.message = user.message;

            string route = !String.IsNullOrEmpty(tempUser.id) ? APIRoutes.sendSMSWithLinkWithUserIdRoute(tempUser.id) : 
                                                                APIRoutes.sendSMSWithLinkWithExternalIdRoute(tempUser.external_id);

            SMResponse m = await AsyncClient.post(route, ConstructSMRequest(tempUser));

            return m == null ? null : m.GetVerificationResponseModel();

        }
Beispiel #9
0
        private static SMRequest ConstructSMRequest(User user)
        {
            SMRequest request = new SMRequest();
            request.user = user;

            return request;
        }
Beispiel #10
0
        public static async Task<User> getPointHistory(User user, string startDate, string endDate, Nullable<int> limit, string cursor)
        {
            User tempUser = new User();
            tempUser.id = user.id;

            string route = !String.IsNullOrEmpty(tempUser.id) ? APIRoutes.pointHistoryWithUserIdRoute(tempUser.id, startDate, endDate, limit, cursor) :
                                                                APIRoutes.pointHistoryWithExternalIdRoute(tempUser.external_id, startDate, endDate, limit, cursor);

            SMResponse m = await AsyncClient.get(route);
            return m == null ? null : m.GetUserResponseModel();
        }
Beispiel #11
0
 public static async Task<User> removeProxyId(string externalId, string proxyIdToUnregister)
 {
     User user = new User();
     user.external_id = externalId;
     ProxyId proxyId = new ProxyId();
     proxyId.unregister = proxyIdToUnregister;
     user.proxyId = proxyId;
     
     string route = APIRoutes.addRemoveProxyIdWithExternalIdRoute(externalId);
     SMResponse m = await AsyncClient.put(route, ConstructSMRequest(user));
     return m == null ? null : m.user;
 }
Beispiel #12
0
        public static async Task<User> addUserMetaDataByUserId(User user, Dictionary<string, string> metaData)
        {
            User tempUser = new User();
            tempUser.id = user.id;
            tempUser.external_id = user.external_id;
            tempUser.meta = metaData;

            string route = !String.IsNullOrEmpty(tempUser.id) ? APIRoutes.addUserMetaDataWithUserIdRoute(tempUser.id) :
                                                                APIRoutes.addUserMetaDataWithExternalIdRoute(tempUser.external_id);

            SMResponse m = await AsyncClient.post(route, ConstructSMRequest(tempUser));
            return m == null ? null : m.user;
        }
Beispiel #13
0
        public static async Task<Verification> validateSMSVerificationCode(User user)
        {
            User tempUser = new User();
            tempUser.id = user.id;

            string route = !String.IsNullOrEmpty(tempUser.id) ? APIRoutes.validateActivationCodeWithUserIdRoute(tempUser.id) :
                                                                APIRoutes.validateActivationCodeWithExternalIdRoute(tempUser.external_id);

            SMResponse m = await AsyncClient.post(route, ConstructSMRequest(tempUser));
            return m == null ? null : m.GetVerificationResponseModel();
        }