@tec.pet/tecpet-sdk 0.0.36 → 0.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/domain/breed/breed.service.js +0 -2
  2. package/dist/domain/chatbot/index.d.ts +1 -0
  3. package/dist/domain/chatbot/index.js +1 -0
  4. package/dist/domain/client/client.service.js +3 -6
  5. package/package.json +4 -1
  6. package/.github/workflows/main.yml +0 -152
  7. package/changelog.md +0 -2
  8. package/jest.config.js +0 -14
  9. package/src/domain/availableTimes/availableTimes.service.ts +0 -23
  10. package/src/domain/availableTimes/dto/pa.get-available-time.dto.ts +0 -5
  11. package/src/domain/availableTimes/dto/pa.get-available-times.dto.ts +0 -9
  12. package/src/domain/availableTimes/index.ts +0 -3
  13. package/src/domain/billingMethod/billingMethod.service.ts +0 -20
  14. package/src/domain/billingMethod/dto/pa.get-billing-methods.dto.ts +0 -22
  15. package/src/domain/billingMethod/enum/billing-method-type.enum.ts +0 -14
  16. package/src/domain/billingMethod/index.ts +0 -3
  17. package/src/domain/booking/booking.service.ts +0 -35
  18. package/src/domain/booking/dto/pa.change-booking-status.dto.ts +0 -13
  19. package/src/domain/booking/dto/pa.create-booking.dto.ts +0 -13
  20. package/src/domain/booking/dto/pa.get-booking.dto.ts +0 -19
  21. package/src/domain/booking/dto/pa.get-bookings.dto.ts +0 -11
  22. package/src/domain/booking/index.ts +0 -3
  23. package/src/domain/breed/breed.service.ts +0 -23
  24. package/src/domain/breed/dto/pa.get-breed.dto.ts +0 -11
  25. package/src/domain/breed/dto/pa.get-breeds.dto.ts +0 -8
  26. package/src/domain/breed/index.ts +0 -3
  27. package/src/domain/chatbot/chatbotService.ts +0 -49
  28. package/src/domain/chatbot/dto/chatbot-settings.json.ts +0 -254
  29. package/src/domain/chatbot/dto/get-chatbot-formatted-messages.dto.ts +0 -20
  30. package/src/domain/chatbot/dto/pa.change-notification-status.dto.ts +0 -19
  31. package/src/domain/chatbot/dto/pa.handle-button-action.dto.ts +0 -13
  32. package/src/domain/chatbot/enum/chatbotActionEnums/chatbot-action-mode-type.enum.ts +0 -5
  33. package/src/domain/chatbot/enum/chatbotActionEnums/chatbot-action-schedule-permission.enum.ts +0 -5
  34. package/src/domain/chatbot/enum/chatbotActionEnums/chatbot-action-type.enum.ts +0 -9
  35. package/src/domain/chatbot/enum/chatbotActionEnums/media-type.enum.ts +0 -5
  36. package/src/domain/chatbot/enum/chatbotBehaviorEnums/chatbot-behavior-type.enum.ts +0 -4
  37. package/src/domain/chatbot/enum/chatbotBehaviorEnums/chatbot-inactive-employee-action.enum.ts +0 -4
  38. package/src/domain/chatbot/enum/chatbotBehaviorEnums/chatbot-timeout-action.enum.ts +0 -5
  39. package/src/domain/chatbot/enum/chatbotFluxEnums/chatbot-flux-type.enum.ts +0 -10
  40. package/src/domain/chatbot/enum/chatbotGuidanceEnums/chatbot-action-button-type.enum.ts +0 -12
  41. package/src/domain/chatbot/enum/chatbotInfoCollectionEnums/chatbot-info-collection-subtype.enum.ts +0 -32
  42. package/src/domain/chatbot/enum/chatbotInfoCollectionEnums/chatbot-info-collection-type.enum.ts +0 -12
  43. package/src/domain/chatbot/enum/chatbotInfoCollectionEnums/chatbot-price-display-mode.enum.ts +0 -5
  44. package/src/domain/chatbot/enum/chatbotInfoCollectionEnums/chatbot-size_display-mode.enum.ts +0 -5
  45. package/src/domain/chatbot/enum/chatbotInfoCollectionEnums/chatbot-time-display-mode.enum.ts +0 -5
  46. package/src/domain/chatbot/enum/chatbotInfoCollectionEnums/chatbot-time-selection-behavior.enum.ts +0 -4
  47. package/src/domain/chatbot/enum/chatbotSendingInfoItemEnums/chatbot-sending-info-item-type.enum.ts +0 -7
  48. package/src/domain/chatbot/enum/chatbotSettingsEnums/chatbot-ai-voice.enum.ts +0 -4
  49. package/src/domain/chatbot/enum/chatbotSettingsEnums/chatbot-channel-type.enum.ts +0 -3
  50. package/src/domain/chatbot/enum/chatbotSettingsEnums/chatbot-mode.enum.ts +0 -5
  51. package/src/domain/chatbot/enum/chatbotSettingsEnums/chatbot-platform-type.enum.ts +0 -4
  52. package/src/domain/chatbot/enum/chatbotSettingsEnums/chatbot-settings-ai-personality.enum.ts +0 -10
  53. package/src/domain/chatbot/enum/chatbotTriggerEnums/chatbot-trigger-pattern-type.enum.ts +0 -4
  54. package/src/domain/chatbot/index.ts +0 -10
  55. package/src/domain/client/client.service.ts +0 -40
  56. package/src/domain/client/dto/pa.create-client.dto.ts +0 -11
  57. package/src/domain/client/dto/pa.edit-client.dto.ts +0 -11
  58. package/src/domain/client/dto/pa.get-client-summary.dto.ts +0 -11
  59. package/src/domain/client/dto/pa.get-client.dto.ts +0 -20
  60. package/src/domain/client/dto/pa.get-clients.dto.ts +0 -11
  61. package/src/domain/client/index.ts +0 -5
  62. package/src/domain/combo/combo.service.ts +0 -20
  63. package/src/domain/combo/dto/pa.get-combo-pricing.dto.ts +0 -13
  64. package/src/domain/combo/index.ts +0 -2
  65. package/src/domain/employee/dto/pa.employee-filter.dto.ts +0 -4
  66. package/src/domain/employee/dto/pa.get-employee.dto.ts +0 -18
  67. package/src/domain/employee/employee.service.ts +0 -19
  68. package/src/domain/employee/index.ts +0 -3
  69. package/src/domain/pet/dto/pa.create-pet.dto.ts +0 -13
  70. package/src/domain/pet/dto/pa.edit-pet.dto.ts +0 -15
  71. package/src/domain/pet/dto/pa.get-pet-activity.dto.ts +0 -5
  72. package/src/domain/pet/dto/pa.get-pet.dto.ts +0 -23
  73. package/src/domain/pet/dto/pa.get-pets.dto.ts +0 -8
  74. package/src/domain/pet/index.ts +0 -5
  75. package/src/domain/pet/pet.service.ts +0 -36
  76. package/src/domain/segment/enum/segment.enum.ts +0 -6
  77. package/src/domain/service/dto/pa.get-service-pricing.dto.ts +0 -35
  78. package/src/domain/service/index.ts +0 -2
  79. package/src/domain/service/service.service.ts +0 -20
  80. package/src/domain/shop/dto/pa.get-shop-configurations.dto.ts +0 -92
  81. package/src/domain/shop/index.ts +0 -6
  82. package/src/domain/shop/shop.service.ts +0 -15
  83. package/src/domain/specie/dto/pa.get-specie.dto.ts +0 -7
  84. package/src/domain/specie/dto/pa.get-species.dto.ts +0 -7
  85. package/src/domain/specie/enum/specie-type.enum.ts +0 -21
  86. package/src/domain/specie/index.ts +0 -5
  87. package/src/domain/specie/specie.service.ts +0 -18
  88. package/src/domain/token/dto/pa.extract-token.dto.ts +0 -4
  89. package/src/domain/token/index.ts +0 -1
  90. package/src/domain/token/token.service.ts +0 -15
  91. package/src/domain/types/pagination.types.ts +0 -10
  92. package/src/index.ts +0 -66
  93. package/src/infra/http/client.http.ts +0 -91
  94. package/src/infra/logger/logger.interface.ts +0 -7
  95. package/src/infra/logger/stdout.logger.ts +0 -85
  96. package/tsconfig.json +0 -17
@@ -1,13 +0,0 @@
1
- import { PaServicePricingResponse } from "../../service";
2
-
3
- export interface PaComboPricingResponse {
4
- id: number;
5
- name: string;
6
- price: number;
7
- description: string;
8
- services: PaServicePricingResponse[];
9
- }
10
-
11
- export interface PaGetCombosPricingResponse {
12
- data: PaComboPricingResponse[];
13
- }
@@ -1,2 +0,0 @@
1
- export * from './dto/pa.get-combo-pricing.dto';
2
-
@@ -1,4 +0,0 @@
1
-
2
- export interface PaEmployeeFilter {
3
- serviceCategoryIds: number[]
4
- }
@@ -1,18 +0,0 @@
1
- import { PaServiceCategoryResponse, ServiceCategoryType } from "../../service";
2
-
3
- export interface PaEmployeeResponse {
4
- id: number;
5
- name: string;
6
- phoneNumber: string;
7
- categories: PaServiceCategoryResponse[]
8
- }
9
-
10
- export interface PaGetEmployeeResponse {
11
- data: PaEmployeeResponse[];
12
- }
13
-
14
-
15
- export interface PaEmployeeIndication {
16
- id: number;
17
- serviceCategoryType: ServiceCategoryType;
18
- }
@@ -1,19 +0,0 @@
1
- import { HttpClient } from "infra/http/client.http";
2
- import { PaEmployeeFilter } from "./dto/pa.employee-filter.dto";
3
- import { PaEmployeeResponse, PaGetEmployeeResponse } from "./dto/pa.get-employee.dto";
4
-
5
- export class EmployeeService {
6
- constructor(private readonly api: HttpClient) {
7
- }
8
-
9
- async getEmployeesByServiceCategory(filter: PaEmployeeFilter, shopId: number): Promise<PaEmployeeResponse[]> {
10
- const response = await this.api.get<PaGetEmployeeResponse>(`/employee/list`, {
11
- filter
12
- }, shopId)
13
-
14
- if (response && response.data?.length) {
15
- return response.data;
16
- }
17
- return [];
18
- }
19
- }
@@ -1,3 +0,0 @@
1
- export * from './dto/pa.employee-filter.dto';
2
- export * from './dto/pa.get-employee.dto';
3
-
@@ -1,13 +0,0 @@
1
- import { BillingItemType } from "../../billingMethod/enum/billing-method-type.enum";
2
- import { GenderType } from "./pa.get-pet.dto";
3
-
4
- export interface PaCreatePetInput {
5
- clientId: number;
6
- name: string;
7
- specieId: string;
8
- breedId: number;
9
- genre: GenderType;
10
- hair: BillingItemType;
11
- size: BillingItemType;
12
- birthDate?: Date;
13
- }
@@ -1,15 +0,0 @@
1
- import { BillingItemType } from "../../billingMethod/enum/billing-method-type.enum";
2
- import { SpecieType } from "../../specie/enum/specie-type.enum";
3
- import { GenderType } from "./pa.get-pet.dto";
4
-
5
- export class PaEditPetInput {
6
- name?: string;
7
- specieId?: string;
8
- specie?: SpecieType;
9
- breedId?: number;
10
- genre?: GenderType;
11
- hair?: BillingItemType;
12
- size?: BillingItemType;
13
- birthDate?: string;
14
- weigth?: number;
15
- }
@@ -1,5 +0,0 @@
1
- export interface PaGetPetActivityResponse {
2
- id: string;
3
- name: string;
4
- petId: number;
5
- }
@@ -1,23 +0,0 @@
1
- import { BillingItemType } from "../../billingMethod";
2
- import { SpecieType, SpecieTypeEnum } from "../../specie/enum/specie-type.enum";
3
-
4
- export enum GenderType {
5
- MALE = 'MALE',
6
- FEMALE = 'FEMALE'
7
- }
8
-
9
- export interface PaPetResponse {
10
- id: number | string;
11
- name: string;
12
- specieId: string;
13
- specieType: SpecieTypeEnum;
14
- specie: SpecieType;
15
- specieName: string;
16
- breedId: number;
17
- breedName: string;
18
- genre: GenderType;
19
- weigth: number;
20
- hair: BillingItemType;
21
- size: BillingItemType;
22
- birthDate: string;
23
- }
@@ -1,8 +0,0 @@
1
- import {IPaginationResponse} from "../../types/pagination.types";
2
- import {PaPetResponse} from "./pa.get-pet.dto";
3
-
4
-
5
- export interface PaGetPetsResponse {
6
- data: PaPetResponse[];
7
- pagination: IPaginationResponse;
8
- }
@@ -1,5 +0,0 @@
1
- export * from './dto/pa.create-pet.dto';
2
- export * from './dto/pa.edit-pet.dto';
3
- export * from './dto/pa.get-pet.dto';
4
- export * from './dto/pa.get-pets.dto';
5
-
@@ -1,36 +0,0 @@
1
- import {HttpClient} from "infra/http/client.http";
2
- import {PaPetResponse} from "./dto/pa.get-pet.dto";
3
- import {PaGetPetsResponse} from "./dto/pa.get-pets.dto";
4
- import {PaCreatePetInput} from "./dto/pa.create-pet.dto";
5
- import {PaEditPetInput} from "./dto/pa.edit-pet.dto";
6
-
7
- export class PetService {
8
- constructor(private readonly api: HttpClient) {
9
- }
10
-
11
- async getByClient(clientId: number): Promise<Array<PaPetResponse> | null> {
12
- const response = await this.api.get<PaGetPetsResponse>(`/pet`, {
13
- clientId,
14
- })
15
- if (response?.data?.length) {
16
- return response.data;
17
- }
18
- return [];
19
- }
20
-
21
- async create(petInput: PaCreatePetInput): Promise<PaPetResponse | null> {
22
- const response = await this.api.post<PaPetResponse>(`/pet`, petInput)
23
- if (response?.id) {
24
- return response;
25
- }
26
- return null;
27
- }
28
-
29
- async edit(petId: number, body: PaEditPetInput): Promise<PaPetResponse | null> {
30
- const response = await this.api.put<PaPetResponse>(`/pet/${petId}`, body)
31
- if (response?.id) {
32
- return response;
33
- }
34
- return null;
35
- }
36
- }
@@ -1,6 +0,0 @@
1
- export enum ShopSegment {
2
- PET_SHOP = 'PET_SHOP',
3
- CLINIC = 'CLINIC',
4
- DAY_CARE = 'DAY_CARE',
5
- HOTEL = 'HOTEL',
6
- }
@@ -1,35 +0,0 @@
1
- export enum ServiceCategoryType {
2
- BATH = 'BATH',
3
- GROOM = 'GROOM',
4
- CLINIC = 'CLINIC',
5
- DAY_CARE = 'DAY_CARE',
6
- HOTEL = 'HOTEL',
7
- ADDITIONAL = 'ADDITIONAL',
8
- CUSTOM = 'CUSTOM',
9
- }
10
-
11
- export interface PaServicePricingResponse {
12
- id: number;
13
- name: string;
14
- price: number;
15
- description: string;
16
- serviceCategory: PaServiceCategoryResponse;
17
- }
18
-
19
-
20
- export interface PaServiceCategoryResponse {
21
- id: number;
22
- name: string;
23
- type: ServiceCategoryType;
24
- }
25
-
26
- export interface PaGetServicePricingResponse {
27
- id: number;
28
- name: string;
29
- type: ServiceCategoryType;
30
- services: Array<PaServicePricingResponse>;
31
- }
32
-
33
- export interface PaGetServicesPricingResponse {
34
- data: PaGetServicePricingResponse[];
35
- }
@@ -1,2 +0,0 @@
1
- export * from './dto/pa.get-service-pricing.dto';
2
-
@@ -1,20 +0,0 @@
1
- import { HttpClient } from "infra/http/client.http";
2
- import { ShopSegment } from "../segment/enum/segment.enum";
3
- import { PaGetServicePricingResponse, PaGetServicesPricingResponse, ServiceCategoryType } from "./dto/pa.get-service-pricing.dto";
4
-
5
- export class ServiceService {
6
- constructor(private readonly api: HttpClient) {
7
- }
8
-
9
- async pricing(petId: number, segment: ShopSegment,serviceCategoryTypes:ServiceCategoryType[], shopId: number): Promise<Array<PaGetServicePricingResponse> | null> {
10
- const response = await this.api.get<PaGetServicesPricingResponse>(`/service/pricing`, {
11
- petId,
12
- segment,
13
- serviceCategoryTypes,
14
- }, shopId)
15
- if (response && response.data?.length) {
16
- return response.data;
17
- }
18
- return [];
19
- }
20
- }
@@ -1,92 +0,0 @@
1
- import {ShopSegment} from "../../segment/enum/segment.enum";
2
- import {AddressDto} from "../../client";
3
- import {SpecieTypeEnum} from "../../specie/enum/specie-type.enum";
4
- import {PaBillingResponse} from "../../billingMethod/dto/pa.get-billing-methods.dto";
5
-
6
- interface AdvancedConfigSegment {
7
- id: number;
8
- segmentType: ShopSegment
9
- }
10
-
11
- export interface PaShopConfigurationsSpecie {
12
- id: string;
13
- type: SpecieTypeEnum;
14
- name: string;
15
- }
16
-
17
- export interface PaShopConfigurationsSegment {
18
- id: number;
19
- type: ShopSegment;
20
- name: string;
21
- }
22
-
23
- export interface AdvancedConfigResponseDto {
24
- extraAuth: boolean;
25
- extraAuthPassword: string;
26
- segments: AdvancedConfigSegment[];
27
- global: {
28
- allowSearchByCPF: boolean;
29
- defaultToSearchByCPF: boolean;
30
- defaultToSearchByPhone: boolean;
31
- multipleChatDepartments: boolean;
32
- replaceCatWithOtherSpecies: boolean;
33
- bypassEmployeeCode: boolean;
34
- serviceByBreed: boolean;
35
- requestEmployeeOnClientAccess: boolean;
36
- };
37
- serviceArea: {
38
- hideReception: boolean;
39
- };
40
- employee: {
41
- mandatoryCPF: boolean;
42
- };
43
- client: {
44
- mandatoryAddress: boolean;
45
- mandatoryCPF: boolean;
46
- hideRemove: boolean;
47
- };
48
- booking: {
49
- replaceComboWithPromotion: boolean;
50
- filterServicesByBreed: boolean;
51
- canSchedule: boolean;
52
- canCancelIfPaid: boolean;
53
- canDeliverIfUnpaid: boolean;
54
- canCancelIfStarted: boolean;
55
- canEditIfDelivered: boolean;
56
- canRevertIfStarted: boolean;
57
- };
58
- finance: {
59
- mandatoryCardInputs: boolean;
60
- enableCouponInputs: boolean;
61
- enableConvertPaymentToVoucher: boolean;
62
- };
63
- dashboard: {
64
- enableEmployeesCommissions: boolean;
65
- enableCommissionProjection: boolean;
66
- };
67
- paymentGateway: {
68
- enabled: boolean;
69
- };
70
- invoice: {
71
- allowManualItemAddition: boolean;
72
- };
73
- notification: {
74
- triggerSchedule: boolean;
75
- };
76
- petCare: {
77
- enabled: boolean;
78
- };
79
- animalMating: {
80
- enabled: boolean;
81
- };
82
- }
83
-
84
- export interface PaShopConfigurationsResponse {
85
- id: number;
86
- name: string;
87
- advancedConfig: AdvancedConfigResponseDto;
88
- address: AddressDto;
89
- segments: Array<PaShopConfigurationsSegment>;
90
- species: Array<PaShopConfigurationsSpecie>;
91
- billing: PaBillingResponse[];
92
- }
@@ -1,6 +0,0 @@
1
- export * from '../shop/dto/pa.get-shop-configurations.dto';
2
-
3
- export * from '../shop/dto/pa.get-shop-configurations.dto';
4
-
5
- export * from '../segment/enum/segment.enum';
6
-
@@ -1,15 +0,0 @@
1
- import {HttpClient} from "infra/http/client.http";
2
- import {PaShopConfigurationsResponse} from "./dto/pa.get-shop-configurations.dto";
3
-
4
- export class ShopService {
5
- constructor(private readonly api: HttpClient) {
6
- }
7
-
8
- async getConfigurations(shopId: number): Promise<PaShopConfigurationsResponse | null> {
9
- const response = await this.api.get<PaShopConfigurationsResponse>(`/shop/configurations`, {}, shopId)
10
- if (response?.id) {
11
- return response;
12
- }
13
- return null;
14
- }
15
- }
@@ -1,7 +0,0 @@
1
- import { SpecieTypeEnum } from '../enum/specie-type.enum';
2
-
3
- export interface PaSpecieResponse {
4
- id: string;
5
- name: string;
6
- specieType: SpecieTypeEnum;
7
- }
@@ -1,7 +0,0 @@
1
- import {PaSpecieResponse} from "./pa.get-specie.dto";
2
- import {IPaginationResponse} from "../../types/pagination.types";
3
-
4
- export interface PaGetSpeciesResponse {
5
- data: PaSpecieResponse[];
6
- pagination: IPaginationResponse;
7
- }
@@ -1,21 +0,0 @@
1
- export enum SpecieTypeEnum {
2
- CANINE = 'CANINE',
3
- FELINE = 'FELINE',
4
- RODENT = 'RODENT',
5
- FISH = 'FISH',
6
- BIRD = 'BIRD',
7
- EQUINE = 'EQUINE',
8
- REPTILE = 'REPTILE',
9
- BOVINE = 'BOVINE',
10
- PRIMATE = 'PRIMATE',
11
- LEPORID = 'LEPORID',
12
- SWINE = 'SWINE',
13
- INSECT = 'INSECT',
14
- ARCHNIDE = 'ARCHNIDE',
15
- AMPHIBIAN = 'AMPHIBIAN',
16
- }
17
-
18
- export enum SpecieType {
19
- DOG = 'DOG',
20
- CAT = 'CAT',
21
- }
@@ -1,5 +0,0 @@
1
- export * from './dto/pa.get-specie.dto';
2
- export * from './dto/pa.get-species.dto';
3
- export * from './enum/specie-type.enum';
4
-
5
-
@@ -1,18 +0,0 @@
1
- import {HttpClient} from "infra/http/client.http";
2
- import {logger} from "../../infra/logger/stdout.logger";
3
- import {PaGetSpeciesResponse} from "./dto/pa.get-species.dto";
4
- import {PaSpecieResponse} from "./dto/pa.get-specie.dto";
5
-
6
- export class SpecieService {
7
- constructor(private readonly api: HttpClient) {
8
- }
9
-
10
- async list(shopId: number): Promise<Array<PaSpecieResponse> | null> {
11
- const response = await this.api.get<PaGetSpeciesResponse>(`/specie`, {}, shopId)
12
- if (response && response.data?.length) {
13
- logger.debug(SpecieService.name, JSON.stringify(response, null, 2));
14
- return response.data;
15
- }
16
- return [];
17
- }
18
- }
@@ -1,4 +0,0 @@
1
- export interface PaExtractTokenResponse {
2
- user: string;
3
- shop: { id: number; name: string; }
4
- }
@@ -1 +0,0 @@
1
- export * from '../token/dto/pa.extract-token.dto';
@@ -1,15 +0,0 @@
1
- import {HttpClient} from "infra/http/client.http";
2
- import {PaExtractTokenResponse} from "./dto/pa.extract-token.dto";
3
-
4
- export class TokenService {
5
- constructor(private readonly api: HttpClient) {
6
- }
7
-
8
- async extract(token: string): Promise<PaExtractTokenResponse | null> {
9
- const response = await this.api.get<PaExtractTokenResponse>(`/token/${token}`)
10
- if (response?.user && response?.shop) {
11
- return response;
12
- }
13
- return null;
14
- }
15
- }
@@ -1,10 +0,0 @@
1
- export interface IPaginationResponse {
2
- page: number;
3
- count: number;
4
- hasMore: boolean;
5
- limit: number;
6
- }
7
- export interface IPaginationGeneric {
8
- page?: number;
9
- limit?: number;
10
- }
package/src/index.ts DELETED
@@ -1,66 +0,0 @@
1
- import { AvailableTimesService } from "./domain/availableTimes/availableTimes.service";
2
- import { BillingMethodService } from "./domain/billingMethod/billingMethod.service";
3
- import { BookingService } from "./domain/booking/booking.service";
4
- import { BreedService } from "./domain/breed/breed.service";
5
- import { ChatbotService } from "./domain/chatbot/chatbotService";
6
- import { ClientService } from "./domain/client/client.service";
7
- import { ComboService } from "./domain/combo/combo.service";
8
- import { EmployeeService } from "./domain/employee/employee.service";
9
- import { PetService } from "./domain/pet/pet.service";
10
- import { ServiceService } from "./domain/service/service.service";
11
- import { ShopService } from "./domain/shop/shop.service";
12
- import { SpecieService } from "./domain/specie/specie.service";
13
- import { TokenService } from "./domain/token/token.service";
14
- import { HttpClient } from "./infra/http/client.http";
15
-
16
- export class TecpetSDK {
17
- private api: HttpClient;
18
- public client: ClientService;
19
- public pet: PetService;
20
- public breed: BreedService;
21
- public chatbot: ChatbotService;
22
- public specie: SpecieService;
23
- public billingMethod: BillingMethodService;
24
- public shop: ShopService;
25
- public combo: ComboService;
26
- public service: ServiceService;
27
- public availableTimes: AvailableTimesService;
28
- public booking: BookingService;
29
- public token: TokenService;
30
- public employee: EmployeeService;
31
-
32
- constructor(baseURL: string, apiKey?: string) {
33
- this.api = new HttpClient(baseURL, apiKey);
34
- this.client = new ClientService(this.api);
35
- this.pet = new PetService(this.api);
36
- this.breed = new BreedService(this.api);
37
- this.chatbot = new ChatbotService(this.api);
38
- this.specie = new SpecieService(this.api);
39
- this.billingMethod = new BillingMethodService(this.api);
40
- this.shop = new ShopService(this.api);
41
- this.combo = new ComboService(this.api);
42
- this.service = new ServiceService(this.api);
43
- this.availableTimes = new AvailableTimesService(this.api);
44
- this.booking = new BookingService(this.api);
45
- this.token = new TokenService(this.api);
46
- this.employee = new EmployeeService(this.api)
47
- }
48
- }
49
-
50
- export * from './domain/availableTimes';
51
- export * from './domain/billingMethod';
52
- export * from './domain/booking';
53
- export * from './domain/breed';
54
- export * from './domain/chatbot';
55
- export * from './domain/client';
56
- export * from './domain/combo';
57
- export * from './domain/employee';
58
- export * from './domain/pet';
59
- export * from './domain/service';
60
- export * from './domain/shop';
61
- export * from './domain/specie';
62
- export * from './domain/token';
63
-
64
-
65
-
66
-
@@ -1,91 +0,0 @@
1
- import axios, { AxiosHeaders, AxiosInstance, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
2
- import { logger } from "../logger/stdout.logger";
3
-
4
- export class HttpClient {
5
- private readonly client: AxiosInstance;
6
-
7
- constructor(
8
- private readonly apiUrl: string,
9
- private readonly apiKey?: string
10
- ) {
11
- this.client = axios.create({
12
- baseURL: apiUrl,
13
- headers: {
14
- 'Content-Type': 'application/json',
15
- ...(this.apiKey && {Authorization: `Bearer ${this.apiKey}`})
16
- }
17
- });
18
-
19
- this.client.interceptors.request.use((config: InternalAxiosRequestConfig) => {
20
- logger.debug('tecpet-sdk', `[HTTP] ${this.shop(config.headers)} → ${config.method?.toUpperCase()} [HTTP] → ${config.baseURL}${config.url}`, config?.params || '', config?.data || '');
21
- return config;
22
- });
23
-
24
- this.client.interceptors.response.use(
25
- (response: AxiosResponse) => {
26
- logger.debug('tecpet-sdk', `[HTTP] ${this.shop(response.config.headers)} ← ${response.status} ${response.config.url}`, response?.data);
27
- return response;
28
- },
29
- (error) => {
30
- logger.error('tecpet-sdk', `[HTTP] ${this.shop(error)} ← Error: ${error.message}`);
31
- if (error.response) {
32
- logger.error('tecpet-sdk', `[HTTP] ${this.shop(error)} ← Response:`, error?.response?.data);
33
- }
34
- return Promise.reject(error);
35
- }
36
- );
37
- }
38
-
39
- async get<T>(path: string, payload?: any, shopId?: number): Promise<T> {
40
- try {
41
- const response = await this.client.get<T>(
42
- path,
43
- {params: payload, headers: this.headers({shopId})},
44
- );
45
- return response?.data as T;
46
- } catch (error: any) {
47
- throw error.response.data;
48
- }
49
- }
50
-
51
- async post<T>(path: string, payload?: any, shopId?: number): Promise<T> {
52
- try {
53
- const response = await this.client.post<T>(
54
- path,
55
- payload,
56
- {headers: this.headers({shopId})},
57
- );
58
- return response?.data as T;
59
- } catch (error: any) {
60
- throw error.response.data;
61
- }
62
- }
63
-
64
- async put<T>(path: string, payload?: any, shopId?: number): Promise<T> {
65
- try {
66
- const response = await this.client.put<T>(
67
- path,
68
- payload,
69
- {headers: this.headers({shopId})},
70
- );
71
- return response?.data as T;
72
- } catch (error: any) {
73
- throw error.response.data;
74
- }
75
- }
76
-
77
- private headers({shopId}: { shopId?: number }) {
78
- if (shopId) {
79
- return {
80
- ...this.client.defaults.headers.common,
81
- 'x-shop': shopId
82
- }
83
- }
84
- return this.client.defaults.headers.common;
85
- }
86
-
87
- private shop(headers: AxiosHeaders): string {
88
- const shop = headers?.['x-shop']?.toString();
89
- return shop ? `shop=${shop}` : '';
90
- }
91
- }
@@ -1,7 +0,0 @@
1
- export interface ILogger {
2
- debug(tag: string, message: string, ...meta: any[]): void;
3
- info(tag: string, message: string, ...meta: any[]): void;
4
- warn(tag: string, message: string, ...meta: any[]): void;
5
- error(tag: string, message: string, ...meta: any[]): void;
6
- fatal(tag: string, message: string, ...meta: any[]): void;
7
- }