Skip to content

Commit

Permalink
Merge pull request #53 from AppSci/0.6.1
Browse files Browse the repository at this point in the history
0.6.1
  • Loading branch information
alexfill-gen authored Feb 16, 2022
2 parents 63176ce + 1cef777 commit 321bb37
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
2 changes: 1 addition & 1 deletion PandaSDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |spec|
#

spec.name = "PandaSDK"
spec.version = "0.5.2"
spec.version = "0.6.1"
spec.summary = "Panda pod which will help us boost our revenue."

# This description is used to generate tags and improve search results.
Expand Down
5 changes: 2 additions & 3 deletions Sources/PandaSDK/ConfiguredPanda.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final public class Panda: PandaProtocol, ObserverSupport {
private var viewControllers: Set<WeakObject<WebViewController>> = []
private var payload: PandaPayload?
private var entryPoint: String? {
return payload?.extraEventValues["entry_point"]
return payload?.entryPoint
}

public var onPurchase: ((String) -> Void)?
Expand Down Expand Up @@ -330,8 +330,7 @@ final public class Panda: PandaProtocol, ObserverSupport {

private func createViewModel(screenData: ScreenData, product: String? = nil, payload: PandaPayload? = nil) -> WebViewModel {
let viewModel = WebViewModel(screenData: screenData, payload: payload)
let extraValues = viewModel.payload?.extraEventValues
let entryPoint = extraValues?["entry_point"]
let entryPoint = payload?.entryPoint

if let product = product {
appStoreClient.getProduct(with: product) { result in
Expand Down
36 changes: 27 additions & 9 deletions Sources/PandaSDK/Models/PandaPayload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,44 @@
import UIKit

public struct PandaPayload {
let shouldShowDefaultScreen: Bool
let screenBackgroundColor: UIColor?
let extraEventValues: [String: String]
let pageLoadingTimeout: TimeInterval
let htmlDownloadTimeout: TimeInterval?
let data: [String: Any]?
internal let shouldShowDefaultScreen: Bool
internal let screenBackgroundColor: UIColor?
internal let entryPoint: String?
internal let pageLoadingTimeout: TimeInterval
internal let htmlDownloadTimeout: TimeInterval?
internal let data: [String: Any]?

public init(
shouldShowDefaultScreen: Bool = true,
screenBackgroundColor: UIColor? = nil,
extraEventValues: [String: String] = [:],
entryPoint: String? = nil,
pageLoadingTimeout: TimeInterval = 3.0,
htmlDownloadTimeout: TimeInterval? = nil,
data: [String: Any]? = nil
targetLanguage: String? = nil,
fromLanguage: String? = nil,
strings: [[String: String]]? = nil,
lessonTitle: String? = nil
) {
self.shouldShowDefaultScreen = shouldShowDefaultScreen
self.screenBackgroundColor = screenBackgroundColor
self.extraEventValues = extraEventValues
self.entryPoint = entryPoint
self.pageLoadingTimeout = pageLoadingTimeout
self.htmlDownloadTimeout = htmlDownloadTimeout
var data: [String: Any] = [:]
if let targetLanguage = targetLanguage {
data["target_language"] = targetLanguage
}
if let fromLanguage = fromLanguage {
data["from_language"] = fromLanguage
}

if let strings = strings {
data["strings"] = strings
}
if let lessonTitle = lessonTitle {
data["lesson_title"] = lessonTitle
}

self.data = data
}
}
3 changes: 1 addition & 2 deletions Sources/PandaSDK/UnconfiguredPanda.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ final class UnconfiguredPanda: PandaProtocol, ObserverSupport {
payload: PandaPayload? = nil
) -> WebViewModel {
let viewModel = WebViewModel(screenData: screenData, payload: payload)
let extraValues = viewModel.payload?.extraEventValues
let source = extraValues?["entry_point"]
let source = payload?.entryPoint
viewModel.onSurvey = { value, screenId, screenName in
pandaLog("Survey: \(value)")
}
Expand Down

0 comments on commit 321bb37

Please sign in to comment.