Skip to content

Commit

Permalink
1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Batistella Bellas committed Oct 18, 2021
1 parent b86b574 commit 8598646
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bling-erp-api",
"version": "1.0.0",
"version": "1.0.1",
"description": "Pacote de interação com a REST API do serviço Bling ERP",
"main": "index.js",
"directories": {
Expand Down
6 changes: 3 additions & 3 deletions src/bling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import createError from './core/createError'
export default class Bling {
private api: AxiosInstance

constructor (apiKey: string) {
constructor(apiKey: string) {
if (!apiKey || typeof apiKey !== 'string') {
throw createError(
"The API key wasn't correctly provided for Bling connection.",
Expand All @@ -35,11 +35,11 @@ export default class Bling {
this.api = api
}

public products () {
public products() {
return new Products(this.api)
}

public orders () {
public orders() {
return new Orders(this.api)
}
}
2 changes: 1 addition & 1 deletion src/core/createError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface IBlingError extends Error {
* @param {string} [code] The error code (for example, 'ECONNABORTED').
* @returns {IBlingError} The created error.
*/
export default function createError (
export default function createError(
message: string,
status: number,
config: any,
Expand Down
24 changes: 12 additions & 12 deletions src/core/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class BlingBaseEntity<
singularName: string
pluralName: string

constructor (api: AxiosInstance) {
constructor(api: AxiosInstance) {
this.api = api

this.qs = qs
Expand All @@ -31,27 +31,27 @@ export default class BlingBaseEntity<
this.pluralName = ''
}

async all (params?: IFilters): Promise<IEntity[] | IError> {
async all(params?: IFilters): Promise<IEntity[] | IError> {
return await this._getAll(this.pluralName, params)
}

async find (id: number | string, params?: IInfos): Promise<IEntity | IError> {
async find(id: number | string, params?: IInfos): Promise<IEntity | IError> {
return await this._getOne(this.singularName, String(id), params)
}

async findBy (params?: IFilters & IInfos): Promise<IEntity[] | IError> {
async findBy(params?: IFilters & IInfos): Promise<IEntity[] | IError> {
return await this._getAll(this.pluralName, params)
}

async create (data: IEntity): Promise<IEntity | IError> {
async create(data: IEntity): Promise<IEntity | IError> {
return await this._create(this.singularName, data)
}

async update (id: number, data: IEntity): Promise<IEntity | IError> {
async update(id: number, data: IEntity): Promise<IEntity | IError> {
return await this._update(this.singularName, id, data)
}

async delete (id: number): Promise<IEntity | IError> {
async delete(id: number): Promise<IEntity | IError> {
return await this._delete(this.singularName, id)
}

Expand All @@ -65,7 +65,7 @@ export default class BlingBaseEntity<
* @param {string[]} acceptedParams The actual useful query params for the request.
* @returns {Array} An array of entities.
*/
protected async _getAll (
protected async _getAll(
endpoint: string,
params?: IFilters
): Promise<IEntity[] | IError> {
Expand Down Expand Up @@ -106,7 +106,7 @@ export default class BlingBaseEntity<
* @param {string[]} acceptedParams The actual useful query params for the request.
* @returns {Object} The found entity.
*/
protected async _getOne (
protected async _getOne(
endpoint: string,
id: string,
params?: IFilters | IInfos | (IFilters & IInfos)
Expand All @@ -130,7 +130,7 @@ export default class BlingBaseEntity<
* @param endpoint The entity request endpoint.
* @param data The data for the entity to be created.
*/
protected async _create (
protected async _create(
endpoint: string,
data: IEntity
): Promise<IEntity | IError> {
Expand Down Expand Up @@ -182,7 +182,7 @@ export default class BlingBaseEntity<
* @param id The entity code or id.
* @param data The data for the entity to be updated.
*/
protected async _update (
protected async _update(
endpoint: string,
id: number,
data: IEntity
Expand Down Expand Up @@ -243,7 +243,7 @@ export default class BlingBaseEntity<
* @param endpoint The entity request endpoint.
* @param id The entity code or id.
*/
protected async _delete (
protected async _delete(
endpoint: string,
id: number
): Promise<IEntity | IError> {
Expand Down
2 changes: 1 addition & 1 deletion src/entities/orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default class Orders extends BlingEntity<
BlingBaseResponse<OrderResponse>,
OrderError
> {
constructor (api: AxiosInstance) {
constructor(api: AxiosInstance) {
super(api)

this.singularName = 'pedido'
Expand Down
4 changes: 2 additions & 2 deletions src/entities/products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ export default class Products extends BlingEntity<
BlingBaseResponse<ProductResponse>,
ProductError
> {
constructor (api: AxiosInstance) {
constructor(api: AxiosInstance) {
super(api)

this.singularName = 'produto'
this.pluralName = 'produtos'
}

async findBySupplierCode (
async findBySupplierCode(
code: string,
supplierId: number,
params: ProductInfos
Expand Down

0 comments on commit 8598646

Please sign in to comment.