Class: StatementService

Inherits:
BaseService show all
Defined in:
lib/popbill/statement.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
15
16
17
# File 'lib/popbill/statement.rb', line 7

def instance(linkID, secretKey)
  super(linkID, secretKey)
  @instance ||= new
  @instance.addScope("121")
  @instance.addScope("122")
  @instance.addScope("123")
  @instance.addScope("124")
  @instance.addScope("125")
  @instance.addScope("126")
  return @instance
end

Instance Method Details

#attachFile(corpNum, itemCode, mgtKey, filePath, userID = '') ⇒ Object



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

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

  httppostfiles("/Statement/#{itemCode}/#{mgtKey}/Files", corpNum, '', [filePath], userID)
end

#attachStatement(corpNum, itemCode, mgtKey, subItemCode, subMgtKey, userID = '') ⇒ Object



394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
# File 'lib/popbill/statement.rb', line 394

def attachStatement(corpNum, itemCode, mgtKey, subItemCode, subMgtKey, userID = '')
  if corpNum.length != 10
    raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
  end
  if mgtKey.to_s == ''
    raise PopbillException.new('-99999999', '문서관리번호가 입력되지 않았습니다.')
  end
  if itemCode.to_s == ''
    raise PopbillException.new('-99999999', '전자명세서 종류코드가 입력되지 않았습니다.')
  end
  if subItemCode.to_s == ''
    raise PopbillException.new('-99999999', '전자명세서 종류코드가 입력되지 않았습니다.')
  end
  if subMgtKey.to_s == ''
    raise PopbillException.new('-99999999', '전자명세서 문서관리번호가 입력되지 않았습니다.')
  end

  postData = {}
  postData["ItemCode"] = subItemCode
  postData["MgtKey"] = subMgtKey
  postData = postData.to_json

  httppost("/Statement/#{itemCode}/#{mgtKey}/AttachStmt", corpNum, postData, "", userID)
end

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



125
126
127
128
129
130
131
132
133
134
# File 'lib/popbill/statement.rb', line 125

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

  httppost("/Statement/#{itemCode}/#{mgtKey}", corpNum, postData, "CANCEL", userID)
end

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



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/popbill/statement.rb', line 42

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

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

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



137
138
139
140
141
142
143
# File 'lib/popbill/statement.rb', line 137

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

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

#deleteFile(corpNum, itemCode, mgtKey, fileID, userID = '') ⇒ Object



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

def deleteFile(corpNum, itemCode, mgtKey, fileID, userID = '')
  if corpNum.length != 10
    raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
  end
  if mgtKey.to_s == ''
    raise PopbillException.new('-99999999', '문서관리번호 올바르지 않습니다.')
  end
  if fileID.to_s == ''
    raise PopbillException.new('-99999999', '파일아이디가 입력되지 않았습니다.')
  end

  httppost("/Statement/#{itemCode}/#{mgtKey}/Files/#{fileID}", corpNum, '', "DELETE", userID)
end

#detachStatement(corpNum, itemCode, mgtKey, subItemCode, subMgtKey, userID = '') ⇒ Object



419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/popbill/statement.rb', line 419

def detachStatement(corpNum, itemCode, mgtKey, subItemCode, subMgtKey, userID = '')
  if corpNum.length != 10
    raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
  end
  if mgtKey.to_s == ''
    raise PopbillException.new('-99999999', '문서관리번호가 입력되지 않았습니다.')
  end
  if itemCode.to_s == ''
    raise PopbillException.new('-99999999', '전자명세서 종류코드가 입력되지 않았습니다.')
  end
  if subItemCode.to_s == ''
    raise PopbillException.new('-99999999', '전자명세서 종류코드가 입력되지 않았습니다.')
  end
  if subMgtKey.to_s == ''
    raise PopbillException.new('-99999999', '전자명세서 문서관리번호가 입력되지 않았습니다.')
  end

  postData = {}
  postData["ItemCode"] = subItemCode
  postData["MgtKey"] = subMgtKey
  postData = postData.to_json

  httppost("/Statement/#{itemCode}/#{mgtKey}/DetachStmt", corpNum, postData, "", userID)
end

#faxSend(corpNum, statement, sendNum, receiveNum, userID = '') ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/popbill/statement.rb', line 61

def faxSend(corpNum, statement, sendNum, receiveNum, userID = '')
  if corpNum.length != 10
    raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
  end
  if sendNum.to_s == ''
    raise PopbillException.new(-99999999, "팩스 발신번호가 입력되지 않았습니다.")
  end
  if receiveNum.to_s == ''
    raise PopbillException.new(-99999999, "팩스 수신번호가 입력되지 않았습니다.")
  end

  statement["sendNum"] = sendNum
  statement["receiveNum"] = receiveNum

  postData = statement.to_json

  httppost("/Statement", corpNum, postData, "FAX", userID)['receiptNum']
end

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



21
22
23
24
25
26
# File 'lib/popbill/statement.rb', line 21

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

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



202
203
204
205
206
207
208
209
210
211
# File 'lib/popbill/statement.rb', line 202

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

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

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



358
359
360
361
362
363
364
365
366
367
# File 'lib/popbill/statement.rb', line 358

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

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

#getFiles(corpNum, itemCode, mgtKey, userID = '') ⇒ Object



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

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

  httpget("/Statement/#{itemCode}/#{mgtKey}/Files", corpNum)
end

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



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

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

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

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



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

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

  postData = mgtKeyList.to_json

  httppost("/Statement/#{itemCode}", corpNum, postData, "", userID)
end

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



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

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

  httpget("/Statement/#{itemCode}/#{mgtKey}/Logs", corpNum, userID)
end

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



369
370
371
372
373
374
375
376
377
378
# File 'lib/popbill/statement.rb', line 369

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

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

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



381
382
383
384
385
386
387
388
389
390
391
# File 'lib/popbill/statement.rb', line 381

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

  postData = mgtKeyList.to_json
  httppost("/Statement/#{itemCode}?Print", corpNum, postData, "", userID)['url']
end

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



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

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

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

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



347
348
349
350
351
352
353
354
355
356
# File 'lib/popbill/statement.rb', line 347

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

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

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



35
36
37
38
39
40
# File 'lib/popbill/statement.rb', line 35

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

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



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

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

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



113
114
115
116
117
118
119
120
121
122
123
# File 'lib/popbill/statement.rb', line 113

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

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

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



444
445
446
447
448
449
450
# File 'lib/popbill/statement.rb', line 444

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

  httpget("/Statement/EmailSendConfig", corpNum, userID)
end

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



92
93
94
95
96
97
98
99
# File 'lib/popbill/statement.rb', line 92

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

  postData = statement.to_json
  httppost("/Statement", corpNum, postData, "", userID)
end

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



81
82
83
84
85
86
87
88
89
# File 'lib/popbill/statement.rb', line 81

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

  statement["memo"] = memo
  postData = statement.to_json
  httppost("/Statement", corpNum, postData, "ISSUE", userID)
end

#search(corpNum, dType, sDate, eDate, state, itemCode, page, perPage, order, qstring = '', userID = '') ⇒ Object



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/popbill/statement.rb', line 146

def search(corpNum, dType, sDate, eDate, state, itemCode, page, perPage, order,
  qstring= '', 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 = "/Statement/Search?DType=#{dType}&SDate=#{sDate}&EDate=#{eDate}"
  uri += "&State=" + state.join(',')
  uri += "&ItemCode=" + itemCode.join(',')
  uri += "&Page=" + page.to_s
  uri += "&PerPage=" + perPage.to_s
  uri += "&Order=" + order
  uri += "&QString=" + qstring

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

end

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



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/popbill/statement.rb', line 213

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

  postData = {}
  postData["receiver"] = receiverMail
  postData = postData.to_json

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

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



263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/popbill/statement.rb', line 263

def sendFax(corpNum, itemCode, 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("/Statement/#{itemCode}/#{mgtKey}", corpNum, postData, "FAX", userID)
end

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



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/popbill/statement.rb', line 232

def sendSMS(corpNum, itemCode, 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("/Statement/#{itemCode}/#{mgtKey}", corpNum, postData, "SMS", userID)
end

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



102
103
104
105
106
107
108
109
110
# File 'lib/popbill/statement.rb', line 102

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

  postData = statement.to_json

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

#updateEmailConfig(corpNum, emailType, sendYN, userID = '') ⇒ Object



452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
# File 'lib/popbill/statement.rb', line 452

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

  if emailType.to_s == ''
    raise PopbillException.new('-99999999', '메일전송 타입이 입력되지 않았습니다.')
  end

  if sendYN.to_s == ''
    raise PopbillException.new('-99999999', '메일전송 여부 항목이 입력되지 않았습니다.')
  end

  httppost("/Statement/EmailSendConfig?EmailType=#{emailType}&SendYN=#{sendYN}", corpNum, userID)
end