From 8cc92d0bd494f33e734436fd3cc8018833c8b792 Mon Sep 17 00:00:00 2001
From: AmiyahJo <86239804+AmiyahJo@users.noreply.github.com>
Date: Tue, 24 Sep 2024 15:05:50 -0400
Subject: [PATCH 1/4] Create README.md
Accidentally removed my work the 1st time by merging
---
lesson_00/amiyahjones/README.md | 43 +++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
create mode 100644 lesson_00/amiyahjones/README.md
diff --git a/lesson_00/amiyahjones/README.md b/lesson_00/amiyahjones/README.md
new file mode 100644
index 000000000..14fc62d70
--- /dev/null
+++ b/lesson_00/amiyahjones/README.md
@@ -0,0 +1,43 @@
+# Mya.README
+ ```Javascript
+const Mya = class SoftwareEngineer {
+ intern(code, tools) {
+ self.code = Javascript, HTML, CSS, Java;
+ self.tools = React, Docker;
+ }
+};
+
+// Intrested in bringing ideas to life within a web browser.
+// Learning how websites become quick, responsive, and accesssible to everyone.
+```
+
+
+
+### ☴ My work hours
+9AM-5PM
I'm an early bird and often begin the day with a head start of my work. Feel free to reach me by email during this time, and I'll get back to you as soon as I'm able!
+
+### What's the best way to communicate with me? .☘︎ ݁˖
+Private message through google chat works perfectly. Email works too as a follow up or if I happened to miss one of your messages.
+> [!TIP]
+> _In case I don't respond:_ Ping me again on google chat or send me another email!
+
+### I'd be happy to help you with ꒰ ﹍ ꒱
+* Code suggestions
+* Explain or understand a code snippet
+* Photos + design ideas
+
+## Extra ⓘ
+* ✦ procreate artist ↓
+ - I like to combine my art and code together!
+ - In case you find me with my ipad, that's why
+* visual learner
+* Jr Developer HS Intern for 4 years with Code Differently (youth program)
+* No, I don't drink coffee. ~~Hot chocolate is my go to~~
+
+> I'm the type of person that if you ask me a question and I don't know the answer, I'm gonna tell you that I don't know. But I bet you what, I know how to find the answer and I will find the answer.
- Will smith
+
+
+###### // readme inspired by [Kaeti's repo][kaeti-repo] , code snippet inspired by [Thai Brega]
+
+[kaeti-repo]: https://github.com/kaeti/personal-readme
+[Thai brega]: https://github.com/Thaiane/Thaiane
From 50b18619d9de9203384f678c1e0eee84a70510a0 Mon Sep 17 00:00:00 2001
From: AmiyahJo <86239804+AmiyahJo@users.noreply.github.com>
Date: Tue, 24 Sep 2024 15:07:22 -0400
Subject: [PATCH 2/4] Delete lesson_00/amiyahjones/README.md
---
lesson_00/amiyahjones/README.md | 43 ---------------------------------
1 file changed, 43 deletions(-)
delete mode 100644 lesson_00/amiyahjones/README.md
diff --git a/lesson_00/amiyahjones/README.md b/lesson_00/amiyahjones/README.md
deleted file mode 100644
index 14fc62d70..000000000
--- a/lesson_00/amiyahjones/README.md
+++ /dev/null
@@ -1,43 +0,0 @@
-# Mya.README
- ```Javascript
-const Mya = class SoftwareEngineer {
- intern(code, tools) {
- self.code = Javascript, HTML, CSS, Java;
- self.tools = React, Docker;
- }
-};
-
-// Intrested in bringing ideas to life within a web browser.
-// Learning how websites become quick, responsive, and accesssible to everyone.
-```
-
-
-
-### ☴ My work hours
-9AM-5PM
I'm an early bird and often begin the day with a head start of my work. Feel free to reach me by email during this time, and I'll get back to you as soon as I'm able!
-
-### What's the best way to communicate with me? .☘︎ ݁˖
-Private message through google chat works perfectly. Email works too as a follow up or if I happened to miss one of your messages.
-> [!TIP]
-> _In case I don't respond:_ Ping me again on google chat or send me another email!
-
-### I'd be happy to help you with ꒰ ﹍ ꒱
-* Code suggestions
-* Explain or understand a code snippet
-* Photos + design ideas
-
-## Extra ⓘ
-* ✦ procreate artist ↓
- - I like to combine my art and code together!
- - In case you find me with my ipad, that's why
-* visual learner
-* Jr Developer HS Intern for 4 years with Code Differently (youth program)
-* No, I don't drink coffee. ~~Hot chocolate is my go to~~
-
-> I'm the type of person that if you ask me a question and I don't know the answer, I'm gonna tell you that I don't know. But I bet you what, I know how to find the answer and I will find the answer.
- Will smith
-
-
-###### // readme inspired by [Kaeti's repo][kaeti-repo] , code snippet inspired by [Thai Brega]
-
-[kaeti-repo]: https://github.com/kaeti/personal-readme
-[Thai brega]: https://github.com/Thaiane/Thaiane
From 7e05f497ae10db7c77d26bb6327f6c193b3270a6 Mon Sep 17 00:00:00 2001
From: AmiyahJo
Date: Mon, 25 Nov 2024 15:53:21 +0000
Subject: [PATCH 3/4] feat: adds media item controller methods
only failed test is simply for addItems where status expects 200 but is actually 400
---
.../lesson26/web/MediaItemsController.java | 68 +++++++++++++++++--
1 file changed, 64 insertions(+), 4 deletions(-)
diff --git a/lesson_26/api/java/api_app/src/main/java/com/codedifferently/lesson26/web/MediaItemsController.java b/lesson_26/api/java/api_app/src/main/java/com/codedifferently/lesson26/web/MediaItemsController.java
index a393a53b9..eb71739aa 100644
--- a/lesson_26/api/java/api_app/src/main/java/com/codedifferently/lesson26/web/MediaItemsController.java
+++ b/lesson_26/api/java/api_app/src/main/java/com/codedifferently/lesson26/web/MediaItemsController.java
@@ -1,16 +1,28 @@
package com.codedifferently.lesson26.web;
-import com.codedifferently.lesson26.library.Librarian;
-import com.codedifferently.lesson26.library.Library;
-import com.codedifferently.lesson26.library.MediaItem;
-import com.codedifferently.lesson26.library.search.SearchCriteria;
import java.io.IOException;
import java.util.List;
+import java.util.Map;
import java.util.Set;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
+import com.codedifferently.lesson26.library.Librarian;
+import com.codedifferently.lesson26.library.Library;
+import com.codedifferently.lesson26.library.MediaItem;
+import com.codedifferently.lesson26.library.exceptions.MediaItemCheckedOutException;
+import com.codedifferently.lesson26.library.search.SearchCriteria;
+
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import jakarta.validation.Valid;
+
@RestController
@CrossOrigin
public class MediaItemsController {
@@ -29,4 +41,52 @@ public GetMediaItemsResponse getItems() {
var response = GetMediaItemsResponse.builder().items(responseItems).build();
return response;
}
+
+ @GetMapping("/items/{id}")
+ public ResponseEntity getItemById(@PathVariable("id") String id) {
+ Set items = library.search(SearchCriteria.builder().id(id).build());
+ if (items.isEmpty()) {
+ return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
+ }
+ MediaItem item = items.iterator().next();
+ MediaItemResponse response = MediaItemResponse.from(item);
+ return ResponseEntity.ok(response);
+ }
+
+ @PostMapping("/items")
+public ResponseEntity> addItem(@Valid @RequestBody MediaItemRequest request) {
+ if (request == null) {
+ return ResponseEntity.badRequest().body(Map.of("errors", List.of("Missing required fields")));
+ }
+
+ MediaItem newItem;
+ try {
+ newItem = MediaItemRequest.asMediaItem(request);
+ } catch (IllegalArgumentException e) {
+ return ResponseEntity.badRequest().body(Map.of("errors", List.of("Unknown media item type: " + request.getType())));
+ }
+
+ library.addMediaItem(newItem, new Librarian("Jane Doe", "JaneDoe@gmail.com"));
+
+ return ResponseEntity.ok(Map.of("item", Map.of("id", newItem.getId().toString())));
+}
+
+@DeleteMapping("/items/{id}")
+ public ResponseEntity