Skip to content
Snippets Groups Projects
anoncredsCredentials.controller.ts 3.29 KiB
Newer Older
import { Controller } from '@nestjs/common';
import { MessagePattern } from '@nestjs/microservices';
import {
  EventAnonCredsCredentialOfferGetById,
  EventAnonCredsCredentialOfferGetByIdInput,
  EventAnonCredsCredentialRequestGetById,
  EventAnonCredsCredentialRequestGetByIdInput,
  EventAnonCredsCredentialsDeleteById,
  EventAnonCredsCredentialsDeleteByIdInput,
  EventAnonCredsCredentialsGetAll,
  EventAnonCredsCredentialsGetAllInput,
  EventAnonCredsCredentialsGetById,
  EventAnonCredsCredentialsGetByIdInput,
  EventDidcommAnonCredsCredentialsOffer,
  EventDidcommAnonCredsCredentialsOfferInput,
  EventDidcommAnonCredsCredentialsOfferToSelf,
  EventDidcommAnonCredsCredentialsOfferToSelfInput
} from '@ocm/shared';

import { AnonCredsCredentialsService } from './anoncredsCredentials.service.js';

@Controller('anoncredsCredentials')
export class AnonCredsCredentialsController {
  public constructor(private credentialsService: AnonCredsCredentialsService) {}

  @MessagePattern(EventAnonCredsCredentialsGetAll.token)
  public async getAll(
    options: EventAnonCredsCredentialsGetAllInput,
  ): Promise<EventAnonCredsCredentialsGetAll> {
    return new EventAnonCredsCredentialsGetAll(
      await this.credentialsService.getAll(options),
      options.tenantId,
    );
  }

  @MessagePattern(EventAnonCredsCredentialsGetById.token)
  public async getById(
    options: EventAnonCredsCredentialsGetByIdInput,
  ): Promise<EventAnonCredsCredentialsGetById> {
    return new EventAnonCredsCredentialsGetById(
      await this.credentialsService.getById(options),
      options.tenantId,
    );
  }

  @MessagePattern(EventAnonCredsCredentialOfferGetById.token)
  public async getOfferById(
    options: EventAnonCredsCredentialOfferGetByIdInput,
  ): Promise<EventAnonCredsCredentialOfferGetById> {
    return new EventAnonCredsCredentialOfferGetById(
      await this.credentialsService.getOfferById(options),
      options.tenantId,
    );
  }

  @MessagePattern(EventAnonCredsCredentialRequestGetById.token)
  public async getRequestById(
    options: EventAnonCredsCredentialRequestGetByIdInput,
  ): Promise<EventAnonCredsCredentialRequestGetById> {
    return new EventAnonCredsCredentialRequestGetById(
      await this.credentialsService.getRequestById(options),
      options.tenantId,
    );
  }

  @MessagePattern(EventAnonCredsCredentialsDeleteById.token)
  public async deleteById(
    options: EventAnonCredsCredentialsDeleteByIdInput,
  ): Promise<EventAnonCredsCredentialsDeleteById> {
    return new EventAnonCredsCredentialsDeleteById(
      await this.credentialsService.deleteById(options),
      options.tenantId,
    );
  }

  @MessagePattern(EventDidcommAnonCredsCredentialsOffer.token)
  public async offer(
    options: EventDidcommAnonCredsCredentialsOfferInput,
  ): Promise<EventDidcommAnonCredsCredentialsOffer> {
    return new EventDidcommAnonCredsCredentialsOffer(
      await this.credentialsService.offer(options),
      options.tenantId,
    );
  }

  @MessagePattern(EventDidcommAnonCredsCredentialsOfferToSelf.token)
  public async offerToSelf(
    options: EventDidcommAnonCredsCredentialsOfferToSelfInput,
  ): Promise<EventDidcommAnonCredsCredentialsOfferToSelf> {
    return new EventDidcommAnonCredsCredentialsOfferToSelf(
      await this.credentialsService.offerToSelf(options),
      options.tenantId,
    );
  }
}