django-chelseru 2.0.0__py3-none-any.whl → 2.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: django-chelseru
3
- Version: 2.0.0
3
+ Version: 2.0.2
4
4
  Summary: Authentication system, online and real-time chat, SMS & BANK system for Iranian SMS services.
5
5
  Home-page: https://pipdjango.chelseru.com
6
6
  Author: Sobhan Bahman Rashnu
@@ -1,4 +1,4 @@
1
- django_chelseru-2.0.0.dist-info/licenses/LICENSE,sha256=VupU5KV4NteHaNQb-WH31G_WZWezxXoomjiCIAHoQJo,1089
1
+ django_chelseru-2.0.2.dist-info/licenses/LICENSE,sha256=VupU5KV4NteHaNQb-WH31G_WZWezxXoomjiCIAHoQJo,1089
2
2
  drfchelseru/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  drfchelseru/admin.py,sha256=uamcWPCCw9_dD00XL8Brp8A1NvfhB5FtUfF9DWQCK9c,1022
4
4
  drfchelseru/apps.py,sha256=hOTTzFGLXiTPZeN8p_LLcSECLtsR2Q0SUo8zJzgM-qQ,211
@@ -7,8 +7,8 @@ drfchelseru/middlewares.py,sha256=Ej_9GTlVPzfzYAUqxUn7VHJRdlywQmrbSIW43yK5q5U,38
7
7
  drfchelseru/models.py,sha256=jQ5IbS5q4GufZC9W_zgX1Qg8YU_f8V-Jusbh5hQYPhQ,11214
8
8
  drfchelseru/routing.py,sha256=shAlgzcIwVuVPlvKeWBLCqr6PuBTHyIrWNgHEfnqrxg,165
9
9
  drfchelseru/serializers.py,sha256=I3kS2NhzIprY8-WWhjQPShAom6R7epg7do7RnDkpnys,1421
10
- drfchelseru/services.py,sha256=9sHlY-_Prd1Wl1WTddT-e1nE7rYKlDjFaYl6FGjwvTA,27142
11
- drfchelseru/settings.py,sha256=zzOKwaciRMOhf5tQM4jAT4_80nggTwl_HqCby7TCUaE,11385
10
+ drfchelseru/services.py,sha256=K-VzisPliuKv0BL6Z3U6Tz0ewiVwhUkxt7yn08pemCk,29024
11
+ drfchelseru/settings.py,sha256=LhdRLmUJnNlET0JYnHqRdFzmBD_nEX18qU1C1j0qN0E,11466
12
12
  drfchelseru/signals.py,sha256=CI1mZR5RrdOddXBnPC1eMdt9iQkYFDypfgogtfTc2eQ,2714
13
13
  drfchelseru/tests.py,sha256=mrbGGRNg5jwbTJtWWa7zSKdDyeB4vmgZCRc2nk6VY-g,60
14
14
  drfchelseru/urls.py,sha256=qD3As2gSCEaNDxgU0ejIADLUt9t2EvoaTmqeiV1LRSA,898
@@ -37,7 +37,7 @@ drfchelseru/migrations/0020_payment_paid_at.py,sha256=H6cr-tfjJVjN3tCsCD8ecg9JGJ
37
37
  drfchelseru/migrations/0021_alter_payment_message.py,sha256=g5qIvQ-wecdXGcMf7ZhyfL2u85QpgMUOADHE7t4QHog,397
38
38
  drfchelseru/migrations/0022_payment_pay_mode_wallet.py,sha256=241lZITO1jQHqXkJKYm8DKUh7w9rmROh65LzNifP3BA,1521
39
39
  drfchelseru/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
- django_chelseru-2.0.0.dist-info/METADATA,sha256=EObLgGe6BtL_uteht0I9gkfDai8YPHmlsTKDhm4ea2Y,18242
41
- django_chelseru-2.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
42
- django_chelseru-2.0.0.dist-info/top_level.txt,sha256=fsaO1F03W3j4AYi0TfDGv5Cjb_Qrh6RSkwkWqfqaMns,12
43
- django_chelseru-2.0.0.dist-info/RECORD,,
40
+ django_chelseru-2.0.2.dist-info/METADATA,sha256=XpDHKGThjY6g1xxY19GijeYm8hZTWBjjp1yMEM5F3g4,18242
41
+ django_chelseru-2.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
42
+ django_chelseru-2.0.2.dist-info/top_level.txt,sha256=fsaO1F03W3j4AYi0TfDGv5Cjb_Qrh6RSkwkWqfqaMns,12
43
+ django_chelseru-2.0.2.dist-info/RECORD,,
drfchelseru/services.py CHANGED
@@ -116,10 +116,38 @@ class KavenegarCom:
116
116
 
117
117
  def __init__(self, mobile, options, *args, **kwargs):
118
118
  self.RECEIVER = mobile
119
- if options and 'api_key' in options and 'from' in options:
119
+ if options and 'api_key' in options:
120
120
  self.API_KEY = options['api_key']
121
- self.SENDER = options['from']
121
+ if 'from' in options:
122
+ self.SENDER = options['from']
123
+
124
+ def send_message_lookup(self, message, template_id, **kwargs):
125
+ try:
126
+ api_url = f'https://api.kavenegar.com/v1/{self.API_KEY}/verify/lookup.json'
127
+ message = ''.join(list(map(lambda x: x if x != ' ' else '-', message.strip())))
128
+ data = {
129
+ 'receptor': self.RECEIVER,
130
+ 'template': template_id,
131
+ 'token': message,
132
+ }
133
+ if kwargs.get('token2'):
134
+ data['token2'] = ''.join(list(map(lambda x: x if x != ' ' else '-', kwargs.get('token2').strip())))
135
+
136
+ if kwargs.get('token3'):
137
+ data['token3'] = ''.join(list(map(lambda x: x if x != ' ' else '-', kwargs.get('token3').strip())))
138
+
139
+ if kwargs.get('token10'):
140
+ data['token10'] = kwargs.get('token10').strip()
122
141
 
142
+ if kwargs.get('token20'):
143
+ data['token20'] = kwargs.get('token20').strip()
144
+
145
+ response = requests.post(url=api_url, data=data)
146
+ return response
147
+
148
+ except Exception as e:
149
+ print(str(e))
150
+ return False
123
151
 
124
152
  def send_message(self, message):
125
153
  try:
@@ -148,7 +176,8 @@ class KavenegarCom:
148
176
  418 Your credit is not sufficient.
149
177
  451 Excessive calls within a specific time period are restricted to IP addresses.
150
178
  """
151
- except:
179
+ except Exception as e:
180
+ print(str(e))
152
181
  return False
153
182
 
154
183
 
@@ -213,7 +242,24 @@ def send_message(mobile_number, message_text, data=None, template_id=None):
213
242
  elif sms_service == 'KAVENEGAR_COM':
214
243
  service = KavenegarCom(mobile=mobile_number, options=options)
215
244
  try:
216
- response = service.send_message(message=message_text)
245
+ if template_id or data.get('template_id'):
246
+ if not template_id:
247
+ template_id = data.get('template_id')
248
+
249
+ _data = {}
250
+ if 'token2' in data:
251
+ _data['token2'] = data.get('token2')
252
+ if 'token3' in data:
253
+ _data['token3'] = data.get('token3')
254
+ if 'token10' in data:
255
+ _data['token10'] = data.get('token10')
256
+ if 'token20' in data:
257
+ _data['token20'] = data.get('token20')
258
+
259
+ response = service.send_message_lookup(message=message_text, template_id=template_id, **_data)
260
+ else:
261
+ response = service.send_message(message=message_text)
262
+
217
263
  response_json = response.json()
218
264
  entries = response_json.get('entries', [])
219
265
  _return = response_json.get('return', {})
drfchelseru/settings.py CHANGED
@@ -187,11 +187,13 @@ def sms_init_check():
187
187
  options['api_key'] = api_key
188
188
 
189
189
  _from = getattr(settings, SERVICE_NAME).get('SMS').get('SETTINGS').get('KAVENEGAR_COM_FROM')
190
- if not _from:
191
- raise ImproperlyConfigured(f'KAVENEGAR_COM_FROM must be defined in {SERVICE_NAME}: SMS: SETTINGS, To send an SMS, the sender`s number is required.')
192
-
193
- else:
190
+ if _from:
194
191
  options['from'] = _from
192
+ # if not _from:
193
+ # raise ImproperlyConfigured(f'KAVENEGAR_COM_FROM must be defined in {SERVICE_NAME}: SMS: SETTINGS, To send an SMS, the sender`s number is required.')
194
+
195
+ # else:
196
+
195
197
 
196
198
  return {'SMS_SERVICE': sms_service, 'SETTINGS': options, 'TEMPLATES': templates}
197
199
  except ImproperlyConfigured as e: