openapi: 3.0.3
info:
  title: EasyJobs API
  description: API pour la gestion des offres d'emploi sur la plateforme EasyJobs.
  version: "1.0.0"

servers:
  - url: https://api.easyjobs.fr/v1-sandbox/json
    description: Mode Sandbox [JSON]

security:
  - bearerAuth: []
    userSecretKeyAuth: []

paths:
  /job-posting:
    post:
      summary: Créer une nouvelle offre d'emploi
      tags:
        - Job Posting
      parameters:
        - $ref: '#/components/parameters/Origin'
        - $ref: '#/components/parameters/User-Agent'
        - $ref: '#/components/parameters/Accept-Language'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Job'
      responses:
        "201":
          description: Offre créée avec succès
        "400":
          description: Mauvaise requête (erreurs de validation)
        "401":
          description: Non autorisé (token manquant ou invalide)
        "403":
          description: Interdit (User-Agent ou Usersecretkey manquant/non conforme)
        "429":
          description: Trop de requêtes (retry limité)
        "500":
          description: Erreur interne du serveur

  /jobs-posting:
    post:
      summary: Créer plusieurs offres d'emploi
      tags:
        - Jobs Posting
      parameters:
        - $ref: '#/components/parameters/Origin'
        - $ref: '#/components/parameters/User-Agent'
        - $ref: '#/components/parameters/Accept-Language'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                jobs:
                  type: object
                  properties:
                    job:
                      type: array
                      items:
                        $ref: '#/components/schemas/Job'
      responses:
        "201":
          description: Offres créées avec succès
        "400":
          description: Mauvaise requête
        "401":
          description: Non autorisé

  /job-edit:
    put:
      summary: Modifier une offre existante
      tags:
        - Job Edit
      parameters:
        - $ref: '#/components/parameters/Origin'
        - $ref: '#/components/parameters/User-Agent'
        - $ref: '#/components/parameters/Accept-Language'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/JobEdit'
      responses:
        "200":
          description: Offre modifiée avec succès
        "400":
          description: Mauvaise requête
        "403":
          description: Interdit

  /jobs-edit:
    put:
      summary: Modifier plusieurs offres existantes
      tags:
        - Jobs Edit
      parameters:
        - $ref: '#/components/parameters/Origin'
        - $ref: '#/components/parameters/User-Agent'
        - $ref: '#/components/parameters/Accept-Language'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                jobs:
                  type: object
                  properties:
                    job:
                      type: array
                      items:
                        $ref: '#/components/schemas/JobEdit'
      responses:
        "200":
          description: Offres modifiées avec succès
        "400":
          description: Mauvaise requête

  /job-delete:
    delete:
      summary: Supprimer une offre existante
      tags:
        - Job Delete
      servers:
        - url: https://api.easyjobs.fr/v1-sandbox
          description: Sandbox spécifique pour l’endpoint DELETE
      parameters:
        - $ref: '#/components/parameters/Origin'
        - $ref: '#/components/parameters/User-Agent'
        - $ref: '#/components/parameters/Accept-Language'
        - in: query
          name: id
          required: true
          schema:
            type: string
          description: Identifiant de l'offre à supprimer
      responses:
        "204":
          description: Offre supprimée avec succès
        "400":
          description: Mauvaise requête

  /jobs-delete:
    delete:
      summary: Supprimer plusieurs offres existantes
      tags:
        - Jobs Delete
      parameters:
        - $ref: '#/components/parameters/Origin'
        - $ref: '#/components/parameters/User-Agent'
        - $ref: '#/components/parameters/Accept-Language'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                jobs:
                  type: array
                  items:
                    type: string
      responses:
        "204":
          description: Offres supprimées avec succès
        "400":
          description: Mauvaise requête

  /jobs-list:
    get:
      summary: Lister les offres pour un utilisateur
      tags:
        - Jobs Listing
      servers:
        - url: https://api.easyjobs.fr/v1-sandbox
          description: Serveur spécifique pour la consultation (sandbox)
      parameters:
        - $ref: '#/components/parameters/Origin'
        - $ref: '#/components/parameters/User-Agent'
        - $ref: '#/components/parameters/Accept-Language'
        - name: page
          in: query
          description: Numéro de page (par défaut 1)
          required: false
          schema:
            type: integer
            minimum: 1
            example: 1

        - name: limit
          in: query
          description: Nombre maximal de résultats par page (max. 50, par défaut 10)
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 50
            example: 10

        - name: search
          in: query
          description: Terme de recherche (mots-clés liés à l’intitulé ou à la description)
          required: false
          schema:
            type: string
            example: développeur

        - name: location
          in: query
          description: Lieu ou région ciblée (ville, département ou code postal)
          required: false
          schema:
            type: string
            example: Paris

        - name: job_id
          in: query
          description: Identifiant unique de l’offre (utile pour filtrer une offre précise)
          required: false
          schema:
            type: string
            example: A123456789B

        - name: date_created
          in: query
          description: Date de création au format YYYY-MM-DD
          required: false
          schema:
            type: string
            format: date
            example: 2025-06-01

        - name: last_update
          in: query
          description: Date de dernière mise à jour au format YYYY-MM-DD
          required: false
          schema:
            type: string
            format: date
            example: 2025-06-10
      responses:
        "200":
          description: Liste d'offres renvoyée
        "400":
          description: Mauvaise requête

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    userSecretKeyAuth:
      type: apiKey
      in: header
      name: Usersecretkey

  parameters:
    Origin:
      name: Origin
      in: header
      required: true
      schema:
        type: string
        default: https://api.easyjobs.fr
      description: Domaine d'origine de la requête (CORS).
    User-Agent:
      name: User-Agent
      in: header
      required: true
      schema:
        type: string
        default: EasyJobsSwaggerTest/1.0
      description: Chaîne User-Agent identifiant l'application cliente.
    Accept-Language:
      name: Accept-Language
      in: header
      schema:
        type: string
        default: fr
      description: Préférence de langue pour la réponse (ex. en, fr, es).

  schemas:
    JobBase:
      type: object
      properties:
        id:
          type: string
        date:
          type: string
          format: date-time
        valid_through:
          type: string
          format: date-time
        title:
          type: string
        contract_type:
          type: string
        work_hours:
          type: string
        employment_type:
          type: string
        description:
          type: string
        position:
          type: string
        profile:
          type: string
        location:
          type: string
        postcode:
          type: string
        region:
          type: string
        country:
          type: string
        subsidiary:
          type: string
        url:
          type: string
        salary:
          type: string
        salary_min:
          type: string
        salary_max:
          type: string
        rome:
          type: string
        available:
          type: integer
        experience:
          type: string
        company_logo_url:
          type: string
        posted_via:
          type: string
      oneOf:
        - required:
            - salary
          not:
            required:
              - salary_min
              - salary_max
        - required:
            - salary_min
            - salary_max
          not:
            required:
              - salary

    Job:
      allOf:
        - $ref: '#/components/schemas/JobBase'
      required:
        - id
        - date
        - title
        - position
        - contract_type
        - location
        - country

    JobEdit:
      allOf:
        - $ref: '#/components/schemas/JobBase'
      required:
        - id
        - date
