{"openapi":"3.0.0","info":{"version":"1.0.0","title":"A Cloud Mission","description":"Services API","contact":{"email":"a.hernandez@gravity.es"}},"servers":[{"url":"http://localhost:3000","description":"LOCAL"},{"url":"https://in2l4w7bq8.execute-api.eu-west-1.amazonaws.com/dev","description":"DEV"}],"paths":{"/missions":{"get":{"summary":"Obtaining the list of available missions","tags":["missions"],"parameters":[{"$ref":"#/components/parameters/langParam"},{"$ref":"#/components/parameters/tokenParam"},{"$ref":"#/components/parameters/apiKeyParam"}],"responses":{"200":{"description":"List of missions","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Mission"}}}}},"400":{"$ref":"#/components/responses/ClientError"},"401":{"$ref":"#/components/responses/AuthError"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/missions/{missionId}":{"get":{"summary":"Details of a specific mission","tags":["missions"],"parameters":[{"$ref":"#/components/parameters/langParam"},{"$ref":"#/components/parameters/tokenParam"},{"$ref":"#/components/parameters/missionId"},{"$ref":"#/components/parameters/apiKeyParam"}],"responses":{"200":{"description":"Mission details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MissionDetails"}}}},"400":{"$ref":"#/components/responses/ClientError"},"401":{"$ref":"#/components/responses/AuthError"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/missions/{missionId}/unlock":{"post":{"summary":"Unlock a mission for a user","description":"Unlocks and makes a previously purchased mission, is available to the user","tags":["missions"],"parameters":[{"$ref":"#/components/parameters/langParam"},{"$ref":"#/components/parameters/tokenParam"},{"$ref":"#/components/parameters/missionId"},{"$ref":"#/components/parameters/apiKeyParam"}],"responses":{"200":{"description":"Mission details unlocked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MissionDetails"}}}},"400":{"$ref":"#/components/responses/ClientError"},"401":{"$ref":"#/components/responses/AuthError"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/missions/{missionId}/resolve":{"post":{"summary":"Resolve user exam in a mission.","description":"Unlocks and makes a previously purchased mission, is available to the user","tags":["missions"],"parameters":[{"$ref":"#/components/parameters/tokenParam"},{"$ref":"#/components/parameters/missionId"},{"$ref":"#/components/parameters/apiKeyParam"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"challenge":{"type":"string"},"examId":{"type":"string","description":"Exam identifier, not mandatory, only with pre-built exams"},"dateStart":{"type":"string","example":"2020-02-21T14:56:12+00:00"},"dateEnd":{"type":"string","example":"2020-02-21T14:56:12+00:00"},"answers":{"type":"array","items":{"type":"object","properties":{"questionId":{"type":"number"},"selection":{"type":"array","items":{"type":"number"},"description":"Options selected as answers"},"tipUsed":{"type":"boolean"},"timeUsed":{"type":"number","description":"Time in seconds dedicated to the answer"}}}}}}}}},"responses":{"200":{"description":"Exam results","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExamResults"}}}},"400":{"$ref":"#/components/responses/ClientError"},"401":{"$ref":"#/components/responses/AuthError"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/missions/{missionId}/ranking":{"get":{"summary":"Gets a list with the users ranking","description":"Obtains a list with the first 100 users that make up the mission's ranking","tags":["missions"],"parameters":[{"$ref":"#/components/parameters/tokenParam"},{"$ref":"#/components/parameters/missionId"},{"$ref":"#/components/parameters/apiKeyParam"}],"responses":{"200":{"description":"Users ranking","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/UserRanking"}}}}},"400":{"$ref":"#/components/responses/ClientError"},"401":{"$ref":"#/components/responses/AuthError"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/questions/{missionId}/{challenge}":{"get":{"summary":"Obtaining the set of questions for a challenge","tags":["questions"],"parameters":[{"$ref":"#/components/parameters/langParam"},{"$ref":"#/components/parameters/tokenParam"},{"$ref":"#/components/parameters/missionId"},{"$ref":"#/components/parameters/challenge"},{"$ref":"#/components/parameters/apiKeyParam"},{"name":"domain","in":"query","schema":{"type":"string"},"required":false},{"name":"service","in":"query","schema":{"type":"string"},"required":false}],"responses":{"200":{"description":"Object with exam questions","content":{"application/json":{"schema":{"type":"object","properties":{"prebuilt_exam_id":{"type":"string","description":"Pre-built exam identifier, is not mandatory"},"questions":{"type":"array","items":{"$ref":"#/components/schemas/Question"}}}}}}},"400":{"$ref":"#/components/responses/ClientError"},"401":{"$ref":"#/components/responses/AuthError"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/achievements/{missionId}":{"get":{"summary":"Gets the achievements of a user.","description":"Obtains an object with the achievements of a user in a specific mission.","tags":["achievements"],"parameters":[{"$ref":"#/components/parameters/tokenParam"},{"$ref":"#/components/parameters/apiKeyParam"},{"$ref":"#/components/parameters/missionId"}],"responses":{"200":{"description":"User achievements.","content":{"application/json":{"schema":{"type":"object","properties":{"games":{"type":"number","description":"Challenges that the user has done"},"bestPoints":{"type":"number","description":"Best punctuation of the user."},"evolution":{"type":"array","description":"Evolution of points that has been earned throughout the playing time","items":{"type":"number"}},"averageScoreByGame":{"type":"object","description":"Average points scored by each of the games"},"achievements":{"type":"object","properties":{"WINNER_OF_THE_GAME":{"type":"number","description":"number of times the user has won the mission"},"PERFECT_MISSION":{"type":"number","description":"number of missions solved with scoring = 100"},"EXAM_APPROVED":{"type":"number","description":"number of exam simulation solved"},"10_HOURS_OF_MISSIONS":{"type":"boolean","description":"count if the user has spent 10 hours or more."}}}}}}}},"400":{"$ref":"#/components/responses/ClientError"},"401":{"$ref":"#/components/responses/AuthError"},"500":{"$ref":"#/components/responses/ServerError"}}}}},"components":{"parameters":{"apiKeyParam":{"in":"header","required":true,"name":"X-Api-Key","description":"Api key for access","schema":{"type":"string"}},"langParam":{"in":"header","name":"X-User-Lang","description":"User language","schema":{"type":"string","enum":["en","es"],"default":"en"}},"tokenParam":{"in":"header","required":true,"name":"X-User-Token","description":"Access token","schema":{"type":"string"}},"missionId":{"name":"missionId","in":"path","required":true,"description":"Mission identifier","schema":{"type":"string"}},"challenge":{"name":"challenge","in":"path","description":"Parameter where it is specified for which challenge the questions are","required":true,"schema":{"type":"string","enum":["quick_mission","exam","domain","service"]}}},"schemas":{"Mission":{"type":"object","required":["id","provider","name","description","updated","status","unlocked","exam","price","unlocked_days"],"properties":{"id":{"type":"string"},"provider":{"type":"string","example":"Amazon"},"name":{"type":"string","example":"AWS Cloud Practitioner"},"description":{"type":"string"},"updated":{"type":"string","example":"2020-02-21T14:56:12+00:00"},"status":{"type":"string","enum":["available","unavailable","soon"]},"exam":{"type":"object","properties":{"duration":{"description":"Exam duration in minutes","type":"number"},"questions":{"description":"Number of exam questions","type":"number"}}},"price":{"type":"number","description":"Precio de la mision","example":12.56},"unlocked_days":{"type":"number","description":"Days that the user will have mission available when unlocking"},"period_challenge":{"type":"string","description":"Period of time in which the points in the challenge are reset","enum":["week","month"]},"content_url":{"type":"string","description":"Url of the content displayed in the training area"},"unlocked":{"description":"Indicates if the user has unlocked(purchased) it","type":"boolean","default":true},"points":{"description":"Total points that the user has achieved in the challenge period","type":"number"},"success_percentage":{"description":"Percentage of user hits","type":"number","example":43},"rank":{"description":"Position in the user's ranking","type":"string","example":"+100"}}},"MissionDetails":{"type":"object","required":["id","name","description","updated","available","unlocked","exam","price","unlocked_days","domains","services"],"properties":{"id":{"type":"string"},"provider":{"type":"string","example":"Amazon"},"name":{"type":"string","example":"AWS Cloud Practitioner"},"description":{"type":"string"},"updated":{"type":"string","example":"2020-02-21T14:56:12+00:00"},"status":{"type":"string","enum":["AVAILABLE","UNAVAILABLE","SOON"]},"exam":{"type":"object","properties":{"duration":{"description":"Exam duration in minutes","type":"number"},"questions":{"description":"Number of exam questions","type":"number"}}},"price":{"type":"number","description":"Precio de la mision","example":12.56},"unlocked_days":{"type":"number","description":"Days that the user will have mission available when unlocking"},"unlocked":{"description":"Indicates if the user has unlocked(purchased) it","type":"boolean","default":true},"points":{"description":"Total points that the user has achieved in the challenge period","type":"number"},"success_percentage":{"description":"Percentage of user hits","type":"number","example":43},"rank":{"description":"Position in the user's ranking","type":"string","example":"+100"},"domanins":{"type":"array","items":{"$ref":"#/components/schemas/Domain"}},"services":{"type":"array","items":{"$ref":"#/components/schemas/Service"}}}},"Service":{"type":"object","required":["id","name"],"properties":{"id":{"type":"string"},"name":{"type":"string","example":"DynamoDB"},"despcription":{"type":"string"},"missions":{"type":"array","items":{"type":"string","description":"Identifier of the associated mission"}}}},"Domain":{"type":"object","required":["id","mission_id","name","percentage"],"properties":{"id":{"type":"string"},"mission_id":{"type":"string"},"name":{"type":"string","example":"Redes"},"despcription":{"type":"string"},"percentage":{"type":"number","description":"Percentage or weight in the associated mission","example":26}}},"Question":{"type":"object","required":["id","mission_id","domain_id","service_id","ask","options"],"properties":{"id":{"type":"string"},"mission_id":{"type":"string"},"domain_id":{"type":"string"},"service_id":{"type":"string"},"ask":{"type":"string","description":"Question text"},"options":{"type":"array","items":{"type":"object","properties":{"id":{"type":"number"},"content":{"type":"string"},"is_correct":{"type":"boolean"}}}},"tip":{"type":"string"},"correction":{"type":"object","properties":{"content":{"type":"string"},"url":{"type":"string"}}}}},"ExamResults":{"type":"object","required":["play_mode","period_points","points","scoring","answers_total","answers_ok","rank"],"properties":{"play_mode":{"type":"string","enum":["quick_mission","exam","domain","service"]},"period_points":{"type":"number","description":"Total points scored in the game period"},"points":{"type":"number","description":"Total points scored in the exam"},"scoring":{"type":"number"},"answers_total":{"type":"number"},"answers_ok":{"type":"number"},"rank":{"type":"string","description":"Position in the ranking"},"questions":{"type":"array","items":{"properties":{"ask":{"type":"string"},"options":{"type":"array","items":{"properties":{"id":{"type":"number"},"content":{"type":"string"},"is_correct":{"type":"boolean"}}}},"tip":{"type":"string"},"correction":{"type":"object","properties":{"content":{"type":"string"},"url":{"type":"string"}}},"success":{"type":"boolean"}}}},"domains":{"type":"array","description":"List of domains, mandatory only when play_mode is exam or quick_mission","items":{"properties":{"id":{"type":"string"},"mission_id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"percentage":{"type":"number"},"answers_total":{"type":"number"},"answers_ok":{"type":"number"}}}},"name":{"type":"string","description":"Domain or service name, mandatory when play_mode equals service or domain"}}},"UserRanking":{"type":"object","required":["user_id","given_name","email","points","is_me"],"properties":{"user_id":{"type":"string"},"given_name":{"type":"string"},"family_name":{"type":"string"},"email":{"type":"string"},"points":{"type":"number","description":"Total points scored in the game period"},"is_me":{"type":"boolean","description":"Indicates if the user is the one logged into the application"},"image_url":{"type":"string","description":"The url of the profile image"}}},"UserMission":{"type":"object","properties":{"user_id":{"type":"string"},"mission_id":{"type":"string"},"unlocked_until":{"type":"string","description":"Days that it will be unlocked"},"period_points":{"type":"number","description":"Total points scored in the game period"},"period_answer_ok":{"type":"number","description":"Total of correct answers in the period of the game"},"period_answer_fail":{"type":"number","description":"Total of failed answers in the period of the game"},"total_points":{"type":"number","description":"Total points earned on the platform"},"total_answer_ok":{"type":"number","description":"Total of correct answers in the platform"},"total_answer_fail":{"type":"number","description":"Total of failed answers in the platform"},"history":{"type":"array","description":"History of user exams in the mission","items":{"type":"object","properties":{"play_mode":{"type":"string","enum":["quick_mission","exam","domain","service"]},"prebuilt_exam_id":{"type":"string","description":"Exam identifier, not mandatory, only with pre-built exams"},"play_date_start":{"type":"string","example":"2011-10-05T14:48:00.000Z"},"play_date_end":{"type":"string","example":"2011-10-05T15:48:00.000Z"},"points":{"type":"number"},"scoring":{"type":"number"},"num_tips_used":{"type":"number","description":"Total tips used in the exam"},"answers":{"type":"array","items":{"type":"object","properties":{"question_id":{"type":"string"},"domain_id":{"type":"string"},"service_id":{"type":"string"},"selection":{"type":"array","items":{"type":"number"}},"success":{"type":"boolean","description":"Indicates that the answer was correct or not"},"tip_used":{"type":"boolean","description":"Indicates if in the answer you have used a tip or not"},"time_used":{"type":"number","description":"Time in seconds dedicated to the answer"}}}}}}}}}},"responses":{"ClientError":{"description":"Client exception","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"description":"Error message code","type":"string","default":"com.gravity.client.error"},"info":{"description":"Extra information from the error response","type":"object"}}}}}},"ServerError":{"description":"Server exception","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"description":"Error message code","type":"string","default":"com.gravity.server.error"},"info":{"description":"Extra information from the error response","type":"object"}}}}}},"AuthError":{"description":"Authentication exception","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"description":"Error message code","type":"string","default":"com.gravity.auth.error"},"info":{"description":"Extra information from the error response","type":"object"}}}}}}}}}