예제 #1
0
        private static SMRequest ConstructSMRequest(Challenge challenge)
        {
            SMRequest retVal = new SMRequest();
            retVal.challenge = challenge;

            return retVal;
        }
예제 #2
0
        private static SMRequest ConstructSMRequest(User user)
        {
            SMRequest retVal = new SMRequest();
            retVal.user = user;

            return retVal;
        }
예제 #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;
        }
예제 #4
0
 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;
 }
예제 #5
0
 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; }
 }
예제 #6
0
 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;
 }
예제 #7
0
        public static async Task<bool> sendEventByExternalId(string externalId, IEvents events)
        {

            SMRequest createUserRequest = new SMRequest();
            createUserRequest.autoClaim = true;
            createUserRequest.events = events;
            await AsyncClient.post(API.APIRoutes.sendEventWithExternalIdRoute(externalId), createUserRequest);
            return true;
        }
예제 #8
0
        public static async Task <SMResponse> put(string path, SMRequest request)
        {
            string json = JsonConvert.SerializeObject(request, Formatting.Indented,
                                                      new JsonSerializerSettings {
                DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore
            });
            string responseString = await putResponseString(path, json);

            SMResponse m = JsonConvert.DeserializeObject <SMResponse>(responseString);

            return(m);
        }
        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();
        }
예제 #10
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();
        }
예제 #11
0
        public static async Task<Order> createOrderByExternalId(String offerId, String ipAddress, String ExternalId)
        {
            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.createNewOrderForOfferWithExternalIdRoute(offerId,ExternalId), newOrderRequest);
            if (m == null) return null;
            return m.order;
        }
예제 #12
0
 public static async Task<SMResponse> put(string path, SMRequest request)
 {
     string json = JsonConvert.SerializeObject(request, Formatting.Indented,
          new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore });
     string responseString = await putResponseString(path, json);
     SMResponse m = JsonConvert.DeserializeObject<SMResponse>(responseString);
     return m;
 }
예제 #13
0
        private static SMRequest ConstructSMRequest(Verification verification)
        {
            SMRequest request = new SMRequest();
            request.verification = verification;

            return request;
        }
예제 #14
0
        private static SMRequest ConstructSMRequest(User user)
        {
            SMRequest request = new SMRequest();
            request.user = user;

            return request;
        }