-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor sms_services module to centralize SMS service instance retri…
…eval
- Loading branch information
1 parent
206b7b3
commit 935d7b0
Showing
3 changed files
with
34 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from sms_services import getsmscode | ||
from sms_services import smspool | ||
from sms_services import fivesim | ||
|
||
def get_sms_instance(sms_info): | ||
""" | ||
Retrieves an instance of an SMS provider based on the given SMS information. | ||
Args: | ||
sms_info (dict): A dictionary containing the SMS service name and associated data. | ||
Returns: | ||
object: An instance of the SMS provider based on the provided SMS service. | ||
""" | ||
service_name = sms_info['name'] | ||
|
||
if service_name == 'getsmscode': | ||
data = sms_info['data'] | ||
data.update({'project': 1, 'country': 'hk'}) | ||
sms_provider = getsmscode.GetsmsCode(**data) | ||
elif service_name == 'smspool': | ||
data = sms_info['data'] | ||
data.update({'service': 395}) | ||
sms_provider = smspool.SMSPool(**data) | ||
elif service_name == '5sim': | ||
data = sms_info['data'] | ||
data.update({'service': 'google'}) | ||
sms_provider = fivesim.FiveSim(**data) | ||
|
||
return sms_provider |