Coverage for src/integrify/lsim/bulk/client.py: 100%

24 statements  

« prev     ^ index     » next       coverage.py v7.9.2, created at 2025-09-01 02:22 +0000

1from typing import TYPE_CHECKING 

2 

3from integrify.api import APIClient 

4from integrify.lsim import env as base_env 

5from integrify.lsim.bulk import env 

6from integrify.lsim.bulk.handlers import ( 

7 GetBalancePayloadHandler, 

8 GetBulkSMSDeatiledReportPayloadHandler, 

9 GetBulkSMSDeatiledWithDateReportPayloadHandler, 

10 GetBulkSMSReportPayloadHandler, 

11 SendBulkSMSDifferentMessagesPayloadHandler, 

12 SendBulkSMSOneMessagePayloadHandler, 

13) 

14from integrify.lsim.bulk.schemas.response import ( 

15 GetBalanceResponseSchema, 

16 GetBulkSMSDetailedReportResponseSchema, 

17 GetBulkSMSReportResponseSchema, 

18 SendBulkSMSResponseSchema, 

19) 

20from integrify.schemas import APIResponse 

21 

22 

23class LSIMBulkSMSClientClass(APIClient): 

24 def __init__( 

25 self, 

26 name='LSIM-BulkSMS', 

27 base_url=env.API.BASE_URL, 

28 default_handler=None, 

29 sync=True, 

30 dry=False, 

31 ): 

32 super().__init__(name, base_url, default_handler, sync, dry) 

33 

34 self.add_url('bulk_send_one_message', env.API.ENDPOINT, verb='POST') 

35 self.add_handler('bulk_send_one_message', SendBulkSMSOneMessagePayloadHandler) 

36 

37 self.add_url('bulk_send_different_messages', env.API.ENDPOINT, verb='POST') 

38 self.add_handler('bulk_send_different_messages', SendBulkSMSDifferentMessagesPayloadHandler) 

39 

40 self.add_url('get_report', env.API.ENDPOINT, verb='POST') 

41 self.add_handler('get_report', GetBulkSMSReportPayloadHandler) 

42 

43 self.add_url('get_detailed_report', env.API.ENDPOINT, verb='POST') 

44 self.add_handler('get_detailed_report', GetBulkSMSDeatiledReportPayloadHandler) 

45 

46 self.add_url('get_detailed_report_with_dates', env.API.ENDPOINT, verb='POST') 

47 self.add_handler( 

48 'get_detailed_report_with_dates', 

49 GetBulkSMSDeatiledWithDateReportPayloadHandler, 

50 ) 

51 

52 self.add_url('check_balance', env.API.ENDPOINT, verb='POST') 

53 self.add_handler('check_balance', GetBalancePayloadHandler) 

54 

55 if TYPE_CHECKING: 

56 

57 def bulk_send_one_message( 

58 self, 

59 controlid: int, 

60 msisdns: list[str], 

61 bulkmessage: str, 

62 scheduled: str = 'NOW', 

63 login: str = base_env.LSIM_LOGIN, # type: ignore[assignment] 

64 password: str = base_env.LSIM_PASSWORD, # type: ignore[assignment] 

65 title: str = base_env.LSIM_SENDER_NAME, # type: ignore[assignment] 

66 ) -> APIResponse[SendBulkSMSResponseSchema]: 

67 """Bir SMS-i toplu şəkildə bir çox nəfərə göndərmək sorğusu 

68 

69 **Endpoint:** */smxml/api* 

70 

71 Example: 

72 ```python 

73 from integrify.lsim import LSIMBulkSMSClient 

74 

75 LSIMBulkSMSClient.bulk_send_one_message(controlid=1, msisdns=['99450XXXXXXX'], bulkmessage='Hello world') 

76 ``` 

77 

78 Cavab formatı: [`SendBulkSMSResponseSchema`][integrify.lsim.bulk.schemas.response.SendBulkSMSResponseSchema] 

79 

80 Args: 

81 controlid: Unikal sorğu id-si. Siz tərəfdən generasiya olunur. 

82 msisdns: SMS göndəriləcək nömrələr listi. Hər nömrə bu formatda olmalıdır: ölkə kodu + operator kodu + nömrə: 99450XXXXXXX 

83 bulkmessage: Bu nömrələrə göndəriləcək mesaj məzmunu 

84 scheduled: Öncədən SMS göndərilməsi üçün seçilmiş zaman. Zamanı `2023-05-19 15:40:05` 

85 formatında verməlisiniz. Sahə boş qaldıqda, SMS sorğu atdığınız an gedəcək. 

86 login: LSIM logininiz. Mühit dəyişəni kimi təyin olunmayıbsa, burada parametr kimi ötürülməlidir. 

87 password: LSIM parolunuz. Mühit dəyişəni kimi təyin olunmayıbsa, burada parametr kimi ötürülməlidir. 

88 title: LSIM tərəfindən təyin olunmuş göndərən adınız. Mühit dəyişəni kimi təyin olunmayıbsa, burada parametr kimi ötürülməlidir. 

89 """ # noqa: E501 

90 

91 def bulk_send_different_messages( 

92 self, 

93 controlid: int, 

94 msisdns: list[str], 

95 messages: list[str], 

96 scheduled: str = 'NOW', 

97 login: str = base_env.LSIM_LOGIN, # type: ignore[assignment] 

98 password: str = base_env.LSIM_PASSWORD, # type: ignore[assignment] 

99 title: str = base_env.LSIM_SENDER_NAME, # type: ignore[assignment] 

100 ) -> APIResponse[SendBulkSMSResponseSchema]: 

101 """Toplu şəkildə bir çox nəfərə fərqli SMS göndərmək sorğusu 

102 

103 **Endpoint:** */smxml/api* 

104 

105 Example: 

106 ```python 

107 from integrify.lsim import LSIMBulkSMSClient 

108 

109 LSIMBulkSMSClient.bulk_send_one_message(controlid=1, msisdns=['99450XXXXXXX', '99451XXXXXXX'], 

110 messages=['Hello world 1', 'Hello world 2']) 

111 ``` 

112 

113 Cavab formatı: [`SendBulkSMSResponseSchema`][integrify.lsim.bulk.schemas.response.SendBulkSMSResponseSchema] 

114 

115 Args: 

116 controlid: Unikal sorğu id-si. Siz tərəfdən generasiya olunur. 

117 msisdns: SMS göndəriləcək nömrələr listi. Hər nömrə bu formatda olmalıdır: ölkə kodu + operator kodu + nömrə: 99450XXXXXXX 

118 messages: Bu nömrələrə göndəriləcək mesajların düzgün ardıcıllıqla məzmunu 

119 scheduled: Öncədən SMS göndərilməsi üçün seçilmiş zaman. Zamanı `2023-05-19 15:40:05` 

120 formatında verməlisiniz. Sahə boş qaldıqda, SMS sorğu atdığınız an gedəcək. 

121 login: LSIM logininiz. Mühit dəyişəni kimi təyin olunmayıbsa, burada parametr kimi ötürülməlidir. 

122 password: LSIM parolunuz. Mühit dəyişəni kimi təyin olunmayıbsa, burada parametr kimi ötürülməlidir. 

123 title: LSIM tərəfindən təyin olunmuş göndərən adınız. Mühit dəyişəni kimi təyin olunmayıbsa, burada parametr kimi ötürülməlidir. 

124 """ # noqa: E501 

125 

126 def get_report( 

127 self, 

128 taskid: int, 

129 login: str = base_env.LSIM_LOGIN, # type: ignore[assignment] 

130 password: str = base_env.LSIM_PASSWORD, # type: ignore[assignment] 

131 ) -> APIResponse[GetBulkSMSReportResponseSchema]: 

132 """Toplu göndərilmiş SMSlərin report sorğusu 

133 

134 **Endpoint:** */smxml/api* 

135 

136 Example: 

137 ```python 

138 from integrify.lsim import LSIMBulkSMSClient 

139 

140 LSIMBulkSMSClient.get_report(taskid=1) 

141 ``` 

142 

143 Cavab formatı: [`GetBulkSMSReportResponseSchema`][integrify.lsim.bulk.schemas.response.GetBulkSMSReportResponseSchema] 

144 

145 Args: 

146 taskid: Uğurlu toplu SMS göndərdikdə alınmış taskid. 

147 login: LSIM logininiz. Mühit dəyişəni kimi təyin olunmayıbsa, burada parametr kimi ötürülməlidir. 

148 password: LSIM parolunuz. Mühit dəyişəni kimi təyin olunmayıbsa, burada parametr kimi ötürülməlidir. 

149 """ # noqa: E501 

150 

151 def get_detailed_report( 

152 self, 

153 taskid: int, 

154 login: str = base_env.LSIM_LOGIN, # type: ignore[assignment] 

155 password: str = base_env.LSIM_PASSWORD, # type: ignore[assignment] 

156 ) -> APIResponse[GetBulkSMSDetailedReportResponseSchema]: 

157 """Toplu göndərilmiş SMSlərin detallı report sorğusu 

158 

159 **Endpoint:** */smxml/api* 

160 

161 Example: 

162 ```python 

163 from integrify.lsim import LSIMBulkSMSClient 

164 

165 LSIMBulkSMSClient.get_detailed_report(taskid=1) 

166 ``` 

167 

168 Cavab formatı: [`GetBulkSMSDetailedReportResponseSchema`][integrify.lsim.bulk.schemas.response.GetBulkSMSDetailedReportResponseSchema] 

169 

170 Args: 

171 taskid: Uğurlu toplu SMS göndərdikdə alınmış taskid. 

172 login: LSIM logininiz. Mühit dəyişəni kimi təyin olunmayıbsa, burada parametr kimi ötürülməlidir. 

173 password: LSIM parolunuz. Mühit dəyişəni kimi təyin olunmayıbsa, burada parametr kimi ötürülməlidir. 

174 """ # noqa: E501 

175 

176 def get_detailed_report_with_dates( 

177 self, 

178 taskid: int, 

179 login: str = base_env.LSIM_LOGIN, # type: ignore[assignment] 

180 password: str = base_env.LSIM_PASSWORD, # type: ignore[assignment] 

181 ) -> APIResponse[GetBulkSMSDetailedReportResponseSchema]: 

182 """Toplu göndərilmiş SMSlərin detallı report (+ tarix) sorğusu 

183 

184 **Endpoint:** */smxml/api* 

185 

186 Example: 

187 ```python 

188 from integrify.lsim import LSIMBulkSMSClient 

189 

190 LSIMBulkSMSClient.get_detailed_report_with_dates(taskid=1) 

191 ``` 

192 

193 Cavab formatı: [`GetBulkSMSDetailedReportResponseSchema`][integrify.lsim.bulk.schemas.response.GetBulkSMSDetailedReportResponseSchema] 

194 

195 Args: 

196 taskid: Uğurlu toplu SMS göndərdikdə alınmış taskid. 

197 login: LSIM logininiz. Mühit dəyişəni kimi təyin olunmayıbsa, burada parametr kimi ötürülməlidir. 

198 password: LSIM parolunuz. Mühit dəyişəni kimi təyin olunmayıbsa, burada parametr kimi ötürülməlidir. 

199 """ # noqa: E501 

200 

201 def check_balance( 

202 self, 

203 login: str = base_env.LSIM_LOGIN, # type: ignore[assignment] 

204 password: str = base_env.LSIM_PASSWORD, # type: ignore[assignment] 

205 ) -> APIResponse[GetBalanceResponseSchema]: 

206 """Balansı öyrənmək sorğusu 

207 

208 **Endpoint:** */smxml/api* 

209 

210 Example: 

211 ```python 

212 from integrify.lsim import LSIMBulkSMSClient 

213 

214 LSIMBulkSMSClient.check_balance() 

215 ``` 

216 

217 Cavab formatı: [`GetBalanceResponseSchema`][integrify.lsim.bulk.schemas.response.GetBalanceResponseSchema] 

218 

219 Args: 

220 login: LSIM logininiz. Mühit dəyişəni kimi təyin olunmayıbsa, burada parametr kimi ötürülməlidir. 

221 password: LSIM parolunuz. Mühit dəyişəni kimi təyin olunmayıbsa, burada parametr kimi ötürülməlidir. 

222 """ # noqa: E501 

223 

224 

225LSIMBulkSMSClient = LSIMBulkSMSClientClass() 

226LSIMBulkSMSAsyncClient = LSIMBulkSMSClientClass(sync=False)