diff --git a/documentation/docs-index.js b/documentation/docs-index.js index cce0cb47..0b34e547 100644 --- a/documentation/docs-index.js +++ b/documentation/docs-index.js @@ -22,7 +22,9 @@ module.exports = { ], Companies: [ "companies/list", + "companies/get", "companies/finish-registration", + "companies/edit", "companies/block", "companies/unblock", "companies/disable", diff --git a/documentation/docs/companies/edit.md b/documentation/docs/companies/edit.md new file mode 100644 index 00000000..08476dd8 --- /dev/null +++ b/documentation/docs/companies/edit.md @@ -0,0 +1,263 @@ +--- +id: edit +title: Edit Company +sidebar_label: Edit Company +slug: /company/edit +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +import Highlight from "../../src/highlight.js" + +## Details + +This endpoint is used to edit companies. Both Admins and Companies can use it. The company cannot be blocked or disabled. + +**URL** : `/company/:companyId/edit` + +**Method** : PUT + +:::caution Authentication +Auth is required to edit a Company as a Company owner or Admin. Otherwise, if in god mode, [god_token](#god_token) must be +provided. +::: + +## Parameters + +### god_token + +Body Parameter + +Optional +String + +If set, will use this for validating the usage of god mode (in case no session details are available, i.e., no logged-in +user). + +### name + +Body Parameter +Optional +String +
+Min Length: 2 +Max Length: 50 + +Name of the company, to be displayed to all users. + +### bio + +Form Parameter +Optional +
+String +Max Length: 1500 + +Description of the company. + +### contacts + +Form Parameter +Optional +
+Array +Minimum: 1 +Maximum: 10 + +List of contacts of the company. + +### logo + +Form Parameter + +Optional +File + +Logo to be displayed in the company's profile and offers. + +:::caution File types +The only valid file types are: png, jpeg and jpg. +::: + +## Request examples + +### Example 1 - Valid Request (Logged-in as Company) + +**Code** : 200 OK + + + + + +```json +{ + "name": "New Company", + "bio": "This is the rebranded company", + "contacts": [ + "contact@company.com", + "contact-me@company.com" + ] +} +``` + + + + + +```json +{ + "_id": "62601cb7cb39d3001b3664d9", + // highlight-start + "name": "New Company", + "bio": "This is the rebranded company", + "contacts": [ + "contact@company.com", + "contact-me@company.com" + ], + // highlight-end + "hasFinishedRegistration": true, + "isBlocked": false, + "isDisabled": false, + "__v": 0, + "logo": "https://res.cloudinary.com/coolimage.jpg" +} +``` + + + + +### Example 2 - Blocked Company (Logged-in as Admin or Company owner) + +**Code** : 403 FORBIDDEN + + + + + +```bash +{ + "name": "New Company", + "bio": "This is the rebranded company", + "contacts": [ + "contact@company.com", + "contact-me@company.com" + ] +} +``` + + + + + +```json +{ + "error_code": 3, + "errors": [ + { + "msg": "company-blocked" + } + ] +} +``` + + + + +### Example 3 - Disabled Company (Logged-in as Admin or Company owner) + +**Code** : 403 FORBIDDEN + + + + + +```bash +{ + "name": "New Company", + "bio": "This is the rebranded company", + "contacts": [ + "contact@company.com", + "contact-me@company.com" + ] +} +``` + + + + + +```json +{ + "error_code": 3, + "errors": [ + { + "msg": "company-disabled" + } + ] +} +``` + + + + +### Example 4 - W/o Auth or No Permissions + +**Code** : 403 FORBIDDEN + + + + + +```bash +{ + "name": "New Company", + "bio": "This is the rebranded company", + "contacts": [ + "contact@company.com", + "contact-me@company.com" + ] +} +``` + + + + + +```json +{ + "error_code": 3, + "errors": [ + { + "msg": "insufficient-permissions-to-manage-company-settings" + } + ] +} +``` + + + diff --git a/documentation/docs/companies/get.md b/documentation/docs/companies/get.md new file mode 100644 index 00000000..ec88d977 --- /dev/null +++ b/documentation/docs/companies/get.md @@ -0,0 +1,437 @@ +--- +id: get +title: Get Company +sidebar_label: Get Company +slug: /company/get +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +import Highlight from "../../src/highlight.js" + +## Details + +This endpoint returns a company based on the ID provided. + +**URL** : `/company/:companyId` + +**Method** : GET + +:::caution Authentication +Auth is required to get Companies that are blocked or disabled. Only Admins and Gods will have access to blocked companies but its owner will get an error informing that it is blocked. +On the other hand, Admins, Gods and the Company owner will have access to it if disabled. These entities will also get an informative error if the company hasn't finished its registration. + +All other situations will result in a 404 not found error. + +If in god mode, [god_token](#god_token) must be provided. +::: + +## Parameters + +### god_token + +Body Parameter + +Optional +String + +If set, will use this for validating the usage of god mode (in case no session details are available, i.e., no logged-in +user). + +## Request examples + +### Example 1 - Valid Request + +**Code** : 200 OK + + + + + +```bash +/company/62601cb7cb39d3001b3664d9 +``` + + + + + +```json +{ + "_id": "62601cb7cb39d3001b3664d9", + "name": "Company Name", + "contacts": [ + "company@company.com" + ], + "hasFinishedRegistration": true, + "isBlocked": false, + "isDisabled": false, + "__v": 0, + "bio": "We are an amazing company with amazing job opportunities. We're currently looking for amazing engineers", + "logo": "https://res.cloudinary.com/coolimage.jpg", + "offers": [ + { + "contacts": [ + "contact@company.com" + ], + "fields": [ + "FRONTEND", + "FULL-STACK" + ], + "technologies": [ + "React", + "JavaScript" + ], + "isHidden": false, + "isArchived": false, + "requirements": [ + "Ambitious people with a passion for this area", + "Degree in Computer Engineering or similar" + ], + "_id": "62601cb7cb39d3001b3664d9", + "title": "React JS Developer", + "publishDate": "2022-04-20T14:28:59.072Z", + "publishEndDate": "2022-10-19T02:57:47.000Z", + "jobMinDuration": 1, + "jobMaxDuration": 12, + "description": "We are an amazing company with amazing job opportunities. We're currently looking for amazing engineers", + "applyURL": "https://www.company.com/apply", + "isPaid": true, + "jobType": "FULL-TIME", + "owner": "62601cb7cb39d3001b3664d9", + "ownerName": "Company Name", + "ownerLogo": "https://res.cloudinary.com/coolimage.jpg", + "location": "Porto, Portugal", + "createdAt": "2022-04-20T14:46:15.281Z", + "updatedAt": "2022-04-20T14:46:15.281Z", + "__v": 0 + } + ] +} +``` + + + + +### Example 2 - Non-Existing Company or Blocked / Disabled / Unfinished Registration w/o Auth + +**Code** : 404 NOT FOUND + + + + + +```bash +/company/62601cb7cb39d3001b3664d9 +``` + + + + + +```json +{ + "error_code": 3, + "errors": [ + { + "msg": "no-company-found-with-id:62601cb7cb39d3001b3664d9" + } + ] +} +``` + + + + +### Example 3 - Invalid ID + +**Code** : 422 UNPROCESSABLE ENTITY + + + + + +```bash +/company/invalid +``` + + + + + +```json +{ + "error_code": 1, + "errors": [ + { + "value": "invalid", + "msg": "must-be-a-valid-id", + "param": "companyId", + "location": "params" + } + ] +} +``` + + + + +### Example 4 - Blocked Company (Logged-in as Admin) + +**Code** : 200 OK + + + + + +```bash +/company/62601cb7cb39d3001b3664d9 +``` + + + + + +```json +{ + "_id": "62601cb7cb39d3001b3664d9", + "name": "Company Name", + "contacts": [ + "company@company.com" + ], + "hasFinishedRegistration": true, + // highlight-start + "isBlocked": true, + "adminReason": "Company was spamming offers", + // highlight-end + "isDisabled": false, + "__v": 0, + "bio": "We are an amazing company with amazing job opportunities. We're currently looking for amazing engineers", + "logo": "https://res.cloudinary.com/coolimage.jpg", + "offers": [ + { + "contacts": [ + "contact@company.com" + ], + "fields": [ + "FRONTEND", + "FULL-STACK" + ], + "technologies": [ + "React", + "JavaScript" + ], + // highlight-start + "isHidden": true, + "hiddenReason": "COMPANY_BLOCKED", + // highlight-end + "isArchived": false, + "requirements": [ + "Ambitious people with a passion for this area", + "Degree in Computer Engineering or similar" + ], + "_id": "62601cb7cb39d3001b3664d9", + "title": "React JS Developer", + "publishDate": "2022-04-20T14:28:59.072Z", + "publishEndDate": "2022-10-19T02:57:47.000Z", + "jobMinDuration": 1, + "jobMaxDuration": 12, + "description": "We are an amazing company with amazing job opportunities. We're currently looking for amazing engineers", + "applyURL": "https://www.company.com/apply", + "isPaid": true, + "jobType": "FULL-TIME", + "owner": "62601cb7cb39d3001b3664d9", + "ownerName": "Company Name", + "ownerLogo": "https://res.cloudinary.com/coolimage.jpg", + "location": "Porto, Portugal", + "createdAt": "2022-04-20T14:46:15.281Z", + "updatedAt": "2022-04-20T14:46:15.281Z", + "__v": 0 + } + ] +} +``` + + + + +### Example 5 - Blocked Company (Logged-in as Company owner) + +**Code** : 403 FORBIDDEN + + + + + +```bash +/company/62601cb7cb39d3001b3664d9 +``` + + + + + +```json +{ + "error_code": 3, + "errors": [ + { + "msg": "company-blocked" + } + ] +} +``` + + + + +### Example 6 - Disabled Company (Logged-in as Admin or Company owner) + +**Code** : 200 OK + + + + + +```bash +/company/62601cb7cb39d3001b3664d9 +``` + + + + + +```json +{ + "_id": "62601cb7cb39d3001b3664d9", + "name": "Company Name", + "contacts": [ + "company@company.com" + ], + "hasFinishedRegistration": true, + "isBlocked": false, + // highlight-start + "isDisabled": true, + // highlight-end + "__v": 0, + "bio": "We are an amazing company with amazing job opportunities. We're currently looking for amazing engineers", + "logo": "https://res.cloudinary.com/coolimage.jpg", + "offers": [ + { + "contacts": [ + "contact@company.com" + ], + "fields": [ + "FRONTEND", + "FULL-STACK" + ], + "technologies": [ + "React", + "JavaScript" + ], + // highlight-start + "isHidden": true, + "hiddenReason": "COMPANY_DISABLED", + // highlight-end + "isArchived": false, + "requirements": [ + "Ambitious people with a passion for this area", + "Degree in Computer Engineering or similar" + ], + "_id": "62601cb7cb39d3001b3664d9", + "title": "React JS Developer", + "publishDate": "2022-04-20T14:28:59.072Z", + "publishEndDate": "2022-10-19T02:57:47.000Z", + "jobMinDuration": 1, + "jobMaxDuration": 12, + "description": "We are an amazing company with amazing job opportunities. We're currently looking for amazing engineers", + "applyURL": "https://www.company.com/apply", + "isPaid": true, + "jobType": "FULL-TIME", + "owner": "62601cb7cb39d3001b3664d9", + "ownerName": "Company Name", + "ownerLogo": "https://res.cloudinary.com/coolimage.jpg", + "location": "Porto, Portugal", + "createdAt": "2022-04-20T14:46:15.281Z", + "updatedAt": "2022-04-20T14:46:15.281Z", + "__v": 0 + } + ] +} +``` + + + + +### Example 7 - Unfinished Registration (Logged-in as Admin or Company owner) + +**Code** : 403 FORBIDDEN + + + + + +```bash +/company/62601cb7cb39d3001b3664d9 +``` + + + + + +```json +{ + "error_code": 3, + "errors": [ + { + "msg": "registration-not-finished-yet" + } + ] +} +``` + + +