---
# System prepended metadata

title: Barber Day Certificate API
tags: [barber-day]

---

---
title: Barber Day Certificate API
tags: barber-day
---

# Barber Day Certificate

**Auth:**
   - Login
   
**User:**
   - Edit user
   - Get user publicity
   - Get User Conquests
   - Edit User Conquests
   - Update User avatar

**Courses:**
   - Get Courses
   - Get Course Journeys
   - Get Course Conquests

**Certificates:**
   - Get certificate

**Proofs:**
   - Get Proof Info
   - Start Proof
   - Finish Proof

**Shopping:**
- Get Products list
- Get product info
- Delivery Calculator
- Create order
- Get Order Info
- Get Orders

**Certification Validation:**
- Get User id by certificate code
- Get User plublic info


## API MOCK
**Base URL:** https://us-central1-barberday-69896.cloudfunctions.net/app
**Login Token:** 4c09788c-3b63-4fd2-86eb-0af1fff5ffc5

### Request Examples
#### Login:
```typescript=
URL: 'https://us-central1-barberday-69896.cloudfunctions.net/app/login'
METHOD: 'GET'
```

#### Get Courses:
```typescript=
URL: 'https://us-central1-barberday-69896.cloudfunctions.net/app/courses'
METHOD: 'GET'
HEADER: '{ token: "4c09788c-3b63-4fd2-86eb-0af1fff5ffc5" }'
```


## Auth

### Login
- **Description:** Realiza o login na plataforma
- **End-point:** `/auth/login`
- **Method:** `POST`
- **Payload:**
    ```typescript
    interface LoginPayload {
        token: string;
    }
    ```
- **Response:**
    ````typescript
    type IUserTheme = "light" | "dark" | "auto";

    interface IUser {
      id: string;
      name: string;
      email: string;
      avatarURL: string | null;
      whatsApp: string | null;
      instagram: string | null;
      facebook: string | null;
      workLevel: string | null;
      myDifficulties: string | null;
      isFirstAccess: boolean;
      theme: IUserTheme;
    }
    ````
    
## User

### Edit User
- **Description:** Permite editar os dados do usuário
- **End-point:** `/users/:userId`
- **Method:** `POST`
- **Payload:**
    ```typescript
    type IUserTheme = "light" | "dark" | "auto";

    interface EditUser {
      name?: string;
      email?: string;
      avatarURL?: string | null;
      whatsApp?: string | null;
      instagram?: string | null;
      facebook?: string | null;
      workLevel?: string | null;
      myDifficulties?: string | null;
      isFirstAccess?: boolean;
      theme?: IUserTheme;
    }
    
    // Todos os parâmetros são opcionais
    ```
- **Response:**
    ````typescript
    type IUserTheme = "light" | "dark" | "auto";

    interface IUser {
      id: string;
      name: string;
      email: string;
      avatarURL: string | null;
      whatsApp: string | null;
      instagram: string | null;
      facebook: string | null;
      workLevel: string | null;
      myDifficulties: string | null;
      isFirstAccess: boolean;
      theme: IUserTheme;
    }
    ````
    
### Get User Publicity
- **Description:** Retorna as publicidades de um usuário
- **End-point:** `/users/:userId/publicity`
- **Method:** `GET`
- **Payload:** -
- **Response:**
    ````typescript
    interface IUserPublicity {
      id: string;
      banner: string;
      link: string;
    }
    ````

### Get User Conquests
- **Description:** Retorna as conquistas de um usuário
- **End-point:** `/users/:userId/conquests`
- **Method:** `GET`
- **Payload:** -
- **Response:**
    ````typescript
    interface IConquest {
      id: string;
      name: string;
      description: string;
      icon: string | null;
      postPhotoLink: string | null;
      blocked: boolean;
    }

    interface IUserConquestsByCertificates {
      id: string;
      name: string;
      isApproved: boolean;
      conquests: IConquest[];
    }

    interface IUserConquestsByCourse {
      courseId: string;
      courseName: string;
      certificates: IUserConquestsByCertificates[];
    }
    ````
    
### Edit User Conquests
- **Description:** Edita as images relacionadas com a conquista
- **End-point:** `/users/:userId/conquests/:conquestId`
- **Method:** `PUT` / `{ "Content-type": "multipart/form-data" }`
- **Payload:** fields files with file content
- **Response:** -

### Update user avatar
- **Description:** Responsável por atualizar a imagem de perfil do usuário
- **End-point:** `/users/:id/avatar`
- **Method:** `POST` / `{ "Content-type": "multipart/form-data" }`
- **Payload:** field avatar with file content
- **Response:**
    ````typescript
    interface IReturn {
      avatarURL: string;
    }
    ````

## Courses

### Get Courses
- **Description:** Retorna os cursos do usuário
- **End-point:** `/courses`
- **Method:** `GET`
- **Response:**
    ````typescript
    interface ICourse {
      id: string;
      courseName: string;
      description: string;
      progress: number;
      buyLink: string;
      isBlocked: boolean;
    }

    type reponse = ICourse[];
    ````

### Get Course Journeys
- **Description:** Retorna as jornadas de um curso em específico
- **End-point:** ``/courses/:courseId/journeys``
- **Method:** `GET`
- **Response:**
    ````typescript
    interface IJourney {
      id: string;
      conquestId: string;
      name: string;
      number: number;
      status: IJourneyStatus;
      approvedPercentage: number;
      testAvailableAt: string | null;
    }

    interface ICourseCertificates {
      id: string;
      name: string;
      isApproved: boolean;
      journeys: IJourney[];
    }

    interface ICourseJourneys {
      courseId: string;
      courseName: string;
      currentJourney: string;
      certificates: ICourseCertificates[];
    }
    ````

### Get Course Conquests
- **Description:** Retorna as conquistas de um curso em específico
- **End-point:** `/courses/:courseId/conquests`
- **Method:** `GET`
- **Response:**
    ````typescript
    interface IConquest {
      id: string;
      name: string;
      description: string;
      icon: string | null;
      images: string[];
      blocked: boolean;
    }

    type response = IConquest[];
    ````
## Certificates

### Get certificate
- **Description:** Retorna as informações de um certificado
- **End-point:** `/certificate/:certificateID`
- **Method:** `GET`
- **Response:**
    ````typescript
    interface ICertificate {
      id: string;
      courseId: string;
      videoId: string;
      videoThumb?: string;
      description: string;
      buyProductId: string;
    }
    ````

## Proofs

### Get infos
- **Description:** Retorna as informações de uma prova
- **End-point:** `/proofs/:journeyId`
- **Method:** `GET`
- **Response:**
    ````typescript
    interface IProofPreview {
      courseId: string;
      journeyId: string;
      journeyName: string;
      numberOfQuestions: number;
      duration: number;
    }
    ````

### Start Proof
- **Description:** Inicia uma prova
- **End-point:** `/proofs/:journeyId/start`
- **Method:** `GET`
- **Response:**
    ````typescript
    interface IProofQuestionVideo {
      id: string;
      overlay?: string | null;
    }

    interface IProofQuestion {
      id: string;
      title: string;
      type: string;
      assetType: "none" | "image" | "video";
      image?: string | null;
      video?: IProofQuestionVideo | null;
      alternatives: string[];
    }

    interface IProof {
      courseId: string;
      journeyId: string;
      journeyName: string;
      numberOfQuestions: number;
      duration: number;
      finishAt: string;
      token: string;
      questions: IProofQuestion[];
    }
    ````

### Finish Proof
- **Description:** Finaliza uma prova que já foi iniciada, enviando as respostas das questões.
- **End-point:** `/proof-finish`
- **Method:** `POST`
- **Payload:**
    ```typescript
    interface IProofFinishReq {
      token: string;
      questions: Array<{
        id: string;
        answer: string;
      }>;
    }
    ```
- **Response:**
    ````typescript
    interface IConquest {
      id: string;
      name: string;
      description: string;
      icon: string | null;
      postPhotoLink: string | null;
      blocked: boolean;
    }

    interface IProofFinish {
      status: "disapproved" | "approved";
      conquest: IConquest | null;
      currentAnswersPercentage: number;
      incurrentAnswersPercentage: number;
      testAvailableAt?: string | null;
    }
    ````
    
## Shopping

### Get Products list
- **Description:** Retorna a lista de produtos
- **End-point:** `/shopping/products`
- **Method:** `GET`
- **Payload:** -
- **Response:**
    ````typescript
    interface IProductPreview {
      id: string;
      name: string;
      image: string;
      value: number;
    }

    type response = IProductPreview[];
    ````

### Get product info
- **Description:** Retorna informações de um produto específico
- **End-point:** `/shopping/products/:id`
- **Method:** `GET`
- **Payload:** -
- **Response:**
    ````typescript
    type IProductAttributesType = "color";

    interface IProductAttributeOption {
      label: string;
      value: string;
    }

    interface IProductAttribute {
      id: string;
      type: IProductAttributesType;
      name: string;
      options: IProductAttributeOption[];
      defaultValue: string;
    }

    interface IProduct {
      id: string;
      name: string;
      defaultImage: string;
      value: number;
      images: string[];
      attributes: IProductAttribute[];
      description: string;
    }
    ````

### Delivery Calculator
- **Description:** Calcula o frete
- **End-point:** `/shopping/calculate-delivery`
- **Method:** `POST`
- **Payload:**
    ````typescript
    interface IDeliveryCalcPayload {
      zipCode: string;
    }
    ````
- **Response:**
    ````typescript
    interface IDeliveryCalc {
      service: string;
      serviceCode: string;
      deliveryTime: number;
      productionTime: number;
      value: number;
    }

    type response = IDeliveryCalc[];
    ````
    
### Create order
- **Description:** Cria um pedido
- **End-point:** `/shopping/order`
- **Method:** `POST`
- **Payload:**
    ````typescript  

    interface IOrderShippingMethod {
      id: string;
      value: number;
      name: string;
    }

    interface ICheckoutAddress {
      fullName: string;
      zipCode: string;
      street: string;
      number: string;
      state: string;
      city: string;
      neighborhood: string;
      complement: string;
      country: string;
    }

    interface IOrderProductAttribute {
      id: string;
      label: string;
      name: string;
      value: string;
    }

    interface IOderProduct {
      id: string;
      image: string;
      name: string;
      value: number;
      attributes: IOrderProductAttribute[];
    }

    interface ICreateOrder {
      shippingMethod: IOrderShippingMethod;
      shippingAddress: ICheckoutAddress;
      product: IOderProduct;
      value: number;
    }
    ````
- **Response:**
    ````typescript
    interface ICreateOrderResponse {
      paymentUrl: string;
    }
    ````
    
### Get Order Info
- **Description:** Retornar informações de um pedido
- **End-point:** `/shopping/order/:id`
- **Method:** `GET`
- **Payload:** -
- **Response:**
    ````typescript
    interface IOrderProductAttribute {
      id: string;
      label: string;
      name: string;
      value: string;
    }

    interface IOderProduct {
      id: string;
      image: string;
      name: string;
      value: number;
      attributes: IOrderProductAttribute[];
    }

    interface ICheckoutAddress {
      fullName: string;
      zipCode: string;
      street: string;
      number: string;
      state: string;
      city: string;
      neighborhood: string;
      complement: string;
      country: string;
    }

    interface IOrderShippingMethod {
      id: string;
      value: number;
      name: string;
    }

    type IOrderStatus =
      | "paid"
      | "pending"
      | "cancel"
      | "printedCertificate"
      | "orderDispatched"
      | "orderDelivered";

    interface IOrder {
      id: string;
      pagarmeId: string;
      pagarmeCode: string;
      value: number;
      product: IOderProduct;
      shippingAddress: ICheckoutAddress;
      shippingMethod: IOrderShippingMethod;
      status: IOrderStatus;
      paidDate: string | null;
      printedCertificateDate: string | null;
      orderDispatchedDate: string | null;
      orderDeliveredDate: string | null;
      trackingCode: string | null;
      createdAt: string;
    }
    ````
    
### Get Orders
- **Description:** Retorna todos os pedidos
- **End-point:** `/shopping/order/:id`
- **Method:** `GET`
- **Payload:** -
- **Response:**
    ````typescript
    interface IOrderProductAttribute {
      id: string;
      label: string;
      name: string;
      value: string;
    }

    interface IOderProduct {
      id: string;
      image: string;
      name: string;
      value: number;
      attributes: IOrderProductAttribute[];
    }

    interface ICheckoutAddress {
      fullName: string;
      zipCode: string;
      street: string;
      number: string;
      state: string;
      city: string;
      neighborhood: string;
      complement: string;
      country: string;
    }

    interface IOrderShippingMethod {
      id: string;
      value: number;
      name: string;
    }

    type IOrderStatus =
      | "paid"
      | "pending"
      | "cancel"
      | "printedCertificate"
      | "orderDispatched"
      | "orderDelivered";

    interface IOrder {
      id: string;
      pagarmeId: string;
      pagarmeCode: string;
      value: number;
      product: IOderProduct;
      shippingAddress: ICheckoutAddress;
      shippingMethod: IOrderShippingMethod;
      status: IOrderStatus;
      paidDate: string | null;
      printedCertificateDate: string | null;
      orderDispatchedDate: string | null;
      orderDeliveredDate: string | null;
      trackingCode: string | null;
      createdAt: string;
    }

    type response = IOrder[];
    ````

## Certification Validation:

### Get User id by certificate code
- **Description:** Retorna o ID do usuário de acordo com o código do certificado
- **End-point:** `/users/certificate/:id`
- **Method:** `GET`
- **Payload:** -
- **Response:**
    ````typescript
    interface IGetUserByCertificate {
      userId: string;
    }
    ````
    
### Get User plublic info
- **Description:** Retorna os dados públicos do usuário
- **End-point:** `/users/:userId/public-infos`
- **Method:** `GET`
- **Payload:** -
- **Response:**
    ````typescript
    interface IPublicUserCertificate {
      id: string;
      preview: string;
      name: string;
      description: string;
      course: string;
      finishAt: string;
    }

    interface IConquest {
      id: string;
      name: string;
      description: string;
      icon: string | null;
      images: string[];
    }

    interface IPublicUser {
      userId: string;
      name: string;
      avatarURL: string | null;
      instagram: string | null;
      conquests: IConquest[];
      certificates: IPublicUserCertificate[];
    }
    ````