From a7f84f5352392be79837cc765e54994b3d436bb0 Mon Sep 17 00:00:00 2001 From: Ilya Laryionau Date: Thu, 26 Dec 2024 16:05:21 +0100 Subject: [PATCH] Add AdaptyAttributionSource --- .../Adapty+UpdateAttributionData.swift | 13 +++++++ Sources/Profile/AdaptyAttributionSource.swift | 36 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 Sources/Profile/AdaptyAttributionSource.swift diff --git a/Sources/Profile/Adapty+UpdateAttributionData.swift b/Sources/Profile/Adapty+UpdateAttributionData.swift index 791e67d95..3235c4601 100644 --- a/Sources/Profile/Adapty+UpdateAttributionData.swift +++ b/Sources/Profile/Adapty+UpdateAttributionData.swift @@ -8,6 +8,19 @@ import Foundation public extension Adapty { + /// To set attribution data for the profile, use this method. + /// + /// Read more on the [Adapty Documentation](https://docs.adapty.io/docs/attribution-integration) + /// + /// - Parameter attribution: a dictionary containing attribution (conversion) data. + /// - Parameter source: a source of attribution. The allowed values are: `.appsflyer`, `.adjust`, `.branch` or custom. + nonisolated static func updateAttribution( + _ attribution: [AnyHashable: Any], + source: AdaptyAttributionSource + ) async throws { + try await updateAttribution(attribution, source: source.rawValue) + } + /// To set attribution data for the profile, use this method. /// /// Read more on the [Adapty Documentation](https://docs.adapty.io/docs/attribution-integration) diff --git a/Sources/Profile/AdaptyAttributionSource.swift b/Sources/Profile/AdaptyAttributionSource.swift new file mode 100644 index 000000000..2ca139f9c --- /dev/null +++ b/Sources/Profile/AdaptyAttributionSource.swift @@ -0,0 +1,36 @@ +// +// AdaptyAttributionSource.swift +// AdaptySDK +// +// Created by Ilya Laryionau on 26.12.24. +// + +public struct AdaptyAttributionSource: RawRepresentable { + public let rawValue: String + + public init(rawValue: String) { + self.rawValue = rawValue + } + + public static var adjust: Self { "adjust" } + public static var appsflyer: Self { "appsflyer" } + public static var branch: Self { "branch" } +} + +extension AdaptyAttributionSource: CustomStringConvertible { + public var description: String { + return String(describing: self.rawValue) + } +} + +extension AdaptyAttributionSource: Equatable {} + +extension AdaptyAttributionSource: ExpressibleByStringLiteral { + public init(stringLiteral: String) { + self.init(rawValue: stringLiteral) + } +} + +extension AdaptyAttributionSource: Hashable {} + +extension AdaptyAttributionSource: Sendable {}