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

Commit 8d255e3

Browse files
committed
message resource 소스 수정 및 주석 수정
1 parent e82bc2e commit 8d255e3

1 file changed

Lines changed: 48 additions & 52 deletions

File tree

sdk/api/message.py

Lines changed: 48 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -23,54 +23,32 @@ class Message:
2323
def __init__(self, api_key, api_secret):
2424
self.cool = Coolsms(api_key, api_secret)
2525

26-
## @brief access to send resource
27-
# @param dictionary params [required]
26+
## @brief send messages ( HTTP Method POST )
27+
# @param dictionary params {
28+
# @param string to [required]
29+
# @param string from [required]
30+
# @param string text [required]
31+
# @param string type [optional]
32+
# @param mixed image [optional]
33+
# @param string image_encoding [optional]
34+
# @param string refname [optional]
35+
# @param mixed country [optional]
36+
# @param string datetime [optional]
37+
# @param string subject [optional]
38+
# @param string charset [optional]
39+
# @param string srk [optional]
40+
# @param string mode [optional]
41+
# @param string extension [optional]
42+
# @param integer delay [optional]
43+
# @param boolean force_sms [optional]
44+
# @param string app_version [optional] }
2845
# @return JSONObject
2946
def send(self, params):
30-
"""Request to REST API server to send SMS messages
31-
32-
Arguments:
33-
to : A comma seperated string which contains phone numbers.
34-
from : sender number
35-
text : Message content
36-
type : one of sms, lms, mms
37-
template_code : alimtalk template code
38-
sender_key : alimtalk sender key
39-
subject : If you send LMS or MMS, you should input the subject of the message(s).
40-
image : Include image, when you send MMS.
41-
datetime : Use this field when you send scheduled messages.
42-
country : country code ( korea:82, japan:81 ... visit 'http://countrycode.org' )
43-
44-
and more informations, visit 'http://www.coolsms.co.kr/SMS_API_v2#POSTsend'
45-
46-
Returns:
47-
A JSON type string will be returned. On failure, raise Exception
48-
"""
4947
# params type check
5048
if type(params) is not dict:
5149
raise CoolsmsSDKException("parameter type is not dictionary", 201)
5250

53-
# require fields check
54-
if all (k in params for k in ("to", "from", "text")) == False:
55-
raise CoolsmsSDKException("parameter 'to', 'from', 'text' are required", 201)
56-
57-
for key, val in params.items():
58-
print("Code : {0}, Value : {1}".format(key, val))
59-
60-
if key == "text" and sys.version_info[0] == 2:
61-
text = val
62-
t_temp = text.decode('utf-8')
63-
text = t_temp.encode('utf-8')
64-
text = unicode(text, encoding='utf-8')
65-
params['text'] = text
66-
67-
# convert list to a comma seperated string
68-
if key == "to" and val == list:
69-
to = ','.join(to)
70-
71-
# message type check
72-
if key == "type" and val.lower() not in ['sms', 'lms', 'mms', 'ata']:
73-
raise CoolsmsSDKException("message type is not supported", 201)
51+
params = Coolsms.check_send_data(params)
7452

7553
# system info
7654
params['os_platform'] = platform.system()
@@ -95,30 +73,48 @@ def send(self, params):
9573
response = self.cool.request_post_multipart("send", params, files)
9674
return response
9775

98-
## @brief access to statusresource
99-
# @param dictionary params [optional]
76+
## @brief get status ( HTTP Method GET )
77+
# @param dictionary params {
78+
# @param integer count [optional]
79+
# @param string unit [optional]
80+
# @param string date [optional]
81+
# @param integer channel [optional] }
10082
# @return JSONObject
83+
# @throws CoolsmsException
10184
def status(self, params=None):
10285
response = self.cool.request_get('status', params)
10386
return response
10487

105-
## @brief access to status resource
106-
# @param dictionary params [optional]
88+
## @brief sent messages ( HTTP Method GET )
89+
# @param dictionary params {
90+
# @param integer offset [optional]
91+
# @param integer limit [optional]
92+
# @param string rcpt [optional]
93+
# @param string start [optional]
94+
# @param string end [optional]
95+
# @param string status [optional]
96+
# @param string status [optional]
97+
# @param string resultcode [optional]
98+
# @param string notin_resultcode [optional]
99+
# @param string message_id [optional]
100+
# @param string group_id [optional] }
107101
# @return JSONObject
108102
def sent(self, params=None):
109103
response = self.cool.request_get('sent', params)
110104
return response
111105

112-
## @brief access to balance resource
113-
# @param dictionary params [optional]
114-
# @return JSONObject
106+
## @brief get remaining balance ( HTTP Method GET )
107+
# @param None
108+
# @return JSONobject
115109
def balance(self):
116110
response = self.cool.request_get('balance')
117111
return response
118112

119-
## @brief access to cancel resource
120-
# @param dictionary params [optional]
121-
# @return JSONObject
113+
## @brief cancel reserve message. mid or gid either one must be entered. ( HTTP Method POST )
114+
# @param dictionary params {
115+
# @param string mid [optional]
116+
# @param string gid [optional] }
117+
# @return None
122118
def cancel(self, params):
123119
if 'message_id' not in params and 'group_id' not in params:
124120
raise CoolsmsSDKException("message_id or group_id either one must be entered", 201)

0 commit comments

Comments
 (0)