Skip to content

Commit 5f8b8d4

Browse files
committed
fix #218 fixing domain widenet provider
1 parent 5dc67cd commit 5f8b8d4

File tree

8 files changed

+118
-118
lines changed

8 files changed

+118
-118
lines changed

dist/cep-promise-browser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@
493493
}
494494

495495
function fetchWideNetService(cepWithLeftPad, configurations) {
496-
var url = "https://cep.widenet.host/busca-cep/api/cep/".concat(cepWithLeftPad, ".json");
496+
var url = "https://ws.apicep.com/busca-cep/api/cep/".concat(cepWithLeftPad, ".json");
497497
var options = {
498498
method: 'GET',
499499
mode: 'cors',

dist/cep-promise-browser.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/cep-promise.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@
444444
}
445445

446446
function fetchWideNetService(cepWithLeftPad, configurations) {
447-
var url = "https://cep.widenet.host/busca-cep/api/cep/".concat(cepWithLeftPad, ".json");
447+
var url = "https://ws.apicep.com/busca-cep/api/cep/".concat(cepWithLeftPad, ".json");
448448
var options = {
449449
method: 'GET',
450450
mode: 'cors',

dist/cep-promise.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/services/widenet.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import fetch from 'node-fetch'
44
import ServiceError from '../errors/service.js'
55

6-
export default function fetchWideNetService (cepWithLeftPad, configurations) {
7-
const url = `https://cep.widenet.host/busca-cep/api/cep/${cepWithLeftPad}.json`
6+
export default function fetchWideNetService(cepWithLeftPad, configurations) {
7+
const url = `https://ws.apicep.com/busca-cep/api/cep/${cepWithLeftPad}.json`
88
const options = {
99
method: 'GET',
1010
mode: 'cors',
@@ -21,23 +21,23 @@ export default function fetchWideNetService (cepWithLeftPad, configurations) {
2121
.catch(throwApplicationError)
2222
}
2323

24-
function analyzeAndParseResponse (response) {
24+
function analyzeAndParseResponse(response) {
2525
if (response.ok) {
2626
return response.json()
2727
}
2828

2929
throw Error('Erro ao se conectar com o serviço WideNet.')
3030
}
3131

32-
function checkForWideNetError (object) {
32+
function checkForWideNetError(object) {
3333
if (object.ok === false || object.status !== 200) {
3434
throw new Error('CEP não encontrado na base do WideNet.')
3535
}
3636

3737
return object
3838
}
3939

40-
function extractCepValuesFromResponse (object) {
40+
function extractCepValuesFromResponse(object) {
4141
return {
4242
cep: object.code.replace('-', ''),
4343
state: object.state,
@@ -48,7 +48,7 @@ function extractCepValuesFromResponse (object) {
4848
}
4949
}
5050

51-
function throwApplicationError (error) {
51+
function throwApplicationError(error) {
5252
const serviceError = new ServiceError({
5353
message: error.message,
5454
service: 'widenet'

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

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('[unit] cep-promise for browser', () => {
3636
path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json')
3737
)
3838

39-
nock('https://cep.widenet.host')
39+
nock('https://ws.apicep.com')
4040
.get('/busca-cep/api/cep/05010000.json')
4141
.replyWithFile(
4242
200,
@@ -121,7 +121,7 @@ describe('[unit] cep-promise for browser', () => {
121121

122122
describe('when invoked with an Function', () => {
123123
it('should reject with "validation_error"', () => {
124-
return cep(function zelda () {
124+
return cep(function zelda() {
125125
return 'link'
126126
}).catch(error => {
127127
return expect(error)
@@ -151,7 +151,7 @@ describe('[unit] cep-promise for browser', () => {
151151
path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json')
152152
)
153153

154-
nock('https://cep.widenet.host')
154+
nock('https://ws.apicep.com')
155155
.get('/busca-cep/api/cep/05010000.json')
156156
.replyWithFile(
157157
200,
@@ -167,13 +167,13 @@ describe('[unit] cep-promise for browser', () => {
167167

168168
return cep('05010000')
169169
.then(address => expect(address).to.deep.equal({
170-
cep: '05010000',
171-
state: 'SP',
172-
city: 'São Paulo',
173-
neighborhood: 'Perdizes',
174-
street: 'Rua Caiubi',
175-
service: address.service
176-
})
170+
cep: '05010000',
171+
state: 'SP',
172+
city: 'São Paulo',
173+
neighborhood: 'Perdizes',
174+
street: 'Rua Caiubi',
175+
service: address.service
176+
})
177177
)
178178
})
179179
})
@@ -187,7 +187,7 @@ describe('[unit] cep-promise for browser', () => {
187187
path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json')
188188
)
189189

190-
nock('https://cep.widenet.host')
190+
nock('https://ws.apicep.com')
191191
.get('/busca-cep/api/cep/05010000.json')
192192
.replyWithFile(
193193
200,
@@ -201,15 +201,15 @@ describe('[unit] cep-promise for browser', () => {
201201
path.join(__dirname, '/fixtures/brasilapi-cep-05010000-found.json')
202202
)
203203

204-
return cep(5010000)
205-
.then(address => expect(address).to.deep.equal({
206-
cep: '05010000',
207-
state: 'SP',
208-
city: 'São Paulo',
209-
neighborhood: 'Perdizes',
210-
street: 'Rua Caiubi',
211-
service: address.service
212-
})
204+
return cep(5010000)
205+
.then(address => expect(address).to.deep.equal({
206+
cep: '05010000',
207+
state: 'SP',
208+
city: 'São Paulo',
209+
neighborhood: 'Perdizes',
210+
street: 'Rua Caiubi',
211+
service: address.service
212+
})
213213
)
214214
})
215215
})
@@ -223,7 +223,7 @@ describe('[unit] cep-promise for browser', () => {
223223
path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json')
224224
)
225225

226-
nock('https://cep.widenet.host')
226+
nock('https://ws.apicep.com')
227227
.get('/busca-cep/api/cep/05010000.json')
228228
.replyWithFile(
229229
200,
@@ -237,15 +237,15 @@ describe('[unit] cep-promise for browser', () => {
237237
path.join(__dirname, '/fixtures/brasilapi-cep-99999999-error.json')
238238
)
239239

240-
return cep('05010000')
241-
.then(address => expect(address).to.deep.equal({
242-
cep: '05010000',
243-
state: 'SP',
244-
city: 'São Paulo',
245-
neighborhood: 'Perdizes',
246-
street: 'Rua Caiubi',
247-
service: 'viacep'
248-
})
240+
return cep('05010000')
241+
.then(address => expect(address).to.deep.equal({
242+
cep: '05010000',
243+
state: 'SP',
244+
city: 'São Paulo',
245+
neighborhood: 'Perdizes',
246+
street: 'Rua Caiubi',
247+
service: 'viacep'
248+
})
249249
)
250250
})
251251
})
@@ -259,7 +259,7 @@ describe('[unit] cep-promise for browser', () => {
259259
path.join(__dirname, '/fixtures/viacep-cep-99999999-error.json')
260260
)
261261

262-
nock('https://cep.widenet.host')
262+
nock('https://ws.apicep.com')
263263
.get('/busca-cep/api/cep/05010000.json')
264264
.replyWithFile(
265265
200,
@@ -282,7 +282,7 @@ describe('[unit] cep-promise for browser', () => {
282282
street: 'Rua Caiubi',
283283
service: 'widenet'
284284
}))
285-
})
285+
})
286286
})
287287

288288
describe('Should succeed only with brasilapi service', () => {
@@ -294,7 +294,7 @@ describe('[unit] cep-promise for browser', () => {
294294
path.join(__dirname, '/fixtures/viacep-cep-99999999-error.json')
295295
)
296296

297-
nock('https://cep.widenet.host')
297+
nock('https://ws.apicep.com')
298298
.get('/busca-cep/api/cep/05010000.json')
299299
.replyWithFile(
300300
200,
@@ -317,7 +317,7 @@ describe('[unit] cep-promise for browser', () => {
317317
street: 'Rua Caiubi',
318318
service: 'brasilapi'
319319
}))
320-
})
320+
})
321321
})
322322

323323
describe('when invoked with an inexistent "99999999" CEP', () => {
@@ -329,7 +329,7 @@ describe('[unit] cep-promise for browser', () => {
329329
path.join(__dirname, '/fixtures/viacep-cep-99999999-error.json')
330330
)
331331

332-
nock('https://cep.widenet.host')
332+
nock('https://ws.apicep.com')
333333
.get('/busca-cep/api/cep/99999999.json')
334334
.replyWithFile(
335335
200,
@@ -391,11 +391,11 @@ describe('[unit] cep-promise for browser', () => {
391391
.get('/ws/05010000/json/')
392392
.reply(400, '<h2>Bad Request (400)</h2>')
393393

394-
nock('https://cep.widenet.host')
394+
nock('https://ws.apicep.com')
395395
.get('/busca-cep/api/cep/05010000.json')
396396
.reply(400, '<h2>Bad Request (400)</h2>')
397397

398-
nock('https://brasilapi.com.br/')
398+
nock('https://brasilapi.com.br/')
399399
.get('/api/cep/v1/05010000')
400400
.reply(400, '<h2>Bad Request (400)</h2>')
401401

@@ -425,7 +425,7 @@ describe('[unit] cep-promise for browser', () => {
425425
})
426426
})
427427
})
428-
428+
429429
afterEach(() => {
430430
nock.cleanAll()
431431
})

0 commit comments

Comments
 (0)