Skip to content

Commit bea8cdb

Browse files
authored
Merge pull request #113 from modulr-software/feat/embed-endpoints
embed endpoints
2 parents 8a99943 + 51eda8f commit bea8cdb

File tree

6 files changed

+65
-9
lines changed

6 files changed

+65
-9
lines changed

src/source/routes/bundle.clj

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(ns source.routes.bundle
2+
(:require [ring.util.response :as res]
3+
[source.services.interface :as services]))
4+
5+
(defn get
6+
{:summary "get bundle metadata by authorized uuid"
7+
:parameters {:query [:map [:uuid :string]]}
8+
:responses {200 {:body [:map
9+
[:id :int]
10+
[:name :string]
11+
[:uuid :string]
12+
[:user-id :int]
13+
[:video :int]
14+
[:podcast :int]
15+
[:blog :int]
16+
[:hash [:maybe :string]]
17+
[:content-type-id :int]
18+
[:ts-and-cs [:maybe :int]]]}
19+
404 {:body [:map [:message :string]]}}}
20+
21+
[{:keys [ds bundle-id] :as _request}]
22+
(res/response (services/bundle ds {:id bundle-id})))

src/source/routes/bundle_feeds.clj

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
(ns source.routes.bundle-feeds
2+
(:require [ring.util.response :as res]
3+
[source.services.interface :as services]
4+
[source.db.util :as db.util]))
5+
6+
(defn get
7+
{:summary "get all feeds present in the bundle authorised by uuid"
8+
:parameters {:query [:map [:uuid :string]]}
9+
:responses {200 {:body [:vector
10+
[:map
11+
[:id :int]
12+
[:title :string]
13+
[:display-picture [:maybe :string]]
14+
[:url [:maybe :string]]
15+
[:rss-url :string]
16+
[:user-id :int]
17+
[:provider-id [:maybe :int]]
18+
[:created-at :string]
19+
[:updated-at [:maybe :string]]
20+
[:content-type-id :int]
21+
[:cadence-id :int]
22+
[:baseline-id :int]
23+
[:ts-and-cs [:maybe :int]]
24+
[:state [:enum "live" "not live" "pending"]]]]}
25+
404 {:body [:map [:message :string]]}}}
26+
27+
[{:keys [ds bundle-id] :as _request}]
28+
(let [bundle-ds (db.util/conn :bundle bundle-id)
29+
feed-ids (mapv :feed-id (services/outgoing-posts bundle-ds))]
30+
(res/response (services/feeds ds {:where [:in :id feed-ids]}))))

src/source/routes/bundle_post.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
(defn get
77
{:summary "get a single outgoing post in the uuid-authorized bundle by post id"
8-
:parameters {:path [:map [:id {:title "id"
8+
:parameters {:query [:map [:uuid :string]]
9+
:path [:map [:id {:title "id"
910
:description "post id"} :int]]}
1011
:responses {200 {:body [:map
1112
[:id :int]
@@ -20,7 +21,7 @@
2021
[:stream-url [:maybe :string]]
2122
[:season [:maybe :int]]
2223
[:episode [:maybe :int]]
23-
[:redacted [:maybe :int]]
24+
[:redacted {:optional true} [:maybe :int]]
2425
[:posted-at [:maybe :string]]]}
2526
404 {:body [:map [:message :string]]}}}
2627

src/source/routes/bundle_posts.clj

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
{:summary "get all outgoing posts in the uuid-authorized bundle"
99
:parameters {:query [:map
1010
[:uuid :string]
11-
[:limit :int]
12-
[:start :int]]}
11+
[:limit {:optional true} :int]
12+
[:start {:optional true} :int]]}
1313
:responses {200 {:body [:vector
1414
[:map
1515
[:id :int]
@@ -24,14 +24,13 @@
2424
[:stream-url [:maybe :string]]
2525
[:season [:maybe :int]]
2626
[:episode [:maybe :int]]
27-
[:redacted [:maybe :int]]
27+
[:redacted {:optional true} [:maybe :int]]
2828
[:posted-at [:maybe :string]]]]}
29-
404 {:body [:map [:message :string]]}}}
29+
404 {:boy [:map [:message :string]]}}}
3030

3131
[{:keys [bundle-id query-params] :as _request}]
3232
(let [bundle-ds (db.util/conn :bundle bundle-id)
3333
{:keys [limit start]} (walk/keywordize-keys query-params)]
3434
(res/response (services/outgoing-posts bundle-ds {:where (when start [:>= :id start])
3535
:limit limit
3636
:order-by [[:id :asc]]}))))
37-

src/source/routes/posts.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
[:stream-url [:maybe :string]]
2121
[:season [:maybe :int]]
2222
[:episode [:maybe :int]]
23-
[:redacted [:maybe :int]]
23+
[:redacted {:optional true} [:maybe :int]]
2424
[:posted-at [:maybe :string]]]]}
2525
401 {:body [:map [:message :string]]}
2626
403 {:body [:map [:message :string]]}}}

src/source/routes/reitit.clj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
[source.routes.integrations :as integrations]
4242
[source.routes.integration :as integration]
4343
[source.routes.integration-categories :as integration-categories]
44+
[source.routes.bundle :as bundle]
45+
[source.routes.bundle-feeds :as bundle-feeds]
4446
[source.routes.bundle-posts :as bundle-posts]
4547
[source.routes.bundle-post :as bundle-post]
4648
[source.routes.posts :as posts]
@@ -179,8 +181,10 @@
179181
["/categories" (route {:get feed-categories/get
180182
:post feed-categories/post})]]]
181183

182-
["/bundles" {:middleware [[mw/apply-bundle]]
184+
["/bundle" {:middleware [[mw/apply-bundle]]
183185
:tags #{"bundles"}}
186+
["" (route {:get bundle/get})]
187+
["/feeds" (route {:get bundle-feeds/get})]
184188
["/posts"
185189
["" (route {:get bundle-posts/get})]
186190
["/:id" (route {:get bundle-post/get})]]]

0 commit comments

Comments
 (0)