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

Commit 02ae726

Browse files
committed
inspection rework
1 parent f297382 commit 02ae726

6 files changed

Lines changed: 83 additions & 46 deletions

File tree

examples/message/send.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
# params["app_version] = "Python SDK v2.0" # 어플리케이션 버전
4040

4141
cool = Message(api_key, api_secret)
42+
4243
try:
4344
response = cool.send(params)
4445
print("Success Count : %s" % response['success_count'])

sdk/api/group_message.py

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class GroupMessage:
2222
# @param string api_key [required]
2323
# @param string api_secret [required]
2424
# @param boolean use_http_connection [optional]
25+
# @throws CoolsmsException
2526
def __init__(self, api_key, api_secret, use_http_connection = False):
2627
self.cool = Coolsms(api_key, api_secret)
2728

@@ -31,16 +32,19 @@ def __init__(self, api_key, api_secret, use_http_connection = False):
3132

3233
## @brief create create group ( HTTP Method GET )
3334
# @param dictionary params {
34-
# @param string charset [optional]
35+
# @param string charset [optional] [default:"utf8"]
3536
# @param string srk [optional]
3637
# @param string mode [optional]
37-
# @param string delay [optional]
38-
# @param boolean force_sms [optional]
38+
# @param string delay [optional] [default:"0"]
39+
# @param boolean force_sms [optional] [default:"false"]
3940
# @param string os_platform [optional]
4041
# @param string dev_lang [optional]
4142
# @param string sdk_version [optional]
42-
# @param string app_version [optional] }
43+
# @param string app_version [optional]
44+
# @param string site_user [optional] [default:"__private__"]
45+
# @param string only_ata [optional] [default:"false"] }
4346
# @return JSONObject
47+
# @throws CoolsmsException
4448
def create_group(self, params=None):
4549
response = self.cool.request_get('new_group', params)
4650

@@ -49,6 +53,7 @@ def create_group(self, params=None):
4953
## @brief get group list ( HTTP Method GET )
5054
# @param None
5155
# @return JSONArray
56+
# @throws CoolsmsException
5257
def get_group_list(self):
5358
response = self.cool.request_get('group_list')
5459

@@ -57,6 +62,7 @@ def get_group_list(self):
5762
## @brief delete groups ( HTTP Method POST )
5863
# @param string group_ids [required]
5964
# @return JSONobject
65+
# @throws CoolsmsException
6066
def delete_groups(self, group_ids):
6167
if group_ids == None:
6268
raise CoolsmsSDKException("parameter 'group_ids' is required", 201)
@@ -69,6 +75,7 @@ def delete_groups(self, group_ids):
6975
## @brief get group info ( HTTP Method GET )
7076
# @param string group_id [required]
7177
# @return JSONObject
78+
# @throws CoolsmsException
7279
def get_group_info(self, group_id):
7380
if group_id == None:
7481
raise CoolsmsSDKException("parameter 'group_id' is required", 201)
@@ -84,13 +91,17 @@ def get_group_info(self, group_id):
8491
# @param string to [required]
8592
# @param string from [required]
8693
# @param string text [required]
94+
# @param string type [required] [default:"sms"]
8795
# @param string image_id [optional]
8896
# @param string refname [optional]
89-
# @param string country [optional]
97+
# @param string country [optional] [default:"82"]
9098
# @param string datetime [optional]
9199
# @param string subject [optional]
92-
# @param integer delay [optional] }
100+
# @param integer delay [optional] [default:"0"]
101+
# @param string template_code [optional]
102+
# @param string sender_key [optional] }
93103
# @return JSONObject
104+
# @throws CoolsmsException
94105
def add_messages(self, params):
95106
# params type check
96107
if type(params) is not dict:
@@ -116,16 +127,21 @@ def add_messages(self, params):
116127
## @brief add json type message to group ( HTTP Method POST )
117128
# @param string group_id [required]
118129
# @param JSONArray messages [required] [{
130+
# @param string group_id [required]
119131
# @param string to [required]
120132
# @param string from [required]
121133
# @param string text [required]
134+
# @param string type [required] [default:"sms"]
122135
# @param string image_id [optional]
123136
# @param string refname [optional]
124-
# @param string country [optional]
137+
# @param string country [optional] [default:"82"]
125138
# @param string datetime [optional]
126139
# @param string subject [optional]
127-
# @param integer delay [optional] }]
140+
# @param integer delay [optional] [default:"0"]
141+
# @param string template_code [optional]
142+
# @param string sender_key [optional] }]
128143
# @return JSONObject
144+
# @throws CoolsmsException
129145
def add_messages_json(self, group_id, messages):
130146
# require fields check
131147
if group_id == None or messages == None:
@@ -154,9 +170,10 @@ def add_messages_json(self, group_id, messages):
154170
## @brief get message list ( HTTP Method GET )
155171
# @param dictionary params {
156172
# @param string group_id [required]
157-
# @param integer offset [optional]
158-
# @param integer limit [optional] }
173+
# @param integer offset [optional] [default:"0"]
174+
# @param integer limit [optional] [default:"20"] }
159175
# @return JSONObject
176+
# @throws CoolsmsException
160177
def get_message_list(self, params):
161178
# require fields check
162179
if "group_id" not in params:
@@ -172,6 +189,7 @@ def get_message_list(self, params):
172189
# @param string group_id [required]
173190
# @param string message_ids [required]
174191
# @return JSONObject
192+
# @throws CoolsmsException
175193
def delete_messages(self, group_id, message_ids):
176194
# require fields check
177195
if group_id == None or message_ids == None:
@@ -189,6 +207,7 @@ def delete_messages(self, group_id, message_ids):
189207
## @brief send group message ( HTTP Method POST )
190208
# @param string group_id [required]
191209
# @return JSONObject
210+
# @throws CoolsmsException
192211
def send(self, group_id):
193212
# require filed check
194213
if group_id == None:

sdk/api/image.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,19 @@ class Image:
2121
# @param string api_key [required]
2222
# @param string api_secret [required]
2323
# @param boolean use_http_connection [optional]
24+
# @throws CoolsmsException
2425
def __init__(self, api_key, api_secret, use_http_connection = False):
2526
self.cool = Coolsms(api_key, api_secret)
2627

2728
# if True. use http connection
2829
if use_http_connection == True:
2930
self.cool.use_http_connection()
3031

31-
# @brief get image list( HTTP Method GET )
32-
# @param string offset [optional]
33-
# @param string limit [optional]
34-
# @return JSONObject
32+
## @brief get image list( HTTP Method GET )
33+
# @param string offset [optional] [default:"0"]
34+
# @param string limit [optional] [default:"20"]
35+
# @return JSONObject
36+
# @throws CoolsmsException
3537
def get_image_list(self, offset=None, limit=None):
3638
params = dict()
3739

@@ -44,10 +46,10 @@ def get_image_list(self, offset=None, limit=None):
4446

4547
return response
4648

47-
# @brief get image info ( HTTP Method GET )
48-
# @param string image_id [required]
49-
# @return JSONObject
50-
# @throws CoolsmsException
49+
## @brief get image info ( HTTP Method GET )
50+
# @param string image_id [required]
51+
# @return JSONObject
52+
# @throws CoolsmsException
5153
def get_image_info(self, image_id):
5254
if image_id == None:
5355
raise CoolsmsSDKException("'image_id' is required", 201);
@@ -57,9 +59,10 @@ def get_image_info(self, image_id):
5759

5860
return response
5961

60-
# @brief upload image ( HTTP Method POST )
61-
# @param string image [required]
62-
# @return JSONobject
62+
## @brief upload image ( HTTP Method POST )
63+
# @param string image [required]
64+
# @return JSONobject
65+
# @throws CoolsmsException
6366
def upload_image(self, image):
6467
if image == None:
6568
raise CoolsmsSDKException("'image' is required", 201);
@@ -81,9 +84,10 @@ def upload_image(self, image):
8184

8285
return response
8386

84-
# @brief delete images ( HTTP Method POST )
85-
# @param string image_ids [required]
86-
# @return JSONObject
87+
## @brief delete images ( HTTP Method POST )
88+
# @param string image_ids [required]
89+
# @return JSONObject
90+
# @throws CoolsmsException
8791
def delete_images(self, image_ids):
8892
if image_ids == None:
8993
raise CoolsmsSDKException("'image_ids' is required", 201);

sdk/api/message.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,25 @@ def __init__(self, api_key, api_secret, use_http_connection = False):
3434
# @param string to [required]
3535
# @param string from [required]
3636
# @param string text [required]
37-
# @param string type [optional]
37+
# @param string type [optional] [default:"sms"]
3838
# @param mixed image [optional]
3939
# @param string image_encoding [optional]
4040
# @param string refname [optional]
41-
# @param mixed country [optional]
41+
# @param mixed country [optional] [default:"82"]
4242
# @param string datetime [optional]
4343
# @param string subject [optional]
44-
# @param string charset [optional]
44+
# @param string charset [optional] [default:"utf8"]
4545
# @param string srk [optional]
4646
# @param string mode [optional]
4747
# @param string extension [optional]
48-
# @param integer delay [optional]
48+
# @param integer delay [optional] [default:"0"]
4949
# @param boolean force_sms [optional]
50-
# @param string app_version [optional] }
50+
# @param string app_version [optional]
51+
# @param string template_code [optional]
52+
# @param string sender_key [optional]
53+
# @param string only_ata [optional] [default:"false"] }
5154
# @return JSONObject
55+
# @throws CoolsmsException
5256
def send(self, params):
5357
# params type check
5458
if type(params) is not dict:
@@ -65,7 +69,7 @@ def send(self, params):
6569
files = {}
6670
if 'type' in params and params['type'] == 'mms':
6771
if 'image' not in params:
68-
raise CoolsmsSDKException('image file is required')
72+
raise CoolsmsSDKException('image file is required', 201)
6973

7074
try:
7175
with open(params['image'], 'rb') as content_file:
@@ -82,10 +86,10 @@ def send(self, params):
8286

8387
## @brief get status ( HTTP Method GET )
8488
# @param dictionary params {
85-
# @param integer count [optional]
89+
# @param integer count [optional] [default:"1"]
8690
# @param string unit [optional]
87-
# @param string date [optional]
88-
# @param integer channel [optional] }
91+
# @param string date [optional] [default:현재시각]
92+
# @param integer channel [optional] [default:"1"] }
8993
# @return JSONObject
9094
# @throws CoolsmsException
9195
def status(self, params=None):
@@ -95,24 +99,25 @@ def status(self, params=None):
9599
## @brief sent messages ( HTTP Method GET )
96100
# @param dictionary params {
97101
# @param integer offset [optional]
98-
# @param integer limit [optional]
102+
# @param integer limit [optional] [default:"20"]
99103
# @param string rcpt [optional]
100104
# @param string start [optional]
101105
# @param string end [optional]
102106
# @param string status [optional]
103107
# @param string status [optional]
104108
# @param string resultcode [optional]
105-
# @param string notin_resultcode [optional]
106109
# @param string message_id [optional]
107110
# @param string group_id [optional] }
108111
# @return JSONObject
112+
# @throws CoolsmsException
109113
def sent(self, params=None):
110114
response = self.cool.request_get('sent', params)
111115
return response
112116

113117
## @brief get remaining balance ( HTTP Method GET )
114118
# @param None
115119
# @return JSONobject
120+
# @throws CoolsmsException
116121
def balance(self):
117122
response = self.cool.request_get('balance')
118123
return response
@@ -122,6 +127,7 @@ def balance(self):
122127
# @param string mid [optional]
123128
# @param string gid [optional] }
124129
# @return None
130+
# @throws CoolsmsException
125131
def cancel(self, params):
126132
if 'message_id' not in params and 'group_id' not in params:
127133
raise CoolsmsSDKException("message_id or group_id either one must be entered", 201)

sdk/api/sender_id.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ class SenderID:
1616
# Coolsms Object
1717
cool = None
1818

19-
2019
## @brief initialize
2120
# @param string api_key [required]
2221
# @param string api_secret [required]
2322
# @param boolean use_http_connection [optional]
23+
# @throws CoolsmsException
2424
def __init__(self, api_key, api_secret, use_http_connection = False):
2525
self.cool = Coolsms(api_key, api_secret)
2626

@@ -31,10 +31,11 @@ def __init__(self, api_key, api_secret, use_http_connection = False):
3131
if use_http_connection == True:
3232
self.cool.use_http_connection()
3333

34-
# @brief sender id registration request ( HTTP Method POST )
34+
## @brief sender id registration request ( HTTP Method POST )
3535
# @param string phone [required]
36-
# @param string site_user [optional]
36+
# @param string site_user [optional] [default:"__private__"]
3737
# @return JSONObject
38+
# @throws CoolsmsException
3839
def register(self, phone, site_user=None):
3940
if phone == None:
4041
raise CoolsmsSDKException("'phone' is required", 201);
@@ -48,9 +49,10 @@ def register(self, phone, site_user=None):
4849

4950
return response
5051

51-
# @brief verify sender id ( HTTP Method POST )
52+
## @brief verify sender id ( HTTP Method POST )
5253
# @param string handle_key[required]
5354
# @return None
55+
# @throws CoolsmsException
5456
def verify(self, handle_key):
5557
if handle_key == None:
5658
raise CoolsmsSDKException("'handle_key' is required", 201);
@@ -61,9 +63,10 @@ def verify(self, handle_key):
6163

6264
return response
6365

64-
# @brief delete sender id ( HTTP Method POST )
66+
## @brief delete sender id ( HTTP Method POST )
6567
# @param string handle_key [required]
6668
# @return None
69+
# @throws CoolsmsException
6770
def delete(self, handle_key):
6871
if handle_key == None:
6972
raise CoolsmsSDKException("'handle_key' is required", 201);
@@ -74,9 +77,10 @@ def delete(self, handle_key):
7477

7578
return response
7679

77-
# @brief get sender id list ( HTTP Method GET )
78-
# @param string site_user [optional]
80+
## @brief get sender id list ( HTTP Method GET )
81+
# @param string site_user [optional] [default:"__private__"]
7982
# @return JSONObject
83+
# @throws CoolsmsException
8084
def get_list(self, site_user=None):
8185
params = dict()
8286

@@ -86,10 +90,11 @@ def get_list(self, site_user=None):
8690
response = self.cool.request_get('list', params)
8791
return response
8892

89-
# @brief set default sender id ( HTTP Method POST )
93+
## @brief set default sender id ( HTTP Method POST )
9094
# @param string handle_key [required]
91-
# @param string site_user [optional]
95+
# @param string site_user [optional] [default:"__private__"]
9296
# @return None
97+
# @throws CoolsmsException
9398
def set_default(self, handle_key, site_user=None):
9499
if handle_key == None:
95100
raise CoolsmsSDKException("'handle_key' is required", 201);
@@ -104,9 +109,10 @@ def set_default(self, handle_key, site_user=None):
104109

105110
return response
106111

107-
# @brief get default sender id ( HTTP Method GET )
108-
# @param string site_user [optional]
112+
## @brief get default sender id ( HTTP Method GET )
113+
# @param string site_user [optional] [default:"__private__"]
109114
# @return JSONObject
115+
# @throws CoolsmsException
110116
def get_default(self, site_user=None):
111117
params = dict()
112118

sdk/coolsms.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ def check_send_data(self, params):
245245
raise CoolsmsSDKException("parameter 'to', 'from', 'text' are required", 201)
246246

247247
for key, val in params.items():
248+
# ptyhon 2 version 에서 unicode 문제 해결
248249
if key == "text" and sys.version_info[0] == 2:
249250
text = val
250251
t_temp = text.decode('utf-8')

0 commit comments

Comments
 (0)