add new Solis connector (#19364)

This commit is contained in:
Thomas NOËL 2017-10-11 09:15:38 +02:00
parent 94a2f664c2
commit 5596c972df
7 changed files with 1245 additions and 0 deletions

View File

View File

@ -0,0 +1,880 @@
{
"info" : {
"license" : {
"url" : "http://www.apache.org/licenses/LICENSE-2.0",
"name" : "Apache 2.0"
},
"version" : "1.0",
"contact" : {},
"description" : "Api Documentation",
"termsOfService" : "urn:tos",
"title" : "Api Documentation"
},
"host" : "solis.infodb.fr",
"definitions" : {
"fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeEnInstructionAsgResponseDTO$DemandeAsg$Demande" : {
"type" : "object",
"properties" : {
"type" : {
"type" : "string"
},
"nature" : {
"type" : "string"
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$Droit" : {
"properties" : {
"dateFin" : {
"format" : "date",
"type" : "string"
},
"dateDebut" : {
"format" : "date",
"type" : "string"
}
},
"type" : "object"
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.IndividuResponseDTO" : {
"type" : "object",
"properties" : {
"individu" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.IndividuResponseDTO$Individu"
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.CodeConfidentielIndividuDto" : {
"properties" : {
"codeConfidentiel" : {
"type" : "string"
},
"indexIndividu" : {
"format" : "int64",
"type" : "integer"
}
},
"type" : "object"
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$ComplementDossier" : {
"properties" : {
"dateDepot" : {
"type" : "string",
"format" : "date"
},
"dateDossierComplet" : {
"format" : "date",
"type" : "string"
},
"dateArrivee" : {
"format" : "date",
"type" : "string"
}
},
"type" : "object"
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$PrestationAccordeeAsg$Periode" : {
"type" : "object",
"properties" : {
"dateFin" : {
"format" : "date",
"type" : "string"
},
"dateEffet" : {
"type" : "string",
"format" : "date"
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.token.ApplicationAsgApaToken" : {
"properties" : {
"token" : {
"type" : "string"
},
"endDate" : {
"format" : "date-time",
"type" : "string"
}
},
"type" : "object"
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO" : {
"type" : "object",
"properties" : {
"demandeAsg" : {
"items" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg"
},
"type" : "array"
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.IndividuResponseDTO$Individu$Apa" : {
"type" : "object",
"properties" : {
"centreAutonomie" : {
"type" : "object"
},
"classotheque" : {
"type" : "object"
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeEnInstructionAsgResponseDTO$DemandeAsg$Visite" : {
"properties" : {
"heure" : {
"type" : "string"
},
"date" : {
"format" : "date",
"type" : "string"
}
},
"type" : "object"
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeHistoriqueAsgResponseDTO$DemandeAsg$Suivi" : {
"properties" : {
"decision" : {
"type" : "string"
},
"dateDecision" : {
"format" : "date",
"type" : "string"
}
},
"type" : "object"
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$Gir" : {
"type" : "object",
"properties" : {
"dateEvaluation" : {
"format" : "date",
"type" : "string"
},
"type" : {
"type" : "string"
},
"gir" : {
"format" : "int32",
"type" : "integer"
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeEnInstructionAsgResponseDTO$DemandeAsg" : {
"properties" : {
"droit" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeEnInstructionAsgResponseDTO$DemandeAsg$Droit"
},
"visite" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeEnInstructionAsgResponseDTO$DemandeAsg$Visite"
},
"demande" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeEnInstructionAsgResponseDTO$DemandeAsg$Demande"
},
"complementDossier" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeEnInstructionAsgResponseDTO$DemandeAsg$ComplementDossier"
},
"suivi" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeEnInstructionAsgResponseDTO$DemandeAsg$Suivi"
}
},
"type" : "object"
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$PrestationAccordeeAsg$Attributaire" : {
"type" : "object",
"properties" : {
"type" : {
"type" : "string"
},
"identite" : {
"type" : "string"
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$Suivi$Instructeur" : {
"type" : "object",
"properties" : {
"mail" : {
"type" : "string"
},
"nom" : {
"type" : "string"
},
"prenom" : {
"type" : "string"
},
"telephone" : {
"type" : "string"
},
"civilite" : {
"type" : "string"
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.IndividuResponseDTO$Individu$Tutelles$Tutelle$Adresse" : {
"type" : "object",
"properties" : {
"nomLieu" : {
"type" : "string"
},
"complementLieu" : {
"type" : "string"
},
"commune" : {
"type" : "string"
},
"finLieu" : {
"type" : "string"
},
"codePostal" : {
"type" : "string"
},
"natureLieu" : {
"type" : "string"
},
"cedex" : {
"type" : "string"
},
"numeroLieu" : {
"type" : "string"
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeHistoriqueAsgResponseDTO" : {
"type" : "object",
"properties" : {
"demandeAsg" : {
"items" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeHistoriqueAsgResponseDTO$DemandeAsg"
},
"type" : "array"
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.GenerationCodeConfidentielResponseDTO" : {
"type" : "object",
"properties" : {
"code" : {
"type" : "string"
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$Demande" : {
"type" : "object",
"properties" : {
"type" : {
"type" : "string"
},
"nature" : {
"type" : "string"
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeEnInstructionAsgResponseDTO$DemandeAsg$Droit" : {
"properties" : {
"dateFin" : {
"type" : "string",
"format" : "date"
},
"dateDebut" : {
"type" : "string",
"format" : "date"
}
},
"type" : "object"
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeHistoriqueAsgResponseDTO$DemandeAsg" : {
"properties" : {
"complementDossier" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeHistoriqueAsgResponseDTO$DemandeAsg$ComplementDossier"
},
"demande" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeHistoriqueAsgResponseDTO$DemandeAsg$Demande"
},
"droit" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeHistoriqueAsgResponseDTO$DemandeAsg$Droit"
},
"suivi" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeHistoriqueAsgResponseDTO$DemandeAsg$Suivi"
}
},
"type" : "object"
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeEnInstructionAsgResponseDTO" : {
"properties" : {
"demandeAsg" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeEnInstructionAsgResponseDTO$DemandeAsg"
}
}
},
"type" : "object"
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$Suivi" : {
"type" : "object",
"properties" : {
"instructeur" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$Suivi$Instructeur"
},
"dateDecision" : {
"type" : "string",
"format" : "date"
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeEnInstructionAsgResponseDTO$DemandeAsg$Suivi" : {
"properties" : {
"dateDecision" : {
"type" : "string",
"format" : "date"
},
"decision" : {
"type" : "string"
}
},
"type" : "object"
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$PrestationAccordeeAsg$Montant" : {
"type" : "object",
"properties" : {
"accorde" : {
"type" : "number"
},
"participation" : {
"type" : "number"
},
"verse" : {
"type" : "number"
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$Bilan" : {
"properties" : {
"pourcentageTM" : {
"type" : "number"
}
},
"type" : "object"
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.IndividuResponseDTO$Individu$Contact" : {
"type" : "object",
"properties" : {
"mail" : {
"type" : "string"
},
"telephone" : {
"type" : "string"
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.IndividuResponseDTO$Individu$Tutelles" : {
"type" : "object",
"properties" : {
"tutelle" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.IndividuResponseDTO$Individu$Tutelles$Tutelle"
}
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.IndividuResponseDTO$Individu" : {
"properties" : {
"prenom" : {
"type" : "string"
},
"tutelles" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.IndividuResponseDTO$Individu$Tutelles"
},
"contact" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.IndividuResponseDTO$Individu$Contact"
},
"dateNaissance" : {
"format" : "date",
"type" : "string"
},
"nomNaissance" : {
"type" : "string"
},
"adresse" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.IndividuResponseDTO$Individu$Adresse"
},
"apa" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.IndividuResponseDTO$Individu$Apa"
},
"nomUsuel" : {
"type" : "string"
},
"civilite" : {
"type" : "string"
}
},
"type" : "object"
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeEnInstructionAsgResponseDTO$DemandeAsg$ComplementDossier" : {
"properties" : {
"dateDossierComplet" : {
"type" : "string",
"format" : "date"
},
"dateArrivee" : {
"type" : "string",
"format" : "date"
}
},
"type" : "object"
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$PrestationAccordeeAsg$Tiers" : {
"type" : "object",
"properties" : {
"tarif" : {
"type" : "number"
},
"quantitatif" : {
"type" : "string"
},
"type" : {
"type" : "string"
},
"identite" : {
"type" : "string"
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.IndividuResponseDTO$Individu$Tutelles$Tutelle" : {
"properties" : {
"natureAccord" : {
"type" : "string"
},
"adresse" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.IndividuResponseDTO$Individu$Tutelles$Tutelle$Adresse"
},
"dateFin" : {
"format" : "date",
"type" : "string"
},
"mesure" : {
"type" : "string"
},
"dateEffet" : {
"format" : "date",
"type" : "string"
},
"identite" : {
"type" : "string"
},
"type" : {
"type" : "string"
}
},
"type" : "object"
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeHistoriqueAsgResponseDTO$DemandeAsg$Demande" : {
"type" : "object",
"properties" : {
"type" : {
"type" : "string"
},
"nature" : {
"type" : "string"
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.IndividuResponseDTO$Individu$Adresse" : {
"type" : "object",
"properties" : {
"commune" : {
"type" : "string"
},
"nomLieu" : {
"type" : "string"
},
"complementLieu" : {
"type" : "string"
},
"complementDestinataire" : {
"type" : "string"
},
"numeroLieu" : {
"type" : "string"
},
"natureLieu" : {
"type" : "string"
},
"codePostal" : {
"type" : "string"
},
"finLieu" : {
"type" : "string"
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$PrestationAccordeeAsg" : {
"type" : "object",
"properties" : {
"tiers" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$PrestationAccordeeAsg$Tiers"
},
"attributaire" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$PrestationAccordeeAsg$Attributaire"
},
"montant" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$PrestationAccordeeAsg$Montant"
},
"prestation" : {
"type" : "string"
},
"quantite" : {
"type" : "number"
},
"periode" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$PrestationAccordeeAsg$Periode"
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg" : {
"properties" : {
"droit" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$Droit"
},
"bilan" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$Bilan"
},
"gir" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$Gir"
},
"demande" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$Demande"
},
"complementDossier" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$ComplementDossier"
},
"suivi" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$Suivi"
},
"prestationAccordeeAsg" : {
"items" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO$DemandeAsg$PrestationAccordeeAsg"
},
"type" : "array"
}
},
"type" : "object"
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeHistoriqueAsgResponseDTO$DemandeAsg$ComplementDossier" : {
"type" : "object",
"properties" : {
"dateDossierComplet" : {
"type" : "string",
"format" : "date"
},
"dateArrivee" : {
"type" : "string",
"format" : "date"
}
}
},
"fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeHistoriqueAsgResponseDTO$DemandeAsg$Droit" : {
"properties" : {
"dateDebut" : {
"format" : "date",
"type" : "string"
},
"dateFin" : {
"format" : "date",
"type" : "string"
}
},
"type" : "object"
}
},
"paths" : {
"/asg/apa/exportDonneesIndividu/{token}" : {
"get" : {
"responses" : {
"200" : {
"schema" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.IndividuResponseDTO"
},
"description" : "OK"
},
"401" : {
"description" : "Unauthorized"
},
"404" : {
"description" : "Not Found"
},
"403" : {
"description" : "Forbidden"
}
},
"consumes" : [
"application/json"
],
"produces" : [
"*/*"
],
"operationId" : "exportDonneesIndividuUsingGET",
"parameters" : [
{
"in" : "path",
"description" : "token",
"required" : true,
"type" : "string",
"name" : "token"
}
],
"tags" : [
"API ASG APA"
],
"summary" : "Export des données d'un individu"
}
},
"/asg/apa/suiviDemandeHistorique/{token}" : {
"get" : {
"responses" : {
"403" : {
"description" : "Forbidden"
},
"401" : {
"description" : "Unauthorized"
},
"200" : {
"schema" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeHistoriqueAsgResponseDTO"
},
"description" : "OK"
},
"404" : {
"description" : "Not Found"
}
},
"tags" : [
"API ASG APA"
],
"summary" : "Export des demandes ASG APA historisée",
"parameters" : [
{
"in" : "path",
"description" : "token",
"name" : "token",
"type" : "string",
"required" : true
}
],
"operationId" : "suiviDemandeHistoriqueUsingGET",
"consumes" : [
"application/json"
],
"produces" : [
"*/*"
]
}
},
"/asg/apa/consultationDeMesDroits/{token}" : {
"get" : {
"consumes" : [
"application/json"
],
"produces" : [
"*/*"
],
"operationId" : "consultationDeMesDroitsUsingGET",
"parameters" : [
{
"in" : "path",
"description" : "token",
"type" : "string",
"name" : "token",
"required" : true
}
],
"summary" : "Export des droits en cours sur les aides ASG APA",
"tags" : [
"API ASG APA"
],
"responses" : {
"403" : {
"description" : "Forbidden"
},
"401" : {
"description" : "Unauthorized"
},
"200" : {
"description" : "OK",
"schema" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.ConsultationDroitAsgResponseDTO"
}
},
"404" : {
"description" : "Not Found"
}
}
}
},
"/asg/apa/generationJeton" : {
"post" : {
"responses" : {
"403" : {
"description" : "Forbidden"
},
"401" : {
"description" : "Unauthorized"
},
"200" : {
"schema" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.token.ApplicationAsgApaToken"
},
"description" : "OK"
},
"201" : {
"description" : "Created"
},
"404" : {
"description" : "Not Found"
}
},
"tags" : [
"API ASG APA"
],
"summary" : "Générer un jeton d'authentification métier à partir de l'index individu et d'un code confidentiel",
"parameters" : [
{
"name" : "dto",
"required" : true,
"description" : "dto",
"in" : "body",
"schema" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.CodeConfidentielIndividuDto"
}
}
],
"operationId" : "generationJetonUsingPOST",
"produces" : [
"*/*"
],
"consumes" : [
"application/json"
]
}
},
"/asg/apa/suiviDemandeEnInstruction/{token}" : {
"get" : {
"responses" : {
"403" : {
"description" : "Forbidden"
},
"404" : {
"description" : "Not Found"
},
"401" : {
"description" : "Unauthorized"
},
"200" : {
"schema" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.SuiviDemandeEnInstructionAsgResponseDTO"
},
"description" : "OK"
}
},
"tags" : [
"API ASG APA"
],
"summary" : "Export des demandes ASG APA en cours d'instruction",
"parameters" : [
{
"name" : "token",
"type" : "string",
"required" : true,
"in" : "path",
"description" : "token"
}
],
"operationId" : "suiviDemandeEnInstructionUsingGET",
"consumes" : [
"application/json"
],
"produces" : [
"*/*"
]
}
},
"/asg/apa/generationCodeConfidentiel" : {
"get" : {
"responses" : {
"200" : {
"schema" : {
"$ref" : "#/definitions/fr.infodb.solisapi.module.asg.applications.apa.dto.GenerationCodeConfidentielResponseDTO"
},
"description" : "OK"
},
"401" : {
"description" : "Unauthorized"
},
"404" : {
"description" : "Not Found"
},
"403" : {
"description" : "Forbidden"
}
},
"tags" : [
"API ASG APA"
],
"summary" : "generationCodeConfidentiel",
"operationId" : "generationCodeConfidentielUsingGET",
"produces" : [
"*/*"
],
"consumes" : [
"application/json"
]
}
},
"/main/isAlive" : {
"get" : {
"responses" : {
"403" : {
"description" : "Forbidden"
},
"404" : {
"description" : "Not Found"
},
"401" : {
"description" : "Unauthorized"
},
"200" : {
"schema" : {
"type" : "string"
},
"description" : "OK"
}
},
"summary" : "Ce web service permet de vérifier que l'API est bien démarré.",
"tags" : [
"Utilitaires"
],
"operationId" : "isAliveUsingGET",
"consumes" : [
"application/json"
],
"produces" : [
"*/*"
]
}
}
},
"swagger" : "2.0",
"tags" : [
{
"description" : "web service de maintenance",
"name" : "Utilitaires"
},
{
"description" : "gestion de l'aide APA avec SOLIS",
"name" : "API ASG APA"
}
],
"basePath" : "/solisapi"
}

View File

@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('base', '0005_resourcelog'),
]
operations = [
migrations.CreateModel(
name='Solis',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('title', models.CharField(max_length=50)),
('slug', models.SlugField()),
('description', models.TextField()),
('log_level', models.CharField(default=b'INFO', max_length=10, verbose_name='Log Level', choices=[(b'NOTSET', b'NOTSET'), (b'DEBUG', b'DEBUG'), (b'INFO', b'INFO'), (b'WARNING', b'WARNING'), (b'ERROR', b'ERROR'), (b'CRITICAL', b'CRITICAL'), (b'FATAL', b'FATAL')])),
('service_url', models.URLField(help_text='Solis API base URL', max_length=256, verbose_name='Service URL')),
('username', models.CharField(max_length=128, verbose_name='Username')),
('password', models.CharField(max_length=128, verbose_name='Password')),
('users', models.ManyToManyField(to='base.ApiUser', blank=True)),
],
options={
'verbose_name': 'Solis',
},
),
migrations.CreateModel(
name='SolisAPALink',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name_id', models.CharField(max_length=256)),
('user_id', models.CharField(max_length=64)),
('code', models.CharField(max_length=64)),
('resource', models.ForeignKey(to='solis.Solis')),
],
),
]

View File

@ -0,0 +1,161 @@
# passerelle - uniform access to multiple data sources and services
# Copyright (C) 2017 Entr'ouvert
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import json
from django.db import models
from django.utils.translation import ugettext_lazy as _
from passerelle.base.models import BaseResource
from passerelle.utils.api import endpoint
from passerelle.utils.jsonresponse import APIError
class Solis(BaseResource):
service_url = models.URLField(max_length=256, blank=False, verbose_name=_('Service URL'),
help_text=_('Solis API base URL'))
username = models.CharField(max_length=128, blank=False, verbose_name=_('Username'))
password = models.CharField(max_length=128, blank=False, verbose_name=_('Password'))
category = _('Business Process Connectors')
class Meta:
verbose_name = _('Solis')
@endpoint(name='ping', description=_('Check Solis API availability'))
def ping(self, request):
message = self.requests.get(
self.service_url + 'main/isAlive',
auth=(self.username, self.password)).content
if message.startswith('Solis API'):
return {'data': 'pong', 'message': message}
else:
raise APIError('message is %s' % message)
def request(self, endpoint, data=None):
url = self.service_url + endpoint
auth = (self.username, self.password)
headers = {'Accept': 'application/json'}
if data is None:
return self.requests.get(url, auth=auth, headers=headers)
return self.requests.post(url, json=data, auth=auth, headers=headers)
def get_apa_token(self, user_id, code):
response = self.request('asg/apa/generationJeton', data={
'indexIndividu': user_id,
'codeConfidentiel': code,
})
if response.status_code == 403:
raise APIError('invalid credentials')
elif response.status_code != 200:
raise APIError('unknown error status:%s, content:%r' %
(response.status_code, response.content))
return response.json().get('token')
@endpoint(name='apa-link', methods=['post'], perm='can_access',
description=_('Create link between name_id and '
'Solis APA. payload: name_id, user_id, code'))
def apa_link(self, request):
try:
data = json.loads(request.body)
except ValueError:
raise APIError('payload is not a JSON dict')
if not isinstance(data, dict):
raise APIError('payload is not a JSON dict')
if 'name_id' not in data:
raise APIError('missing name_id')
if 'user_id' not in data or 'code' not in data:
raise APIError('missing user_id/code credentials')
name_id, user_id, code = data['name_id'], data['user_id'], data['code']
self.get_apa_token(user_id, code) # invalid credentials raise APIError
link, created = SolisAPALink.objects.update_or_create(resource=self, name_id=name_id,
defaults={'user_id': user_id, 'code': code})
return {'data': {'user_id': user_id,
'created': created,
'updated': not created}}
@endpoint(name='apa-unlink', perm='can_access',
description=_('Delete Solis APA link with name_id'),
parameters={
'name_id': {
'description': _('user identifier'),
'example_value': '3eb56fc'
}
})
def apa_unlink(self, request, name_id):
SolisAPALink.objects.filter(resource=self, name_id=name_id).delete()
return {'data': {'deleted': True}}
def apa_infos(self, endpoint, name_id):
apa_link = SolisAPALink.objects.get(resource=self, name_id=name_id)
token = self.get_apa_token(apa_link.user_id, apa_link.code)
endpoint = 'asg/apa/' + endpoint + '/' + token
response = self.request(endpoint)
if response.status_code != 200:
raise APIError('unknown error status:%s, content:%r' %
(response.status_code, response.content))
return {'data': response.json()}
@endpoint(name='apa-user-info', perm='can_access',
description=_('Call exportDonneesIndividu on linked Solis APA user'),
parameters={
'name_id': {
'description': _('user identifier'),
'example_value': '3eb56fc'
}
})
def apa_user_info(self, request, name_id):
return self.apa_infos('exportDonneesIndividu', name_id)
@endpoint(name='apa-user-rights', perm='can_access',
description=_('Call consultationDeMesDroits on linked Solis APA user'),
parameters={
'name_id': {
'description': _('user identifier'),
'example_value': '3eb56fc'
}
})
def apa_user_rights(self, request, name_id):
return self.apa_infos('consultationDeMesDroits', name_id)
@endpoint(name='apa-user-request', perm='can_access',
description=_('Call suiviDemandeEnInstruction on linked Solis APA user'),
parameters={
'name_id': {
'description': _('user identifier'),
'example_value': '3eb56fc'
}
})
def apa_user_request(self, request, name_id):
return self.apa_infos('suiviDemandeEnInstruction', name_id)
@endpoint(name='apa-user-history', perm='can_access',
description=_('Call suiviDemandeHistorique on linked Solis APA user'),
parameters={
'name_id': {
'description': _('user identifier'),
'example_value': '3eb56fc'
}
})
def apa_user_history(self, request, name_id):
return self.apa_infos('suiviDemandeHistorique', name_id)
class SolisAPALink(models.Model):
resource = models.ForeignKey(Solis)
name_id = models.CharField(blank=False, max_length=256)
user_id = models.CharField(blank=False, max_length=64)
code = models.CharField(blank=False, max_length=64)

View File

@ -117,6 +117,7 @@ INSTALLED_APPS = (
'passerelle.apps.okina',
'passerelle.apps.cmis',
'passerelle.apps.cityweb',
'passerelle.apps.solis',
# backoffice templates and static
'gadjo',
)

162
tests/test_solis.py Normal file
View File

@ -0,0 +1,162 @@
import pytest
import mock
import utils
from django.contrib.contenttypes.models import ContentType
from passerelle.apps.solis.models import Solis, SolisAPALink
from passerelle.base.models import ApiUser, AccessRight
NAMEID = 'bebe'
APATOKEN = '''{"token":"1c2562e6-b0a9-4bcf-b669-e33a42397147","endDate":"2017-10-11T10:22:40.342"}'''
APATOKEN_403 = '''[{"logref":"db15cb8a-4d05-4e4f-b4e1-44ec39dc11e3","message":"Erreur d'authentification m\xc3\xa9tier ASG APA: Code confidentiel non valide pour l'individu 2823255","links":[]}]'''
APAINFOS = {
'apa-user-info': '{"individu":{"civilite":"Mme","nomUsuel":"PYPPENNE","nomNaissance":"NPYNEZ","prenom":"Pecile","dateNaissance":"1922-12-17","contact":{"telephone":"0344480774","mail":""},"adresse":{"complementDestinataire":"compl dest","numeroLieu":"38","natureLieu":null,"nomLieu":"RUE MARTIN","complementLieu":"MARPA LES NACRES - APPARTEMENT 9","finLieu":"fin adresse","codePostal":"80370","commune":"BERNAVILLE"},"tutelles":{"tutelle":[{"type":"Organisme","identite":"Association Tut\xc3\xa9laire de la Somme","mesure":null,"natureAccord":"Juridique","dateEffet":"2014-01-01","dateFin":null,"adresse":{"numeroLieu":"21","natureLieu":null,"nomLieu":"RUE SULLY","complementLieu":"BP 11660","finLieu":"","codePostal":"80016","commune":"AMIENS","cedex":"1"}},{"type":"Individu/Particulier","identite":"Ehmet TYEP","mesure":"Curatelle simple","natureAccord":"Juridique","dateEffet":"2017-01-01","dateFin":"2017-12-31","adresse":{"numeroLieu":"89","natureLieu":null,"nomLieu":"AVENUE LEON BLUM","complementLieu":"","finLieu":"","codePostal":"80100","commune":"ABBEVILLE","cedex":""}},{"type":"Individu/Particulier","identite":"Esg TYTEYP PE PEPPOXE OEX","mesure":null,"natureAccord":null,"dateEffet":null,"dateFin":null,"adresse":{"numeroLieu":"1","natureLieu":null,"nomLieu":"BOULEVARD DU PORT","complementLieu":"CAD","finLieu":"","codePostal":"80000","commune":"AMIENS","cedex":""}}]},"apa":{"classotheque":"05-2834","centreAutonomie":"Centre Autonomie nord ouest"}}}',
'apa-user-rights': '{"demandeAsg":[{"demande":{"type":"Allocation Personnalis\xc3\xa9e Autonomie","nature":"Domicile"},"droit":{"dateDebut":"2017-01-05","dateFin":"2019-01-31"},"complementDossier":{"dateDepot":"2016-11-15","dateArrivee":"2016-11-16","dateDossierComplet":"2016-11-17"},"gir":{"type":"Synth\xc3\xa8se","gir":3,"dateEvaluation":"2017-02-01"},"suivi":{"instructeur":{"civilite":"madame","nom":"ZEPEQPE","prenom":"EPOZOE","telephone":"0344974383","mail":"e.zepeqpe@xoppe.pp"},"dateDecision":"2017-01-05"},"bilan":{"pourcentageTM":2.1973443031311035},"prestationAccordeeAsg":[{"prestation":"Accueil de jour GIR 1-2","periode":{"dateEffet":"2017-01-05","dateFin":"2019-01-31"},"tiers":{"type":"Ind\xc3\xa9termin\xc3\xa9","identite":null,"tarif":null,"quantitatif":null},"quantite":0,"montant":{"accorde":0,"participation":0,"verse":0},"attributaire":{"type":"Tuteur","identite":"Association Tut\xc3\xa9laire de la Somme"}},{"prestation":"Articles d\'hygi\xc3\xa8ne forfait 45\xc2\x80","periode":{"dateEffet":"2017-01-05","dateFin":null},"tiers":{"type":"Ind\xc3\xa9termin\xc3\xa9","identite":null,"tarif":45,"quantitatif":"Mois"},"quantite":1,"montant":{"accorde":45,"participation":1.68,"verse":43.32},"attributaire":{"type":"B\xc3\xa9n\xc3\xa9ficiaire","identite":"PYPPENNE Pecile"}},{"prestation":"Petite structure","periode":{"dateEffet":"2017-01-05","dateFin":"2019-01-31"},"tiers":{"type":"Etablissement","identite":"MARPA LES NACRES","tarif":null,"quantitatif":null},"quantite":0,"montant":{"accorde":440.42,"participation":7.68,"verse":432.74},"attributaire":{"type":"Etablissement","identite":"MARPA LES NACRES"}},{"prestation":"Aide humaine prestataire","periode":{"dateEffet":"2017-01-05","dateFin":"2019-01-31"},"tiers":{"type":"Prestataire","identite":"COMMUNAUTE DE COMMUNES DU TERRITOIRE NORD PICARDIE BERNAVILLE","tarif":19,"quantitatif":"Heure(s)"},"quantite":45.5,"montant":{"accorde":864.5,"participation":18.93,"verse":845.57},"attributaire":{"type":"Prestataire","identite":"COMMUNAUTE DE COMMUNES DU TERRITOIRE NORD PICARDIE BERNAVILLE"}},{"prestation":"Articles d\'hygi\xc3\xa8ne forfait 90\xc2\x80","periode":{"dateEffet":"2017-01-05","dateFin":null},"tiers":{"type":"Ind\xc3\xa9termin\xc3\xa9","identite":null,"tarif":90,"quantitatif":"Mois"},"quantite":1,"montant":{"accorde":90,"participation":3.35,"verse":86.65},"attributaire":{"type":"B\xc3\xa9n\xc3\xa9ficiaire","identite":"PYPPENNE Pecile"}}]}]}',
'apa-user-request': '{"demandeAsg":[]}',
'apa-user-history': '{"demandeAsg":[{"demande":{"type":"Allocation Personnalis\xc3\xa9e Autonomie","nature":"Domicile"},"droit":{"dateDebut":"2013-03-01","dateFin":"2013-06-19"},"complementDossier":{"dateArrivee":null,"dateDossierComplet":"2012-10-25"},"suivi":{"decision":"Accord","dateDecision":"2013-02-12"}},{"demande":{"type":"Allocation Personnalis\xc3\xa9e Autonomie","nature":"Domicile"},"droit":{"dateDebut":"2013-06-20","dateFin":"2016-03-31"},"complementDossier":{"dateArrivee":null,"dateDossierComplet":"2012-10-25"},"suivi":{"decision":"Accord","dateDecision":"2013-06-25"}},{"demande":{"type":"Allocation Personnalis\xc3\xa9e Autonomie","nature":"Domicile"},"droit":{"dateDebut":"2016-04-01","dateFin":"2017-01-04"},"complementDossier":{"dateArrivee":"2016-06-06","dateDossierComplet":"2016-06-06"},"suivi":{"decision":"Accord","dateDecision":"2016-06-14"}}]}',
}
@pytest.fixture
def solis(db):
return Solis.objects.create(slug='test',
service_url='https://solis.example.net/solisapi/',
username='usertest',
password='userpass')
def test_solis_restricted_access(app, solis):
endpoint = utils.generic_endpoint_url('solis', 'apa-link', slug=solis.slug)
assert endpoint == '/solis/test/apa-link'
with mock.patch('passerelle.utils.LoggedRequest.post') as requests_post:
with mock.patch('passerelle.utils.LoggedRequest.get') as requests_get:
resp = app.post(endpoint, status=403)
assert requests_post.call_count == 0
assert resp.json['err'] == 1
assert 'PermissionDenied' in resp.json['err_class']
resp = app.get(endpoint, status=405)
assert requests_get.call_count == 0
for service in ('apa-unlink', 'apa-user-info', 'apa-user-rights',
'apa-user-request', 'apa-user-history'):
endpoint = utils.generic_endpoint_url('solis', service, slug=solis.slug)
assert endpoint == '/solis/test/%s' % service
with mock.patch('passerelle.utils.LoggedRequest.get') as requests_get:
with mock.patch('passerelle.utils.LoggedRequest.post') as requests_post:
resp = app.get(endpoint, status=403)
assert requests_get.call_count == 0
assert resp.json['err'] == 1
assert 'PermissionDenied' in resp.json['err_class']
resp = app.post(endpoint, status=405)
assert requests_post.call_count == 0
def test_solis_link_infos_unlink(app, solis):
# full opened access
api = ApiUser.objects.create(username='all', keytype='', key='')
obj_type = ContentType.objects.get_for_model(solis)
AccessRight.objects.create(codename='can_access', apiuser=api, resource_type=obj_type,
resource_pk=solis.pk)
# link
with mock.patch('passerelle.utils.LoggedRequest.post') as requests_post:
endpoint = utils.generic_endpoint_url('solis', 'apa-link', slug=solis.slug)
for params in (None, '', []):
resp = app.post_json(endpoint, params=params, status=200)
assert requests_post.call_count == 0
assert resp.json['err'] == 1
assert 'payload is not a JSON dict' in resp.json['err_desc']
for params in ({}, {'user_id': 'x'}, {'code': 'x'}, {'foo': 'bar'}):
resp = app.post_json(endpoint, params=params, status=200)
assert requests_post.call_count == 0
assert resp.json['err'] == 1
assert 'missing name_id' in resp.json['err_desc']
params['name_id'] = 'xx'
resp = app.post_json(endpoint, params=params, status=200)
assert requests_post.call_count == 0
assert resp.json['err'] == 1
assert 'missing user_id/code credentials' in resp.json['err_desc']
requests_post.return_value = utils.FakedResponse(content=APATOKEN_403, status_code=403)
resp = app.post_json(endpoint,
params={'user_id': 'x', 'code': 'x', 'name_id': NAMEID},
status=200)
assert requests_post.call_count == 1
assert resp.json['err'] == 1
assert 'invalid credentials' in resp.json['err_desc']
assert SolisAPALink.objects.count() == 0
requests_post.return_value = utils.FakedResponse(content=APATOKEN, status_code=200)
resp = app.post_json(endpoint,
params={'name_id': NAMEID, 'user_id': '42', 'code': 'foo'},
status=200)
assert requests_post.call_count == 2
assert resp.json['err'] == 0
assert resp.json['data']['user_id'] == '42'
assert resp.json['data']['created']
assert not resp.json['data']['updated']
assert SolisAPALink.objects.count() == 1
assert SolisAPALink.objects.first().name_id == NAMEID
assert SolisAPALink.objects.first().user_id == '42'
assert SolisAPALink.objects.first().code == 'foo'
resp = app.post_json(endpoint,
params={'name_id': NAMEID, 'user_id': '53', 'code': 'bar'},
status=200)
assert requests_post.call_count == 3
assert resp.json['err'] == 0
assert resp.json['data']['user_id'] == '53'
assert not resp.json['data']['created']
assert resp.json['data']['updated']
assert SolisAPALink.objects.count() == 1
assert SolisAPALink.objects.first().name_id == NAMEID
assert SolisAPALink.objects.first().user_id == '53'
assert SolisAPALink.objects.first().code == 'bar'
# get informations from linked user
for apa_endpoint in APAINFOS:
with mock.patch('passerelle.utils.LoggedRequest.get') as requests_get:
with mock.patch('passerelle.utils.LoggedRequest.post') as requests_post:
requests_post.return_value = utils.FakedResponse(content=APATOKEN, status_code=200)
endpoint = utils.generic_endpoint_url('solis', apa_endpoint, slug=solis.slug)
resp = app.get(endpoint, status=400) # missing name_id
assert resp.json['err'] == 1
endpoint += '?name_id=%s' % NAMEID
requests_get.return_value = utils.FakedResponse(content=APAINFOS[apa_endpoint],
status_code=200)
resp = app.get(endpoint, status=200)
assert requests_post.call_count == 1 # get a token
assert requests_get.call_count == 1 # get informations
assert resp.json['err'] == 0
assert resp.json['data']
# solis api crash
requests_get.return_value = utils.FakedResponse(content='boum',
status_code=500)
resp = app.get(endpoint, status=200)
assert requests_post.call_count == 2 # get a token
assert requests_get.call_count == 2 # get informations
assert resp.json['err'] == 1
assert not resp.json['data']
assert resp.json['err_desc'].startswith('unknown error status:500')
# unlink
endpoint = utils.generic_endpoint_url('solis', 'apa-unlink', slug=solis.slug)
resp = app.get(endpoint, status=400) # missing name_id
assert resp.json['err'] == 1
endpoint += '?name_id=%s' % NAMEID
resp = app.get(endpoint, status=200)
assert resp.json['err'] == 0
assert resp.json['data'] == {'deleted': True}
assert SolisAPALink.objects.count() == 0
# get informations from unlinked user
endpoint = utils.generic_endpoint_url('solis', 'apa-user-info', slug=solis.slug)
endpoint += '?name_id=%s' % NAMEID
resp = app.get(endpoint, status=404)
assert resp.json['err'] == 1