public static async Task <Order> createOrderById(String offerId, String ipAddress, String Id) { IPAddress address; if (!IPAddress.TryParse(ipAddress, out address)) { Console.WriteLine("UserFactory - Create User - Invalid IP - " + ipAddress); return(null); } Order myOrder = new Order { quantity = 1, recaptcha_challenge_field = "", recaptcha_response_field = "", ip = ipAddress, email = "" }; SMRequest newOrderRequest = new SMRequest(); newOrderRequest.order = myOrder; SMResponse m = await AsyncClient.post(APIRoutes.createNewOrderForOfferWithIdRoute(offerId, Id), newOrderRequest); return(m.order); }
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 <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); }
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 <User> getUserById(string id) { SMResponse m = await AsyncClient.get(APIRoutes.fetchUserWithIdRoute() + id); if (m == null) { return(null); } return(m.user); }
public static async Task <IList <Offer> > getAllOffers(string locale = null) { SMRequest offerRequest = new SMRequest(); SMResponse m = await AsyncClient.get(APIRoutes.fetchOffersRoute()); if (m == null) { return(null); } return(m.offers); }
public static async Task <IList <Offer> > getAllOffersByExternalId(String externalId, string locale = null) { SMRequest offerRequest = new SMRequest(); SMResponse m = await AsyncClient.get(APIRoutes.fetchOffersWithExternalIdRoute(externalId)); if (m == null) { return(null); } return(m.offers); }
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()); }
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()); }
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()); }
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); }
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); }
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()); }
public static async Task <bool> deleteUserById(string id) { SMResponse r = await AsyncClient.delete(APIRoutes.deleteUserWithIdRoute() + id); if (r == null) { return(false); } if (r.user == null) { return(false); } else { return(true); } }
public static async Task <bool> deleteUserByExternalId(string externalId) { SMResponse m = await AsyncClient.delete(APIRoutes.deleteUserUserWithExternalIdRoute() + externalId); if (m == null) { return(false); } if (m.user == null) { return(false); } else { return(true); } }
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()); }
public static async Task <bool> addToUserModel(IAttributes attributes) { SMRequest createAddRequest = new SMRequest(); createAddRequest.attributes = attributes; SMResponse m = await AsyncClient.post(APIRoutes.addAttributesToUserModel(), createAddRequest); if (m == null) { return(false); } if (m.model == null) { return(false); } else { return(true); } }