Skip to content

Commit 3a3c2be

Browse files
committed
Refactoring.
1 parent 03d21e4 commit 3a3c2be

2 files changed

Lines changed: 18 additions & 13 deletions

File tree

Common/Localizable.xcstrings

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190421,6 +190421,10 @@
190421190421
}
190422190422
}
190423190423
},
190424+
"Show view count on channel" : {
190425+
"comment" : "Toggle action to show the number of viewers on the channel.",
190426+
"isCommentAutoGenerated" : true
190427+
},
190424190428
"Show wind" : {
190425190429
"localizations" : {
190426190430
"de" : {

Moblin/StreamingPlatforms/Kick/KickApi.swift

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -526,38 +526,39 @@ class KickApi {
526526
body: [String: Any]? = nil,
527527
onComplete: @escaping (OperationResult) -> Void)
528528
{
529-
doRequest(method: method, subPath: "v2/\(subPath)", body: body, onComplete: onComplete)
529+
guard let url = URL(string: "https://kick.com/api/v2/\(subPath)") else {
530+
return
531+
}
532+
doRequest(url: url, method: method, body: body, onComplete: onComplete)
530533
}
531534

532535
private func doInternalV1Request(method: String,
533536
subPath: String,
534537
body: [String: Any]? = nil,
535538
onComplete: @escaping (OperationResult) -> Void)
536539
{
537-
doRequest(method: method, subPath: "internal/v1/\(subPath)", body: body, onComplete: onComplete)
540+
guard let url = URL(string: "https://kick.com/api/internal/v1/\(subPath)") else {
541+
return
542+
}
543+
doRequest(url: url, method: method, body: body, onComplete: onComplete)
538544
}
539545

540546
private func doWebV1Request(method: String,
541547
subPath: String,
542548
body: [String: Any]? = nil,
543549
onComplete: @escaping (OperationResult) -> Void)
544550
{
545-
doRequest(method: method,
546-
subPath: "v1/\(subPath)",
547-
body: body,
548-
baseUrl: "https://web.kick.com/api/",
549-
onComplete: onComplete)
551+
guard let url = URL(string: "https://web.kick.com/api/v1/\(subPath)") else {
552+
return
553+
}
554+
doRequest(url: url, method: method, body: body, onComplete: onComplete)
550555
}
551556

552-
private func doRequest(method: String,
553-
subPath: String,
557+
private func doRequest(url: URL,
558+
method: String,
554559
body: [String: Any]? = nil,
555-
baseUrl: String = "https://kick.com/api/",
556560
onComplete: @escaping (OperationResult) -> Void)
557561
{
558-
guard let url = URL(string: "\(baseUrl)\(subPath)") else {
559-
return
560-
}
561562
var request = URLRequest(url: url)
562563
request.httpMethod = method
563564
request.setContentType("application/json")

0 commit comments

Comments
 (0)