Skip to content

Commit

Permalink
TVSeries refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
adamayoung committed Apr 23, 2024
1 parent 22b9d77 commit 5fc4790
Show file tree
Hide file tree
Showing 24 changed files with 1,027 additions and 304 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// PopularTVSeriesRequest.swift
// TMDb
//
// Copyright © 2024 Adam Young.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an AS IS BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

final class PopularTVSeriesRequest: DecodableAPIRequest<TVSeriesPageableList> {

init(page: Int? = nil) {
let path = "/tv/popular"
let queryItems = APIRequestQueryItems(page: page)

super.init(path: path, queryItems: queryItems)
}

}

private extension APIRequestQueryItems {

init(page: Int?) {
self.init()

if let page {
self[.page] = page
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// SimilarTVSeriesRequest.swift
// TMDb
//
// Copyright © 2024 Adam Young.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an AS IS BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

final class SimilarTVSeriesRequest: DecodableAPIRequest<TVSeriesPageableList> {

init(id: TVSeries.ID, page: Int? = nil) {
let path = "/tv/\(id)/similar"
let queryItems = APIRequestQueryItems(page: page)

super.init(path: path, queryItems: queryItems)
}

}

private extension APIRequestQueryItems {

init(page: Int?) {
self.init()

if let page {
self[.page] = page
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// TVSeriesCreditsRequest.swift
// TMDb
//
// Copyright © 2024 Adam Young.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an AS IS BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

final class TVSeriesCreditsRequest: DecodableAPIRequest<ShowCredits> {

init(id: TVSeries.ID) {
let path = "/tv/\(id)/credits"

super.init(path: path)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// TVSeriesExternalLinksRequest.swift
// TMDb
//
// Copyright © 2024 Adam Young.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an AS IS BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

final class TVSeriesExternalLinksRequest: DecodableAPIRequest<TVSeriesExternalLinksCollection> {

init(id: TVSeries.ID) {
let path = "/tv/\(id)/external_ids"

super.init(path: path)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// TVSeriesImagesRequest.swift
// TMDb
//
// Copyright © 2024 Adam Young.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an AS IS BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

final class TVSeriesImagesRequest: DecodableAPIRequest<ImageCollection> {

init(id: TVSeries.ID, languageCode: String? = nil) {
let path = "/tv/\(id)/images"
let queryItems = APIRequestQueryItems(languageCode: languageCode)

super.init(path: path, queryItems: queryItems)
}

}

private extension APIRequestQueryItems {

init(languageCode: String?) {
self.init()

if let languageCode {
self[.includeImageLanguage] = [languageCode, "null"].joined(separator: ",")
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// TVSeriesRecommendationsRequest.swift
// TMDb
//
// Copyright © 2024 Adam Young.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an AS IS BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

final class TVSeriesRecommendationsRequest: DecodableAPIRequest<TVSeriesPageableList> {

init(id: TVSeries.ID, page: Int? = nil) {
let path = "/tv/\(id)/recommendations"
let queryItems = APIRequestQueryItems(page: page)

super.init(path: path, queryItems: queryItems)
}

}

private extension APIRequestQueryItems {

init(page: Int?) {
self.init()

if let page {
self[.page] = page
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// TVSeriesRequest.swift
// TMDb
//
// Copyright © 2024 Adam Young.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an AS IS BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

final class TVSeriesRequest: DecodableAPIRequest<TVSeries> {

init(id: TVSeries.ID) {
let path = "/tv/\(id)"

super.init(path: path)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// TVSeriesReviewsRequest.swift
// TMDb
//
// Copyright © 2024 Adam Young.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an AS IS BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

final class TVSeriesReviewsRequest: DecodableAPIRequest<ReviewPageableList> {

init(id: TVSeries.ID, page: Int? = nil) {
let path = "/tv/\(id)/reviews"
let queryItems = APIRequestQueryItems(page: page)

super.init(path: path, queryItems: queryItems)
}

}

private extension APIRequestQueryItems {

init(page: Int?) {
self.init()

if let page {
self[.page] = page
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// TVSeriesVideosRequest.swift
// TMDb
//
// Copyright © 2024 Adam Young.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an AS IS BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

final class TVSeriesVideosRequest: DecodableAPIRequest<VideoCollection> {

init(id: TVSeries.ID, languageCode: String? = nil) {
let path = "/tv/\(id)/videos"
let queryItems = APIRequestQueryItems(languageCode: languageCode)

super.init(path: path, queryItems: queryItems)
}

}

private extension APIRequestQueryItems {

init(languageCode: String?) {
self.init()

if let languageCode {
self[.includeVideoLanguage] = [languageCode, "null"].joined(separator: ",")
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// TVSeriesWatchProvidersRequest.swift
// TMDb
//
// Copyright © 2024 Adam Young.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an AS IS BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

final class TVSeriesWatchProvidersRequest: DecodableAPIRequest<ShowWatchProviderResult> {

init(id: TVSeries.ID) {
let path = "/tv/\(id)/watch/providers"

super.init(path: path)
}

}
Loading

0 comments on commit 5fc4790

Please sign in to comment.