1.0.10 • Published 10 hours ago

amocrm-nestjs v1.0.10

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
10 hours ago

Установка

Через npm:

npm install amocrm-nestjs

Через yarn:

yarn add amocrm-nestjs

Использование

Импортировать модуль:

import { AmoModule } from 'amocrm-nestjs';

Два способа зарегистрировать модуль через forRoot или forRootAsync

ForRoot:

@Module({
    imports: [
        AmoModule.forRoot({
          href: 'https://***.amocrm.ru/',
          client_id: '***-***-***-***-***',
          client_secret: '***',
          redirect_uri: 'https://***.amocrm.ru/',
          code: '***',
          access_token: '***',
          refresh_token: '***',
        }),
    ],
    controllers: [AppController],
    providers: [AppService],
})
export class AppModule {}

ForRootAsync:

@Module({
    imports: [
        ConfigModule.forRoot({
            isGlobal: true,
        }),
        AmoModule.forRootAsync({
            inject: [ConfigService],
            useFactory: (configService: ConfigService) => ({
                href: configService.get<string>('HREF'),
                client_id: configService.get<string>('CLIENT_ID'),
                client_secret: configService.get<string>('CLIENT_SECRET'),
                redirect_uri: configService.get<string>('REDIRECT_URI'),
                code: configService.get<string>('CODE'),
                access_token: configService.get<string>('ACCESS_TOKEN'),
                refresh_token: configService.get<string>('REFRESH_TOKEN'),
            }),
        }),
    ],
    controllers: [AppController],
    providers: [AppService],
})
export class AppModule {}

Два способа авторизации через code или access_token и refresh_token, code в приоритете

Внедрить зависимости:

import { AmoService } from 'amocrm-nestjs';

@Injectable()
export class AppService {
    constructor(private amoService: AmoService) {
        (async () => {
            // Получим информацию по аккаунту
            const account = await this.amoService.getAccount();
            console.log(account);
        })();
    }
}

Доступные методы:

  • token (ТОКЕН)
  • account (ПАРАМЕТРЫ АККАУНТА)
  • file (ФАЙЛЫ)
  • lead (СДЕЛКИ)
  • contact (КОНТАКТЫ)
  • company (КОМПАНИИ)
  • task (ЗАДАЧИ)
  • tag (ТЕГИ)
  • webhook (ВЕБХУКИ)
  • user (ПОЛЬЗОВАТЕЛИ)
  • role (РОЛИ ПОЛЬЗОВАТЕЛЕЙ)
  • pipeline (ВОРОНКИ)
  • status (ЭТАПЫ)
  • catalog (СПИСКИ)
  • element (ЭЛЕМЕНТЫ СПИСКА)
  • field (ПОЛЯ)
  • group (ГРУППЫ ПОЛЕЙ)
  • links (СВЯЗИ СУЩНОСТЕЙ)

API REFERENCE

Вы можете отправить свой вопрос, отзыв, предложение на адрес электронной почты: webproject67nodejs@gmail.com

1.0.9

11 hours ago

1.0.10

10 hours ago

1.0.8

1 month ago

1.0.7

1 month ago

1.0.6

1 month ago

1.0.5

4 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago