Skip to content

Commit

Permalink
technical notes for testing and usage added
Browse files Browse the repository at this point in the history
  • Loading branch information
alex223125 committed Sep 21, 2022
1 parent 37c8e23 commit 02a6577
Show file tree
Hide file tree
Showing 4 changed files with 434 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
#### Developed features:
an authenticated user, should be able able to archive, unarchive and delete an existing user
an authenticated user, should not be able to archive/unarchive/delete himself
the api should return the users which are archived/unarchived based on a filter parameter
we do want to keep track when these operations happened and which user did it
after archive/unarchive/delete of a user we want to inform that user via email, push notifications and/or webhooks
conform to the https://jsonapi.org/ specs

#### To run application:
bunlde install
rails s



# Staffomatic User Management

This is our Lekker Rails-API :rocket:
Expand Down
101 changes: 101 additions & 0 deletions curl_notes_part1
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
PART 1

SOLUTION 1
User can archive ir dearchive other users

curl --header \
"Authentication: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxfQ.JC6qKuH9SG0SIiYSfhZUFTtirxN9Q47buLk0DPFFFzE" \
--header "Content-Type: application/json" \
-X PUT -d '{"user":{"email":"[email protected]","is_archived":"true"}}' \
http://localhost:3189/users/1


RESULT:

earth@earth:~/Downloads/test_tasks/staffomatic_user_management$ curl --header \
> "Authentication: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxfQ.JC6qKuH9SG0SIiYSfhZUFTtirxN9Q47buLk0DPFFFzE" \
> --header "Content-Type: application/json" \
> -X PUT -d '{"user":{"email":"[email protected]","is_archived":"true"}}' \
> http://localhost:3189/users/1
{"email":"[email protected]","is_archived":true,"id":1,"password_digest":"$2a$12$FB/RKx0T4M60qfqLJ7c4dOsZcdDNVtvSnWHQjKSKrAcy1NOi7S8fi","created_at":"2022-09-12T16:56:16.038Z","updated_at":"2022-09-12T18:48:38.503Z"}earth@earth:~/Downloads/test_tasks/staffomatic_user_management$


create more users to update:

curl --request POST --header "Content-Type: application/json" \
http://localhost:3189/signup --data \
'{"data": {"attributes": {"email": "[email protected]", "password": "welcome", "password_confirmation": "welcome"}}}'


111111111111111111111111111111111111111111111111111111111111111111111

SOLUTION 2

1 create user


curl --request POST --header "Content-Type: application/json" \
http://localhost:3189/signup --data \
'{"data": {"attributes": {"email": "[email protected]", "password": "welcome", "password_confirmation": "welcome"}}}'


2 delete user

curl --header \
"Authentication: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxfQ.JC6qKuH9SG0SIiYSfhZUFTtirxN9Q47buLk0DPFFFzE" \
--header "Content-Type: application/json" \
-X DELETE http://localhost:3189/users/5





11111111111111111111111111111111111111111111111111111111111111111111111111


SOLuTION 3

1 create user


curl --request POST --header "Content-Type: application/json" \
http://localhost:3189/signup --data \
'{"data": {"attributes": {"email": "[email protected]", "password": "welcome", "password_confirmation": "welcome"}}}'


2 delete user

curl --header \
"Authentication: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxfQ.JC6qKuH9SG0SIiYSfhZUFTtirxN9Q47buLk0DPFFFzE" \
--header "Content-Type: application/json" \
-X DELETE http://localhost:3189/users/2


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!




SOLUTION 4

for is archived true


curl -X GET \
-H "Content-type: application/json" \
-H "Authentication: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxfQ.JC6qKuH9SG0SIiYSfhZUFTtirxN9Q47buLk0DPFFFzE" \
-d '{"filter": {"is_archived": "true"}}' \
"http://localhost:3189/users"


for its arcive false


curl -X GET \
-H "Content-type: application/json" \
-H "Authentication: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxfQ.JC6qKuH9SG0SIiYSfhZUFTtirxN9Q47buLk0DPFFFzE" \
-d '{"filter": {"is_archived": "true"}}' \
"http://localhost:3189/users"


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Loading

0 comments on commit 02a6577

Please sign in to comment.