PYTHON SDK
v2.0.3
sender_id.py
이 파일의 문서화 페이지로 가기
1 # vi:set sw=4 ts=4 expandtab:
2 # -*- coding: utf8 -*-
3 
4 import sys
5 sys.path.insert(0, "../../")
6 
7 from sdk.coolsms import Coolsms
8 from sdk.exceptions import CoolsmsException
9 from sdk.exceptions import CoolsmsSDKException
10 from sdk.exceptions import CoolsmsSystemException
11 from sdk.exceptions import CoolsmsServerException
12 
13 ## @class SenderID
14 # @brief management sender id, using Rest API
15 class SenderID:
16  # Coolsms Object
17  cool = None
18 
19  ## @brief initialize
20  # @param string api_key [required]
21  # @param string api_secret [required]
22  # @param boolean use_http_connection [optional]
23  # @throws CoolsmsException
24  def __init__(self, api_key, api_secret, use_http_connection = False):
25  self.cool = Coolsms(api_key, api_secret)
26 
27  # set api name and version
28  self.cool.set_api_config('senderid', '1.1')
29 
30  # if True. use http connection
31  if use_http_connection == True:
32  self.cool.use_http_connection()
33 
34  ## @brief sender id registration request ( HTTP Method POST )
35  # @param string phone [required]
36  # @param string site_user [optional] [default:"__private__"]
37  # @return JSONObject
38  # @throws CoolsmsException
39  def register(self, phone, site_user=None):
40  if phone == None:
41  raise CoolsmsSDKException("'phone' is required", 201);
42 
43  params = dict()
44  params = {'phone':phone}
45  if site_user:
46  params['site_user'] = site_user
47 
48  response = self.cool.request_post('register', params)
49 
50  return response
51 
52  ## @brief verify sender id ( HTTP Method POST )
53  # @param string handle_key[required]
54  # @return None
55  # @throws CoolsmsException
56  def verify(self, handle_key):
57  if handle_key == None:
58  raise CoolsmsSDKException("'handle_key' is required", 201);
59 
60  params = dict()
61  params = {'handle_key':handle_key}
62  response = self.cool.request_post('verify', params)
63 
64  return response
65 
66  ## @brief delete sender id ( HTTP Method POST )
67  # @param string handle_key [required]
68  # @return None
69  # @throws CoolsmsException
70  def delete(self, handle_key):
71  if handle_key == None:
72  raise CoolsmsSDKException("'handle_key' is required", 201);
73 
74  params = dict()
75  params = {'handle_key':handle_key}
76  response = self.cool.request_post('delete', params)
77 
78  return response
79 
80  ## @brief get sender id list ( HTTP Method GET )
81  # @param string site_user [optional] [default:"__private__"]
82  # @return JSONObject
83  # @throws CoolsmsException
84  def get_list(self, site_user=None):
85  params = dict()
86 
87  if site_user:
88  params = {'site_user':site_user}
89 
90  response = self.cool.request_get('list', params)
91  return response
92 
93  ## @brief set default sender id ( HTTP Method POST )
94  # @param string handle_key [required]
95  # @param string site_user [optional] [default:"__private__"]
96  # @return None
97  # @throws CoolsmsException
98  def set_default(self, handle_key, site_user=None):
99  if handle_key == None:
100  raise CoolsmsSDKException("'handle_key' is required", 201);
101 
102  params = dict()
103  params = {'handle_key':handle_key}
104 
105  if site_user:
106  params['site_user'] = site_user
107 
108  response = self.cool.request_post('set_default', params)
109 
110  return response
111 
112  ## @brief get default sender id ( HTTP Method GET )
113  # @param string site_user [optional] [default:"__private__"]
114  # @return JSONObject
115  # @throws CoolsmsException
116  def get_default(self, site_user=None):
117  params = dict()
118 
119  if site_user:
120  params = {'site_user':site_user}
121 
122  response = self.cool.request_get('get_default', params)
123 
124  return response
def register(self, phone, site_user=None)
sender id registration request ( HTTP Method POST )
Definition: sender_id.py:39
def set_default(self, handle_key, site_user=None)
set default sender id ( HTTP Method POST )
Definition: sender_id.py:98
def get_default(self, site_user=None)
get default sender id ( HTTP Method GET )
Definition: sender_id.py:116
def delete(self, handle_key)
delete sender id ( HTTP Method POST )
Definition: sender_id.py:70
Gateway access url : https://api.coolsms.co.kr/{api type}/{verson}/{resource name}.
Definition: coolsms.py:44
def get_list(self, site_user=None)
get sender id list ( HTTP Method GET )
Definition: sender_id.py:84
management sender id, using Rest API
Definition: sender_id.py:15
def __init__(self, api_key, api_secret, use_http_connection=False)
initialize
Definition: sender_id.py:24
def verify(self, handle_key)
verify sender id ( HTTP Method POST )
Definition: sender_id.py:56