Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

Commit 1634e26

Browse files
committed
Resource sms send 구현중
1 parent 952f7e6 commit 1634e26

3 files changed

Lines changed: 34 additions & 25 deletions

File tree

2.55 KB
Binary file not shown.

sdk/api/message.py

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
# -*- coding: utf8 -*-
33

44
import sys
5+
import platform
56
sys.path.insert(0, "../../")
67

78
from sdk.coolsms import Coolsms
8-
from sdk import exceptions
9+
from sdk.exceptions import CoolsmsSDKException
910

1011
#import sdk.coolsms
1112

@@ -18,11 +19,7 @@ def __init__(self, api_key, api_secret):
1819
Coolsms(api_key, api_secret)
1920

2021
# access to send resource
21-
def send(params):
22-
if type(params) is not str:
23-
print("ERROR")
24-
#raise Exception("ERROR", "TT")
25-
22+
def send(self, params):
2623
"""Request to REST API server to send SMS messages
2724
2825
Arguments:
@@ -42,25 +39,35 @@ def send(params):
4239
Returns:
4340
A JSON type string will be returned. On failure, thorw Exception
4441
"""
42+
43+
print("GG")
44+
print(type(params))
45+
if type(params) is not dict:
46+
raise CoolsmsSDKException("params type is no dictionary")
47+
48+
for key, val in params.items():
49+
print("Code : {0}, Value : {1}".format(key, val))
50+
if key == "text" and sys.version_info[0] == 2:
51+
t_temp = text.decode('utf-8')
52+
text = t_temp.encode('utf-8')
53+
text = unicode(text, encoding='utf-8')
54+
params['text'] = text
55+
56+
if key == "to" and type(to) == list:
57+
to = ','.join(to)
4558

46-
# convert list to a comma seperated string
47-
if sys.version_info[0] == 2:
48-
t_temp = text.decode('utf-8')
49-
text = t_temp.encode('utf-8')
50-
text = unicode(text, encoding='utf-8')
51-
if type(to) == list:
52-
to = ','.join(to)
53-
54-
if type:
55-
if type.lower() not in ['sms', 'lms', 'mms']:
56-
self.__set_error__('invalid message type')
57-
return False
58-
else:
59-
type = self.get_type()
6059

61-
os_platform = platform.system()
62-
dev_lang = "Python %s" % platform.python_version()
63-
sdk_version = "sms-python %s" % __version__
60+
params['os_platform'] = platform.system()
61+
params['dev_lang'] = "Python %s" % platform.python_version()
62+
params['sdk_version'] = "sms-python %s" % Coolsms.sdk_version
63+
64+
for key, val in params.items():
65+
print("Code : {0}, Value : {1}".format(key, val))
66+
67+
68+
# convert list to a comma seperated string
69+
"""
70+
6471
if app_version:
6572
self.app_version = app_version
6673
@@ -135,6 +142,7 @@ def send(params):
135142
self.__set_error__("%s:%s" % (err['code'], reason))
136143
return False
137144
return json.loads(response)
145+
"""
138146

139147
# access to sent resource
140148
def status(self, page=1, count=20, s_rcpt=None, s_start=None, s_end=None, mid=None):

sdk/coolsms.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
http://www.coolsms.co.kr
2323
"""
2424

25-
__version__ = "2.0"
26-
2725
# class Coolsms
2826
# Gateway access url : https://api.coolsms.co.kr/{api type}/{verson}/{resource name}
2927
class Coolsms:
28+
# SDK Version
29+
sdk_version = "2.0"
30+
3031
# SMS Gateway address
3132
host = 'api.coolsms.co.kr'
3233

0 commit comments

Comments
 (0)