Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/clients/opencep/open-cep-api-client-impl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('client open-cep', () => {

vi.stubGlobal('fetch', mockedFetch)

const client = new OpenCepAPIClientImpl('https://opencep.com')
const client = new OpenCepAPIClientImpl()

const result = await client.getCep('12345678')

Expand All @@ -46,7 +46,7 @@ describe('client open-cep', () => {

vi.stubGlobal('fetch', mockedFetch)

const client = new OpenCepAPIClientImpl('https://opencep.com')
const client = new OpenCepAPIClientImpl()
await client.getCep('12345678')
expect(mockedWarnLogger).toBeCalledWith({ message: 'Network Error' })
})
Expand Down
4 changes: 1 addition & 3 deletions src/clients/opencep/open-cep-api-client-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import type { OpenCepAPIClient } from './open-cep-api-client'
import type { OpenCepResponse } from './types'

export class OpenCepAPIClientImpl implements OpenCepAPIClient {
constructor(private readonly apiURL: string) {}

async getCep(cep: string): Promise<OpenCepResponse | undefined> {
Logger.info(`Starting getCep [cep=${cep}]`)
return fetch(`${this.apiURL}/v1/${cep}.json`)
return fetch(`https://opencep.com/v1/${cep}.json`)
.then((response) => response.json())
.catch((error) => {
Logger.warn(error)
Expand Down