openapi: 3.0.3
info:
  title: Repzo API - Client
  version: 1.0.0
  description: OpenAPI specification for Repzo Client endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /client:
    get:
      summary: Find clients
      operationId: findClients
      parameters:
        - in: query
          name: params
          schema:
            type: object
          description: Query parameters for filtering clients
      responses:
        "200":
          description: A list of clients
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ClientFindResult"
    post:
      summary: Create a client
      operationId: createClient
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ClientCreateBody"
      responses:
        "201":
          description: Client created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ClientCreateResult"
  /client/{id}:
    get:
      summary: Get a client by ID
      operationId: getClient
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Client details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ClientGetResult"
    put:
      summary: Update a client
      operationId: updateClient
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ClientUpdateBody"
      responses:
        "200":
          description: Client updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ClientUpdateResult"
    delete:
      summary: Remove a client
      operationId: removeClient
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Client removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ClientRemoveResult"
components:
  schemas:
    ClientFindResult:
      type: object
      description: Result of finding clients
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/ClientSchema"
        total_result:
          type: number
          description: Total number of clients
        current_count:
          type: number
          description: Count of clients in current page
        total_pages:
          type: number
          description: Total number of pages
        current_page:
          type: number
          description: Current page number
        per_page:
          type: number
          description: Number of clients per page
        first_page_url:
          type: string
          description: URL for the first page
        last_page_url:
          type: string
          description: URL for the last page
        next_page_url:
          type: string
          nullable: true
          description: URL for the next page
        prev_page_url:
          type: string
          nullable: true
          description: URL for the previous page
        path:
          type: string
          description: Base URL path
    ClientSchema:
      type: object
      description: Client schema
      properties:
        _id:
          type: string
          description: Unique identifier for the client
        name:
          type: string
          description: Name of the client
        local_name:
          type: string
          description: Localized name of the client
        tags:
          type: array
          items:
            type: string
          description: Tags associated with the client
        cell_phone:
          type: string
          description: Cell phone number
        city:
          type: string
          description: City
        client_code:
          type: string
          description: Client code
        contact_name:
          type: string
          description: Contact name
        contact_title:
          type: string
          description: Contact title
        contacts:
          type: array
          items:
            type: string
          description: Associated contacts
        country:
          type: string
          description: Country
        disabled:
          type: boolean
          description: Whether the client is disabled
        formatted_address:
          type: string
          description: Formatted address
        lat:
          type: number
          description: Latitude coordinate
        lng:
          type: number
          description: Longitude coordinate
        location_verified:
          type: boolean
          description: Whether the location is verified
        phone:
          type: string
          description: Phone number
        state:
          type: string
          description: State
        zip:
          type: string
          description: Zip/Postal code
        assigned_to:
          type: array
          items:
            type: string
          description: Representatives assigned to this client
        last_location_update:
          type: number
          description: Timestamp of last location update
        credit_limit:
          type: number
          description: Credit limit
        tax_number:
          type: string
          description: Tax number
        sync_id:
          type: string
          description: Sync identifier
        profile_pic:
          type: string
          description: Profile picture URL
        logo:
          type: string
          description: Logo URL
        website:
          type: string
          description: Website URL
        email:
          type: string
          description: Email address
        comment:
          type: string
          description: Comments
        parent_client_id:
          type: string
          description: Parent client ID for hierarchical relationships
        target_visit:
          type: number
          description: Target number of visits
        geofencing_radius:
          type: number
          description: Geofencing radius
        price_tag:
          type: string
          description: Price tag
        status:
          type: string
          description: Status
        job_category:
          type: array
          items:
            type: string
          description: Job categories
        territory:
          type: string
          description: Territory
        sv_priceList:
          type: string
          description: Price list ID
        customFields:
          type: object
          additionalProperties: true
          description: Custom fields
        paymentTerm:
          type: string
          description: Payment term ID
        speciality:
          type: array
          items:
            type: string
          description: Specialities
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        channel:
          type: string
          description: Channel ID
        isChain:
          type: boolean
          description: Whether this is a chain
        chain:
          type: string
          description: Chain ID
        teams:
          type: array
          items:
            type: string
          description: Teams
        payment_type:
          type: string
          enum: [cash, credit]
          description: Payment type
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        integrated_client_balance:
          type: number
          description: Integrated client balance
        invoice_balance_limit:
          type: number
          description: Invoice balance limit
        enable_invoice_balance_limit:
          type: boolean
          description: Whether invoice balance limit is enabled
        enable_payment_terms_grace_period_days:
          type: boolean
          description: Whether payment terms grace period days is enabled
        is_simplified:
          type: boolean
          description: Whether this is a simplified client
        last_login_time:
          type: number
          description: Last login timestamp
        createdAt:
          type: string
          format: date-time
          description: Creation timestamp
        updatedAt:
          type: string
          format: date-time
          description: Last update timestamp
        __v:
          type: number
          description: Version number
    ClientCreateBody:
      type: object
      description: Body for creating a client
      required:
        - name
      properties:
        name:
          type: string
          description: Name of the client
        local_name:
          type: string
          description: Localized name of the client
        tags:
          type: array
          items:
            type: string
          description: Tags associated with the client
        cell_phone:
          type: string
          description: Cell phone number
        city:
          type: string
          description: City
        client_code:
          type: string
          description: Client code
        contact_name:
          type: string
          description: Contact name
        contact_title:
          type: string
          description: Contact title
        contacts:
          type: array
          items:
            type: string
          description: Associated contacts
        country:
          type: string
          description: Country
        disabled:
          type: boolean
          description: Whether the client is disabled
        formatted_address:
          type: string
          description: Formatted address
        lat:
          type: number
          description: Latitude coordinate
        lng:
          type: number
          description: Longitude coordinate
        location_verified:
          type: boolean
          description: Whether the location is verified
        phone:
          type: string
          description: Phone number
        state:
          type: string
          description: State
        zip:
          type: string
          description: Zip/Postal code
        assigned_to:
          type: array
          items:
            type: string
          description: Representatives assigned to this client
        credit_limit:
          type: number
          description: Credit limit
        tax_number:
          type: string
          description: Tax number
        sync_id:
          type: string
          description: Sync identifier
        profile_pic:
          type: string
          description: Profile picture URL
        logo:
          type: string
          description: Logo URL
        website:
          type: string
          description: Website URL
        email:
          type: string
          description: Email address
        comment:
          type: string
          description: Comments
        parent_client_id:
          type: string
          description: Parent client ID for hierarchical relationships
        target_visit:
          type: number
          description: Target number of visits
        geofencing_radius:
          type: number
          description: Geofencing radius
        price_tag:
          type: string
          description: Price tag
        status:
          type: string
          description: Status
        job_category:
          type: array
          items:
            type: string
          description: Job categories
        territory:
          type: string
          description: Territory
        sv_priceList:
          type: string
          description: Price list ID
        customFields:
          type: object
          additionalProperties: true
          description: Custom fields
        paymentTerm:
          type: string
          description: Payment term ID
        speciality:
          type: array
          items:
            type: string
          description: Specialities
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        channel:
          type: string
          description: Channel ID
        isChain:
          type: boolean
          description: Whether this is a chain
        chain:
          type: string
          description: Chain ID
        teams:
          type: array
          items:
            type: string
          description: Teams
        payment_type:
          type: string
          enum: [cash, credit]
          description: Payment type
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
    ClientCreateResult:
      $ref: "#/components/schemas/ClientSchema"
      description: Result of creating a client
    ClientGetResult:
      $ref: "#/components/schemas/ClientSchema"
      description: Result of getting a client
    ClientUpdateBody:
      type: object
      description: Body for updating a client
      properties:
        name:
          type: string
          description: Name of the client
        local_name:
          type: string
          description: Localized name of the client
        tags:
          type: array
          items:
            type: string
          description: Tags associated with the client
        cell_phone:
          type: string
          description: Cell phone number
        city:
          type: string
          description: City
        client_code:
          type: string
          description: Client code
        contact_name:
          type: string
          description: Contact name
        contact_title:
          type: string
          description: Contact title
        contacts:
          type: array
          items:
            type: string
          description: Associated contacts
        country:
          type: string
          description: Country
        disabled:
          type: boolean
          description: Whether the client is disabled
        formatted_address:
          type: string
          description: Formatted address
        lat:
          type: number
          description: Latitude coordinate
        lng:
          type: number
          description: Longitude coordinate
        location_verified:
          type: boolean
          description: Whether the location is verified
        phone:
          type: string
          description: Phone number
        state:
          type: string
          description: State
        zip:
          type: string
          description: Zip/Postal code
        assigned_to:
          type: array
          items:
            type: string
          description: Representatives assigned to this client
        credit_limit:
          type: number
          description: Credit limit
        tax_number:
          type: string
          description: Tax number
        sync_id:
          type: string
          description: Sync identifier
        profile_pic:
          type: string
          description: Profile picture URL
        logo:
          type: string
          description: Logo URL
        website:
          type: string
          description: Website URL
        email:
          type: string
          description: Email address
        comment:
          type: string
          description: Comments
        parent_client_id:
          type: string
          description: Parent client ID for hierarchical relationships
        target_visit:
          type: number
          description: Target number of visits
        geofencing_radius:
          type: number
          description: Geofencing radius
        price_tag:
          type: string
          description: Price tag
        status:
          type: string
          description: Status
        job_category:
          type: array
          items:
            type: string
          description: Job categories
        territory:
          type: string
          description: Territory
        sv_priceList:
          type: string
          description: Price list ID
        customFields:
          type: object
          additionalProperties: true
          description: Custom fields
        paymentTerm:
          type: string
          description: Payment term ID
        speciality:
          type: array
          items:
            type: string
          description: Specialities
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        channel:
          type: string
          description: Channel ID
        isChain:
          type: boolean
          description: Whether this is a chain
        chain:
          type: string
          description: Chain ID
        teams:
          type: array
          items:
            type: string
          description: Teams
        payment_type:
          type: string
          enum: [cash, credit]
          description: Payment type
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        _id:
          type: string
          description: Unique identifier for the client
        createdAt:
          type: string
          format: date-time
          description: Creation timestamp
        updatedAt:
          type: string
          format: date-time
          description: Last update timestamp
        __v:
          type: number
          description: Version number
    ClientUpdateResult:
      $ref: "#/components/schemas/ClientSchema"
      description: Result of updating a client
    ClientRemoveResult:
      $ref: "#/components/schemas/ClientSchema"
      description: Result of removing a client
