feat: add base types
parent
aad59e55b0
commit
aaab95592b
|
@ -16,6 +16,7 @@
|
|||
"lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
|
||||
},
|
||||
"dependencies": {
|
||||
"@figuro/chatwoot-sdk": "^1.1.16",
|
||||
"@infobip-api/sdk": "^0.3.2",
|
||||
"@nestjs/common": "^10.4.4",
|
||||
"@nestjs/config": "^3.2.3",
|
||||
|
@ -25,6 +26,7 @@
|
|||
"crypto-js": "^4.2.0",
|
||||
"dotenv": "^16.4.5",
|
||||
"morgan": "^1.10.0",
|
||||
"prisma": "^6.0.1",
|
||||
"reflect-metadata": "^0.2.0",
|
||||
"rxjs": "^7.8.1"
|
||||
},
|
||||
|
|
7731
pnpm-lock.yaml
7731
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,19 @@
|
|||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
||||
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "mongodb"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(auto()) @map("_id") @db.ObjectId
|
||||
email String
|
||||
}
|
|
@ -6,11 +6,12 @@ export class ChatwootController {
|
|||
constructor (private readonly chatwootService: ChatwootService) {}
|
||||
|
||||
@Post('/webhook/:sms/:provider/:apikey/:inbox')
|
||||
create (
|
||||
@Param() params: { sms: string, provider: 'infobip', apikey: string, inbox: string }
|
||||
|
||||
receiveChatwootWebhook (
|
||||
@Param() params: { sms: string, provider: 'infobip', apikey: string, inbox: string }
|
||||
) {
|
||||
|
||||
this.chatwootService.
|
||||
|
||||
}
|
||||
|
||||
@Get()
|
||||
|
|
|
@ -1,11 +1,70 @@
|
|||
import ChatwootClient from '@figuro/chatwoot-sdk';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateChatwootDto } from './dto/create-chatwoot.dto';
|
||||
import { UpdateChatwootDto } from './dto/update-chatwoot.dto';
|
||||
|
||||
interface CWWebhook {
|
||||
|
||||
}
|
||||
|
||||
interface CWMessageCreatedWebhook extends CWWebhook {
|
||||
event: "message_created"
|
||||
id: string
|
||||
content: string
|
||||
created_at: string
|
||||
message_type: "incoming" | "outgoing"
|
||||
content_type: "input_select" | "cards" | "form" | "text"
|
||||
content_attributes: any
|
||||
source_id: string
|
||||
sender: {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
}
|
||||
contact: {
|
||||
id: string
|
||||
name: string
|
||||
}
|
||||
account: {
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
conversation: {
|
||||
additional_attributes: any
|
||||
channel: string,
|
||||
id: number,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface ReceiveChatwootWebhookData {
|
||||
event: string
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class ChatwootService {
|
||||
create(createChatwootDto: CreateChatwootDto) {
|
||||
return 'This action adds a new chatwoot';
|
||||
|
||||
constructor(
|
||||
private readonly cw: ChatwootClient,
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
receiveChatwootWebhook(
|
||||
webhookData: ReceiveChatwootWebhookData
|
||||
) {
|
||||
|
||||
const { token } = webhookData
|
||||
|
||||
const client = new ChatwootClient({
|
||||
config: {
|
||||
basePath: 'http://172.31.187.223:3000',
|
||||
with_credentials: true,
|
||||
credentials: "include",
|
||||
token: "clie"
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
findAll() {
|
||||
|
|
Loading…
Reference in New Issue