# Employee Endpoints

#### Job Recommendations

* **Endpoint**: `GET /reco-jobs`
* **Description**: Get personalized job recommendations based on employee's skills and disability status. Uses content-based and collaborative filtering algorithms.
* **Headers Required**:
  * `Authorization: Bearer <access_token>`
* **Request**: No body required
*   **Sample Request (curl)**:

    ```bash
    curl -X GET "http://your-api-url/reco-jobs" \
      -H "Authorization: Bearer <access_token>"
    ```
*   **Sample Response**:

    ```json
    {
      "recommendations": [
        {
          "id": 13,
          "user_id": "148cc1c6-2e81-4037-913c-7617564baa33",
          "title": "Transcriptionist",
          "job_description": "Transcribe audio content to text",
          "skill_1": "Grammar",
          "skill_2": "Transcription Tools",
          "skill_3": "Listening",
          "skill_4": "Detail Orientation",
          "skill_5": "Typing",
          "pwd_friendly": false,
          "created_at": "2025-06-05T12:57:47.917283+00:00",
          "company_name": "TechCorp",
          "location": "Remote",
          "job_type": "Part-time",
          "industry": "Technology",
          "experience": "Entry Level",
          "min_salary": 400.0,
          "max_salary": 600.0,
          "skill_match_score": 0.6,
          "matched_skills": ["typing", "listening", "grammar"]
        }
      ]
    }
    ```
*   **React Native Implementation**:

    ```javascript
    const getJobRecommendations = async () => {
      try {
        const token = await AsyncStorage.getItem('sessionKey');
        
        const response = await fetch('http://your-api-url/reco-jobs', {
          method: 'GET',
          headers: {
            'Authorization': `Bearer ${token}`,
            'Content-Type': 'application/json'
          }
        });
        
        const data = await response.json();
        
        if (data.recommendations) {
          return data.recommendations;
        } else {
          throw new Error(data.Message || 'No recommendations available');
        }
      } catch (error) {
        console.error('Recommendations error:', error);
        throw error;
      }
    };
    ```

***

#### Resume Management

**Upload Resume**

* **Endpoint**: `POST /upload-resume`
* **Description**: Upload or update employee resume. Only PDF files are accepted.
* **Headers Required**:
  * `Authorization: Bearer <access_token>`
* **Request (multipart/form-data)**:
  * `file` (file, required, PDF only, max 5MB)
*   **Sample Request (curl)**:

    ```bash
    curl -X POST "http://your-api-url/upload-resume" \
      -H "Authorization: Bearer <access_token>" \
      -F "file=@/path/to/resume.pdf"
    ```
*   **Sample Response**:

    ```json
    {
      "Status": "Success",
      "Message": "Resume uploaded successfully",
      "ResumeURL": "https://.../resumes/user_id/resume.pdf"
    }
    ```
*   **Error Responses**:

    ```json
    {
      "Status": "Error",
      "Message": "Only PDF files are allowed"
    }
    {
      "Status": "Error",
      "Message": "File size must be less than 5MB"
    }
    ```
*   **React Native Implementation**:

    ```javascript
    const uploadResume = async (resumeUri) => {
      try {
        const token = await AsyncStorage.getItem('sessionKey');
        
        const formData = new FormData();
        formData.append('file', {
          uri: resumeUri,
          type: 'application/pdf',
          name: 'resume.pdf'
        });
        
        const response = await fetch('http://your-api-url/upload-resume', {
          method: 'POST',
          headers: {
            'Authorization': `Bearer ${token}`,
            'Content-Type': 'multipart/form-data'
          },
          body: formData
        });
        
        const data = await response.json();
        
        if (data.Status === 'Success') {
          return data;
        } else {
          throw new Error(data.Message);
        }
      } catch (error) {
        console.error('Resume upload error:', error);
        throw error;
      }
    };
    ```

***

#### Job Applications

**Apply for Job**

* **Endpoint**: `POST /apply-job/{job_id}`
* **Description**: Apply for a specific job. Employee must be authenticated.
* **Headers Required**:
  * `Authorization: Bearer <access_token>`
* **Parameters**:
  * `job_id` (path parameter, required) - The ID of the job to apply for
* **Request**: No body required
*   **Sample Request (curl)**:

    ```bash
    curl -X POST "http://your-api-url/apply-job/16" \
      -H "Authorization: Bearer <access_token>"
    ```
*   **Sample Response**:

    ```json
    {
      "Status": "Successfull",
      "Message": "You applied to job 16",
      "Details": [
        {
          "id": 1,
          "user_id": "f9b86db6-93dc-4e29-a1be-6dfcb114b8f7",
          "job_id": "16",
          "status": "under_review",
          "created_at": "2025-06-05T14:13:35.947101+00:00"
        }
      ]
    }
    ```
*   **Error Response**:

    ```json
    {
      "Status": "Error",
      "Message": "Can't find the user"
    }
    ```
*   **React Native Implementation**:

    ```javascript
    const applyForJob = async (jobId) => {
      try {
        const token = await AsyncStorage.getItem('sessionKey');
        
        const response = await fetch(`http://your-api-url/apply-job/${jobId}`, {
          method: 'POST',
          headers: {
            'Authorization': `Bearer ${token}`,
            'Content-Type': 'application/json'
          }
        });
        
        const data = await response.json();
        
        if (data.Status === 'Successfull') {
          return data;
        } else {
          throw new Error(data.Message);
        }
      } catch (error) {
        console.error('Job application error:', error);
        throw error;
      }
    };
    ```

***

**View Application History**

* **Endpoint**: `GET /my-applications`
* **Description**: Get all job applications submitted by the current employee.
* **Headers Required**:
  * `Authorization: Bearer <access_token>`
* **Request**: No body required
*   **Sample Request (curl)**:

    ```bash
    curl -X GET "http://your-api-url/my-applications" \
      -H "Authorization: Bearer <access_token>"
    ```
*   **Sample Response**:

    ```json
    {
      "Status": "Successfull",
      "Message": [
        {
          "id": 1,
          "user_id": "f9b86db6-93dc-4e29-a1be-6dfcb114b8f7",
          "job_id": "16",
          "status": "under_review",
          "created_at": "2025-06-05T14:13:35.947101+00:00"
        },
        {
          "id": 2,
          "user_id": "f9b86db6-93dc-4e29-a1be-6dfcb114b8f7",
          "job_id": "14",
          "status": "accepted",
          "created_at": "2025-06-04T10:30:22.123456+00:00"
        }
      ]
    }
    ```
*   **React Native Implementation**:

    ```javascript
    const getMyApplications = async () => {
      try {
        const token = await AsyncStorage.getItem('sessionKey');
        
        const response = await fetch('http://your-api-url/my-applications', {
          method: 'GET',
          headers: {
            'Authorization': `Bearer ${token}`,
            'Content-Type': 'application/json'
          }
        });
        
        const data = await response.json();
        
        if (data.Status === 'Successfull') {
          return data.Message; // Contains the applications array
        } else {
          throw new Error(data.Message);
        }
      } catch (error) {
        console.error('Applications history error:', error);
        throw error;
      }
    };
    ```

#### Decline Job Application

* **Endpoint**: `POST /decline-application/{application_id}`
* **Description**: Allow an employee to decline a job application. Creates a record in the declined\_jobs table.
* **Headers Required**:
  * `Authorization: Bearer <access_token>`
* **Parameters**:
  * `application_id` (path parameter, required) - The ID of the job to decline
* **Sample Request (curl)**:

```bash
curl -X POST "http://your-api-url/decline-application/123" \
  -H "Authorization: Bearer <access_token>"
```

* **Sample Response**:

```json
{
  "Status": "Successfull",
  "Message": "Application declined successfully"
}
```

* **Error Response**:

```json
{
  "Status": "Error",
  "Message": "Failed to decline application"
}
```

* **React Native Implementation**:

```javascript
const declineJob = async (applicationId) => {
  try {
    const token = await AsyncStorage.getItem('Token');
    
    const response = await fetch(`http://your-api-url/decline-application/${applicationId}`, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${token}`,
        'Content-Type': 'application/json'
      }
    });
    
    const data = await response.json();
    
    if (data.Status === 'Successfull') {
      return data;
    } else {
      throw new Error(data.Message);
    }
  } catch (error) {
    console.error('Job decline error:', error);
    throw error;
  }
};
```

#### View Declined Applications

* **Endpoint**: `GET /declined-applications`
* **Description**: Get all job applications that have been declined by the employee.
* **Headers Required**:
  * `Authorization: Bearer <access_token>`
* **Request**: No body required
* **Sample Request (curl)**:

```bash
curl -X GET "http://your-api-url/declined-applications" \
  -H "Authorization: Bearer <access_token>"
```

* **Sample Response**:

```json
{
  "Status": "Successfull",
  "Message": [
    {
      "id": 1,
      "user_id": "f5cf5a60-f6d7-4754-b7cc-31ed083b0dd3",
      "job_id": "123",
      "created_at": "2025-06-26T07:24:44.275143+00:00"
    }
  ]
}
```

* **Error Response**:

```json
{
  "Status": "Error",
  "Message": "No Data Found"
}
```

* **React Native Implementation**:

```javascript
const getDeclinedApplications = async () => {
  try {
    const token = await AsyncStorage.getItem('Token');
    
    const response = await fetch('http://your-api-url/declined-applications', {
      method: 'GET',
      headers: {
        'Authorization': `Bearer ${token}`,
        'Content-Type': 'application/json'
      }
    });
    
    const data = await response.json();
    
    if (data.Status === 'Successfull') {
      return data.Message;
    } else {
      throw new Error(data.Message);
    }
  } catch (error) {
    console.error('Declined applications fetch error:', error);
    throw error;
  }
};
```

***
