Пример #1
0
        //send has done but exception thrown,"object refrence null..."
        public SendResponse SendByMobileNumbers(string token, SendByMobileNumbersBodyModel model)
        {
            try
            {
                token.TokenValidation();
                if (model == null)
                {
                    throw new ArgumentException("مدل ارسال را پر نمایید");
                }

                if (string.IsNullOrWhiteSpace(model.Message))
                {
                    throw new ArgumentException("متن پیام نمیتواند خالی باشد");
                }

                if (model.MobileNumbers == null || !model.MobileNumbers.Any())
                {
                    throw new ArgumentException("لیست شمارهمخاطبین نمیتواند خالی باشد");
                }

                var uri = $@"https://api.sms.ir/users/v1/Message/SendByMobileNumbers";
                _client.BaseUrl = new Uri(uri);

                var body = model.ToJson();

                var request  = new IPERequest(Method.POST, token, body);
                var response = _client.Execute(request);
                return(response.GetContent <SendResponse>());
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message);
            }
        }
Пример #2
0
        //todo in response.EmojiId is null,fix it...
        public AddContactsResponse AddContacts(string token, ContactInfo model)
        {
            try
            {
                token.TokenValidation();

                if (model == null)
                {
                    throw new ArgumentException("مدل را وارد کنید");
                }

                if (model.ContactsDetails == null || !model.ContactsDetails.Any())
                {
                    throw new ArgumentException("آرایه اطلاعات مخاطبین را پر نمایید");
                }

                var uri = $@"https://api.sms.ir/users/v1/Contacts/AddContacts";
                _client.BaseUrl = new Uri(uri);

                var body = model.ToJson();

                var request  = new IPERequest(Method.POST, token, body);
                var response = _client.Execute(request);
                return(response.GetContent <AddContactsResponse>());
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message);
            }
        }
Пример #3
0
 //T
 public GetBankTransaction GetBankTransactionsFromLastId(string token, int lastId)
 {
     try
     {
         token.TokenValidation();
         var uri = $@"https://api.sms.ir/users/v1/BankTransaction/GetBankTransactionsFromLastId?lastid={lastId}";
         _client.BaseUrl = new Uri(uri);
         var request  = new IPERequest(Method.GET, token);
         var response = _client.Execute(request);
         return(response.GetContent <GetBankTransaction>());
     }
     catch (Exception ex)
     {
         throw new ArgumentException(ex.Message);
     }
 }
Пример #4
0
 //T
 public GetTicketsByPageIdResponse GetTicketsByPageId(string token, int pageId)
 {
     try
     {
         token.TokenValidation();
         var uri = $@"https://api.sms.ir/users/v1/Ticket/GetTicketsByPageId?pageId={pageId}";
         _client.BaseUrl = new Uri(uri);
         var request  = new IPERequest(Method.GET, token);
         var response = _client.Execute(request);
         return(response.GetContent <GetTicketsByPageIdResponse>());
     }
     catch (Exception ex)
     {
         throw new ArgumentException(ex.Message);
     }
 }
Пример #5
0
 //Todo recheck after fix above...
 public GetOccasionalMessagesResponse GetOccasionalMessages(string token, int occasionalMessageCategoryId)
 {
     try
     {
         token.TokenValidation();
         var uri = $@"https://api.sms.ir/users/v1/OccasionalMessage/GetOccasionalMessages?occasionalMessageCategoryId={occasionalMessageCategoryId}";
         _client.BaseUrl = new Uri(uri);
         var request  = new IPERequest(Method.GET, token);
         var response = _client.Execute(request);
         return(response.GetContent <GetOccasionalMessagesResponse>());
     }
     catch (Exception ex)
     {
         throw new ArgumentException(ex.Message);
     }
 }
Пример #6
0
        //T
        public GetUserInfoResponse GetUserInfo(string token)
        {
            try
            {
                token.TokenValidation();
                var uri = $@"https://api.sms.ir/users/v1/WhiteSms/GetUserInfo";
                _client.BaseUrl = new Uri(uri);

                var request  = new IPERequest(Method.GET, token);
                var response = _client.Execute(request);
                return(response.GetContent <GetUserInfoResponse>());
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message);
            }
        }
Пример #7
0
        //todo I have not currect notif. id!
        public BaseResponse UpdateNotificationStatus(string token, int id)
        {
            try
            {
                token.TokenValidation();
                var uri = $@"https://api.sms.ir/users/v1/Notification/UpdateNotificationStatus?id=0";
                _client.BaseUrl = new Uri(uri);

                var request  = new IPERequest(Method.GET, token);
                var response = _client.Execute(request);
                return(response.GetContent <BaseResponse>());
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message);
            }
        }
Пример #8
0
        //T
        public GetSentMessagesMobileNumbersResponse GetSentMessagesMobileNumbers(string token, int lastId, string batchKey)
        {
            try
            {
                token.TokenValidation();
                var uri = $@"https://api.sms.ir/users/v1/Message/GetSentMessagesMobileNumbers?lastId={lastId}&batchKey={batchKey}";
                _client.BaseUrl = new Uri(uri);

                var request  = new IPERequest(Method.GET, token);
                var response = _client.Execute(request);
                return(response.GetContent <GetSentMessagesMobileNumbersResponse>());
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message);
            }
        }
Пример #9
0
        //T
        public SearchContactsResponse SearchContacts(string token, string prefix, string firstName, string lastName, string mobile, int groupId, int pageId)
        {
            try
            {
                token.TokenValidation();
                var uri = $@"https://api.sms.ir/users/v1/Contacts/SearchContacts?prefix={prefix}&firstname={firstName}&lastname={lastName}&mobile={mobile}&groupid={groupId}&pageid={pageId}";
                _client.BaseUrl = new Uri(uri);

                var request  = new IPERequest(Method.GET, token);
                var response = _client.Execute(request);
                return(response.GetContent <SearchContactsResponse>());
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message);
            }
        }
Пример #10
0
        //T
        public BaseResponse DeleteContactGroup(string token, int groupId)
        {
            try
            {
                token.TokenValidation();

                var uri = $@"https://api.sms.ir/users/v1/Contacts/DeleteContactGroup?groupId={groupId}";
                _client.BaseUrl = new Uri(uri);
                var request  = new IPERequest(Method.GET, token);
                var response = _client.Execute(request);
                return(response.GetContent <BaseResponse>());
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message);
            }
        }
Пример #11
0
        //T
        public TransferContactsToGroupResponse TransferContactsToGroup(string token, TransferContactsToGroupBodyModel model)
        {
            try
            {
                token.TokenValidation();
                var uri = $@"https://api.sms.ir/users/v1/Contacts/TransferContactsToGroup";
                _client.BaseUrl = new Uri(uri);

                var body     = model.ToJson();
                var request  = new IPERequest(Method.POST, token, body);
                var response = _client.Execute(request);
                return(response.GetContent <TransferContactsToGroupResponse>());
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message);
            }
        }
Пример #12
0
        //todo,in api, empty array does not accepted!wrong documentaton...
        public GroupContactsDistinctCountResponse GroupContactsDistinctCount(string token, GroupContactsDistinctCountBodyModel model)
        {
            try
            {
                token.TokenValidation();
                var uri = $@"https://api.sms.ir/users/v1/Message/GroupContactsDistinctCount";
                _client.BaseUrl = new Uri(uri);

                var body = model.ToJson();

                var request  = new IPERequest(Method.POST, token, body);
                var response = _client.Execute(request);
                return(response.GetContent <GroupContactsDistinctCountResponse>());
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message);
            }
        }
Пример #13
0
        //todo api has error "object reference null..."
        public AddOrUpdateDraftMessageResponse AddOrUpdateDraftMessage(string token, AddOrUpdateDraftMessageBodyModel model)
        {
            try
            {
                token.TokenValidation();
                var uri = $@"https://api.sms.ir/users/v1/DraftMessage/AddOrUpdateDraftMessage";
                _client.BaseUrl = new Uri(uri);

                var body = model.ToJson();

                var request  = new IPERequest(Method.POST, token, body);
                var response = _client.Execute(request);
                return(response.GetContent <AddOrUpdateDraftMessageResponse>());
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message);
            }
        }
Пример #14
0
        //todo api does not work!
        public BaseResponse DeleteContacts(string token, int[] ids)
        {
            try
            {
                token.TokenValidation();
                if (ids == null || !ids.Any())
                {
                    throw new ArgumentException("آرایه شناسه مخاطبین را پر نمایید");
                }

                var uri = $@"https://api.sms.ir/users/v1/Contacts/DeleteContacts";
                _client.BaseUrl = new Uri(uri);
                var obj = ids.ToJson();

                var request  = new IPERequest(Method.POST, token, obj);
                var response = _client.Execute(request);
                return(response.GetContent <BaseResponse>());
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message);
            }
        }
Пример #15
0
        //T
        public GetTokenResponse GetToken()
        {
            try
            {
                var uri = $@"https://api.sms.ir/users/v1/Token/GetToken";
                _client.BaseUrl = new Uri(uri);
                var body = new GetTokenBodyModel
                {
                    SecretKey  = _secretKey,
                    UserApiKey = _userApiKey
                }.ToJson();
                var param = new Parameter {
                    ContentType = "Body", Type = ParameterType.RequestBody, Value = body, Name = "undefined"
                };
                var request  = new IPERequest(Method.POST, param);
                var response = _client.Execute(request);

                return(response.GetContent <GetTokenResponse>());
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message);
            }
        }