diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..69f58eb --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +partnerapi.html \ No newline at end of file diff --git a/docs/createPartner/curl-request.adoc b/docs/createPartner/curl-request.adoc new file mode 100644 index 0000000..b6def0f --- /dev/null +++ b/docs/createPartner/curl-request.adoc @@ -0,0 +1,11 @@ +[source,bash] +---- +$ curl 'http://localhost:8080/partner' -i -X POST \ + -H 'Content-Type: application/json' \ + -d '{ + "reference" : "FYI25", + "expirationTime" : "2013-10-03T12:18:46+01:00", + "name" : "UPS", + "locale" : "en_BE" +}' +---- \ No newline at end of file diff --git a/docs/createPartner/http-request.adoc b/docs/createPartner/http-request.adoc new file mode 100644 index 0000000..bd304f5 --- /dev/null +++ b/docs/createPartner/http-request.adoc @@ -0,0 +1,14 @@ +[source,http,options="nowrap"] +---- +POST /partner HTTP/1.1 +Content-Type: application/json +Content-Length: 117 +Host: localhost:8080 + +{ + "reference" : "FYI25", + "expirationTime" : "2013-10-03T12:18:46+01:00", + "name" : "UPS", + "locale" : "en_BE" +} +---- \ No newline at end of file diff --git a/docs/createPartner/http-response.adoc b/docs/createPartner/http-response.adoc new file mode 100644 index 0000000..d3d24f3 --- /dev/null +++ b/docs/createPartner/http-response.adoc @@ -0,0 +1,14 @@ +[source,http,options="nowrap"] +---- +HTTP/1.1 201 Created +Content-Type: application/json +Content-Length: 130 + +{ + "id" : 13, + "name" : "UPS", + "reference" : "FYI25", + "locale" : "en_BE", + "expirationTime" : "2013-10-03T12:18:46+01:00" +} +---- \ No newline at end of file diff --git a/docs/createPartner/httpie-request.adoc b/docs/createPartner/httpie-request.adoc new file mode 100644 index 0000000..3ac9979 --- /dev/null +++ b/docs/createPartner/httpie-request.adoc @@ -0,0 +1,10 @@ +[source,bash] +---- +$ echo '{ + "reference" : "FYI25", + "expirationTime" : "2013-10-03T12:18:46+01:00", + "name" : "UPS", + "locale" : "en_BE" +}' | http POST 'http://localhost:8080/partner' \ + 'Content-Type:application/json' +---- \ No newline at end of file diff --git a/docs/createPartner/request-body.adoc b/docs/createPartner/request-body.adoc new file mode 100644 index 0000000..fcd537c --- /dev/null +++ b/docs/createPartner/request-body.adoc @@ -0,0 +1,9 @@ +[source,options="nowrap"] +---- +{ + "reference" : "FYI25", + "expirationTime" : "2013-10-03T12:18:46+01:00", + "name" : "UPS", + "locale" : "en_BE" +} +---- \ No newline at end of file diff --git a/docs/createPartner/request-fields.adoc b/docs/createPartner/request-fields.adoc new file mode 100644 index 0000000..bdf22e0 --- /dev/null +++ b/docs/createPartner/request-fields.adoc @@ -0,0 +1,20 @@ +|=== +|Path|Type|Description + +|`+name+` +|`+String+` +|The name of the partner + +|`+reference+` +|`+String+` +|The unique reference of the partner + +|`+locale+` +|`+String+` +|A valid Locale of the partner + +|`+expirationTime+` +|`+String+` +|The ISO-8601 UTC date time when the partner is going to expire + +|=== \ No newline at end of file diff --git a/docs/createPartner/response-body.adoc b/docs/createPartner/response-body.adoc new file mode 100644 index 0000000..735f168 --- /dev/null +++ b/docs/createPartner/response-body.adoc @@ -0,0 +1,10 @@ +[source,options="nowrap"] +---- +{ + "id" : 13, + "name" : "UPS", + "reference" : "FYI25", + "locale" : "en_BE", + "expirationTime" : "2013-10-03T12:18:46+01:00" +} +---- \ No newline at end of file diff --git a/docs/getAPartner/curl-request.adoc b/docs/getAPartner/curl-request.adoc new file mode 100644 index 0000000..0dd655d --- /dev/null +++ b/docs/getAPartner/curl-request.adoc @@ -0,0 +1,4 @@ +[source,bash] +---- +$ curl 'http://localhost:8080/partner/1' -i -X GET +---- \ No newline at end of file diff --git a/docs/getAPartner/http-request.adoc b/docs/getAPartner/http-request.adoc new file mode 100644 index 0000000..c9a410f --- /dev/null +++ b/docs/getAPartner/http-request.adoc @@ -0,0 +1,6 @@ +[source,http,options="nowrap"] +---- +GET /partner/1 HTTP/1.1 +Host: localhost:8080 + +---- \ No newline at end of file diff --git a/docs/getAPartner/http-response.adoc b/docs/getAPartner/http-response.adoc new file mode 100644 index 0000000..33ce3b5 --- /dev/null +++ b/docs/getAPartner/http-response.adoc @@ -0,0 +1,14 @@ +[source,http,options="nowrap"] +---- +HTTP/1.1 200 OK +Content-Type: application/json +Content-Length: 129 + +{ + "id" : 1, + "name" : "B2boost", + "reference" : "FYI1", + "locale" : "en_BE", + "expirationTime" : "2022-11-24 17:46:00+01" +} +---- \ No newline at end of file diff --git a/docs/getAPartner/httpie-request.adoc b/docs/getAPartner/httpie-request.adoc new file mode 100644 index 0000000..67fe52c --- /dev/null +++ b/docs/getAPartner/httpie-request.adoc @@ -0,0 +1,4 @@ +[source,bash] +---- +$ http GET 'http://localhost:8080/partner/1' +---- \ No newline at end of file diff --git a/docs/getAPartner/path-parameters.adoc b/docs/getAPartner/path-parameters.adoc new file mode 100644 index 0000000..d9d939d --- /dev/null +++ b/docs/getAPartner/path-parameters.adoc @@ -0,0 +1,8 @@ +.+/partner/{id}+ +|=== +|Parameter|Description + +|`+id+` +|id of partner to be searched + +|=== \ No newline at end of file diff --git a/docs/getAPartner/request-body.adoc b/docs/getAPartner/request-body.adoc new file mode 100644 index 0000000..dab5f81 --- /dev/null +++ b/docs/getAPartner/request-body.adoc @@ -0,0 +1,4 @@ +[source,options="nowrap"] +---- + +---- \ No newline at end of file diff --git a/docs/getAPartner/response-body.adoc b/docs/getAPartner/response-body.adoc new file mode 100644 index 0000000..69ad736 --- /dev/null +++ b/docs/getAPartner/response-body.adoc @@ -0,0 +1,10 @@ +[source,options="nowrap"] +---- +{ + "id" : 1, + "name" : "B2boost", + "reference" : "FYI1", + "locale" : "en_BE", + "expirationTime" : "2022-11-24 17:46:00+01" +} +---- \ No newline at end of file diff --git a/docs/getAPartner/response-fields.adoc b/docs/getAPartner/response-fields.adoc new file mode 100644 index 0000000..a503466 --- /dev/null +++ b/docs/getAPartner/response-fields.adoc @@ -0,0 +1,24 @@ +|=== +|Path|Type|Description + +|`+id+` +|`+Number+` +|The id of the partner + +|`+name+` +|`+String+` +|The name of the partner + +|`+reference+` +|`+String+` +|The unique reference of the partner + +|`+locale+` +|`+String+` +|A valid Locale of the partner + +|`+expirationTime+` +|`+String+` +|The ISO-8601 UTC date time when the partner is going to expire + +|=== \ No newline at end of file diff --git a/docs/getAllPartners/curl-request.adoc b/docs/getAllPartners/curl-request.adoc new file mode 100644 index 0000000..0e4a059 --- /dev/null +++ b/docs/getAllPartners/curl-request.adoc @@ -0,0 +1,4 @@ +[source,bash] +---- +$ curl 'http://localhost:8080/partners' -i -X GET +---- \ No newline at end of file diff --git a/docs/getAllPartners/http-request.adoc b/docs/getAllPartners/http-request.adoc new file mode 100644 index 0000000..a615d84 --- /dev/null +++ b/docs/getAllPartners/http-request.adoc @@ -0,0 +1,6 @@ +[source,http,options="nowrap"] +---- +GET /partners HTTP/1.1 +Host: localhost:8080 + +---- \ No newline at end of file diff --git a/docs/getAllPartners/http-response.adoc b/docs/getAllPartners/http-response.adoc new file mode 100644 index 0000000..310533f --- /dev/null +++ b/docs/getAllPartners/http-response.adoc @@ -0,0 +1,8 @@ +[source,http,options="nowrap"] +---- +HTTP/1.1 200 OK +Content-Type: application/json +Content-Length: 1360 + +[{"id":1,"name":"B2boost","reference":"FYI1","locale":"en_BE","expirationTime":"2022-11-24 17:46:00+01"},{"id":2,"name":"Proximus","reference":"FYI2","locale":"en_BE","expirationTime":"2022-11-24 17:46:00+01"},{"id":3,"name":"KBC Bank","reference":"FYI3","locale":"en_BE","expirationTime":"2022-11-24 17:46:00+01"},{"id":4,"name":"AB InBev","reference":"FYI4","locale":"en_BE","expirationTime":"2022-11-24 17:46:00+01"},{"id":5,"name":"Spotify","reference":"FYI5","locale":"sv_SE","expirationTime":"2022-11-24 17:46:00+01"},{"id":6,"name":"AMSOM-Habitat","reference":"FYI6","locale":"fr_FR","expirationTime":"2022-11-24 17:46:00+01"},{"id":7,"name":"Microsoft","reference":"FYI7","locale":"en_US","expirationTime":"2022-11-24 17:46:00-04"},{"id":8,"name":"Sony","reference":"FYI8","locale":"ja_JP","expirationTime":"2022-11-24 17:46:00+09"},{"id":9,"name":"Intel","reference":"FYI9","locale":"en_US","expirationTime":"2022-11-24 17:46:00-04"},{"id":10,"name":"Cisco","reference":"FYI10","locale":"en_US","expirationTime":"2022-11-24 17:46:00-04"},{"id":11,"name":"Dell","reference":"FYI11","locale":"en_US","expirationTime":"2022-11-24 17:46:00-04"},{"id":12,"name":"Canonical","reference":"FYI12","locale":"en_US","expirationTime":"2022-11-24 17:46:00-04"},{"id":13,"name":"UPS","reference":"FYI25","locale":"en_BE","expirationTime":"2013-10-03 12:18:46+01"}] +---- \ No newline at end of file diff --git a/docs/getAllPartners/httpie-request.adoc b/docs/getAllPartners/httpie-request.adoc new file mode 100644 index 0000000..856b92b --- /dev/null +++ b/docs/getAllPartners/httpie-request.adoc @@ -0,0 +1,4 @@ +[source,bash] +---- +$ http GET 'http://localhost:8080/partners' +---- \ No newline at end of file diff --git a/docs/getAllPartners/request-body.adoc b/docs/getAllPartners/request-body.adoc new file mode 100644 index 0000000..dab5f81 --- /dev/null +++ b/docs/getAllPartners/request-body.adoc @@ -0,0 +1,4 @@ +[source,options="nowrap"] +---- + +---- \ No newline at end of file diff --git a/docs/getAllPartners/response-body.adoc b/docs/getAllPartners/response-body.adoc new file mode 100644 index 0000000..8d26e22 --- /dev/null +++ b/docs/getAllPartners/response-body.adoc @@ -0,0 +1,4 @@ +[source,options="nowrap"] +---- +[{"id":1,"name":"B2boost","reference":"FYI1","locale":"en_BE","expirationTime":"2022-11-24 17:46:00+01"},{"id":2,"name":"Proximus","reference":"FYI2","locale":"en_BE","expirationTime":"2022-11-24 17:46:00+01"},{"id":3,"name":"KBC Bank","reference":"FYI3","locale":"en_BE","expirationTime":"2022-11-24 17:46:00+01"},{"id":4,"name":"AB InBev","reference":"FYI4","locale":"en_BE","expirationTime":"2022-11-24 17:46:00+01"},{"id":5,"name":"Spotify","reference":"FYI5","locale":"sv_SE","expirationTime":"2022-11-24 17:46:00+01"},{"id":6,"name":"AMSOM-Habitat","reference":"FYI6","locale":"fr_FR","expirationTime":"2022-11-24 17:46:00+01"},{"id":7,"name":"Microsoft","reference":"FYI7","locale":"en_US","expirationTime":"2022-11-24 17:46:00-04"},{"id":8,"name":"Sony","reference":"FYI8","locale":"ja_JP","expirationTime":"2022-11-24 17:46:00+09"},{"id":9,"name":"Intel","reference":"FYI9","locale":"en_US","expirationTime":"2022-11-24 17:46:00-04"},{"id":10,"name":"Cisco","reference":"FYI10","locale":"en_US","expirationTime":"2022-11-24 17:46:00-04"},{"id":11,"name":"Dell","reference":"FYI11","locale":"en_US","expirationTime":"2022-11-24 17:46:00-04"},{"id":12,"name":"Canonical","reference":"FYI12","locale":"en_US","expirationTime":"2022-11-24 17:46:00-04"},{"id":13,"name":"UPS","reference":"FYI25","locale":"en_BE","expirationTime":"2013-10-03 12:18:46+01"}] +---- \ No newline at end of file diff --git a/docs/partnerapi.adoc b/docs/partnerapi.adoc new file mode 100644 index 0000000..e04cf3d --- /dev/null +++ b/docs/partnerapi.adoc @@ -0,0 +1,73 @@ += Api partner for B2Boost +Doc Writer +:toc: left +:hide-uri-scheme: +:source-highlighter: highlight.js + +== Framework and build tools + +For this project I chose to use Spring Boot alongside Gradle. + +== Purpose + +Small assignment to assess your capacity to execute a specific request + +It is taking into account some of the software engineering aspects beyond programming, like (non-exhaustive list): + +- Packaging +- Layering +- Error management +- Documentation +- Deployment aspects +- Testing + +This is a contrived example, especially designed to make the candidates exercise a deeper knowledge of the framework, going beyond simple tutorials that can be found online. + +_Credits (Purpose section) : B2Boost_ + +== Api documentation + +In the following document you will find a simple documentation of the API. +Most of the following sections have been generated with https://spring.io/projects/spring-restdocs[Spring Rest Docs]. + +=== Accessing all the partners GET +A `GET` request is used to access all the partners read. + +==== Request structure +include::getAllPartners/http-request.adoc[] + + +==== Example response +include::getAllPartners/http-response.adoc[] + +==== CURL request +include::getAllPartners/curl-request.adoc[] + + +=== Accessing the partner GET +A `GET` request is used to access the partner read. + +==== Request structure +include::getAPartner/http-request.adoc[] + +==== Path Parameters +include::getAPartner/path-parameters.adoc[] + +==== Example response +include::getAPartner/http-response.adoc[] + +==== CURL request +include::getAPartner/curl-request.adoc[] + + +=== Accessing the partner POST +A `POST` request is used to add a partners resource. + +==== Request structure +include::createPartner/http-request.adoc[] + +==== Example response +include::createPartner/http-response.adoc[] + +==== CURL request +include::createPartner/curl-request.adoc[]