Class: Kth::Sms::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/kth/sms.rb

Constant Summary collapse

BASE_URL =
"http://api.apistore.co.kr".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_id, key) ⇒ Client

Returns a new instance of Client.



11
12
13
14
# File 'lib/kth/sms.rb', line 11

def initialize(client_id, key)
  self.client_id = client_id
  self.key = key
end

Instance Attribute Details

#client_idObject

Returns the value of attribute client_id.



7
8
9
# File 'lib/kth/sms.rb', line 7

def client_id
  @client_id
end

#keyObject

Returns the value of attribute key.



7
8
9
# File 'lib/kth/sms.rb', line 7

def key
  @key
end

Instance Method Details

#callbacks(send_phone_number = nil) ⇒ Object



87
88
89
90
# File 'lib/kth/sms.rb', line 87

def callbacks(send_phone_number = nil)
  request_url = "/ppurio/1/sendnumber/list/#{client_id}?sendnumber=#{send_phone_number}"
  send_get_request request_url
end

#lms(send_phone, dest_phone, msg_body, options) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/kth/sms.rb', line 34

def lms(send_phone, dest_phone, msg_body, options)
  request_url = "/ppurio/1/message/lms/#{client_id}"

  params = {
    'send_phone' => send_phone,
    'dest_phone' => dest_phone,
    'msg_body' => msg_body
  }

  if options.present?
    params['send_time'] = options['send_time'].strftime("%Y%m%d%H%M%S") if options['send_time']
    params['send_name'] = options['send_name'] if options['send_name']
    params['dest_name'] = options['dest_name'] if options['dest_name']
    params['subject'] = options['subject'] if options['subject']
    # smsExcel 은 스펙 제외
  end

  send_post_request request_url, params
end

#register_callback(send_phone_number, comment, pin_type = 'SMS') ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/kth/sms.rb', line 62

def register_callback(send_phone_number, comment, pin_type = 'SMS')
  request_url = "/ppurio/2/sendnumber/save/#{client_id}"

  params = {
    'sendnumber' => send_phone_number,
    'comment' => comment,
    'pintype' => pin_type
  }

  send_post_request request_url, params
end

#report(cmid) ⇒ Object

mms 는 일단 스펙 제외



56
57
58
59
60
# File 'lib/kth/sms.rb', line 56

def report(cmid)
  request_url = "/ppurio/1/message/report/#{client_id}?cmid=#{cmid}&client_id=#{client_id}"

  send_get_request request_url
end

#report_test(cmid) ⇒ Object



110
111
112
113
114
# File 'lib/kth/sms.rb', line 110

def report_test(cmid)
  request_url = "/ppurio_test/1/message_test/report/#{client_id}?cmid=#{cmid}&client_id=#{client_id}"

  send_get_request request_url
end

#sms(send_phone, dest_phone, msg_body, options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/kth/sms.rb', line 16

def sms(send_phone, dest_phone, msg_body, options)
  request_url = "/ppurio/1/message/sms/#{client_id}"
  params = {
    'send_phone' => send_phone,
    'dest_phone' => dest_phone,
    'msg_body' => msg_body
  }

  if options.present?
    params['send_time'] = options['send_time'].strftime("%Y%m%d%H%M%S") if options['send_time']
    params['send_name'] = options['send_name'] if options['send_name']
    params['dest_name'] = options['dest_name'] if options['dest_name']
    # smsExcel 은 스펙 제외
  end

  send_post_request request_url, params
end

#sms_test(send_phone, dest_phone, msg_body, options) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/kth/sms.rb', line 92

def sms_test(send_phone, dest_phone, msg_body, options)
  request_url = "/ppurio_test/1/message_test/sms/#{client_id}"
  params = {
    'send_phone' => send_phone,
    'dest_phone' => dest_phone,
    'msg_body' => msg_body
  }

  if options.present?
    params['send_time'] = options['send_time'].strftime("%Y%m%d%H%M%S") if options['send_time']
    params['send_name'] = options['send_name'] if options['send_name']
    params['dest_name'] = options['dest_name'] if options['dest_name']
    # smsExcel 은 스펙 제외
  end

  send_post_request request_url, params
end

#verify_callback(send_phone_number, comment, pin_type = 'SMS', pin_code) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/kth/sms.rb', line 74

def verify_callback(send_phone_number, comment, pin_type = 'SMS', pin_code)
  request_url = "/ppurio/2/sendnumber/save/#{client_id}"

  params = {
    'sendnumber' => send_phone_number,
    'comment' => comment,
    'pintype' => pin_type,
    'pincode' => pin_code
  }

  send_post_request request_url, params
end