diff --git a/workup-bash/.env b/workup-bash/.env new file mode 100644 index 00000000..4d76723e --- /dev/null +++ b/workup-bash/.env @@ -0,0 +1,3 @@ +UPLOAD_USER=user +UPLOAD_PASSWORD=password +DISCOGS_API_KEY=123 \ No newline at end of file diff --git a/workup-bash/.gitignore b/workup-bash/.gitignore new file mode 100644 index 00000000..972c54e4 --- /dev/null +++ b/workup-bash/.gitignore @@ -0,0 +1 @@ +/media/ \ No newline at end of file diff --git a/workup-bash/commands/contracts/evaluate_milestone.sh b/workup-bash/commands/contracts/evaluate_milestone.sh new file mode 100644 index 00000000..6f6ee25a --- /dev/null +++ b/workup-bash/commands/contracts/evaluate_milestone.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +YELLOW='\033[0;33m' +NC='\033[0m' + +read -p "milestone id: " milestoneId + +EVAL_STATUS=("OPEN" "IN_PROGRESS" "IN_REVIEW" "ACCEPTED" "PAID") + +evaluatedState=$(bash ./commands/dropdown.sh ${EVAL_STATUS[@]}) + +echo -e "${YELLOW}Sending your request to the server...${NC}" + +bearerToken=$(cat ./token.txt) + +json_payload=$(cat < /dev/null +select OPTION in "${OPTIONS[@]}"; do + if [[ " ${OPTIONS[@]} " =~ " ${OPTION} " ]]; then + echo "$OPTION" + break + else + echo "Invalid selection. Please choose a valid option." > /dev/null + fi +done \ No newline at end of file diff --git a/workup-bash/commands/jobs/accept_proposal.sh b/workup-bash/commands/jobs/accept_proposal.sh new file mode 100644 index 00000000..cc4b2f2f --- /dev/null +++ b/workup-bash/commands/jobs/accept_proposal.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +YELLOW='\033[0;33m' +NC='\033[0m' + +read -p "jon id: " jobId +read -p "proposal id: " proposalId + + +echo -e "${YELLOW}Sending your request to the server...${NC}" + +bearerToken=$(cat ./token.txt) + +status_code=$(curl -s -o response_body -w "%{http_code}" -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $bearerToken" http://localhost:80/api/v1/jobs/{$jobId}/proposals/{$proposalId}/accept) + +response_body=$(cat response_body) + +rm response_body + +bash ./response_formatter.sh "$status_code" "$response_body" \ No newline at end of file diff --git a/workup-bash/commands/jobs/create_job.sh b/workup-bash/commands/jobs/create_job.sh new file mode 100644 index 00000000..ec2584a1 --- /dev/null +++ b/workup-bash/commands/jobs/create_job.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +YELLOW='\033[0;33m' +NC='\033[0m' + +read -p "title: " title +read -p "description: " description +read -p "location: " location +read -p "budget: " budget +EXPERIENCE=("ENTRY_LEVEL" "INTERMEDIATE" "EXPERT") +experience=$(bash ./commands/dropdown.sh ${EXPERIENCE[@]}) +skills=$(bash ./commands/take_list.sh "skill") + +json_payload=$(cat < "./media/client_image.png" diff --git a/workup-bash/commands/users/client_get_profile.sh b/workup-bash/commands/users/client_get_profile.sh new file mode 100644 index 00000000..cc1f45ac --- /dev/null +++ b/workup-bash/commands/users/client_get_profile.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +YELLOW='\033[0;33m' +NC='\033[0m' + + +echo -e "${YELLOW}Sending your request to the server...${NC}" + +bearerToken=$(cat ./token.txt) + +status_code=$(curl -s -o response_body -w "%{http_code}" -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $bearerToken" http://localhost:80/api/v1/users/client/profile) + +response_body=$(cat response_body) + +rm response_body + +bash ./response_formatter.sh "$status_code" "$response_body" \ No newline at end of file diff --git a/workup-bash/commands/users/client_register.sh b/workup-bash/commands/users/client_register.sh new file mode 100644 index 00000000..cb7133a3 --- /dev/null +++ b/workup-bash/commands/users/client_register.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# Define color codes +YELLOW='\033[0;33m' +NC='\033[0m' + +read -p "Enter username: " username +read -p "Enter email: " email +read -p "Enter password: " password +read -p "Enter your industry: " industry +read -p "Enter your city: " city +read -p "Enter your Employee count: " employee_count +read -p "Enter description: " description + +# Create a JSON payload +json_payload=$(cat < ./token.txt + +rm response_body + +bash ./response_formatter.sh "$status_code" "$response_body" \ No newline at end of file diff --git a/workup-bash/commands/users/client_set_profile.sh b/workup-bash/commands/users/client_set_profile.sh new file mode 100644 index 00000000..922863cc --- /dev/null +++ b/workup-bash/commands/users/client_set_profile.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# Define color codes +YELLOW='\033[0;33m' +NC='\033[0m' + +read -p "Enter username: " username +read -p "Enter email: " email +read -p "Enter your industry: " industry +read -p "Enter your city: " city +read -p "Enter your Employee count: " employee_count +read -p "Enter description: " description + +# Create a JSON payload +json_payload=$(cat < "./media/freelancer_image.png" diff --git a/workup-bash/commands/users/freelancer_get_profile.sh b/workup-bash/commands/users/freelancer_get_profile.sh new file mode 100644 index 00000000..5e5d5e99 --- /dev/null +++ b/workup-bash/commands/users/freelancer_get_profile.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +YELLOW='\033[0;33m' +NC='\033[0m' + + +echo -e "${YELLOW}Sending your request to the server...${NC}" + +bearerToken=$(cat ./token.txt) + +status_code=$(curl -s -o response_body -w "%{http_code}" -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $bearerToken" http://localhost:80/api/v1/users/freelancer/profile) + +response_body=$(cat response_body) + +rm response_body + +bash ./response_formatter.sh "$status_code" "$response_body" \ No newline at end of file diff --git a/workup-bash/commands/users/freelancer_get_resume.sh b/workup-bash/commands/users/freelancer_get_resume.sh new file mode 100644 index 00000000..19e86184 --- /dev/null +++ b/workup-bash/commands/users/freelancer_get_resume.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +YELLOW='\033[0;33m' +NC='\033[0m' + + +echo -e "${YELLOW}Sending your request to the server...${NC}" + +bearerToken=$(cat ./token.txt) + +status_code=$(curl -s -o response_body -w "%{http_code}" -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $bearerToken" http://localhost:80/api/v1/users/freelancer/resume) + +response_body=$(cat response_body) + +rm response_body + +bash ./response_formatter.sh "$status_code" "$response_body" + +photoLink=$(echo "$response_body" | jq -r '.resumeLink') + +curl --request GET \ + --url http://localhost:8080$photoLink > "./media/freelancer_resume.pdf" diff --git a/workup-bash/commands/users/freelancer_get_skills.sh b/workup-bash/commands/users/freelancer_get_skills.sh new file mode 100644 index 00000000..8f401afd --- /dev/null +++ b/workup-bash/commands/users/freelancer_get_skills.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +YELLOW='\033[0;33m' +NC='\033[0m' + + +echo -e "${YELLOW}Sending your request to the server...${NC}" + +bearerToken=$(cat ./token.txt) + +status_code=$(curl -s -o response_body -w "%{http_code}" -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $bearerToken" http://localhost:80/api/v1/users/freelancer/skills) + +response_body=$(cat response_body) + +rm response_body + +bash ./response_formatter.sh "$status_code" "$response_body" \ No newline at end of file diff --git a/workup-bash/commands/users/freelancer_register.sh b/workup-bash/commands/users/freelancer_register.sh new file mode 100644 index 00000000..87ed8292 --- /dev/null +++ b/workup-bash/commands/users/freelancer_register.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +YELLOW='\033[0;33m' + +read -p "Enter username: " fullname +read -p "Enter email: " email +read -p "Enter password: " password +read -p "Enter your job title: " job_title +read -p "Enter your city: " city +read -p "Enter your birth date (YYYY-MM-DD): " birth_date + +# Create a JSON payload +json_payload=$(cat < ./token.txt + +rm response_body + +bash ./response_formatter.sh "$status_code" "$response_body" \ No newline at end of file diff --git a/workup-bash/commands/users/freelancer_set_profile.sh b/workup-bash/commands/users/freelancer_set_profile.sh new file mode 100644 index 00000000..df4b7f85 --- /dev/null +++ b/workup-bash/commands/users/freelancer_set_profile.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# Define color codes +YELLOW='\033[0;33m' +NC='\033[0m' + +read -p "Enter username: " fullName +read -p "Enter email: " email +read -p "Enter your job title: " jobTitle +read -p "Enter your city: " city +read -p "Enter your birth date (YYYY-MM-DD): " birthDate +read -p "Enter description: " description + +# Create a JSON payload +json_payload=$(cat < ./token.txt + +rm response_body + +bash ./response_formatter.sh "$status_code" "$response_body" + + diff --git a/workup-bash/response_formatter.sh b/workup-bash/response_formatter.sh new file mode 100644 index 00000000..62d11c2a --- /dev/null +++ b/workup-bash/response_formatter.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +BLUE='\033[0;34m' +CYAN='\033[0;36m' +NC='\033[0m' + +case $1 in + 200) echo -e "${GREEN}200 OK${NC}" ;; + 201) echo -e "${GREEN}201 Created${NC}" ;; + 204) echo -e "${GREEN}204 No Content${NC}" ;; + 400) echo -e "${YELLOW}400 Bad Request${NC}" ;; + 401) echo -e "${YELLOW}401 Unauthorized${NC}" ;; + 403) echo -e "${YELLOW}403 Forbidden${NC}" ;; + 404) echo -e "${YELLOW}404 Not Found${NC}" ;; + 500) echo -e "${RED}500 Internal Server Error${NC}" ;; + 502) echo -e "${RED}502 Bad Gateway${NC}" ;; + 503) echo -e "${RED}503 Service Unavailable${NC}" ;; + 504) echo -e "${RED}504 Gateway Timeout${NC}" ;; + *) echo -e "${YELLOW}Unknown Status Code${NC}" ;; +esac + +echo "$2" | jq + diff --git a/workup-bash/services/contracts.sh b/workup-bash/services/contracts.sh new file mode 100644 index 00000000..99dbfb2b --- /dev/null +++ b/workup-bash/services/contracts.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +CYAN='\033[0;36m' +NC='\033[0m' # No Color + +handle_contracts_command() { + case $1 in + get-contract) + bash ./commands/contracts/get_contract.sh + ;; + get-contract-milestones) + bash ./commands/contracts/get_contract_milestones.sh + ;; + get-milestone) + bash ./commands/contracts/get_milestone.sh + ;; + get-pending-terminations) + bash ./commands/contracts/get_pending_terminations.sh + ;; + request-contract-termination) + bash ./commands/contracts/request_termination.sh + ;; + evaluate-milestone) + bash ./commands/contracts/evaluate_milestone.sh + ;; + handle-termination-request) + bash ./commands/contracts/handle_termination_request.sh + ;; + progress-milestone) + bash ./commands/contracts/progress_milestone.sh + ;; + exit) + echo -e "${CYAN}Exiting Jobs service.${NC}" + exit 0 + ;; + *) + echo -e "${RED}Unknown command: ${NC}$1${NC}." + ;; + esac +} + +while true; do + echo -n -e "${CYAN}contracts> ${NC}" + read contracts_command + handle_contracts_command "$contracts_command" +done \ No newline at end of file diff --git a/workup-bash/services/jobs.sh b/workup-bash/services/jobs.sh new file mode 100644 index 00000000..33c91331 --- /dev/null +++ b/workup-bash/services/jobs.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +CYAN='\033[0;36m' +NC='\033[0m' # No Color + +handle_jobs_command() { + case $1 in + get-job) + bash ./commands/jobs/get_job.sh + ;; + create-job) + bash ./commands/jobs/create_job.sh + ;; + get-my-jobs) + bash ./commands/jobs/get_my_jobs.sh + ;; + get-job-proposals) + bash ./commands/jobs/get_job_proposals.sh + ;; + get-my-proposals) + bash ./commands/jobs/get_my_proposals.sh + ;; + accept-proposal) + bash ./commands/jobs/accept_proposal.sh + ;; + exit) + echo -e "${CYAN}Exiting Jobs service.${NC}" + exit 0 + ;; + *) + echo -e "${RED}Unknown command: ${NC}$1${NC}." + ;; + esac +} + +while true; do + echo -n -e "${CYAN}jobs> ${NC}" + read job_command + handle_jobs_command "$job_command" +done \ No newline at end of file diff --git a/workup-bash/services/payments.sh b/workup-bash/services/payments.sh new file mode 100644 index 00000000..db4933d2 --- /dev/null +++ b/workup-bash/services/payments.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +CYAN='\033[0;36m' +NC='\033[0m' # No Color + +handle_payments_command() { + case $1 in + cget-my-payment-requests) + bash ./commands/payments/cget_my_payment_requests.sh + ;; + cget-my-payment-transactions) + bash ./commands/payments/cget_my_payment_transactions.sh + ;; + fget-my-payment-requests) + bash ./commands/payments/fget_my_payment_requests.sh + ;; + fget-my-payment-transactions) + bash ./commands/payments/fget_my_payment_transactions.sh + ;; + get-wallet-transactions) + bash ./commands/payments/get_wallet_transactions.sh + ;; + get-wallet-transaction) + bash ./commands/payments/get_wallet_transaction.sh + ;; + get-my-wallet) + bash ./commands/payments/get_wallet.sh + ;; + withdraw-from-wallet) + bash ./commands/payments/withdraw_from_wallet.sh + ;; + pay-request) + bash ./commands/payments/pay_request.sh + ;; + exit) + echo -e "${CYAN}Exiting Jobs service.${NC}" + exit 0 + ;; + *) + echo -e "${RED}Unknown command: ${NC}$1${NC}." + ;; + esac +} + +while true; do + echo -n -e "${CYAN}payments> ${NC}" + read payments_command + handle_payments_command "$payments_command" +done \ No newline at end of file diff --git a/workup-bash/services/users.sh b/workup-bash/services/users.sh new file mode 100644 index 00000000..cc601414 --- /dev/null +++ b/workup-bash/services/users.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +CYAN='\033[0;36m' +NC='\033[0m' #NO_COLOR + +handle_users_command() { + case $1 in + client-register) + bash ./commands/users/client_register.sh + ;; + freelancer-register) + bash ./commands/users/freelancer_register.sh + ;; + login) + bash ./commands/users/login.sh + ;; + freelancer-add-achievment) + bash ./commands/users/freelancer_add_achievment.sh + ;; + freelancer-add-education) + bash ./commands/users/freelancer_add_education.sh + ;; + freelancer-add-experience) + bash ./commands/users/freelancer_add_experience.sh + ;; + freelancer-add-language) + bash ./commands/users/freelancer_add_language.sh + ;; + freelancer-add-skill) + bash ./commands/users/freelancer_add_skill.sh + ;; + client-get-photo) + bash ./commands/users/client_get_photo.sh + ;; + client-get-profile) + bash ./commands/users/client_get_profile.sh + ;; + client-add-photo) + bash ./commands/users/client_add_photo.sh + ;; + client-set-profile) + bash ./commands/users/client_set_profile.sh + ;; + freelancer-add-photo) + bash ./commands/users/freelancer_add_photo.sh + ;; + freelancer-get-photo) + bash ./commands/users/freelancer_get_photo.sh + ;; + freelancer-get-brief) + bash ./commands/users/freelancer_get_brief.sh + ;; + freelancer-get-profile) + bash ./commands/users/freelancer_get_profile.sh + ;; + freelancer-add-resume) + bash ./commands/users/freelancer_add_resume.sh + ;; + freelancer-get-resume) + bash ./commands/users/freelancer_get_resume.sh + ;; + freelancer-set-profile) + bash ./commands/users/freelancer_set_profile.sh + ;; + freelancer-get-achievments) + bash ./commands/users/freelancer_get_achievments.sh + ;; + freelancer-get-experience) + bash ./commands/users/freelancer_get_experience.sh + ;; + freelancer-get-education) + bash ./commands/users/freelancer_get_education.sh + ;; + freelancer-get-languages) + bash ./commands/users/freelancer_get_languages.sh + ;; + freelancer-get-skills) + bash ./commands/users/freelancer_get_skills.sh + ;; + exit) + echo -e "${CYAN}Exiting Users service.${NC}" + exit 0 + ;; + *) + echo -e "${RED}Unknown command: ${NC}$1${NC}." + ;; + esac +} + +while true; do + echo -n -e "${CYAN}users> ${NC}" + read user_command + handle_users_command "$user_command" +done \ No newline at end of file diff --git a/workup-bash/workup.sh b/workup-bash/workup.sh new file mode 100644 index 00000000..34fe4336 --- /dev/null +++ b/workup-bash/workup.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +BLUE='\033[0;34m' +CYAN='\033[0;36m' +NC='\033[0m' + +handle_service() { + case $1 in + users) + bash ./services/users.sh + ;; + contracts) + bash ./services/contracts.sh + ;; + payments) + bash ./services/payments.sh + ;; + jobs) + bash ./services/jobs.sh + ;; + exit) + echo "Exiting Workup." + rm ./token.txt + exit 0 + ;; + ls) + echo "users" + echo "payments" + echo "jobs" + echo "contracts" + ;; + *) + echo -e "${RED}Invalid service. Available services: users, contracts, payments, jobs, exit $NC" + ;; + esac +} + +touch token.txt + +while true; do + echo -ne "${YELLOW}workup>$NC " + read service + handle_service "$service" +done \ No newline at end of file