Skip to content

Commit c4502e6

Browse files
authored
Merge pull request #256 from stone-ton/master
Alteração no endereço público da apicep.com
2 parents 52d3bc7 + 455e93b commit c4502e6

File tree

4 files changed

+59
-58
lines changed

4 files changed

+59
-58
lines changed

src/services/widenet.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import fetch from 'node-fetch'
44
import ServiceError from '../errors/service.js'
55

66
export default function fetchWideNetService(cepWithLeftPad, configurations) {
7-
const url = `https://ws.apicep.com/busca-cep/api/cep/${cepWithLeftPad}.json`
7+
const cepWithDash = `${cepWithLeftPad.slice(0, 5)}-${cepWithLeftPad.slice(5)}`
8+
const url = `https://cdn.apicep.com/file/apicep/${cepWithDash}.json`
89
const options = {
910
method: 'GET',
1011
mode: 'cors',
1112
headers: {
12-
'content-type': 'application/json;charset=utf-8'
13+
accept: 'application/json'
1314
},
1415
timeout: configurations.timeout || 30000
1516
}

test/unit/cep-promise-browser.spec.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ describe('[unit] cep-promise for browser', () => {
3636
path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json')
3737
)
3838

39-
nock('https://ws.apicep.com')
40-
.get('/busca-cep/api/cep/05010000.json')
39+
nock('https://cdn.apicep.com')
40+
.get('/file/apicep/05010-000.json')
4141
.replyWithFile(
4242
200,
4343
path.join(__dirname, '/fixtures/widenet-cep-05010000-found.json')
@@ -151,8 +151,8 @@ describe('[unit] cep-promise for browser', () => {
151151
path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json')
152152
)
153153

154-
nock('https://ws.apicep.com')
155-
.get('/busca-cep/api/cep/05010000.json')
154+
nock('https://cdn.apicep.com')
155+
.get('/file/apicep/05010-000.json')
156156
.replyWithFile(
157157
200,
158158
path.join(__dirname, '/fixtures/widenet-cep-05010000-found.json')
@@ -187,8 +187,8 @@ describe('[unit] cep-promise for browser', () => {
187187
path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json')
188188
)
189189

190-
nock('https://ws.apicep.com')
191-
.get('/busca-cep/api/cep/05010000.json')
190+
nock('https://cdn.apicep.com')
191+
.get('/file/apicep/05010-000.json')
192192
.replyWithFile(
193193
200,
194194
path.join(__dirname, '/fixtures/widenet-cep-05010000-found.json')
@@ -223,8 +223,8 @@ describe('[unit] cep-promise for browser', () => {
223223
path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json')
224224
)
225225

226-
nock('https://ws.apicep.com')
227-
.get('/busca-cep/api/cep/05010000.json')
226+
nock('https://cdn.apicep.com')
227+
.get('/file/apicep/05010-000.json')
228228
.replyWithFile(
229229
200,
230230
path.join(__dirname, '/fixtures/widenet-cep-99999999-error.json')
@@ -259,8 +259,8 @@ describe('[unit] cep-promise for browser', () => {
259259
path.join(__dirname, '/fixtures/viacep-cep-99999999-error.json')
260260
)
261261

262-
nock('https://ws.apicep.com')
263-
.get('/busca-cep/api/cep/05010000.json')
262+
nock('https://cdn.apicep.com')
263+
.get('/file/apicep/05010-000.json')
264264
.replyWithFile(
265265
200,
266266
path.join(__dirname, '/fixtures/widenet-cep-05010000-found.json')
@@ -294,8 +294,8 @@ describe('[unit] cep-promise for browser', () => {
294294
path.join(__dirname, '/fixtures/viacep-cep-99999999-error.json')
295295
)
296296

297-
nock('https://ws.apicep.com')
298-
.get('/busca-cep/api/cep/05010000.json')
297+
nock('https://cdn.apicep.com')
298+
.get('/file/apicep/05010-000.json')
299299
.replyWithFile(
300300
200,
301301
path.join(__dirname, '/fixtures/widenet-cep-99999999-error.json')
@@ -329,8 +329,8 @@ describe('[unit] cep-promise for browser', () => {
329329
path.join(__dirname, '/fixtures/viacep-cep-99999999-error.json')
330330
)
331331

332-
nock('https://ws.apicep.com')
333-
.get('/busca-cep/api/cep/99999999.json')
332+
nock('https://cdn.apicep.com')
333+
.get('/file/apicep/99999-999.json')
334334
.replyWithFile(
335335
200,
336336
path.join(__dirname, '/fixtures/widenet-cep-99999999-error.json')
@@ -391,8 +391,8 @@ describe('[unit] cep-promise for browser', () => {
391391
.get('/ws/05010000/json/')
392392
.reply(400, '<h2>Bad Request (400)</h2>')
393393

394-
nock('https://ws.apicep.com')
395-
.get('/busca-cep/api/cep/05010000.json')
394+
nock('https://cdn.apicep.com')
395+
.get('/file/apicep/05010-000.json')
396396
.reply(400, '<h2>Bad Request (400)</h2>')
397397

398398
nock('https://brasilapi.com.br/')

test/unit/cep-promise-node.spec.js

+27-27
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ describe('[unit] cep-promise for node', () => {
4848
path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json')
4949
)
5050

51-
nock('https://ws.apicep.com')
52-
.get('/busca-cep/api/cep/05010000.json')
51+
nock('https://cdn.apicep.com')
52+
.get('/file/apicep/05010-000.json')
5353
.replyWithFile(
5454
200,
5555
path.join(__dirname, '/fixtures/widenet-cep-05010000-found.json')
@@ -177,8 +177,8 @@ describe('[unit] cep-promise for node', () => {
177177
path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json')
178178
)
179179

180-
nock('https://ws.apicep.com')
181-
.get('/busca-cep/api/cep/05010000.json')
180+
nock('https://cdn.apicep.com')
181+
.get('/file/apicep/05010-000.json')
182182
.replyWithFile(
183183
200,
184184
path.join(__dirname, '/fixtures/widenet-cep-05010000-found.json')
@@ -227,8 +227,8 @@ describe('[unit] cep-promise for node', () => {
227227
path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json')
228228
)
229229

230-
nock('https://ws.apicep.com')
231-
.get('/busca-cep/api/cep/05010000.json')
230+
nock('https://cdn.apicep.com')
231+
.get('/file/apicep/05010-000.json')
232232
.replyWithFile(
233233
200,
234234
path.join(__dirname, '/fixtures/widenet-cep-05010000-found.json')
@@ -278,7 +278,7 @@ describe('[unit] cep-promise for node', () => {
278278
)
279279

280280
nock('https://cep.widenet.host')
281-
.get('/busca-cep/api/cep/05010000.json')
281+
.get('/file/apicep/05010-000.json')
282282
.replyWithFile(
283283
200,
284284
path.join(__dirname, '/fixtures/widenet-cep-99999999-error.json')
@@ -328,8 +328,8 @@ describe('[unit] cep-promise for node', () => {
328328
path.join(__dirname, '/fixtures/viacep-cep-99999999-error.json')
329329
)
330330

331-
nock('https://ws.apicep.com')
332-
.get('/busca-cep/api/cep/05010000.json')
331+
nock('https://cdn.apicep.com')
332+
.get('/file/apicep/05010-000.json')
333333
.replyWithFile(
334334
200,
335335
path.join(__dirname, '/fixtures/widenet-cep-99999999-error.json')
@@ -379,8 +379,8 @@ describe('[unit] cep-promise for node', () => {
379379
path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json')
380380
)
381381

382-
nock('https://ws.apicep.com')
383-
.get('/busca-cep/api/cep/05010000.json')
382+
nock('https://cdn.apicep.com')
383+
.get('/file/apicep/05010-000.json')
384384
.replyWithFile(
385385
200,
386386
path.join(__dirname, '/fixtures/widenet-cep-99999999-error.json')
@@ -429,8 +429,8 @@ describe('[unit] cep-promise for node', () => {
429429
path.join(__dirname, '/fixtures/viacep-cep-99999999-error.json')
430430
)
431431

432-
nock('https://ws.apicep.com')
433-
.get('/busca-cep/api/cep/05010000.json')
432+
nock('https://cdn.apicep.com')
433+
.get('/file/apicep/05010-000.json')
434434
.replyWithFile(
435435
200,
436436
path.join(__dirname, '/fixtures/widenet-cep-05010000-found.json')
@@ -478,8 +478,8 @@ describe('[unit] cep-promise for node', () => {
478478
path.join(__dirname, '/fixtures/viacep-cep-99999999-error.json')
479479
)
480480

481-
nock('https://ws.apicep.com')
482-
.get('/busca-cep/api/cep/05010000.json')
481+
nock('https://cdn.apicep.com')
482+
.get('/file/apicep/05010-000.json')
483483
.replyWithFile(
484484
200,
485485
path.join(__dirname, '/fixtures/widenet-cep-99999999-error.json')
@@ -527,8 +527,8 @@ describe('[unit] cep-promise for node', () => {
527527
path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json')
528528
)
529529

530-
nock('https://ws.apicep.com')
531-
.get('/busca-cep/api/cep/05010000.json')
530+
nock('https://cdn.apicep.com')
531+
.get('/file/apicep/05010-000.json')
532532
.replyWithFile(
533533
200,
534534
path.join(__dirname, '/fixtures/widenet-cep-05010000-found.json')
@@ -575,8 +575,8 @@ describe('[unit] cep-promise for node', () => {
575575
path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json')
576576
)
577577

578-
nock('https://ws.apicep.com')
579-
.get('/busca-cep/api/cep/05010000.json')
578+
nock('https://cdn.apicep.com')
579+
.get('/file/apicep/05010-000.json')
580580
.replyWithFile(
581581
200,
582582
path.join(__dirname, '/fixtures/widenet-cep-05010000-found.json')
@@ -624,8 +624,8 @@ describe('[unit] cep-promise for node', () => {
624624
path.join(__dirname, '/fixtures/viacep-cep-99999999-error.json')
625625
)
626626

627-
nock('https://ws.apicep.com')
628-
.get('/busca-cep/api/cep/99999999.json')
627+
nock('https://cdn.apicep.com')
628+
.get('/file/apicep/99999-999.json')
629629
.replyWithFile(
630630
200,
631631
path.join(__dirname, '/fixtures/widenet-cep-99999999-error.json')
@@ -704,8 +704,8 @@ describe('[unit] cep-promise for node', () => {
704704
.get('/ws/05010000/json/')
705705
.reply(400, '<h2>Bad Request (400)</h2>')
706706

707-
nock('https://ws.apicep.com')
708-
.get('/busca-cep/api/cep/05010000.json')
707+
nock('https://cdn.apicep.com')
708+
.get('/file/apicep/05010-000.json')
709709
.reply(400, '<h2>Bad Request (400)</h2>')
710710

711711
nock('https://brasilapi.com.br/')
@@ -764,8 +764,8 @@ describe('[unit] cep-promise for node', () => {
764764
.get('/ws/05010000/json/')
765765
.reply(400, '<h2>Bad Request (400)</h2>')
766766

767-
nock('https://ws.apicep.com')
768-
.get('/busca-cep/api/cep/05010000.json')
767+
nock('https://cdn.apicep.com')
768+
.get('/file/apicep/05010-000.json')
769769
.reply(400, '<h2>Bad Request (400)</h2>')
770770

771771
nock('https://brasilapi.com.br/')
@@ -825,8 +825,8 @@ describe('[unit] cep-promise for node', () => {
825825
'getaddrinfo ENOTFOUND apps.correios.com.br apps.correios.com.br:443'
826826
)
827827

828-
nock('https://ws.apicep.com')
829-
.get('/busca-cep/api/cep/05010000.json')
828+
nock('https://cdn.apicep.com')
829+
.get('/file/apicep/05010-000.json')
830830
.replyWithError(
831831
'getaddrinfo ENOTFOUND apps.correios.com.br apps.correios.com.br:443'
832832
)

test/unit/cep-promise-providers.spec.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ describe('when invoked with providers parameter', () => {
143143
path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json')
144144
)
145145

146-
const wideNetMock = nock('https://ws.apicep.com')
147-
.get('/busca-cep/api/cep/05010000.json')
146+
const wideNetMock = nock('https://cdn.apicep.com')
147+
.get('/file/apicep/05010-000.json')
148148
.replyWithFile(
149149
200,
150150
path.join(__dirname, '/fixtures/widenet-cep-05010000-found.json')
@@ -192,8 +192,8 @@ describe('when invoked with providers parameter', () => {
192192
path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json')
193193
)
194194

195-
const wideNetMock = nock('https://ws.apicep.com')
196-
.get('/busca-cep/api/cep/05010000.json')
195+
const wideNetMock = nock('https://cdn.apicep.com')
196+
.get('/file/apicep/05010-000.json')
197197
.replyWithFile(
198198
200,
199199
path.join(__dirname, '/fixtures/widenet-cep-05010000-found.json')
@@ -241,8 +241,8 @@ describe('when invoked with providers parameter', () => {
241241
path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json')
242242
)
243243

244-
const wideNetMock = nock('https://ws.apicep.com')
245-
.get('/busca-cep/api/cep/05010000.json')
244+
const wideNetMock = nock('https://cdn.apicep.com')
245+
.get('/file/apicep/05010-000.json')
246246
.replyWithFile(
247247
200,
248248
path.join(__dirname, '/fixtures/widenet-cep-05010000-found.json')
@@ -291,7 +291,7 @@ describe('when invoked with providers parameter', () => {
291291
)
292292

293293
const wideNetMock = nock('https://cep.widenet.host')
294-
.get('/busca-cep/api/cep/05010000.json')
294+
.get('/file/apicep/05010-000.json')
295295
.replyWithFile(
296296
200,
297297
path.join(__dirname, '/fixtures/widenet-cep-05010000-found.json')
@@ -339,8 +339,8 @@ describe('when invoked with providers parameter', () => {
339339
path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json')
340340
)
341341

342-
const wideNetMock = nock('https://ws.apicep.com')
343-
.get('/busca-cep/api/cep/05010000.json')
342+
const wideNetMock = nock('https://cdn.apicep.com')
343+
.get('/file/apicep/05010-000.json')
344344
.replyWithFile(
345345
200,
346346
path.join(__dirname, '/fixtures/widenet-cep-05010000-found.json')
@@ -396,8 +396,8 @@ describe('when invoked with providers parameter', () => {
396396
path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json')
397397
)
398398

399-
const wideNetMock = nock('https://ws.apicep.com')
400-
.get('/busca-cep/api/cep/05010000.json')
399+
const wideNetMock = nock('https://cdn.apicep.com')
400+
.get('/file/apicep/05010-000.json')
401401
.replyWithFile(
402402
200,
403403
path.join(__dirname, '/fixtures/widenet-cep-05010000-found.json')
@@ -445,8 +445,8 @@ describe('when invoked with providers parameter', () => {
445445
path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json')
446446
)
447447

448-
const wideNetMock = nock('https://ws.apicep.com')
449-
.get('/busca-cep/api/cep/05010000.json')
448+
const wideNetMock = nock('https://cdn.apicep.com')
449+
.get('/file/apicep/05010-000.json')
450450
.replyWithFile(
451451
200,
452452
path.join(__dirname, '/fixtures/widenet-cep-05010000-found.json')

0 commit comments

Comments
 (0)