Skip to content

Commit

Permalink
cli for dealing with the proj (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
HusseinYasser authored May 19, 2024
1 parent 3aa7d5c commit a53dd81
Show file tree
Hide file tree
Showing 57 changed files with 1,480 additions and 0 deletions.
3 changes: 3 additions & 0 deletions workup-bash/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
UPLOAD_USER=user
UPLOAD_PASSWORD=password
DISCOGS_API_KEY=123
1 change: 1 addition & 0 deletions workup-bash/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/media/
30 changes: 30 additions & 0 deletions workup-bash/commands/contracts/evaluate_milestone.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF
{
"milestoneId": "$milestoneId",
"evaluatedState": "$evaluatedState"
}
EOF
)

status_code=$(curl -s -o response_body -w "%{http_code}" -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $bearerToken" -d "$json_payload" http://localhost:80/api/v1/contracts/milestones/${milestoneId}/evaluate)

response_body=$(cat response_body)

rm response_body

bash ./response_formatter.sh "$status_code" "$response_body"
18 changes: 18 additions & 0 deletions workup-bash/commands/contracts/get_contract.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

YELLOW='\033[0;33m'
NC='\033[0m'

read -p "contract id: " contractId

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/contracts/${contractId})

response_body=$(cat response_body)

rm response_body

bash ./response_formatter.sh "$status_code" "$response_body"
18 changes: 18 additions & 0 deletions workup-bash/commands/contracts/get_contract_milestones.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

YELLOW='\033[0;33m'
NC='\033[0m'

read -p "contract id: " contractId

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/contracts/${contractId}/milestones)

response_body=$(cat response_body)

rm response_body

bash ./response_formatter.sh "$status_code" "$response_body"
18 changes: 18 additions & 0 deletions workup-bash/commands/contracts/get_milestone.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

YELLOW='\033[0;33m'
NC='\033[0m'

read -p "milestone id: " milestoneId

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/contracts/milestones/${milestoneId})

response_body=$(cat response_body)

rm response_body

bash ./response_formatter.sh "$status_code" "$response_body"
18 changes: 18 additions & 0 deletions workup-bash/commands/contracts/get_pending_terminations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

YELLOW='\033[0;33m'
NC='\033[0m'

read -p "contract id: " contractId

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/contracts/${contractId}/terminations)

response_body=$(cat response_body)

rm response_body

bash ./response_formatter.sh "$status_code" "$response_body"
30 changes: 30 additions & 0 deletions workup-bash/commands/contracts/handle_termination_request.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

YELLOW='\033[0;33m'
NC='\033[0m'

read -p "termination request id: " contractTerminationRequestId

EVAL_STATUS=("PENDING" "REJECTED" "ACCEPTED")

chosenStatus=$(bash ./commands/dropdown.sh ${EVAL_STATUS[@]})

echo -e "${YELLOW}Sending your request to the server...${NC}"

bearerToken=$(cat ./token.txt)

json_payload=$(cat <<EOF
{
"contractTerminationRequestId": "$contractTerminationRequestId",
"chosenStatus": "$chosenStatus"
}
EOF
)

status_code=$(curl -s -o response_body -w "%{http_code}" -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $bearerToken" -d "$json_payload" http://localhost:80/api/v1/contracts/terminations/${contractTerminationRequestId}/handle)

response_body=$(cat response_body)

rm response_body

bash ./response_formatter.sh "$status_code" "$response_body"
28 changes: 28 additions & 0 deletions workup-bash/commands/contracts/progress_milestone.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# this has to send the json payload because the endpoint in webserver needs requestbody
# even though not used there but have to send from here

YELLOW='\033[0;33m'
NC='\033[0m'

read -p "milestone id: " milestoneId

echo -e "${YELLOW}Sending your request to the server...${NC}"

bearerToken=$(cat ./token.txt)

json_payload=$(cat <<EOF
{
"milestoneId": "$milestoneId"
}
EOF
)

status_code=$(curl -s -o response_body -w "%{http_code}" -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $bearerToken" -d "$json_payload" http://localhost:80/api/v1/contracts/milestones/${milestoneId}/progress)

response_body=$(cat response_body)

rm response_body

bash ./response_formatter.sh "$status_code" "$response_body"
28 changes: 28 additions & 0 deletions workup-bash/commands/contracts/request_termination.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

YELLOW='\033[0;33m'
NC='\033[0m'

read -p "contract id: " contractId

read -p "reason for termination: " reason

echo -e "${YELLOW}Sending your request to the server...${NC}"

bearerToken=$(cat ./token.txt)

json_payload=$(cat <<EOF
{
"contractId": "$contractId",
"reason": "$reason"
}
EOF
)

status_code=$(curl -s -o response_body -w "%{http_code}" -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $bearerToken" -d "$json_payload" http://localhost:80/api/v1/contracts/${contractId}/terminations/request)

response_body=$(cat response_body)

rm response_body

bash ./response_formatter.sh "$status_code" "$response_body"
14 changes: 14 additions & 0 deletions workup-bash/commands/dropdown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# Define the options
OPTIONS=("$@")

echo "Select your experience level:" > /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
20 changes: 20 additions & 0 deletions workup-bash/commands/jobs/accept_proposal.sh
Original file line number Diff line number Diff line change
@@ -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"
38 changes: 38 additions & 0 deletions workup-bash/commands/jobs/create_job.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF
{
"title": "$title",
"description": "$description",
"location": "$location",
"budget": $budget,
"skills": $skills,
"experience": "$experience"
}
EOF
)

echo "$json_payload"

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" -d "$json_payload" http://localhost:80/api/v1/jobs)

response_body=$(cat response_body)

rm response_body

bash ./response_formatter.sh "$status_code" "$response_body"
19 changes: 19 additions & 0 deletions workup-bash/commands/jobs/get_job.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

YELLOW='\033[0;33m'
NC='\033[0m'

read -p "job id: " id


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/jobs/{$id})

response_body=$(cat response_body)

rm response_body

bash ./response_formatter.sh "$status_code" "$response_body"
18 changes: 18 additions & 0 deletions workup-bash/commands/jobs/get_job_proposals.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

YELLOW='\033[0;33m'
NC='\033[0m'

read -p "job id: " id

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/jobs/{$id}/proposals)

response_body=$(cat response_body)

rm response_body

bash ./response_formatter.sh "$status_code" "$response_body"
17 changes: 17 additions & 0 deletions workup-bash/commands/jobs/get_my_jobs.sh
Original file line number Diff line number Diff line change
@@ -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/jobs/me)

response_body=$(cat response_body)

rm response_body

bash ./response_formatter.sh "$status_code" "$response_body"
17 changes: 17 additions & 0 deletions workup-bash/commands/jobs/get_my_proposals.sh
Original file line number Diff line number Diff line change
@@ -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/jobs/me/proposals)

response_body=$(cat response_body)

rm response_body

bash ./response_formatter.sh "$status_code" "$response_body"
16 changes: 16 additions & 0 deletions workup-bash/commands/payments/cget_my_payment_requests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/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/payments/clients/me/requests)

response_body=$(cat response_body)

rm response_body

bash ./response_formatter.sh "$status_code" "$response_body"
Loading

0 comments on commit a53dd81

Please sign in to comment.