Skip to content

Commit

Permalink
feat(helix): add startCommercial endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
LosFarmosCTL committed Jan 23, 2024
1 parent a8849a5 commit fafd9a1
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Sources/Twitch/API/Endpoints/Ads/StartCommercial.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Foundation

#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

extension Helix {
public func startCommercial(broadcasterId: String, length: Int) async throws
-> Commercial?
{
var queryItems = [URLQueryItem]()
queryItems.append(
URLQueryItem(name: "broadcaster_id", value: broadcasterId))
queryItems.append(URLQueryItem(name: "length", value: String(length)))

return try await self.request(.get("channels"), with: queryItems).first
}
}

public struct Commercial: Codable {
let length: Int
let message: String
let retryAfter: Int

enum CodingKeys: String, CodingKey {
case length
case message
case retryAfter = "retry_after"
}
}

0 comments on commit fafd9a1

Please sign in to comment.