popbill 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,170 @@
1
+ # -*- coding: utf-8 -*-
2
+ require_relative './popbill.rb'
3
+
4
+ # 팝빌 홈택스 세금계산서 연계 API Service Implementation
5
+ class HTTaxinvoiceService < BaseService
6
+ class << self
7
+ def instance(linkID, secretKey)
8
+ super(linkID, secretKey)
9
+ @instance ||= new
10
+ @instance.addScope("111")
11
+ return @instance
12
+ end
13
+ private :new
14
+ end
15
+
16
+ def getChargeInfo(corpNum, userID = "")
17
+ if corpNum.length != 10
18
+ raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
19
+ end
20
+ httpget("/HomeTax/Taxinvoice/ChargeInfo", corpNum, userID)
21
+ end
22
+
23
+ def requestJob(corpNum, type, dType, sDate, eDate, userID = "")
24
+ if corpNum.length != 10
25
+ raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
26
+ end
27
+ if dType.to_s == ''
28
+ raise PopbillException.new('-99999999', '검색일자 유형이 입력되지 않았습니다.')
29
+ end
30
+ if sDate.to_s == ''
31
+ raise PopbillException.new('-99999999', '시작일자가 입력되지 않았습니다.')
32
+ end
33
+ if eDate.to_s == ''
34
+ raise PopbillException.new('-99999999', '종료일자가 입력되지 않았습니다.')
35
+ end
36
+
37
+ uri = "/HomeTax/Taxinvoice/#{type}?DType=#{dType}&SDate=#{sDate}&EDate=#{eDate}"
38
+
39
+ httppost(uri, corpNum, "", "", userID)['jobID']
40
+ end
41
+
42
+ def getJobState(corpNum, jobID, userID = "")
43
+ if corpNum.length != 10
44
+ raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
45
+ end
46
+ if jobID.to_s == ''
47
+ raise PopbillException.new('-99999999', '작업아이디(jobID)가 입력되지 않았습니다.')
48
+ end
49
+
50
+ httpget("/HomeTax/Taxinvoice/#{jobID}/State", corpNum, userID)
51
+ end
52
+
53
+ def listActiveJob(corpNum, userID = "")
54
+ if corpNum.length != 10
55
+ raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
56
+ end
57
+
58
+ httpget("/HomeTax/Taxinvoice/JobList", corpNum, userID)
59
+ end
60
+
61
+ def search(corpNum, jobID, type, taxType, purposeType, taxRegIDType, taxRegIDYN,
62
+ taxRegID, page, perPage, order, userID = '')
63
+ if corpNum.length != 10
64
+ raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
65
+ end
66
+ if jobID.length != 18
67
+ raise PopbillException.new('-99999999', '작업아이디(jobID)가 올바르지 않습니다.')
68
+ end
69
+
70
+ uri = "/HomeTax/Taxinvoice/#{jobID}"
71
+ uri += "?Type=" + type.join(',')
72
+ uri += "&TaxType=" + taxType.join(',')
73
+ uri += "&PurposeType=" + purposeType.join(',')
74
+ uri += "&TaxRegIDType=" + taxRegIDType
75
+ uri += "&TaxRegID=" + taxRegID
76
+ uri += "&Page=" + page.to_s
77
+ uri += "&PerPage=" + perPage.to_s
78
+ uri += "&Order=" + order
79
+
80
+ if taxRegIDYN.to_s != ''
81
+ uri += "&TaxRegIDYN=" + taxRegIDYN
82
+ end
83
+
84
+ httpget(URI.escape(uri), corpNum, userID)
85
+ end
86
+
87
+ def summary(corpNum, jobID, type, taxType, purposeType, taxRegIDType, taxRegIDYN,
88
+ taxRegID, userID = '')
89
+ if corpNum.length != 10
90
+ raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
91
+ end
92
+ if jobID.length != 18
93
+ raise PopbillException.new('-99999999', '작업아이디(jobID)가 올바르지 않습니다.')
94
+ end
95
+
96
+ uri = "/HomeTax/Taxinvoice/#{jobID}/Summary"
97
+ uri += "?Type=" + type.join(',')
98
+ uri += "&TaxType=" + taxType.join(',')
99
+ uri += "&PurposeType=" + purposeType.join(',')
100
+ uri += "&TaxRegIDType=" + taxRegIDType
101
+ uri += "&TaxRegID=" + taxRegID
102
+
103
+ if taxRegIDYN.to_s != ''
104
+ uri += "&TaxRegIDYN=" + taxRegIDYN
105
+ end
106
+
107
+ httpget(URI.escape(uri), corpNum, userID)
108
+ end
109
+
110
+ def getTaxinvoice(corpNum, ntsConfirmNum, userID = "")
111
+ if corpNum.length != 10
112
+ raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
113
+ end
114
+ if ntsConfirmNum.length != 24
115
+ raise PopbillException.new('-99999999', '전자세금계산서 국세청승인번호가 올바르지 않습니다.')
116
+ end
117
+
118
+ httpget("/HomeTax/Taxinvoice/#{ntsConfirmNum}", corpNum, userID)
119
+ end
120
+
121
+ def getXML(corpNum, ntsConfirmNum, userID = "")
122
+ if corpNum.length != 10
123
+ raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
124
+ end
125
+ if ntsConfirmNum.length != 24
126
+ raise PopbillException.new('-99999999', '전자세금계산서 국세청승인번호가 올바르지 않습니다.')
127
+ end
128
+
129
+ httpget("/HomeTax/Taxinvoice/#{ntsConfirmNum}?T=xml", corpNum, userID)
130
+ end
131
+
132
+ def getFlatRatePopUpURL(corpNum, userID = "")
133
+ if corpNum.length != 10
134
+ raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
135
+ end
136
+
137
+ httpget("/HomeTax/Taxinvoice?TG=CHRG", corpNum, userID)['url']
138
+ end
139
+
140
+ def getCertificatePopUpURL(corpNum, userID = "")
141
+ if corpNum.length != 10
142
+ raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
143
+ end
144
+
145
+ httpget("/HomeTax/Taxinvoice?TG=CERT", corpNum, userID)['url']
146
+ end
147
+
148
+ def getFlatRateState(corpNum, userID = "")
149
+ if corpNum.length != 10
150
+ raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
151
+ end
152
+
153
+ httpget("/HomeTax/Taxinvoice/Contract", corpNum, userID)
154
+ end
155
+
156
+ def getCertificateExpireDate(corpNum, userID = "")
157
+ if corpNum.length != 10
158
+ raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
159
+ end
160
+
161
+ httpget("/HomeTax/Taxinvoice/CertInfo", corpNum, userID)['certificateExpiration']
162
+ end
163
+
164
+ end # end of HTTaxinvoiceService
165
+
166
+ module KeyType
167
+ SELL = "SELL"
168
+ BUY = "BUY"
169
+ TRUSTEE = "TRUSTEE"
170
+ end
data/lib/message.rb ADDED
@@ -0,0 +1,272 @@
1
+ # -*- coding: utf-8 -*-
2
+ require_relative './popbill.rb'
3
+
4
+ # 팝빌 문자 API Service Implementation
5
+ class MessageService < BaseService
6
+ class << self
7
+ def instance(linkID, secretKey)
8
+ super(linkID, secretKey)
9
+ @instance ||= new
10
+ @instance.addScope("150")
11
+ @instance.addScope("151")
12
+ @instance.addScope("152")
13
+ return @instance
14
+ end
15
+ private :new
16
+ end
17
+
18
+ def getChargeInfo(corpNum, msgType, userID = '')
19
+ if corpNum.length != 10
20
+ raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
21
+ end
22
+ httpget("/Message/ChargeInfo?Type=#{msgType}", corpNum, userID)
23
+ end
24
+
25
+ def getAutoDenyList(corpNum, userID = '')
26
+ if corpNum.length != 10
27
+ raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
28
+ end
29
+ httpget("/Message/Denied", corpNum, userID)
30
+ end
31
+
32
+ def getUnitCost(corpNum, msgType, userID = '')
33
+ if corpNum.length != 10
34
+ raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
35
+ end
36
+ httpget("/Message/UnitCost?Type=#{msgType}", corpNum, userID)['unitCost']
37
+ end
38
+
39
+
40
+ def sendMessage(msgType, corpNum, sender, senderName, subject, contents,
41
+ messages, reserveDT, adsYN = false, userID = '')
42
+
43
+ if corpNum.length != 10
44
+ raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
45
+ end
46
+
47
+ req = {}
48
+
49
+ if sender.to_s != ''
50
+ req["snd"] = sender
51
+ end
52
+ if senderName.to_s != ''
53
+ req["sndnm"] = senderName
54
+ end
55
+ if subject.to_s != ''
56
+ req["subject"] = subject
57
+ end
58
+ if contents.to_s != ''
59
+ req["content"] = contents
60
+ end
61
+ if reserveDT.to_s != ''
62
+ req["sndDT"] = reserveDT
63
+ end
64
+ if messages.to_s != ''
65
+ req["msgs"] = messages
66
+ end
67
+ if adsYN
68
+ req["adsYN"] = true
69
+ end
70
+
71
+ postData = req.to_json
72
+
73
+ httppost("/#{msgType}", corpNum, postData, "", userID)['receiptNum']
74
+ end
75
+
76
+
77
+ def sendSMS(corpNum, sender, senderName, receiver, receiverName, contents,
78
+ reserveDT = '', adsYN = false, userID = '')
79
+
80
+ messages = [
81
+ {
82
+ "snd" => sender,
83
+ "sndName" => senderName,
84
+ "rcv" => receiver,
85
+ "rcvnm" => receiverName,
86
+ "msg" => contents,
87
+ }
88
+ ]
89
+ sendMessage("SMS", corpNum, '', '', '', '', messages, reserveDT,
90
+ adsYN, userID
91
+ )
92
+ end
93
+
94
+ def sendSMS_multi(corpNum, sender, senderName, contents, messages, reserveDT = '',
95
+ adsYN = false, userID = '')
96
+
97
+ sendMessage("SMS", corpNum, sender, senderName, '', contents, messages, reserveDT,
98
+ adsYN, userID
99
+ )
100
+ end
101
+
102
+
103
+ def sendLMS(corpNum, sender, senderName, receiver, receiverName, subject, contents,
104
+ reserveDT = '', adsYN = false, userID = '')
105
+
106
+ messages = [
107
+ {
108
+ "snd" => sender,
109
+ "sndName" => senderName,
110
+ "rcv" => receiver,
111
+ "rcvnm" => receiverName,
112
+ "msg" => contents,
113
+ "sjt" => subject,
114
+ }
115
+ ]
116
+
117
+ sendMessage("LMS", corpNum, '', '', '', '', messages, reserveDT,
118
+ adsYN, userID
119
+ )
120
+ end
121
+
122
+ def sendXMS_multi(corpNum, sender, senderName, subject, contents, messages,
123
+ reserveDT = '', adsYN = false, userID = '')
124
+
125
+ sendMessage("XMS", corpNum, sender, senderName, subject, contents, messages,
126
+ reserveDT, adsYN, userID
127
+ )
128
+ end
129
+
130
+ def sendXMS(corpNum, sender, senderName, receiver, receiverName, subject, contents,
131
+ reserveDT = '', adsYN = false, userID = '')
132
+
133
+ messages = [
134
+ {
135
+ "snd" => sender,
136
+ "sndName" => senderName,
137
+ "rcv" => receiver,
138
+ "rcvnm" => receiverName,
139
+ "msg" => contents,
140
+ "sjt" => subject,
141
+ }
142
+ ]
143
+
144
+ sendMessage("XMS", corpNum, '', '', '', '', messages, reserveDT,
145
+ adsYN, userID
146
+ )
147
+ end
148
+
149
+ def sendLMS_multi(corpNum, sender, senderName, subject, contents, messages,
150
+ reserveDT = '', adsYN = false, userID = '')
151
+
152
+ sendMessage("LMS", corpNum, sender, senderName, subject, contents, messages,
153
+ reserveDT, adsYN, userID
154
+ )
155
+ end
156
+
157
+
158
+ def sendMMS(corpNum, sender, senderName, receiver, receiverName, subject, contents,
159
+ filePath, reserveDT = '', adsYN = false, userID = '')
160
+
161
+ messages = [
162
+ {
163
+ "snd" => sender,
164
+ "sndnm" => senderName,
165
+ "rcv" => receiver,
166
+ "rcvnm" => receiverName,
167
+ "msg" => contents,
168
+ "sjt" => subject,
169
+ }
170
+ ]
171
+
172
+ sendMMS_multi(corpNum, sender, senderName, subject, contents, messages, filePath,
173
+ reserveDT, adsYN, userID
174
+ )
175
+ end
176
+
177
+ def sendMMS_multi(corpNum, sender, senderName, subject, contents, messages, filePath,
178
+ reserveDT = '', adsYN = false, userID = '')
179
+
180
+ if corpNum.length != 10
181
+ raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
182
+ end
183
+
184
+ req = {}
185
+
186
+ if sender.to_s != ''
187
+ req["snd"] = sender
188
+ end
189
+ if senderName.to_s != ''
190
+ req["sndnm"] = senderName
191
+ end
192
+ if subject.to_s != ''
193
+ req["subject"] = subject
194
+ end
195
+ if contents.to_s != ''
196
+ req["content"] = contents
197
+ end
198
+ if reserveDT.to_s != ''
199
+ req["sndDT"] = reserveDT
200
+ end
201
+ if messages.to_s != ''
202
+ req["msgs"] = messages
203
+ end
204
+ if adsYN
205
+ req["adsYN"] = true
206
+ end
207
+
208
+ httppostfile("/MMS", corpNum, req, [filePath], userID)['receiptNum']
209
+ end
210
+
211
+ def getMessages(corpNum, receiptNum, userID = '')
212
+ if corpNum.length != 10
213
+ raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
214
+ end
215
+ if receiptNum.to_s == ''
216
+ raise PopbillException.new(-99999999, "접수번호(receiptNum)가 입력되지 않았습니다.")
217
+ end
218
+
219
+ httpget("/Message/#{receiptNum}", corpNum, userID)
220
+ end
221
+
222
+ def cancelReserve(corpNum, receiptNum, userID = '')
223
+ if corpNum.length != 10
224
+ raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
225
+ end
226
+ if receiptNum.to_s == ''
227
+ raise PopbillException.new(-99999999, "접수번호(receiptNum)가 입력되지 않았습니다.")
228
+ end
229
+
230
+ httpget("/Message/#{receiptNum}/Cancel", corpNum, userID)
231
+ end
232
+
233
+ def getURL(corpNum, togo, userID = '')
234
+ if corpNum.length != 10
235
+ raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
236
+ end
237
+
238
+ httpget("/Message/?TG=#{togo}", corpNum, userID)['url']
239
+ end
240
+
241
+ def search(corpNum, sDate, eDate, state, item, reserveYN, senderYN, page, perPage,
242
+ order, userID = '')
243
+ if corpNum.length != 10
244
+ raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
245
+ end
246
+ if sDate.to_s == ''
247
+ raise PopbillException.new('-99999999', '시작일자가 입력되지 않았습니다.')
248
+ end
249
+ if eDate.to_s == ''
250
+ raise PopbillException.new('-99999999', '종료일자가 입력되지 않았습니다.')
251
+ end
252
+
253
+ uri = "/Message/Search?SDate=#{sDate}&EDate=#{eDate}"
254
+ uri += "&State=" + state.join(',')
255
+ uri += "&Item=" + item.join(',')
256
+ uri += "&ReserveYN=" + reserveYN
257
+ uri += "&SenderYN=" + senderYN
258
+ uri += "&Page=" + page.to_s
259
+ uri += "&PerPage=" + perPage.to_s
260
+ uri += "&Order=" + order
261
+
262
+ httpget(URI.escape(uri), corpNum, userID)
263
+ end
264
+
265
+
266
+ end # end of MessageService
267
+
268
+ module MsgType
269
+ SMS = "SMS"
270
+ LMS = "LMS"
271
+ MMS = "MMS"
272
+ end