Skip to content

Faire le branchement du module control dans le sdk - #412

Open
AminJELLADParticeep wants to merge 3 commits into
developfrom
feature/sc-38599/ngle-setup-sdk-brancher-le-module-api-control
Open

AminJELLADParticeep wants to merge 3 commits into
developfrom
feature/sc-38599/ngle-setup-sdk-brancher-le-module-api-control

Conversation

@AminJELLADParticeep

Copy link
Copy Markdown

No description provided.

@AminJELLADParticeep
AminJELLADParticeep changed the base branch from master to develop April 6, 2023 10:04
@AminJELLADParticeep
AminJELLADParticeep force-pushed the feature/sc-38599/ngle-setup-sdk-brancher-le-module-api-control branch from a60ded7 to 633b5ea Compare April 6, 2023 10:06
}

def audit(id: String, entity_type: String, timeout: Long = defaultTimeOut)(implicit exec: ExecutionContext): Future[Either[ErrorResult, EventControl]] = {
ws.get[EventControl](s"$endPoint/$entity_type/$id/audit", timeout)

@Driox Driox Apr 11, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En retour on n'a pas une Seq[EventControl] ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Une erreur de ma part, je rectifie.


import ControlClient._

def byId(id: String, entity_type: String, timeout: Long = defaultTimeOut)(implicit exec: ExecutionContext): Future[Either[ErrorResult, Control]] = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

supprime byId

Si on veut un byId on utilisera byIds avec un unique id en input

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je supprime.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seul la méthode audit doit retourner un EventControl

Les autres méthodes : create / update / updateBlock / publish devrait retourner l'entité modifiée donc un control ou un ControlView

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Toutes les méthodes que tu cites retournent un EventControl.

Pour les méthodes que tu cites, si je veux respecter ta volonté, ma seule solution serait d'appeler byids pour chaque méthode. On aurait un truc comme ça :

  def update(id: String, timeout: Long = defaultTimeOut, control_update: ControlUpdate)(implicit exec: ExecutionContext): Future[Either[ErrorResult, ControlView]] = {
    for {
      _ <- ws.post[JsValue](s"$endPoint/$id", timeout, Json.toJson(control_update))
      controls <- this.byIds(id, timeout)
    } yield {
      val new_control: Either[ErrorResult, Option[ControlView]] = controls.map(_.find(_.id == id))
      new_control match {
        case Left(errors)         => Left(errors)
        case Right(Some(control)) => Right(control)
        case Right(None)          => Left(Errors(hasError = true, errors = List(Error(technicalCode = "control.not.found", message = "control.not.found"))))
      }
    }
  }

Pourquoi je dis que cela est impossible : je ne peux pas créer un contrôle ou un ContrôleView dynamiquement à partir des données de retour de mes appels à particeep API car particeep API me retourne à chaque fois un EventControl. Et EventControl retourne le delta entre les attributs modifiés et je ne peux pas par exemple déduire la valeur "assigned_to" dans updateBlock. La seule exception est la méthode create qui retourne le contrôle en entier dans le payload de EventControl.

Avec tout ça, que souhaites-tu que je fasse ? Ce que je t'ai dit via mon code ou as-tu une autre idée ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tu imagines trop compliqué

Il faut simplement changer les méthodes de l'API pour retourner un objet et pas un event

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Driox Qu'entends-tu par objet ?

Tu veux que Particeep API retourne un contrôle pour chaque méthode que tu as citées ? En conséquence changer ControlController ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oui c'est ca

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Driox Entendu, je vais créer le code nécessaire.

fhammache pushed a commit that referenced this pull request Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants