diff --git a/api/v01/entities/vrp_result.rb b/api/v01/entities/vrp_result.rb index 578aa3032..33a4a38c3 100644 --- a/api/v01/entities/vrp_result.rb +++ b/api/v01/entities/vrp_result.rb @@ -146,6 +146,14 @@ class VrpResult < Grape::Entity expose :job, using: VrpResultJob, documentation: { desc: 'The Job status' } end + class VrpSyncJob < Grape::Entity + expose :solutions, using: VrpResultSolution, documentation: { is_array: true, desc: 'The current best solution' } + end + + class VrpAsyncJob < Grape::Entity + expose :job, using: VrpResultJob, documentation: { desc: 'The Job status' } + end + class VrpJobsList < Grape::Entity expose :jobs, using: VrpResultJob, documentation: { is_array: true, desc: 'The Jobs' } end diff --git a/api/v01/vrp.rb b/api/v01/vrp.rb index ae20ffea9..8f572e04e 100644 --- a/api/v01/vrp.rb +++ b/api/v01/vrp.rb @@ -75,10 +75,24 @@ class Vrp < APIBase desc 'Submit VRP problem', { nickname: 'submit_vrp', - success: VrpResult, - failure: [ - { code: 400, message: 'Bad Request', model: ::Api::V01::Status } - ], + success: [{ + code: 200, + message: 'The VRP has been processed synchronously', + model: VrpSyncJob + }, { + code: 201, + message: 'The VRP has been placed in a queue to be processed', + model: VrpAsyncJob + }], + failure: [{ + code: 400, + message: 'Bad Request', + model: ::Api::V01::Status + }, { + code: 413, + message: 'Exceeded limit authorized for your account. Please contact support or sales to increase limits.', + model: ::Api::V01::Status + }], detail: 'Submit vehicle routing problem. If the problem can be quickly solved, the solution is returned in the response. In other case, the response provides a job identifier in a queue: you need to perfom another request to fetch vrp job status and solution.' } params { @@ -196,7 +210,9 @@ class Vrp < APIBase desc 'Delete vrp job', { nickname: 'deleteJob', - success: { code: 204 }, + success: { + code: 202, + model: VrpResult}, failure: [ { code: 404, message: 'Not Found', model: ::Api::V01::Status } ],