@@ -12,6 +12,8 @@ import app.model.Commit
1212import app.model.CommitGroup
1313import app.model.Fact
1414import app.model.FactGroup
15+ import app.model.Process
16+ import app.model.ProcessEntry
1517import app.model.Repo
1618import app.model.User
1719import com.github.kittinunf.fuel.core.FuelManager
@@ -93,10 +95,6 @@ class ServerApi (private val configurator: Configurator) : Api {
9395 .body(repo.serialize())
9496 }
9597
96- private fun createRequestPostComplete (): Request {
97- return post(" /complete" ).header(getContentTypeHeader())
98- }
99-
10098 private fun createRequestPostCommits (commits : CommitGroup ): Request {
10199 return post(" /commits" ).header(getContentTypeHeader())
102100 .body(commits.serialize())
@@ -117,6 +115,16 @@ class ServerApi (private val configurator: Configurator) : Api {
117115 .body(authors.serialize())
118116 }
119117
118+ private fun createRequestPostProcessCreate (process : Process ): Request {
119+ return post(" /process/create" ).header(getContentTypeHeader())
120+ .body(process.serialize())
121+ }
122+
123+ private fun createRequestPostProcess (process : Process ): Request {
124+ return post(" /process" ).header(getContentTypeHeader())
125+ .body(process.serialize())
126+ }
127+
120128 private fun <T > makeRequest (request : Request ,
121129 requestName : String ,
122130 parser : (ByteArray ) -> T ): Result <T > {
@@ -172,11 +180,6 @@ class ServerApi (private val configurator: Configurator) : Api {
172180 { body -> Repo (body) })
173181 }
174182
175- override fun postComplete (): Result <Unit > {
176- return makeRequest(createRequestPostComplete(),
177- " postComplete" , {})
178- }
179-
180183 override fun postCommits (commitsList : List <Commit >): Result <Unit > {
181184 val commits = CommitGroup (commitsList)
182185 return makeRequest(createRequestPostCommits(commits),
@@ -198,4 +201,17 @@ class ServerApi (private val configurator: Configurator) : Api {
198201 val authors = AuthorGroup (authorsList)
199202 return makeRequest(createRequestPostAuthors(authors), " postAuthors" , {})
200203 }
204+
205+ override fun postProcessCreate (requestNumEntries : Int ): Result <Process > {
206+ val process = Process (requestNumEntries = requestNumEntries)
207+ return makeRequest(createRequestPostProcessCreate(process),
208+ " postProcessCreate" , { body -> Process (body) })
209+ }
210+
211+ override fun postProcess (processEntries : List <ProcessEntry >): Result <Unit > {
212+ // TODO(anatoly): Restrict possible status and error codes on CS.
213+ val process = Process (entries = processEntries)
214+ return makeRequest(createRequestPostProcess(process), " postProcess" , {})
215+ }
216+
201217}
0 commit comments