-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a5a351
commit b64195a
Showing
7 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Empresas } from '..' | ||
import { InMemoryBlingRepository } from '../../../repositories/bling-in-memory.repository' | ||
import meResponse from './me-response' | ||
|
||
describe('Empresas entity', () => { | ||
let repository: InMemoryBlingRepository | ||
let entity: Empresas | ||
|
||
beforeEach(() => { | ||
repository = new InMemoryBlingRepository() | ||
entity = new Empresas(repository) | ||
}) | ||
|
||
afterEach(() => { | ||
jest.restoreAllMocks() | ||
}) | ||
|
||
it('should get successfully', async () => { | ||
const spy = jest.spyOn(repository, 'index') | ||
repository.setResponse(meResponse) | ||
|
||
const response = await entity.me() | ||
|
||
expect(spy).toHaveBeenCalledWith({ | ||
endpoint: 'empresas/me/dados-basicos' | ||
}) | ||
expect(response).toBe(meResponse) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default { | ||
data: { | ||
nome: 'Empresa Teste LTDA', | ||
cnpj: '12.345.657/8910-11', | ||
email: '[email protected]' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Entity } from '../@shared/entity' | ||
import { IMeResponse } from './interfaces/me.interface' | ||
|
||
/** | ||
* Entidade para interação com empresas. | ||
*/ | ||
export class Empresas extends Entity { | ||
/** | ||
* Obtém dados básicos da empresa. | ||
* | ||
* @returns {Promise<IMeResponse>} | ||
* @throws {BlingApiException|BlingInternalException} | ||
* | ||
* @see https://developer.bling.com.br/referencia#/Empresas/get_empresas_me_dados_basicos | ||
*/ | ||
public async me(): Promise<IMeResponse> { | ||
return await this.repository.index({ | ||
endpoint: 'empresas/me/dados-basicos' | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface IMeResponse { | ||
data: { | ||
nome: string | ||
cnpj: string | ||
email: string | ||
} | ||
} |