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

Commit c2617d3

Browse files
committed
sender_id 구현, image 구현중 ( image 파일 upload 처리 중 )
1 parent 2473350 commit c2617d3

14 files changed

Lines changed: 115 additions & 28 deletions

sdk/__init__.pyc

153 Bytes
Binary file not shown.

sdk/api/__init__.pyc

157 Bytes
Binary file not shown.
2.17 KB
Binary file not shown.
-5 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

sdk/api/group_message.pyc

4.65 KB
Binary file not shown.

sdk/api/image.py

Lines changed: 74 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,83 @@
1010
from sdk.exceptions import CoolsmsSystemException
1111
from sdk.exceptions import CoolsmsServerException
1212

13-
# class Image
13+
## @class Image
14+
# @brief management image, using Rest API
1415
class Image:
15-
#
16+
# Coolsms Object
17+
cool = None
18+
19+
## @brief initialize
20+
# @param string api_key [required]
21+
# @param string api_secret [required]
1622
def __init__(self, api_key, api_secret):
17-
Coolsms(api_key, api_secret)
23+
self.cool = Coolsms(api_key, api_secret)
24+
25+
# @brief get image list( HTTP Method GET )
26+
# @param string offset [optional]
27+
# @param string limit [optional]
28+
# @return JSONObject
29+
def get_image_list(self, offset=None, limit=None):
30+
params = dict()
31+
32+
if offset:
33+
params['offset'] = offset
34+
if limit:
35+
params['limit'] = limit
36+
37+
response = self.cool.request_get('image_list', params)
38+
39+
return response
40+
41+
# @brief get image info ( HTTP Method GET )
42+
# @param string image_id [required]
43+
# @return JSONObject
44+
# @throws CoolsmsException
45+
def get_image_info(self, image_id):
46+
if image_id == None:
47+
raise CoolsmsSDKException("'image_id' is required", 201);
48+
49+
resource = "images/" + image_id;
50+
response = self.cool.request_get(resource)
51+
52+
return response
53+
54+
# @brief upload image ( HTTP Method POST )
55+
# @param string image [required]
56+
# @param string encoding [optional]
57+
# @return JSONobject
58+
def upload_image(self, image, encoding=None):
59+
if image == None:
60+
raise CoolsmsSDKException("'image' is required", 201);
61+
62+
params = dict()
63+
params = {'image':image}
64+
if encoding:
65+
params['encoding'] = encoding
66+
67+
files = {}
68+
69+
try:
70+
with open(params['image'], 'rb') as content_file:
71+
content = content_file.read()
72+
except Exception as e:
73+
raise CoolsmsSystemException(e, 399)
74+
75+
files = {'image': {'filename': image, 'content': content}}
1876

19-
#
20-
def get_image_list(self):
21-
return
77+
response = self.cool.request_post_multipart("upload_image", params, files)
2278

23-
#
24-
def get_image_info(self):
25-
return
79+
return response
2680

27-
#
28-
def upload_image(self):
29-
return
81+
# @brief delete images ( HTTP Method POST )
82+
# @param string image_ids [required]
83+
# @return JSONObject
84+
def delete_images(self, image_ids):
85+
if image_ids == None:
86+
raise CoolsmsSDKException("'image_ids' is required", 201);
87+
88+
params = dict()
89+
params = {'image_ids':image_ids}
90+
response = self.cool.request_post('delete_images', params)
3091

31-
#
32-
def delete_images(self):
33-
return
92+
return response

sdk/api/image.pyc

2.63 KB
Binary file not shown.

sdk/api/message.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def send(self, params):
5858
# type이 mms일때 image file check
5959
files = {}
6060
if 'type' in params and params['type'] == 'mms':
61-
if params['image'] is None:
61+
if 'image' not in params:
6262
raise CoolsmsSDKException('image file is required')
6363

6464
try:
@@ -67,7 +67,7 @@ def send(self, params):
6767
except Exception as e:
6868
raise CoolsmsSystemException(e, 399)
6969

70-
files = {'image': {'filename': image, 'content': content}}
70+
files = {'image': {'filename': params['image'], 'content': content}}
7171

7272
# request post multipart-form
7373
response = self.cool.request_post_multipart("send", params, files)

sdk/api/message.pyc

2.91 KB
Binary file not shown.

0 commit comments

Comments
 (0)