diff --git a/imStickered/Common/StickerManager.swift b/imStickered/Common/StickerManager.swift index 312d104..fdb9420 100644 --- a/imStickered/Common/StickerManager.swift +++ b/imStickered/Common/StickerManager.swift @@ -19,11 +19,12 @@ import FoundationNetworking struct StickerManager { let token = SnapAuthKeys.SnapKitAPIToken_Staging - func testit() { + func testit(searchTerm: String, numResults: Int = 3) { var semaphore = DispatchSemaphore (value: 0) - let parameters = "{\"query\":\"query SearchStickerSample {\\r\\n sticker {\\r\\n searchStickers(\\r\\n req:{\\r\\n searchStickersParams:{searchText: \\\"duck\\\", numberResults: 5},\\r\\n stickerUserContext:{countryCode: US, localTimeZoneUTCOffsetMinutes: 2,locale: EN_US}\\r\\n }){\\r\\n stickerResults {\\r\\n items {\\r\\n itemType\\r\\n id\\r\\n pngURL\\r\\n thumbnailURL\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n}\",\"variables\":{}}" + /// yes this is messy but attempting to use raw strings and multi-line raw strings got a JSON error don't have time to debug. + let parameters = "{\"query\":\"query SearchStickerSample {\\r\\n sticker {\\r\\n searchStickers(\\r\\n req:{\\r\\n searchStickersParams:{searchText: \\\"\(searchTerm)\\\", numberResults: \(numResults)},\\r\\n stickerUserContext:{countryCode: US, localTimeZoneUTCOffsetMinutes: 2,locale: EN_US}\\r\\n }){\\r\\n stickerResults {\\r\\n items {\\r\\n itemType\\r\\n id\\r\\n pngURL\\r\\n thumbnailURL\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n}\",\"variables\":{}}" let postData = parameters.data(using: .utf8) var request = URLRequest(url: URL(string: "https://graph.snapchat.com/graphql")!,timeoutInterval: Double.infinity) diff --git a/imStickered/imStickered Code Change Diary.txt b/imStickered/imStickered Code Change Diary.txt index 2a8effb..00e21a2 100644 --- a/imStickered/imStickered Code Change Diary.txt +++ b/imStickered/imStickered Code Change Diary.txt @@ -4,7 +4,7 @@ Creation Created by duplicating the webFromIM and renaming everything. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -Integrating plain StickerKit without auth into app - works with hardcoded +Integrating plain StickerKit without auth into app - works with hardcoded query 2021-10-20 @@ -19,3 +19,20 @@ ViewController.swift StickerManager - added to wrap testing initially using the code from Postman + +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +Parameterising query +2021-10-21 + +Main.storyboard +- add Search Term field + +ViewController.swift +- add outlet searchEntry +- onTest pass searchEntry content to testit + +StickerManager +- testit + - take a non-empty search term & use in hardcoded search + - take count of items to get back and use in search + \ No newline at end of file diff --git a/imStickered/imStickeredapp/Base.lproj/Main.storyboard b/imStickered/imStickeredapp/Base.lproj/Main.storyboard index 19eb49a..34922dc 100644 --- a/imStickered/imStickeredapp/Base.lproj/Main.storyboard +++ b/imStickered/imStickeredapp/Base.lproj/Main.storyboard @@ -37,8 +37,15 @@ -