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

Commit 85ca629

Browse files
committed
doxygen 에 맞춰서 주석 변경
1 parent 4de63a9 commit 85ca629

2 files changed

Lines changed: 68 additions & 32 deletions

File tree

sdk/api/message.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,21 @@
1111
from sdk.exceptions import CoolsmsSystemException
1212
from sdk.exceptions import CoolsmsServerException
1313

14-
# class Message
14+
## @class Message
15+
# @brief management message, using Rest API
1516
class Message:
17+
# Coolsms Object
1618
cool = None
1719

18-
# initialize
20+
## @brief initialize
21+
# @param string api_key [required]
22+
# @param string api_secret [required]
1923
def __init__(self, api_key, api_secret):
2024
self.cool = Coolsms(api_key, api_secret)
2125

22-
# access to send resource
26+
## @brief access to send resource
27+
# @param dictionary params [required]
28+
# @return JSONObject
2329
def send(self, params):
2430
"""Request to REST API server to send SMS messages
2531
@@ -88,22 +94,30 @@ def send(self, params):
8894
response = self.cool.request_post_multipart("send", params, files)
8995
return response
9096

91-
# access to statusresource
97+
## @brief access to statusresource
98+
# @param dictionary params [optional]
99+
# @return JSONObject
92100
def status(self, params=None):
93101
response = self.cool.request_get('status', params)
94102
return response
95103

96-
# access to status resource
104+
## @brief access to status resource
105+
# @param dictionary params [optional]
106+
# @return JSONObject
97107
def sent(self, params=None):
98108
response = self.cool.request_get('sent', params)
99109
return response
100110

101-
# access to balance resource
111+
## @brief access to balance resource
112+
# @param dictionary params [optional]
113+
# @return JSONObject
102114
def balance(self):
103115
response = self.cool.request_get('balance')
104116
return response
105117

106-
# access to cancel resource
118+
## @brief access to cancel resource
119+
# @param dictionary params [optional]
120+
# @return JSONObject
107121
def cancel(self, params):
108122
if 'message_id' not in params and 'group_id' not in params:
109123
raise CoolsmsSDKException("message_id or group_id either one must be entered", 202)

sdk/coolsms.py

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# vi:set sw=4 ts=4 expandtab:
22
# -*- coding: utf8 -*-
3-
from hashlib import md5
3+
44
import sys
55
import hmac
66
import mimetypes
@@ -9,6 +9,7 @@
99
import time
1010
import platform
1111

12+
from hashlib import md5
1213
from sdk.exceptions import CoolsmsServerException
1314

1415
# sys.version_info.major is available in python version 2.7
@@ -19,13 +20,22 @@
1920
else:
2021
from http.client import HTTPSConnection
2122
from urllib.parse import urlencode
22-
"""
23-
Copyright (C) 2008-2016 NURIGO
24-
http://www.coolsms.co.kr
25-
"""
2623

27-
# class Coolsms
28-
# Gateway access url : https://api.coolsms.co.kr/{api type}/{verson}/{resource name}
24+
## @mainpage PYTHON SDK
25+
# @section intro 소개
26+
# - 소개 : Coolsms REST API SDK FOR PYTHON
27+
# - 버전 : 2.0
28+
# - 설명 : Coolsms REST API 를 이용 보다 빠르고 안전하게 문자메시지를 보낼 수 있는 PYTHON으로 만들어진 SDK 입니다.
29+
# @section CreateInfo 작성 정보
30+
# - 작성자 : Nurigo
31+
# - 작성일 : 2016/05/13 *
32+
# @section common 기타 정보
33+
# - 저작권 GPL v2
34+
# - Copyright (C) 2008-2016 NURIGO
35+
# - http://www.coolsms.co.kr
36+
37+
## @class Coolsms
38+
# @brief Gateway access url : https://api.coolsms.co.kr/{api type}/{verson}/{resource name}
2939
class Coolsms:
3040
# SDK Version
3141
sdk_version = "2.0"
@@ -48,27 +58,25 @@ class Coolsms:
4858
# error handle
4959
error_string = None
5060

51-
# constructor
61+
## @brief initialize
62+
# @param string api_key [required]
63+
# @param string api_secret [required]
5264
def __init__(self, api_key=str(), api_secret=str()):
5365
self.api_key = api_key
5466
self.api_secret = api_secret
5567

56-
# return salt, timestamp, signature
68+
## @brief get signature
69+
# @return string salt, string timestamp, string signature
5770
def __get_signature__(self):
5871
salt = str(uuid.uuid1())
5972
timestamp = str(int(time.time()))
6073
data = timestamp + salt
6174
return timestamp, salt, hmac.new(self.api_secret.encode(), data.encode(), md5)
6275

63-
# error handle
64-
def __set_error__(self, error_str):
65-
self.error_string = error_str
66-
67-
# return error string set
68-
def get_error(self):
69-
return self.error_string
70-
71-
# http GET request
76+
## @brief http GET method request
77+
# @param string resource [required]
78+
# @param dictionary params [optional]
79+
# @return JSONObject
7280
def request_get(self, resource, params=None):
7381
if params == None:
7482
params = dict()
@@ -94,7 +102,10 @@ def request_get(self, resource, params=None):
94102

95103
return obj
96104

97-
# http POST request
105+
## @brief http POST method request
106+
# @param string resource [required]
107+
# @param dictionary params [optional]
108+
# @return JSONObject
98109
def request_post(self, resource, params=None):
99110
if params == None:
100111
params = dict()
@@ -119,7 +130,11 @@ def request_post(self, resource, params=None):
119130

120131
return obj
121132

122-
# send multipart form to the server
133+
## @brief http POST method multipart form request
134+
# @param string resource [required]
135+
# @param dictionary params [optional]
136+
# @param dictionary files [optional]
137+
# @return JSONObject
123138
def request_post_multipart(self, resource, params, files):
124139
host = self.host + ':' + str(self.port)
125140
selector = "/sms/%s/%s" % (self.api_version, resource)
@@ -148,12 +163,15 @@ def request_post_multipart(self, resource, params, files):
148163

149164
return obj
150165

151-
# format multipart form
152-
def encode_multipart_formdata(self, fields, files):
166+
## @brief format multipart form
167+
# @param dictionary params [required]
168+
# @param dictionary files [required]
169+
# @return string content_type, string body
170+
def encode_multipart_formdata(self, params, files):
153171
boundary = str(uuid.uuid1())
154172
crlf = '\r\n'
155173
l = []
156-
for key, value in fields.items():
174+
for key, value in params.items():
157175
l.append('--' + boundary)
158176
l.append('Content-Disposition: form-data; name="%s"' % key)
159177
l.append('')
@@ -171,11 +189,15 @@ def encode_multipart_formdata(self, fields, files):
171189
content_type = 'multipart/form-data; boundary=%s' % boundary
172190
return content_type, body
173191

174-
# get content type
192+
## @brief get content type
193+
# @param string filesname [required]
194+
# @return string content_type
175195
def get_content_type(filename):
176196
return mimetypes.guess_type(filename)[0] or 'application/octet-stream'
177197

178-
# set base parameter
198+
## @brief set base parameter
199+
# @param dictionary params [required]
200+
# @return dictionary params
179201
def set_base_params(self, params):
180202
timestamp, salt, signature = self.__get_signature__()
181203
base_params = {'api_key': self.api_key, 'timestamp': timestamp, 'salt': salt,

0 commit comments

Comments
 (0)