Class: KakaoService

Inherits:
BaseService show all
Defined in:
lib/popbill/kakaotalk.rb

Overview

팝빌 카카오톡 API Service Implementation

Constant Summary

Constants inherited from BaseService

BaseService::BOUNDARY, BaseService::POPBILL_APIVersion, BaseService::ServiceID_REAL, BaseService::ServiceID_TEST, BaseService::ServiceURL_REAL, BaseService::ServiceURL_TEST

Instance Attribute Summary

Attributes inherited from BaseService

#isTest, #linkhub, #scopes, #token_table

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseService

#addScope, #checkID, #checkIsMember, #getAccessURL, #getBalance, #getChargeURL, #getCorpInfo, #getPartnerBalance, #getPartnerURL, #getPopbillURL, #getServiceID, #getServiceURL, #getSession_Token, #gzip_parse, #httpget, #httppost, #httppostfile, #httppostfiles, #joinMember, #listContact, #registContact, #setIsTest, #updateContact, #updateCorpInfo

Class Method Details

.instance(linkID, secretKey) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/popbill/kakaotalk.rb', line 7

def instance(linkID, secretKey)
  super(linkID, secretKey)
  @instance ||= new
  @instance.addScope("153")
  @instance.addScope("154")
  @instance.addScope("155")
  return @instance
end

Instance Method Details

#cancelReserve(corpNum, receiptNum, userID = '') ⇒ Object

Raises:



194
195
196
197
198
199
# File 'lib/popbill/kakaotalk.rb', line 194

def cancelReserve(corpNum, receiptNum, userID = '')
  raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.") if corpNum.length != 10
  raise PopbillException.new(-99999999, "접수번호(receiptNum)가 입력되지 않았습니다.") if receiptNum.to_s == ''

  httpget("/KakaoTalk/#{receiptNum}/Cancel", corpNum, userID)
end

#cancelReserveRN(corpNum, requestNum, userID = '') ⇒ Object

Raises:



201
202
203
204
205
206
# File 'lib/popbill/kakaotalk.rb', line 201

def cancelReserveRN(corpNum, requestNum, userID = '')
  raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.") if corpNum.length != 10
  raise PopbillException.new(-99999999, "요청번호(requestNum)가 입력되지 않았습니다.") if requestNum.to_s == ''

  httpget("/KakaoTalk/Cancel/#{requestNum}", corpNum, userID)
end

#getATSTemplateMgtURL(corpNum, userID) ⇒ Object

알림톡 템플릿관리 팝업 URL



48
49
50
51
52
53
54
55
# File 'lib/popbill/kakaotalk.rb', line 48

def getATSTemplateMgtURL(corpNum, userID)
  if corpNum.length != 10
    raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
  end

  response = httpget("/KakaoTalk/?TG=TEMPLATE", corpNum, userID)
  response['url']
end

#getChargeInfo(corpNum, msgType, userID = '') ⇒ Object

Raises:



251
252
253
254
255
# File 'lib/popbill/kakaotalk.rb', line 251

def getChargeInfo(corpNum, msgType, userID = '')
  raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.") if corpNum.length != 10

  httpget("/KakaoTalk/ChargeInfo?Type=#{msgType}", corpNum, userID)
end

#getMessages(corpNum, receiptNum, userID = '') ⇒ Object

Raises:



209
210
211
212
213
214
# File 'lib/popbill/kakaotalk.rb', line 209

def getMessages(corpNum, receiptNum, userID = '')
  raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.") if corpNum.length != 10
  raise PopbillException.new(-99999999, "접수번호(receiptNum)가 입력되지 않았습니다.") if receiptNum.to_s == ''

  httpget("/KakaoTalk/#{receiptNum}", corpNum, userID)
end

#getMessagesRN(corpNum, requestNum, userID = '') ⇒ Object

Raises:



216
217
218
219
220
221
# File 'lib/popbill/kakaotalk.rb', line 216

def getMessagesRN(corpNum, requestNum, userID = '')
  raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.") if corpNum.length != 10
  raise PopbillException.new(-99999999, "요청번호(requestNum)가 입력되지 않았습니다.") if requestNum.to_s == ''

  httpget("/KakaoTalk/Get/#{requestNum}", corpNum, userID)
end

#getPlusFriendMgtURL(corpNum, userID) ⇒ Object

플러스친구 계정관리 팝업 URL



28
29
30
31
32
33
34
35
# File 'lib/popbill/kakaotalk.rb', line 28

def getPlusFriendMgtURL(corpNum, userID)
  if corpNum.length != 10
    raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
  end

  response = httpget("/KakaoTalk/?TG=PLUSFRIEND", corpNum, userID)
  response['url']
end

#getSenderNumberList(corpNum, userID = '') ⇒ Object

Raises:



73
74
75
76
77
# File 'lib/popbill/kakaotalk.rb', line 73

def getSenderNumberList(corpNum, userID = '')
  raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.") if corpNum.length != 10

  httpget("/Message/SenderNumber", corpNum, userID)
end

#getSenderNumberMgtURL(corpNum, userID) ⇒ Object

발신번호 관리 팝업 URL



38
39
40
41
42
43
44
45
# File 'lib/popbill/kakaotalk.rb', line 38

def getSenderNumberMgtURL(corpNum, userID)
  if corpNum.length != 10
    raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
  end

  response = httpget("/Message/?TG=SENDER", corpNum, userID)
  response['url']
end

#getSentListURL(corpNum, userID) ⇒ Object

카카오톡 전송내역 팝업 URL



58
59
60
61
62
63
64
65
# File 'lib/popbill/kakaotalk.rb', line 58

def getSentListURL(corpNum, userID)
  if corpNum.length != 10
    raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
  end

  response = httpget("/KakaoTalk/?TG=BOX", corpNum, userID)
  response['url']
end

#getUnitCost(corpNum, msgType, userID = '') ⇒ Object

Raises:



245
246
247
248
249
# File 'lib/popbill/kakaotalk.rb', line 245

def getUnitCost(corpNum, msgType, userID = '')
  raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.") if corpNum.length != 10

  httpget("/KakaoTalk/UnitCost?Type=#{msgType}", corpNum, userID)
end

#getURL(corpNum, togo, userID = '') ⇒ Object

Raises:



19
20
21
22
23
24
25
# File 'lib/popbill/kakaotalk.rb', line 19

def getURL(corpNum, togo, userID = '')
  raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.") if corpNum.length != 10

  (togo == "SENDER") ?
      httpget("/Message/?TG=#{togo}", corpNum, userID)['url'] :
      httpget("/KakaoTalk/?TG=#{togo}", corpNum, userID)['url']
end

#listATSTemplate(corpNum, userID = '') ⇒ Object

Raises:



79
80
81
82
83
# File 'lib/popbill/kakaotalk.rb', line 79

def listATSTemplate(corpNum, userID = '')
  raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.") if corpNum.length != 10

  httpget("/KakaoTalk/ListATSTemplate", corpNum, userID)
end

#listPlusFriendID(corpNum, userID = '') ⇒ Object

Raises:



67
68
69
70
71
# File 'lib/popbill/kakaotalk.rb', line 67

def listPlusFriendID(corpNum, userID = '')
  raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.") if corpNum.length != 10

  httpget("/KakaoTalk/ListPlusFriendID", corpNum, userID)
end

#search(corpNum, sDate, eDate, state, item, reserveYN, senderYN, page, perPage, order, userID = '', queryString = '') ⇒ Object

Raises:



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/popbill/kakaotalk.rb', line 223

def search(corpNum, sDate, eDate, state, item, reserveYN, senderYN, page, perPage, order, userID = '', queryString ='')
  raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.") if corpNum.length != 10
  raise PopbillException.new(-99999999, "시작일자가 입력되지 않았습니다.") if sDate.to_s == ''
  raise PopbillException.new(-99999999, "종료일자가 입력되지 않았습니다.") if eDate.to_s == ''

  uri = "/KakaoTalk/Search?SDate=#{sDate}&EDate=#{eDate}"
  uri += "&State=" + state.join(',') if state.to_s != ''
  uri += "&Item=" + item.join(',') if item.to_s != ''
  uri += "&ReserveYN=" + reserveYN
  uri += "&SenderYN=" + senderYN
  uri += "&Page=" + page.to_s
  uri += "&PerPage=" + perPage.to_s
  uri += "&Order=" + order

  if queryString.to_s != ''
    uri += "&QString=" + queryString
  end

  httpget(URI.escape(uri), corpNum, userID)
end

#sendATS_multi(corpNum, templateCode, snd, altSendType, sndDT, msgs, requestNum = '', userID = '') ⇒ Object



97
98
99
# File 'lib/popbill/kakaotalk.rb', line 97

def sendATS_multi(corpNum, templateCode, snd, altSendType, sndDT, msgs, requestNum = '', userID = '')
  sendATS_same(corpNum, templateCode, snd, "", "", altSendType, sndDT, msgs, requestNum, userID)
end

#sendATS_one(corpNum, templateCode, snd, content, altContent, altSendType, sndDT, receiver, receiverName, requestNum = '', userID = '') ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
# File 'lib/popbill/kakaotalk.rb', line 85

def sendATS_one(corpNum, templateCode, snd, content, altContent, altSendType, sndDT, receiver, receiverName, requestNum = '', userID = '')
  msg = [
      {
          "rcv" => receiver,
          "rcvnm" => receiverName,
          "msg" => content,
          "altmsg" => altContent,
      }
  ]
  sendATS_same(corpNum, templateCode, snd, "", "", altSendType, sndDT, msg, requestNum, userID)
end

#sendATS_same(corpNum, templateCode, snd, content, altContent, altSendType, sndDT, msgs, requestNum = '', userID = '') ⇒ Object

Raises:



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/popbill/kakaotalk.rb', line 101

def sendATS_same(corpNum, templateCode, snd, content, altContent, altSendType, sndDT, msgs, requestNum = '', userID = '')
  raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.") if corpNum.length != 10
  raise PopbillException.new(-99999999, "알림톡 템플릿코드가 입력되지 않았습니다.") if templateCode.to_s == ''
  raise PopbillException.new(-99999999, "발신번호가 입력되지 않았습니다.") if snd.to_s == ''

  req = {}
  req["templateCode"] = templateCode if templateCode.to_s != ''
  req["snd"] = snd if snd.to_s != ''
  req["content"] = content if content.to_s != ''
  req["altContent"] = altContent if altContent.to_s != ''
  req["altSendType"] = altSendType if altSendType.to_s != ''
  req["sndDT"] = sndDT if sndDT.to_s != ''
  req["requestNum"] = requestNum if requestNum.to_s != ''
  req["msgs"] = msgs if msgs.to_s != ''

  postData = req.to_json
  httppost("/ATS", corpNum, postData, "", userID)
end

#sendFMS_multi(corpNum, plusFriendID, snd, altSendType, sndDT, filePath, imageURL, msgs, btns, adsYN = false, requestNum = '', userID = '') ⇒ Object



169
170
171
# File 'lib/popbill/kakaotalk.rb', line 169

def sendFMS_multi(corpNum, plusFriendID, snd, altSendType, sndDT, filePath, imageURL, msgs, btns, adsYN = false, requestNum = '', userID = '')
  sendFMS_same(corpNum, plusFriendID, snd, "", "", altSendType, sndDT, filePath, imageURL, msgs, btns, adsYN, requestNum, userID)
end

#sendFMS_one(corpNum, plusFriendID, snd, content, altContent, altSendType, sndDT, filePath, imageURL, receiver, receiverName, btns, adsYN = false, requestNum = '', userID = '') ⇒ Object



157
158
159
160
161
162
163
164
165
166
167
# File 'lib/popbill/kakaotalk.rb', line 157

def sendFMS_one(corpNum, plusFriendID, snd, content, altContent, altSendType, sndDT, filePath, imageURL, receiver, receiverName, btns, adsYN = false, requestNum = '', userID = '')
  msg = [
      {
          "rcv" => receiver,
          "rcvnm" => receiverName,
          "msg" => content,
          "altmsg" => altContent,
      }
  ]
  sendFMS_same(corpNum, plusFriendID, snd, "", "", altSendType, sndDT, filePath, imageURL, msg, btns, adsYN, requestNum, userID)
end

#sendFMS_same(corpNum, plusFriendID, snd, content, altContent, altSendType, sndDT, filePath, imageURL, msgs, btns, adsYN = false, requestNum = '', userID = '') ⇒ Object

Raises:



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/popbill/kakaotalk.rb', line 173

def sendFMS_same(corpNum, plusFriendID, snd, content, altContent, altSendType, sndDT, filePath, imageURL, msgs, btns, adsYN = false, requestNum = '', userID = '')
  raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.") if corpNum.length != 10
  raise PopbillException.new(-99999999, "플러스친구 아이디가 입력되지 않았습니다.") if plusFriendID.to_s == ''
  raise PopbillException.new(-99999999, "발신번호가 입력되지 않았습니다.") if snd.to_s == ''

  req = {}
  req["plusFriendID"] = plusFriendID if plusFriendID.to_s != ''
  req["snd"] = snd if snd.to_s != ''
  req["content"] = content if content.to_s != ''
  req["altContent"] = altContent if altContent.to_s != ''
  req["altSendType"] = altSendType if altSendType.to_s != ''
  req["sndDT"] = sndDT if sndDT.to_s != ''
  req["imageURL"] = imageURL if imageURL.to_s != ''
  req["msgs"] = msgs if msgs.to_s != ''
  req["btns"] = btns if btns.to_s != ''
  req["adsYN"] = adsYN if adsYN.to_s != ''
  req["requestNum"] = requestNum if requestNum.to_s != ''

  httppostfile("/FMS", corpNum, req, [filePath], userID)
end

#sendFTS_multi(corpNum, plusFriendID, snd, altSendType, sndDT, msgs, btns, adsYN = false, requestNum = '', userID = '') ⇒ Object



132
133
134
# File 'lib/popbill/kakaotalk.rb', line 132

def sendFTS_multi(corpNum, plusFriendID, snd, altSendType, sndDT, msgs, btns, adsYN = false, requestNum = '', userID = '')
  sendFTS_same(corpNum, plusFriendID, snd, "", "", altSendType, sndDT, msgs, btns, adsYN, requestNum, userID)
end

#sendFTS_one(corpNum, plusFriendID, snd, content, altContent, altSendType, sndDT, receiver, receiverName, btns, adsYN = false, requestNum = '', userID = '') ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
# File 'lib/popbill/kakaotalk.rb', line 120

def sendFTS_one(corpNum, plusFriendID, snd, content, altContent, altSendType, sndDT, receiver, receiverName, btns, adsYN = false, requestNum = '', userID = '')
  msg = [
      {
          "rcv" => receiver,
          "rcvnm" => receiverName,
          "msg" => content,
          "altmsg" => altContent,
      }
  ]
  sendFTS_same(corpNum, plusFriendID, snd, "", "", altSendType, sndDT, msg, btns, adsYN, requestNum, userID)
end

#sendFTS_same(corpNum, plusFriendID, snd, content, altContent, altSendType, sndDT, msgs, btns, adsYN = false, requestNum = '', userID = '') ⇒ Object

Raises:



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/popbill/kakaotalk.rb', line 136

def sendFTS_same(corpNum, plusFriendID, snd, content, altContent, altSendType, sndDT, msgs, btns, adsYN = false, requestNum = '', userID = '')
  raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.") if corpNum.length != 10
  raise PopbillException.new(-99999999, "플러스친구 아이디가 입력되지 않았습니다.") if plusFriendID.to_s == ''
  raise PopbillException.new(-99999999, "발신번호가 입력되지 않았습니다.") if snd.to_s == ''

  req = {}
  req["plusFriendID"] = plusFriendID if plusFriendID.to_s != ''
  req["snd"] = snd if snd.to_s != ''
  req["content"] = content if content.to_s != ''
  req["altContent"] = altContent if altContent.to_s != ''
  req["altSendType"] = altSendType if altSendType.to_s != ''
  req["sndDT"] = sndDT if sndDT.to_s != ''
  req["msgs"] = msgs if msgs.to_s != ''
  req["btns"] = btns if btns.to_s != ''
  req["adsYN"] = adsYN if adsYN.to_s != ''
  req["requestNum"] = requestNum if requestNum.to_s != ''

  postData = req.to_json
  httppost("/FTS", corpNum, postData, "", userID)
end