Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new fields to settings object decode. #263

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Sources/Segment/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public struct Settings: Codable {
public var plan: JSON? = nil
public var edgeFunction: JSON? = nil
public var middlewareSettings: JSON? = nil
public var metrics: JSON? = nil
public var consentSettings: JSON? = nil

public init(writeKey: String, apiHost: String) {
integrations = try! JSON([
Expand All @@ -37,6 +39,8 @@ public struct Settings: Codable {
self.plan = try? values.decode(JSON.self, forKey: CodingKeys.plan)
self.edgeFunction = try? values.decode(JSON.self, forKey: CodingKeys.edgeFunction)
self.middlewareSettings = try? values.decode(JSON.self, forKey: CodingKeys.middlewareSettings)
self.metrics = try? values.decode(JSON.self, forKey: CodingKeys.metrics)
self.consentSettings = try? values.decode(JSON.self, forKey: CodingKeys.consentSettings)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this CodingKeys.consentSettings defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

down below as

    enum CodingKeys: String, CodingKey {
        case integrations
        case plan
        case edgeFunction
        case middlewareSettings
        case metrics
        case consentSettings
    }

}

static public func load(from url: URL?) -> Settings? {
Expand All @@ -56,6 +60,8 @@ public struct Settings: Codable {
case plan
case edgeFunction
case middlewareSettings
case metrics
case consentSettings
}

/**
Expand Down
Loading