Skip to content

Commit

Permalink
Update TraktSwift
Browse files Browse the repository at this point in the history
  • Loading branch information
Pietro Caselani committed Dec 16, 2019
1 parent 776cc29 commit 7df44f4
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 19 deletions.
4 changes: 0 additions & 4 deletions TraktSwift/Endpoints/Seasons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ extension Seasons: TraktType {
}
}

public var authorizationType: AuthorizationType {
return .none
}

public var sampleData: Data {
switch self {
case .summary:
Expand Down
8 changes: 3 additions & 5 deletions TraktSwift/Endpoints/Shows.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@ extension Shows: TraktType {
return .requestParameters(parameters: params, encoding: URLEncoding.default)
}

public var authorizationType: AuthorizationType {
public var authorizationType: AuthorizationType? {
switch self {
case .watchedProgress:
return .bearer
default:
return .none
case .watchedProgress: return .bearer
default: return nil
}
}

Expand Down
2 changes: 1 addition & 1 deletion TraktSwift/Endpoints/Sync.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ extension Sync: TraktType {
}
}

public var authorizationType: AuthorizationType {
public var authorizationType: AuthorizationType? {
return .bearer
}

Expand Down
2 changes: 1 addition & 1 deletion TraktSwift/Endpoints/Users.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extension Users: TraktType {
return .requestPlain
}

public var authorizationType: AuthorizationType {
public var authorizationType: AuthorizationType? {
return .bearer
}

Expand Down
10 changes: 5 additions & 5 deletions TraktSwift/Trakt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ public class Trakt {

if let redirectURL = credentials.redirectURL {
let url = Trakt.siteURL.appendingPathComponent(Trakt.OAuth2AuthorizationPath)
var componenets = URLComponents(url: url, resolvingAgainstBaseURL: false)
var components = URLComponents(url: url, resolvingAgainstBaseURL: false)

let responseTypeItem = URLQueryItem(name: "response_type", value: "code")
let clientIdItem = URLQueryItem(name: "client_id", value: clientId)
let redirectURIItem = URLQueryItem(name: "redirect_uri", value: redirectURL)
componenets?.queryItems = [responseTypeItem, clientIdItem, redirectURIItem]
components?.queryItems = [responseTypeItem, clientIdItem, redirectURIItem]

oauthURL = componenets?.url
oauthURL = components?.url
} else {
oauthURL = nil
}
Expand All @@ -67,8 +67,8 @@ public class Trakt {

interceptors.append(TraktTokenInterceptor(trakt: self))

plugins.append(AccessTokenPlugin { [weak self] () -> String in
self?.accessToken?.accessToken ?? ""
plugins.append(AccessTokenPlugin { [accessToken] _ -> String in
accessToken?.accessToken ?? ""
})
}

Expand Down
1 change: 0 additions & 1 deletion TraktSwift/TraktTokenInterceptor.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Moya
import Result

final class TraktTokenInterceptor: RequestInterceptor {
private weak var trakt: Trakt?
Expand Down
4 changes: 2 additions & 2 deletions TraktSwift/TraktType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public extension TraktType {

var task: Task { return .requestPlain }

var authorizationType: AuthorizationType { return .none }
var authorizationType: AuthorizationType? { return nil }

var sampleData: Data {
return "".utf8Encoded
Expand All @@ -23,7 +23,7 @@ public extension TraktType {
hasher.combine(typeName)
hasher.combine(path)
hasher.combine(method)
hasher.combine(authorizationType.value)
hasher.combine(authorizationType?.value)
}

static func == (lhs: Self, rhs: Self) -> Bool {
Expand Down

0 comments on commit 7df44f4

Please sign in to comment.