vibes-react-native 5.0.0 → 5.0.1-rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/ios/Vibes.swift +2 -3
  2. package/ios/VibesClient.swift +3 -4
  3. package/ios/VibesPluginLogger.swift +2 -5
  4. package/package.json +3 -2
  5. package/vendor/VibesPush/LICENSE +13 -0
  6. package/vendor/VibesPush/Sources/APIDefinition.swift +502 -0
  7. package/vendor/VibesPush/Sources/Actions.swift +24 -0
  8. package/vendor/VibesPush/Sources/AppObserver.swift +137 -0
  9. package/vendor/VibesPush/Sources/AuthTokenBehavior.swift +17 -0
  10. package/vendor/VibesPush/Sources/CombinedLogger.swift +53 -0
  11. package/vendor/VibesPush/Sources/ConsoleLogger.swift +97 -0
  12. package/vendor/VibesPush/Sources/Credential.swift +41 -0
  13. package/vendor/VibesPush/Sources/CredentialManager.swift +24 -0
  14. package/vendor/VibesPush/Sources/Date+iso8601.swift +34 -0
  15. package/vendor/VibesPush/Sources/Date+logPrefix.swift +20 -0
  16. package/vendor/VibesPush/Sources/DeviceToken.swift +15 -0
  17. package/vendor/VibesPush/Sources/DeviceType.swift +143 -0
  18. package/vendor/VibesPush/Sources/Dictionary+merged.swift +11 -0
  19. package/vendor/VibesPush/Sources/Event.swift +83 -0
  20. package/vendor/VibesPush/Sources/EventCollection.swift +36 -0
  21. package/vendor/VibesPush/Sources/EventTracker.swift +39 -0
  22. package/vendor/VibesPush/Sources/FoundationExtensions.swift +16 -0
  23. package/vendor/VibesPush/Sources/GitTag.swift +27 -0
  24. package/vendor/VibesPush/Sources/HTTP/HTTPBehavior.swift +19 -0
  25. package/vendor/VibesPush/Sources/HTTP/HTTPMethod.swift +20 -0
  26. package/vendor/VibesPush/Sources/HTTP/HTTPResource.swift +69 -0
  27. package/vendor/VibesPush/Sources/HTTP/HTTPResourceClient.swift +190 -0
  28. package/vendor/VibesPush/Sources/HTTP/JSONParser.swift +91 -0
  29. package/vendor/VibesPush/Sources/HTTP/Operations/AssociatePersonOperation.swift +56 -0
  30. package/vendor/VibesPush/Sources/HTTP/Operations/BaseOperation.swift +153 -0
  31. package/vendor/VibesPush/Sources/HTTP/Operations/EventOperation.swift +73 -0
  32. package/vendor/VibesPush/Sources/HTTP/Operations/GetGitTagsOperation.swift +61 -0
  33. package/vendor/VibesPush/Sources/HTTP/Operations/GetInboxMessageOperation.swift +59 -0
  34. package/vendor/VibesPush/Sources/HTTP/Operations/GetInboxMessagesOperation.swift +57 -0
  35. package/vendor/VibesPush/Sources/HTTP/Operations/GetPersonOperation.swift +53 -0
  36. package/vendor/VibesPush/Sources/HTTP/Operations/GetVibesAppInfoOperation.swift +45 -0
  37. package/vendor/VibesPush/Sources/HTTP/Operations/MigrationCallbackOperation.swift +45 -0
  38. package/vendor/VibesPush/Sources/HTTP/Operations/RegisterDeviceOperation.swift +66 -0
  39. package/vendor/VibesPush/Sources/HTTP/Operations/RegisterPushOperation.swift +73 -0
  40. package/vendor/VibesPush/Sources/HTTP/Operations/TrackProductActionOperation.swift +75 -0
  41. package/vendor/VibesPush/Sources/HTTP/Operations/TrackPurchaseActionOperation.swift +81 -0
  42. package/vendor/VibesPush/Sources/HTTP/Operations/UnregisterDeviceOperation.swift +64 -0
  43. package/vendor/VibesPush/Sources/HTTP/Operations/UnregisterPushOperation.swift +72 -0
  44. package/vendor/VibesPush/Sources/HTTP/Operations/UpdateDeviceOperationPatch.swift +57 -0
  45. package/vendor/VibesPush/Sources/HTTP/Operations/UpdateDeviceOperationPut.swift +59 -0
  46. package/vendor/VibesPush/Sources/HTTP/Operations/UpdateMessageOperation.swift +50 -0
  47. package/vendor/VibesPush/Sources/HTTP/Operations/VibesQueueOperation.swift +76 -0
  48. package/vendor/VibesPush/Sources/HTTP/ResourceResult.swift +38 -0
  49. package/vendor/VibesPush/Sources/HTTPURLResponse+cURL.swift +16 -0
  50. package/vendor/VibesPush/Sources/InboxMessage.swift +219 -0
  51. package/vendor/VibesPush/Sources/Info.plist +26 -0
  52. package/vendor/VibesPush/Sources/InputStream+readToString.swift +19 -0
  53. package/vendor/VibesPush/Sources/KeychainStorage.swift +64 -0
  54. package/vendor/VibesPush/Sources/LocalObject.swift +25 -0
  55. package/vendor/VibesPush/Sources/LocalStorageKeys.swift +19 -0
  56. package/vendor/VibesPush/Sources/LocalStorageType.swift +47 -0
  57. package/vendor/VibesPush/Sources/LocalValue.swift +67 -0
  58. package/vendor/VibesPush/Sources/PersistentEventStorage.swift +81 -0
  59. package/vendor/VibesPush/Sources/Person.swift +98 -0
  60. package/vendor/VibesPush/Sources/Product.swift +103 -0
  61. package/vendor/VibesPush/Sources/Purchase.swift +108 -0
  62. package/vendor/VibesPush/Sources/TrackedEventType.swift +48 -0
  63. package/vendor/VibesPush/Sources/URLRequest+cURL.swift +36 -0
  64. package/vendor/VibesPush/Sources/UserDefaultsStorage.swift +32 -0
  65. package/vendor/VibesPush/Sources/Vibes.swift +1069 -0
  66. package/vendor/VibesPush/Sources/VibesAPI.swift +81 -0
  67. package/vendor/VibesPush/Sources/VibesAPIDelegate.swift +41 -0
  68. package/vendor/VibesPush/Sources/VibesAppInfo.swift +77 -0
  69. package/vendor/VibesPush/Sources/VibesConfiguration.swift +108 -0
  70. package/vendor/VibesPush/Sources/VibesLogger.swift +65 -0
  71. package/vendor/VibesPush/Sources/VibesResult.swift +78 -0
  72. package/vibes-react-native.podspec +6 -2
@@ -0,0 +1,103 @@
1
+ //
2
+ // Product.swift
3
+ // VibesPush
4
+ //
5
+ // Created by Moin' Victor on 11/08/2022.
6
+ // Copyright © 2022 Vibes. All rights reserved.
7
+ //
8
+
9
+ import Foundation
10
+
11
+ @objcMembers
12
+ public class Product: NSObject, JSONDecodable, LocalObjectType {
13
+ public var attributes: [String: Any] {
14
+ return [
15
+ "id": id ?? "",
16
+ "price": price ?? "",
17
+ "name": name ?? "",
18
+ "brand": brand ?? "",
19
+ "category": category ?? "",
20
+ "variant": variant ?? "",
21
+ "quantity": quantity ?? "",
22
+ "coupon": coupon ?? "",
23
+ "position": position ?? "",
24
+ ]
25
+ }
26
+
27
+ public var id: String?
28
+ public var price: Double?
29
+ public var name: String?
30
+ public var brand: String?
31
+ public var category: String?
32
+ public var variant: String?
33
+ public var quantity: String?
34
+ public var coupon: String?
35
+ public var position: String?
36
+
37
+ override init() {
38
+ }
39
+
40
+ /// Initialize for testing
41
+ ///
42
+ public init(id: String, price: Double, name: String, brand: String,
43
+ category: String, variant: String, quantity: String, coupon: String,
44
+ position: String) {
45
+ self.id = id
46
+ self.price = price
47
+ self.name = name
48
+ self.brand = brand
49
+ self.category = category
50
+ self.variant = variant
51
+ self.quantity = quantity
52
+ self.coupon = coupon
53
+ self.position = position
54
+ }
55
+
56
+ /// Initialize this object using JSONObject
57
+ ///
58
+ /// - Parameter json: The JSONObject
59
+ required convenience init?(json: VibesJSONDictionary) {
60
+ self.init()
61
+
62
+ guard let id = json["id"] as? String else { return nil }
63
+ self.id = id
64
+ name = json["name"] as? String
65
+ price = json["price"] as? Double
66
+ brand = json["brand"] as? String
67
+ category = json["category"] as? String
68
+ variant = json["variant"] as? String
69
+ quantity = json["quantity"] as? String
70
+ coupon = json["coupon"] as? String
71
+ position = json["position"] as? String
72
+
73
+ }
74
+
75
+ /// Initialize this object using Attributes
76
+ ///
77
+ /// - Parameter attributes: - The dictionary with attributes
78
+ public required convenience init?(attributes: [String: Any]) {
79
+ self.init()
80
+ guard let id = attributes["id"] as? String,
81
+ !id.isEmpty else { return nil }
82
+
83
+ self.id = id
84
+ name = attributes["name"] as? String
85
+ price = attributes["price"] as? Double
86
+ brand = attributes["brand"] as? String
87
+ category = attributes["category"] as? String
88
+ variant = attributes["variant"] as? String
89
+ quantity = attributes["quantity"] as? String
90
+ coupon = attributes["coupon"] as? String
91
+ position = attributes["position"] as? String
92
+ }
93
+ }
94
+
95
+ /// Equals Comparison operator for Product
96
+ ///
97
+ /// - Parameters:
98
+ /// - lhs: The left hand side Product
99
+ /// - rhs: The right hand side Product
100
+ /// - Returns: `True` if `lhs` is equal to `rhs`, else returns `False`
101
+ public func == (lhs: Product, rhs: Product) -> Bool {
102
+ return lhs.id == rhs.id
103
+ }
@@ -0,0 +1,108 @@
1
+ //
2
+ // Purchase.swift
3
+ // VibesPush
4
+ //
5
+ // Created by Clement Wekesa on 19/08/2022.
6
+ // Copyright © 2022 Vibes. All rights reserved.
7
+ //
8
+
9
+ import Foundation
10
+
11
+ @objcMembers
12
+ public class Purchase: NSObject, JSONDecodable, LocalObjectType {
13
+ public var attributes: [String: Any] {
14
+ return [
15
+ "id": id ?? "",
16
+ "affiliation": affiliation ?? "",
17
+ "revenue": revenue ?? "",
18
+ "tax": tax ?? "",
19
+ "shipping": shipping ?? "",
20
+ "coupon": coupon ?? "",
21
+ "list": list ?? "",
22
+ "step": step ?? "",
23
+ "option": option ?? "",
24
+ "products": products ?? "",
25
+ ]
26
+ }
27
+
28
+ public var id: String?
29
+ public var affiliation: String?
30
+ public var revenue: Double?
31
+ public var tax: Double?
32
+ public var shipping: Double?
33
+ public var coupon: Double?
34
+ public var list: String?
35
+ public var step: String?
36
+ public var option: String?
37
+ public var products: [Product]?
38
+
39
+ override init() {
40
+ }
41
+
42
+ /// Initialize for testing
43
+ ///
44
+ public init(id: String, affiliation: String, revenue: Double, tax: Double,
45
+ shipping: Double, coupon: Double, list: String, step: String,
46
+ option: String, products: [Product]) {
47
+ self.id = id
48
+ self.affiliation = affiliation
49
+ self.revenue = revenue
50
+ self.tax = tax
51
+ self.shipping = shipping
52
+ self.coupon = coupon
53
+ self.list = list
54
+ self.step = step
55
+ self.option = option
56
+ self.products = products
57
+ }
58
+
59
+ /// Initialize this object using JSONObject
60
+ ///
61
+ /// - Parameter json: The JSONObject
62
+ required convenience init?(json: VibesJSONDictionary) {
63
+ self.init()
64
+
65
+ guard let id = json["id"] as? String else { return nil }
66
+ self.id = id
67
+ affiliation = json["affiliation"] as? String
68
+ revenue = json["revenue"] as? Double
69
+ tax = json["tax"] as? Double
70
+ shipping = json["shipping"] as? Double
71
+ coupon = json["coupon"] as? Double
72
+ list = json["list"] as? String
73
+ step = json["step"] as? String
74
+ option = json["option"] as? String
75
+ products = json["products"] as? [Product]
76
+
77
+ }
78
+
79
+ /// Initialize this object using Attributes
80
+ ///
81
+ /// - Parameter attributes: - The dictionary with attributes
82
+ public required convenience init?(attributes: [String: Any]) {
83
+ self.init()
84
+ guard let id = attributes["id"] as? String,
85
+ !id.isEmpty else { return nil }
86
+
87
+ self.id = id
88
+ affiliation = attributes["affiliation"] as? String
89
+ revenue = attributes["revenue"] as? Double
90
+ tax = attributes["tax"] as? Double
91
+ shipping = attributes["shipping"] as? Double
92
+ coupon = attributes["coupon"] as? Double
93
+ list = attributes["list"] as? String
94
+ step = attributes["step"] as? String
95
+ option = attributes["option"] as? String
96
+ products = attributes["products"] as? [Product]
97
+ }
98
+ }
99
+
100
+ /// Equals Comparison operator for Product
101
+ ///
102
+ /// - Parameters:
103
+ /// - lhs: The left hand side Product
104
+ /// - rhs: The right hand side Product
105
+ /// - Returns: `True` if `lhs` is equal to `rhs`, else returns `False`
106
+ public func == (lhs: Purchase, rhs: Purchase) -> Bool {
107
+ return lhs.id == rhs.id
108
+ }
@@ -0,0 +1,48 @@
1
+ /// An enum to indicate the type of events that should be reported to Vibes.
2
+ import Foundation
3
+
4
+ @objc public enum TrackedEventType: Int {
5
+ /// Undefined case, since we parse a string in the convert method
6
+ case undefined
7
+
8
+ /// A launch event, tracked when the app is first opened
9
+ case launch
10
+
11
+ /// A clickthru event, tracked when the app is opened from a push
12
+ /// notification
13
+ case clickthru
14
+
15
+ // A inbox open event, tracked when inbox message is clicked
16
+ case inboxopen
17
+
18
+ // Inbox messages fetched event, tracked when inbox messages are fetched or refetched
19
+ case inboxfetch
20
+
21
+ // Push receive event, tracked when push message is received in device
22
+ case pushReceive
23
+
24
+ /// The set of all known events
25
+ public static let all: [TrackedEventType] = [.launch, .clickthru, .inboxopen, .inboxfetch, .pushReceive]
26
+
27
+ func name() -> String {
28
+ switch self {
29
+ case .launch: return "launch"
30
+ case .clickthru: return "clickthru"
31
+ case .inboxopen: return "inbox_open"
32
+ case .inboxfetch: return "inbox_fetch"
33
+ case .pushReceive: return "push_receive"
34
+ case .undefined: return "undefined"
35
+ }
36
+ }
37
+
38
+ public static func convert(rawValue: String) -> TrackedEventType {
39
+ switch rawValue {
40
+ case "launch": return .launch
41
+ case "clickthru": return .clickthru
42
+ case "inbox_open": return .inboxopen
43
+ case "inbox_fetch": return .inboxfetch
44
+ case "push_receive": return .pushReceive
45
+ default: return .undefined
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,36 @@
1
+ import Foundation
2
+
3
+ extension URLRequest {
4
+ /// Represents an HTTP request as a copy-and-pasteable string that can be used with cURL.
5
+ public var urlDescription: String {
6
+ if let url = url?.absoluteString {
7
+ return url
8
+ }
9
+ return "[-]"
10
+ }
11
+
12
+ public var methodDescription: String {
13
+ if let method = httpMethod, method != "GET" && method != "HEAD" {
14
+ return method
15
+ }
16
+ return "[-]"
17
+ }
18
+
19
+ public var headerFieldsDescription: String {
20
+ var result = ""
21
+ if let headers = allHTTPHeaderFields {
22
+ for (key, value) in headers {
23
+ result.append("[\(key) : '\(value)']")
24
+ }
25
+ return result
26
+ }
27
+ return "[-]"
28
+ }
29
+
30
+ public var bodyDescription: String {
31
+ if let body = httpBodyStream?.readToString() {
32
+ return body
33
+ }
34
+ return "[-]"
35
+ }
36
+ }
@@ -0,0 +1,32 @@
1
+ // NOTE: This is probably not worth shipping, but has been included here as a
2
+ // proof-of-concept (and was useful in developing the local storage protocols).
3
+ import Foundation
4
+ /// A storage adapter that uses UserDefaults as a local storage mechanism.
5
+ struct UserDefaultsStorage {
6
+ /// The defaults object to use for storage
7
+ fileprivate let defaults: UserDefaults
8
+
9
+ /// Initialize this object.
10
+ /// - parameters:
11
+ /// - defaults: the defaults object to use for storage
12
+ init(defaults: UserDefaults = UserDefaults.standard) {
13
+ self.defaults = defaults
14
+ }
15
+ }
16
+
17
+ extension UserDefaultsStorage: LocalStorageType {
18
+ func get<T>(_ item: LocalValue<T>) -> T? {
19
+ return defaults.object(forKey: item.key) as? T
20
+ }
21
+
22
+ func set<T>(_ value: T?, for item: LocalValue<T>) -> Bool {
23
+ if let value = value {
24
+ defaults.set(value, forKey: item.key)
25
+ } else {
26
+ defaults.removeObject(forKey: item.key)
27
+ }
28
+ defaults.synchronize()
29
+
30
+ return true
31
+ }
32
+ }