Class: CashbillService

Inherits:
BaseService show all
Defined in:
lib/popbill/cashbill.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, #getBalance, #getCorpInfo, #getPartnerBalance, #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
# File 'lib/popbill/cashbill.rb', line 7

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

Instance Method Details

#cancelIssue(corpNum, mgtKey, memo = '', userID = '') ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/popbill/cashbill.rb', line 105

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

  postData = {}

  if memo.to_s != ''
    postData["memo"] = memo
  end

  postData = postData.to_json

  httppost("/Cashbill/#{mgtKey}", corpNum, postData, "CANCELISSUE", userID)
end

#checkMgtKeyInUse(corpNum, mgtKey, userID = '') ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/popbill/cashbill.rb', line 37

def checkMgtKeyInUse(corpNum, mgtKey, userID = '')
  if corpNum.length != 10
    raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
  end
  if mgtKey.to_s == ''
    raise PopbillException.new(-99999999, "현금영수증 문서관리번호가 입력되지 않았습니다.")
  end

  begin
    response = httpget("/Cashbill/#{mgtKey}", corpNum)
    return response['itemKey'].length != 0
  rescue PopbillException => pe
    if pe.code == -14000003
      return false
    end
    raise PopbillException.new(pe.code, pe.message)
  end
end

#delete(corpNum, mgtKey, userID = '') ⇒ Object



121
122
123
124
125
126
127
# File 'lib/popbill/cashbill.rb', line 121

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

  httppost("/Cashbill/#{mgtKey}", corpNum, "", "DELETE", userID)
end

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



16
17
18
19
20
21
# File 'lib/popbill/cashbill.rb', line 16

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

#getDetailInfo(corpNum, mgtKey, userID = '') ⇒ Object



188
189
190
191
192
193
194
195
196
197
# File 'lib/popbill/cashbill.rb', line 188

def getDetailInfo(corpNum, mgtKey, userID = '')
  if corpNum.length != 10
    raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
  end
  if mgtKey.to_s == ''
    raise PopbillException.new('-99999999', '관리번호가 입력되지 않았습니다.')
  end

  httpget("/Cashbill/#{mgtKey}?Detail", corpNum, userID)
end

#getEPrintURL(corpNum, mgtKey, userID = '') ⇒ Object



322
323
324
325
326
327
328
329
330
331
# File 'lib/popbill/cashbill.rb', line 322

def getEPrintURL(corpNum, mgtKey, userID = '')
  if corpNum.length != 10
    raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
  end
  if mgtKey.to_s == ''
    raise PopbillException.new('-99999999', '문서관리번호 올바르지 않습니다.')
  end

  httpget("/Cashbill/#{mgtKey}?TG=EPRINT", corpNum, userID)['url']
end

#getInfo(corpNum, mgtKey, userID = '') ⇒ Object



162
163
164
165
166
167
168
169
170
171
# File 'lib/popbill/cashbill.rb', line 162

def getInfo(corpNum, mgtKey, userID = '')
  if corpNum.length != 10
    raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
  end
  if mgtKey.to_s == ''
    raise PopbillException.new('-99999999', '관리번호가 입력되지 않았습니다.')
  end

  httpget("/Cashbill/#{mgtKey}", corpNum, userID)
end

#getInfos(corpNum, mgtKeyList, userID = '') ⇒ Object



174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/popbill/cashbill.rb', line 174

def getInfos(corpNum, mgtKeyList, userID = '')
  if corpNum.length != 10
    raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
  end
  unless mgtKeyList.any?
    raise PopbillException.new('-99999999', '문서관리번호 배열이 올바르지 않습니다.')
  end

  postData = mgtKeyList.to_json

  httppost("/Cashbill/States", corpNum, postData, "", userID)
end

#getLogs(corpNum, mgtKey, userID = '') ⇒ Object



277
278
279
280
281
282
283
284
285
# File 'lib/popbill/cashbill.rb', line 277

def getLogs(corpNum, mgtKey, userID = '')
  if corpNum.length != 10
    raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
  end
  if mgtKey.to_s == ''
    raise PopbillException.new('-99999999', '문서관리번호 올바르지 않습니다.')
  end
  httpget("/Cashbill/#{mgtKey}/Logs", corpNum, userID)
end

#getMailURL(corpNum, mgtKey, userID = '') ⇒ Object



310
311
312
313
314
315
316
317
318
319
# File 'lib/popbill/cashbill.rb', line 310

def getMailURL(corpNum, mgtKey, userID = '')
  if corpNum.length != 10
    raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
  end
  if mgtKey.to_s == ''
    raise PopbillException.new('-99999999', '문서관리번호 올바르지 않습니다.')
  end

  httpget("/Cashbill/#{mgtKey}?TG=MAIL", corpNum, userID)['url']
end

#getMassPrintURL(corpNum, mgtKeyList, userID = '') ⇒ Object



334
335
336
337
338
339
340
341
342
343
344
345
# File 'lib/popbill/cashbill.rb', line 334

def getMassPrintURL(corpNum, mgtKeyList, userID = '')
  if corpNum.length != 10
    raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
  end
  unless mgtKeyList.any?
    raise PopbillException.new('-99999999', '문서관리번호 배열이 올바르지 않습니다.')
  end

  postData = mgtKeyList.to_json

  httppost("/Cashbill/Prints", corpNum, postData, "", userID)['url']
end

#getPopUpURL(corpNum, mgtKey, userID = '') ⇒ Object



288
289
290
291
292
293
294
295
296
297
# File 'lib/popbill/cashbill.rb', line 288

def getPopUpURL(corpNum, mgtKey, userID = '')
  if corpNum.length != 10
    raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
  end
  if mgtKey.to_s == ''
    raise PopbillException.new('-99999999', '문서관리번호 올바르지 않습니다.')
  end

  httpget("/Cashbill/#{mgtKey}?TG=POPUP", corpNum, userID)['url']
end

#getPrintURL(corpNum, mgtKey, userID = '') ⇒ Object



299
300
301
302
303
304
305
306
307
308
# File 'lib/popbill/cashbill.rb', line 299

def getPrintURL(corpNum, mgtKey, userID = '')
  if corpNum.length != 10
    raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
  end
  if mgtKey.to_s == ''
    raise PopbillException.new('-99999999', '문서관리번호 올바르지 않습니다.')
  end

  httpget("/Cashbill/#{mgtKey}?TG=PRINT", corpNum, userID)['url']
end

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



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

def getUnitCost(corpNum, userID = '')
  if corpNum.length != 10
    raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
  end
  httpget("/Cashbill?cfg=UNITCOST", corpNum, userID)['unitCost']
end

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



23
24
25
26
27
28
# File 'lib/popbill/cashbill.rb', line 23

def getURL(corpNum, togo, userID = '')
  if corpNum.length != 10
    raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
  end
  httpget("/Cashbill?TG=#{togo}", corpNum, userID)['url']
end

#issue(corpNum, mgtKey, memo = '', userID = '') ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/popbill/cashbill.rb', line 89

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

  postData = {}

  if memo.to_s != ''
    postData["memo"] = memo
  end

  postData = postData.to_json

  httppost("/Cashbill/#{mgtKey}", corpNum, postData, "ISSUE", userID)
end

#register(corpNum, cashbill, userID = '') ⇒ Object



68
69
70
71
72
73
74
75
76
# File 'lib/popbill/cashbill.rb', line 68

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

  postData = cashbill.to_json

  httppost("/Cashbill", corpNum, postData, "", userID)
end

#registIssue(corpNum, cashbill, memo = '', userID = '') ⇒ Object



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

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

  postData = cashbill.to_json

  httppost("/Cashbill", corpNum, postData, "ISSUE", userID)
end

#search(corpNum, dType, sDate, eDate, state, tradeType, tradeUsage, taxationType, page, perPage, order, queryString = '', userID = '') ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/popbill/cashbill.rb', line 129

def search(corpNum, dType, sDate, eDate, state, tradeType, tradeUsage,
  taxationType, page, perPage, order, queryString = '', userID = '')
  if corpNum.length != 10
    raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
  end
  if dType.to_s == ''
    raise PopbillException.new('-99999999', '검색일자유형이 입력되지 않았습니다.')
  end

  if sDate.to_s == ''
    raise PopbillException.new('-99999999', '시작일자가 입력되지 않았습니다.')
  end

  if eDate.to_s == ''
    raise PopbillException.new('-99999999', '종료일자가 입력되지 않았습니다.')
  end

  uri = "/Cashbill/Search?DType=#{dType}&SDate=#{sDate}&EDate=#{eDate}"
  uri += "&State" + state.join(',')
  uri += "&TradeUsage" + tradeUsage.join(',')
  uri += "&TradeType" + tradeType.join(',')
  uri += "&TaxationType" + taxationType.join(',')
  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

#sendEmail(corpNum, mgtKey, receiverMail, userID = '') ⇒ Object



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/popbill/cashbill.rb', line 199

def sendEmail(corpNum, mgtKey, receiverMail, userID = '')
  if corpNum.length != 10
    raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
  end
  if mgtKey.to_s == ''
    raise PopbillException.new('-99999999', '문서관리번호 올바르지 않습니다.')
  end

  postData = {}

  if receiverMail.to_s != ''
    postData["receiver"] = receiverMail
  end

  postData = postData.to_json

  httppost("/Cashbill/#{mgtKey}", corpNum, postData, "EMAIL", userID)
end

#sendFax(corpNum, mgtKey, senderNum, receiverNum, userID = '') ⇒ Object



250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/popbill/cashbill.rb', line 250

def sendFax(corpNum, mgtKey, senderNum, receiverNum, userID = '')
  if corpNum.length != 10
    raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
  end
  if mgtKey.to_s == ''
    raise PopbillException.new('-99999999', '문서관리번호 올바르지 않습니다.')
  end

  if senderNum.to_s == ''
    raise PopbillException.new('-99999999', '발신번호가 입력되지 않았습니다.')
  end

  if receiverNum.to_s == ''
    raise PopbillException.new('-99999999', '수신번호가 입력되지 않았습니다.')
  end

  postData = {}
  postData["sender"] = senderNum
  postData["receiver"] = receiverNum

  postData = postData.to_json

  httppost("/Cashbill/#{mgtKey}", corpNum, postData, "FAX", userID)

end

#sendSMS(corpNum, mgtKey, senderNum, receiverNum, contents, userID = '') ⇒ Object



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/popbill/cashbill.rb', line 219

def sendSMS(corpNum, mgtKey, senderNum, receiverNum, contents, userID = '')
  if corpNum.length != 10
    raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
  end
  if mgtKey.to_s == ''
    raise PopbillException.new('-99999999', '문서관리번호 올바르지 않습니다.')
  end

  if senderNum.to_s == ''
    raise PopbillException.new('-99999999', '발신번호가 입력되지 않았습니다.')
  end

  if receiverNum.to_s == ''
    raise PopbillException.new('-99999999', '수신번호가 입력되지 않았습니다.')
  end

  if contents.to_s == ''
    raise PopbillException.new('-99999999', '문자 메시지 내용이 입력되지 않았습니다.')
  end

  postData = {}
  postData["sender"] = senderNum
  postData["receiver"] = receiverNum
  postData["contents"] = contents

  postData = postData.to_json

  httppost("/Cashbill/#{mgtKey}", corpNum, postData, "SMS", userID)
end

#update(corpNum, mgtKey, cashbill, userID = '') ⇒ Object



79
80
81
82
83
84
85
86
87
# File 'lib/popbill/cashbill.rb', line 79

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

  postData = cashbill.to_json

  httppost("/Cashbill/#{mgtKey}", corpNum, postData, "PATCH", userID)
end