Skip to content

Commit d72df7b

Browse files
Merge pull request #22 from ScalaInc/feature/auth-content-url
EXP-1239 added _rt to content and location layout urls
2 parents 8f9989e + 3c392db commit d72df7b

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Pod/Classes/ContentNode.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,15 @@ public final class ContentNode: Model,ResponseObject,ResponseCollection {
8888

8989
public func getUrl () -> String? {
9090

91+
let rt = auth?.get("restrictedToken") as! String
92+
9193
switch(self.subtype) {
9294
case .FILE:
9395
let escapeUrl = self.document["path"]!.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
94-
return hostUrl + "/api/delivery" + escapeUrl
96+
return "\(hostUrl)/api/delivery\(escapeUrl)?_rt=\(rt)"
9597
case .APP:
9698
let escapeUrl = self.document["path"]!.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
97-
return hostUrl + "/api/delivery" + escapeUrl + "/index.html"
99+
return "\(hostUrl)/api/delivery\(escapeUrl)/index.html?_rt=\(rt)"
98100
case .URL:
99101
return self.document["url"] as? String
100102
default:
@@ -110,7 +112,9 @@ public final class ContentNode: Model,ResponseObject,ResponseCollection {
110112

111113
if(CONTENT_TYPES.FILE == self.subtype && hasVariant(name)){
112114
if let url = getUrl() {
113-
return url + "?variant=" + name.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
115+
let rt = auth?.get("restrictedToken") as! String
116+
let variant = name.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
117+
return "\(url)?variant=\(variant)&_rt=\(rt)"
114118
}
115119
}
116120

Pod/Classes/Location.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public final class Location: Model,ResponseObject,ResponseCollection {
4646
}
4747

4848
public func getLayoutUrl() -> String {
49-
return hostUrl + "/api/locations/" + self.uuid + "/layout"
49+
let rt = auth?.get("restrictedToken")
50+
return "\(hostUrl)/api/locations/\(self.uuid)/layout?_rt=\(rt)"
5051
}
5152
}

0 commit comments

Comments
 (0)