openapi: 3.1.0
info:
  title: Prana Partner API
  description: API Definition to Partner interact with Prana platform
  version: '1.0'
servers:
  - url: https://api.prana.software
tags:
  - name: Country
    description: Consult countries available in the app
  - name: Period
    description: Consult subscription periods available in the app
  - name: Plan
    description: Consult subscription plans available in the app
  - name: Company
    description: Manage company of your subscriptions
  - name: Subscription
    description: Manage your subscriptions
  - name: State
    description: Consult states available in the app
paths:
  /api/v1/partner/subscription/{id}:
    get:
      tags:
        - Subscription
      summary: Get Subscription
      description: Get a specific subscription.
      operationId: getById
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
            format: int32
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiPartnerCustomerReadDto'
    put:
      tags:
        - Subscription
      summary: Update Subscription
      description: Update a specific subscription.
      operationId: update
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
            format: int32
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiPartnerCustomerWriteDto'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiPartnerCustomerReadDto'
  /api/v1/partner/subscription/activate:
    put:
      tags:
        - Subscription
      summary: Activate/deactivate subscriptions
      description: Activate/deactivate list subscriptions.
      operationId: activate
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiManagementActivateRequestDto'
        required: true
      responses:
        '200':
          description: OK
  /api/v1/partner/admin/company/{companyId}/cancel:
    put:
      tags:
        - Company
      summary: Cancel company subscription
      description: Cancel company subscription
      operationId: cancelSubscription
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: integer
            format: int32
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiCancelSubscriptionWriteDto'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: boolean
  /api/v1/partner/subscription:
    post:
      tags:
        - Subscription
      summary: Create Subscription
      description: Create new subscription and send invitation.
      operationId: create
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiPartnerCustomerWriteDto'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiPartnerCustomerReadDto'
  /api/v1/partner/subscription/search:
    post:
      tags:
        - Subscription
      summary: List Subscriptions
      description: Get all your subscriptions.
      operationId: getAll
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiSearchCriteriaDto'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiPageDtoApiPartnerCustomerViewReadDto'
  /api/v1/partner/state/search:
    post:
      tags:
        - State
      summary: List app states
      description: Get all app states.
      operationId: getAll_1
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiSearchCriteriaDto'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiPageDtoApiManagementStateListReadDto'
  /api/v1/partner/plan/search:
    post:
      tags:
        - Plan
      summary: List subscription plans
      description: Get all subscription plans.
      operationId: getAll_2
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiSearchCriteriaDto'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiPageDtoApiPlanListReadDto'
  /api/v1/partner/period/search:
    post:
      tags:
        - Period
      summary: List subscription periods
      description: Get all subscription periods.
      operationId: getAll_3
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiSearchCriteriaDto'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiPageDtoApiManagementPeriodListReadDto'
  /api/v1/partner/country/search:
    post:
      tags:
        - Country
      summary: List app countries
      description: Get all app countries.
      operationId: getAll_4
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiSearchCriteriaDto'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiPageDtoApiManagementCountryListReadDto'
components:
  schemas:
    ApiPartnerCustomerWriteDto:
      type: object
      properties:
        commercialName:
          type: string
          description: Commercial name of the subscription.
          example: Clave Informática S.L.
          maxLength: 200
          minLength: 0
        cif:
          type: string
          description: Cif of the subscription.
          example: B12345678
          maxLength: 20
          minLength: 0
        name:
          type: string
          description: Name of the subscription.
          example: Clavei
          maxLength: 200
          minLength: 0
        discount:
          type: number
          description: Discount percentage.
          example: 10
        web:
          type: string
          description: Web URL.
          example: https://www.acme.es
        logo:
          type: string
          description: Picture or logo (URL or base64).
          example: https://www.acme.es/logo.png
        contactPerson:
          type: string
          description: Main contact person.
          example: Juan Pérez
        firstPhoneNumber:
          type: string
          description: First phone number.
          example: '+34600111222'
          maxLength: 20
          minLength: 0
        secondPhoneNumber:
          type: string
          description: Second phone number.
          example: '+34600333444'
          maxLength: 20
          minLength: 0
        email:
          type: string
          description: Subscription email address.
          example: info@acme.es
          maxLength: 250
          minLength: 0
        country:
          type: integer
          format: int32
          description: Country identifier.
          example: 1
        state:
          type: integer
          format: int32
          description: State identifier.
          example: 1
        address:
          type: string
          description: Postal address of the customer.
          example: Av. de la Estación, 5
          maxLength: 100
          minLength: 0
        postalCode:
          type: string
          description: Postal code.
          example: '03001'
          maxLength: 10
          minLength: 0
        city:
          type: string
          description: Subscription city.
          example: Alicante
          maxLength: 100
          minLength: 0
        externalCode:
          type: string
          description: Internal client code.
          example: Code customer
          maxLength: 20
          minLength: 0
        newsletter:
          type: boolean
          description: Indicate if you subscribe to the newsletter.
          example: true
        plan:
          type: integer
          format: int32
          description: Plan identifier.
          example: 1
        period:
          type: integer
          format: int32
          description: Period identifier.
          example: 1
      required:
        - discount
        - name
    ApiCompanyStatusEnum:
      type: string
      enum:
        - ACTIVE
        - INACTIVE
        - LOCKED
        - DELETED
    ApiCompanyUsersRangeEnum:
      type: string
      enum:
        - ONE
        - FIVE
        - TEN
        - TWENTY_FIVE
        - FIFTY
        - BIGGER
    ApiManagementCompanyListReadDto:
      type: object
      description: Subscription company.
      properties:
        id:
          type: integer
          format: int32
          description: Unique identifier of the entity
          example: 1
        companyName:
          type: string
          description: Company name.
          example: Clavei
        companyType:
          $ref: '#/components/schemas/ApiManagementCompanyTypeEnum'
          description: Type company.
          example: SELF_EMPLOYED
        companyStatus:
          $ref: '#/components/schemas/ApiCompanyStatusEnum'
          description: Status company.
          example: ACTIVE
        employees:
          $ref: '#/components/schemas/ApiCompanyUsersRangeEnum'
          description: Range of number of company employees.
          example: FIVE
        fullName:
          type: string
          description: Full company name.
          example: Clave Informática S.L.
        active:
          type: boolean
          description: Indicate if the company is active.
          example: true
        country:
          $ref: '#/components/schemas/ApiManagementCountryListReadDto'
          description: Country information.
        phone:
          type: string
          description: Phone number.
          example: '+34600111222'
      required:
        - id
    ApiManagementCompanyTypeEnum:
      type: string
      enum:
        - SELF_EMPLOYED
        - COMPANY
        - CONSULTANT_COMPANY
    ApiManagementCountryListReadDto:
      type: object
      description: Country information.
      properties:
        id:
          type: integer
          format: int32
          description: Unique identifier of the entity
          example: 1
        code:
          type: string
          description: Code country.
          example: ES
        description:
          type: string
          description: Country name or description.
          example: Spain
        isoCode:
          type: string
          description: ISO Alpha-2 country code.
          example: ES
      required:
        - id
    ApiManagementPeriodListReadDto:
      type: object
      description: Assigned/contracted billing plan period.
      properties:
        id:
          type: integer
          format: int32
          description: Unique identifier of the entity
          example: 1
        description:
          type: string
          description: Description period.
          example: Anual
        months:
          type: integer
          format: int32
          description: Months period
          example: 12
      required:
        - id
    ApiManagementStateListReadDto:
      type: object
      description: State information.
      properties:
        id:
          type: integer
          format: int32
          description: Unique identifier of the entity
          example: 1
        code:
          type: string
          description: Code state.
          example: ES
        description:
          type: string
          description: Description state.
          example: Spain
        isoCode:
          type: string
          description: Iso code state.
          example: '012'
        country:
          $ref: '#/components/schemas/ApiManagementCountryListReadDto'
          description: Country information.
      required:
        - code
        - id
    ApiPartnerCustomerReadDto:
      type: object
      properties:
        id:
          type: integer
          format: int32
          description: Unique identifier of the entity
          example: 1
        createdOn:
          type: string
          format: date-time
          description: Subscription creation date.
          example: '2025-10-01T12:05:36.930615+02:00'
        modifiedOn:
          type: string
          format: date-time
          description: Subscription modification date.
          example: '2025-10-01T12:05:36.930615+02:00'
        partner:
          $ref: '#/components/schemas/ApiPartnerListReadDto'
          description: Subscription partner.
        company:
          $ref: '#/components/schemas/ApiManagementCompanyListReadDto'
          description: Subscription company.
        commercialName:
          type: string
          description: Commercial name of the subscription.
          example: Clave Informática S.L.
        cif:
          type: string
          description: Cif of the subscription.
          example: B12345678
        name:
          type: string
          description: Name of the subscription.
          example: Clavei
        discount:
          type: number
          description: Discount percentage.
          example: 10
        web:
          type: string
          description: Web URL.
          example: https://www.acme.es
        logo:
          type: string
          description: Picture or logo (URL or base64).
          example: https://www.acme.es/logo.png
        contactPerson:
          type: string
          description: Main contact person.
          example: Juan Pérez
        firstPhoneNumber:
          type: string
          description: First phone number.
          example: '+34600111222'
        secondPhoneNumber:
          type: string
          description: Second phone number.
          example: '+34600333444'
        email:
          type: string
          description: Subscription email address.
          example: info@acme.es
        country:
          $ref: '#/components/schemas/ApiManagementCountryListReadDto'
          description: Country information.
        state:
          $ref: '#/components/schemas/ApiManagementStateListReadDto'
          description: State information.
        address:
          type: string
          description: Postal address of the customer.
          example: Av. de la Estación, 5
        postalCode:
          type: string
          description: Postal code.
          example: '03001'
        city:
          type: string
          description: Subscription city.
          example: Alicante
        active:
          type: boolean
          description: True if the subscription is active.
          example: true
        invitationCode:
          type: string
          description: Invitation code registration subscription.
        invitationSentOn:
          type: string
          format: date-time
          description: Invitation sending date.
          example: '2025-10-01T12:05:36.930615+02:00'
        invitationAcceptedOn:
          type: string
          format: date-time
          description: Accepted invitation date.
          example: '2025-10-01T12:05:36.930615+02:00'
        plan:
          $ref: '#/components/schemas/ApiPlanListReadDto'
          description: Assigned/contracted plan.
        period:
          $ref: '#/components/schemas/ApiManagementPeriodListReadDto'
          description: Assigned/contracted billing plan period.
        status:
          $ref: '#/components/schemas/ApiPartnerStatusEnum'
          description: Subscription status.
        externalCode:
          type: string
          description: Internal client code.
          example: Code customer
        newsletter:
          type: boolean
          description: Indicate if you subscribe to the newsletter.
          example: true
        lastAccess:
          type: string
          format: date-time
          description: Last access to company.
          example: '2025-10-01T12:05:36.930615+02:00'
      required:
        - id
    ApiPartnerListReadDto:
      type: object
      description: Subscription partner.
      properties:
        id:
          type: integer
          format: int32
          description: Unique identifier of the entity
          example: 1
        commercialName:
          type: string
          description: Commercial name of the partner.
          example: Clave Informática S.L.
        cif:
          type: string
          description: Cif of the partner.
          example: B12345678
        name:
          type: string
          description: Name of the partner.
          example: Clavei
        email:
          type: string
          description: Partner email address.
          example: info@acme.es
        marginOne:
          type: number
          description: Product percentage margin.
          example: 10
        marginTwo:
          type: number
          description: Service percentage margin.
          example: 10
        logo:
          type: string
          description: Picture or logo (URL or base64).
          example: https://www.acme.es/logo.png
        status:
          $ref: '#/components/schemas/ApiPartnerStatusEnum'
          description: Partner status.
        externalCode:
          type: string
          description: Internal client code.
          example: Code customer
        subscriptionLimit:
          type: integer
          format: int32
          description: Monthly subscription limit.
          example: 100
      required:
        - id
    ApiPartnerStatusEnum:
      type: string
      description: Subscription status.
      enum:
        - ACTIVE
        - INACTIVE
        - PENDING
    ApiPlanListReadDto:
      type: object
      description: Assigned/contracted plan.
      properties:
        id:
          type: integer
          format: int32
          description: Unique identifier of the entity
          example: 1
        description:
          type: string
          description: Plan description.
          example: PLAN Integral
        suggested:
          type: boolean
          description: Suggested plan.
          example: true
      required:
        - id
    ApiManagementActivateRequestDto:
      type: object
      properties:
        ids:
          type: array
          items:
            type: integer
            format: int32
        activate:
          type: boolean
      required:
        - activate
        - ids
    ApiCancelSubscriptionWriteDto:
      type: object
      properties:
        reason:
          type: string
          description: Subscription cancellation reason.
          example: New activity
          maxLength: 255
          minLength: 0
    ApiCondition:
      type: object
      description: Condition for filtering data in API requests
      properties:
        field:
          type: string
          description: Field name to apply the condition to
          example: name
        value:
          type: object
          description: Value to compare against the field
          example: Example Value
        type:
          $ref: '#/components/schemas/ApiRelationalOperatorEnum'
          description: Relational operator for the condition
          example: EQ
        endValue:
          type: object
          description: End value for range conditions
          example: 100
        innerConditions:
          type: array
          description: Nested conditions for complex queries
          items:
            $ref: '#/components/schemas/ApiCondition'
        conditionType:
          $ref: '#/components/schemas/ApiConditionTypeEnum'
          description: Type of condition for combining multiple conditions
          example: AND
        empty:
          type: boolean
          description: Indicates if the condition is empty
          example: false
        compareFields:
          type: boolean
          description: Indicates if comparing between fields
          example: false
    ApiConditionTypeEnum:
      type: string
      description: Condition types for combining multiple filters
      enum:
        - AND
        - OR
      example: AND
    ApiRelationalOperatorEnum:
      type: string
      description: Relational operators for conditions
      enum:
        - BETWEEN
        - EQ
        - LT
        - LTE
        - GT
        - GTE
        - NE
        - LIKE
        - START
        - FINISH
        - IN
        - NIN
        - NLIKE
        - LENGTH
      example: EQ
    ApiSearchCriteriaDto:
      type: object
      description: Search criteria for API requests
      properties:
        condition:
          $ref: '#/components/schemas/ApiCondition'
          description: Condition to filter results
        sortCriteria:
          type: array
          description: List of sorting criteria to apply
          items:
            $ref: '#/components/schemas/ApiSortDto'
        pageNumber:
          type: integer
          format: int32
          description: Page number to retrieve (0-based)
          example: 0
        pageSize:
          type: integer
          format: int32
          description: Number of items per page
          example: 20
      required:
        - pageNumber
        - pageSize
    ApiSortDirectionEnum:
      type: string
      description: Defines the sort directions.
      enum:
        - ASC
        - DESC
      example: ASC
    ApiSortDto:
      type: object
      description: Sorting criteria for API requests
      properties:
        sortField:
          type: string
          description: Field name to sort by
          example: name
        sortDirection:
          $ref: '#/components/schemas/ApiSortDirectionEnum'
          description: Sort direction (ascending or descending)
          example: ASC
    ApiPageDtoApiPartnerCustomerViewReadDto:
      type: object
      description: Paginated response wrapper for API data
      properties:
        data:
          type: array
          description: List of data items for the current page
          items:
            $ref: '#/components/schemas/ApiPartnerCustomerViewReadDto'
        page:
          type: integer
          format: int32
          description: Current page number (0-based)
          example: 0
        total:
          type: integer
          format: int32
          description: Total number of items across all pages
          example: 150
        pages:
          type: integer
          format: int64
          description: Last page number (0-based)
          example: 14
        size:
          type: integer
          format: int32
          description: Number of items per page
          example: 10
      required:
        - data
        - page
        - pages
        - size
        - total
    ApiPartnerCustomerViewReadDto:
      type: object
      properties:
        id:
          type: integer
          format: int32
          description: Unique identifier of the entity
          example: 1
        commercialName:
          type: string
          description: Commercial name of the subscription.
          example: Clave Informática S.L.
        cif:
          type: string
          description: Cif of the subscription.
          example: B12345678
        name:
          type: string
          description: Name of the subscription.
          example: Clavei
        email:
          type: string
          description: Subscription email address.
          example: info@acme.es
        discount:
          type: number
          description: Discount percentage.
          example: 10
        logo:
          type: string
          description: Picture or logo (URL or base64).
          example: https://www.acme.es/logo.png
        subscription:
          type: string
          description: description of the contracted/assigned plan.
          example: Integral
        period:
          type: string
          description: Assigned/contracted billing plan period.
          example: Anual
        status:
          $ref: '#/components/schemas/ApiPartnerStatusEnum'
          description: Subscription status.
        partnerId:
          type: integer
          format: int32
          description: Partner ID.
          example: 100
        partnerName:
          type: string
          description: Partner name.
          example: Partner
        companyName:
          type: string
          description: Subscription company.
          example: Clave Informática S.L.
        companyOwnerEmail:
          type: string
          description: Owner subscription company.
          example: info@acme.es
        externalCode:
          type: string
          description: Internal client code.
          example: Code customer
        invitationSentOn:
          type: string
          format: date-time
          description: Invitation sending date.
          example: '2025-10-01T12:05:36.930615+02:00'
        invitationAcceptedOn:
          type: string
          format: date-time
          description: Accepted invitation date.
          example: '2025-10-01T12:05:36.930615+02:00'
        createdOn:
          type: string
          format: date-time
          description: Subscription creation date.
          example: '2025-10-01T12:05:36.930615+02:00'
        firstPhoneNumber:
          type: string
          description: First phone number.
          example: '+34600111222'
        cancellationDate:
          type: string
          format: date-time
          description: Subscription cancellation date.
          example: '2025-10-01T12:05:36.930615+02:00'
        cancellationReason:
          type: string
          description: Subscription cancellation reason.
          example: Creation of new company
        trialExpirationDays:
          type: integer
          format: int32
          description: Days until the end of the trial period.
          example: 15
        trialExtended:
          type: boolean
          description: Extended trial.
          example: true
        lastAccess:
          type: string
          format: date-time
          description: Last access date.
          example: '2025-10-01T12:05:36.930615+02:00'
      required:
        - id
    ApiPageDtoApiManagementStateListReadDto:
      type: object
      description: Paginated response wrapper for API data
      properties:
        data:
          type: array
          description: List of data items for the current page
          items:
            $ref: '#/components/schemas/ApiManagementStateListReadDto'
        page:
          type: integer
          format: int32
          description: Current page number (0-based)
          example: 0
        total:
          type: integer
          format: int32
          description: Total number of items across all pages
          example: 150
        pages:
          type: integer
          format: int64
          description: Last page number (0-based)
          example: 14
        size:
          type: integer
          format: int32
          description: Number of items per page
          example: 10
      required:
        - data
        - page
        - pages
        - size
        - total
    ApiPageDtoApiPlanListReadDto:
      type: object
      description: Paginated response wrapper for API data
      properties:
        data:
          type: array
          description: List of data items for the current page
          items:
            $ref: '#/components/schemas/ApiPlanListReadDto'
        page:
          type: integer
          format: int32
          description: Current page number (0-based)
          example: 0
        total:
          type: integer
          format: int32
          description: Total number of items across all pages
          example: 150
        pages:
          type: integer
          format: int64
          description: Last page number (0-based)
          example: 14
        size:
          type: integer
          format: int32
          description: Number of items per page
          example: 10
      required:
        - data
        - page
        - pages
        - size
        - total
    ApiPageDtoApiManagementPeriodListReadDto:
      type: object
      description: Paginated response wrapper for API data
      properties:
        data:
          type: array
          description: List of data items for the current page
          items:
            $ref: '#/components/schemas/ApiManagementPeriodListReadDto'
        page:
          type: integer
          format: int32
          description: Current page number (0-based)
          example: 0
        total:
          type: integer
          format: int32
          description: Total number of items across all pages
          example: 150
        pages:
          type: integer
          format: int64
          description: Last page number (0-based)
          example: 14
        size:
          type: integer
          format: int32
          description: Number of items per page
          example: 10
      required:
        - data
        - page
        - pages
        - size
        - total
    ApiPageDtoApiManagementCountryListReadDto:
      type: object
      description: Paginated response wrapper for API data
      properties:
        data:
          type: array
          description: List of data items for the current page
          items:
            $ref: '#/components/schemas/ApiManagementCountryListReadDto'
        page:
          type: integer
          format: int32
          description: Current page number (0-based)
          example: 0
        total:
          type: integer
          format: int32
          description: Total number of items across all pages
          example: 150
        pages:
          type: integer
          format: int64
          description: Last page number (0-based)
          example: 14
        size:
          type: integer
          format: int32
          description: Number of items per page
          example: 10
      required:
        - data
        - page
        - pages
        - size
        - total
