Class: Kth::Alimtalk::Client
- Inherits:
-
Object
- Object
- Kth::Alimtalk::Client
- Defined in:
- lib/kth/alimtalk.rb
Constant Summary collapse
- BASE_URL =
"http://api.apistore.co.kr".freeze
Instance Attribute Summary collapse
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#key ⇒ Object
Returns the value of attribute key.
Instance Method Summary collapse
- #callbacks(send_phone_number = '') ⇒ Object
-
#initialize(client_id, key) ⇒ Client
constructor
TODO.
- #msg_test(phone_number, callback, msg, template_code, failed_type, options) ⇒ Object
- #register_callback(send_phone_number, comment, pin_type = 'SMS') ⇒ Object
- #report(cmid) ⇒ Object
- #send_message(phone_number, callback, msg, template_code, failed_type, options) ⇒ Object
- #templates(options = {}) ⇒ Object
- #verify_callback(send_phone_number, comment, pin_type, pin_code) ⇒ Object
Constructor Details
#initialize(client_id, key) ⇒ Client
TODO. 코드 및 메세지 정의 맵핑 추가
12 13 14 15 |
# File 'lib/kth/alimtalk.rb', line 12 def initialize(client_id, key) self.client_id = client_id self.key = key end |
Instance Attribute Details
#client_id ⇒ Object
Returns the value of attribute client_id.
7 8 9 |
# File 'lib/kth/alimtalk.rb', line 7 def client_id @client_id end |
#key ⇒ Object
Returns the value of attribute key.
7 8 9 |
# File 'lib/kth/alimtalk.rb', line 7 def key @key end |
Instance Method Details
#callbacks(send_phone_number = '') ⇒ Object
79 80 81 82 |
# File 'lib/kth/alimtalk.rb', line 79 def callbacks(send_phone_number = '') request_url = "/kko/1/sendnumber/list/#{client_id}?sendnumber=#{send_phone_number}" send_get_request request_url end |
#msg_test(phone_number, callback, msg, template_code, failed_type, options) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/kth/alimtalk.rb', line 84 def msg_test(phone_number, callback, msg, template_code, failed_type, ) request_url = "/kko/1/msg_test/#{client_id}" params = { 'phone' => phone_number, 'callback' => callback, 'msg' => msg, 'template_code' => template_code, 'failed_type' => failed_type } if .present? params['reqdate'] = ['request_date'].strftime("%Y%m%d%H%M%S") if ['request_date'] params['url'] = ['url'] if ['url'] params['url_button_text'] = ['url_button_text'] if ['url_button_text'] params['failed_subject'] = ['failed_subject'] if ['failed_subject'] params['failed_msg'] = ['failed_msg'] end send_post_request request_url, params end |
#register_callback(send_phone_number, comment, pin_type = 'SMS') ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/kth/alimtalk.rb', line 54 def register_callback(send_phone_number, comment, pin_type = 'SMS') phone_number = send_phone_number.gsub("-", "") request_url = "/kko/1/sendnumber/save/#{client_id}" params = { 'sendnumber' => phone_number, 'comment' => comment, 'pintype' => pin_type } send_post_request request_url, params end |
#report(cmid) ⇒ Object
38 39 40 41 42 |
# File 'lib/kth/alimtalk.rb', line 38 def report(cmid) request_url = "/kko/1/report/#{client_id}?CMID=#{cmid}" send_get_request request_url end |
#send_message(phone_number, callback, msg, template_code, failed_type, options) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kth/alimtalk.rb', line 17 def (phone_number, callback, msg, template_code, failed_type, ) request_url = "/kko/1/msg/#{client_id}" params = { 'phone' => phone_number, 'callback' => callback, 'msg' => msg, 'template_code' => template_code, 'failed_type' => failed_type } if .present? params['reqdate'] = ['request_date'].strftime("%Y%m%d%H%M%S") if ['request_date'] params['url'] = ['url'] if ['url'] params['url_button_text'] = ['url_button_text'] if ['url_button_text'] params['failed_subject'] = ['failed_subject'] if ['failed_subject'] params['failed_msg'] = ['failed_msg'] end send_post_request request_url, params end |
#templates(options = {}) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/kth/alimtalk.rb', line 44 def templates( = {}) request_url = "/kko/1/template/list/#{client_id}?" if .present? request_url += "TEMPLATE_CODE=##{['template_code']}&" if ['template_code'] request_url += "STATUS=#{['status']}&" if ['status'] end send_get_request request_url end |
#verify_callback(send_phone_number, comment, pin_type, pin_code) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/kth/alimtalk.rb', line 66 def verify_callback(send_phone_number, comment, pin_type, pin_code) phone_number = send_phone_number.gsub("-", "") request_url = "/kko/1/sendnumber/save/#{client_id}" params = { 'sendnumber' => phone_number, 'comment' => comment, 'pintype' => pin_type, 'pincode' => pin_code } send_post_request request_url, params end |