Commit 5b232920 authored by Jose Blaya's avatar Jose Blaya
Browse files

method to access the messages from the account provider

parent 979f2bb8
......@@ -248,8 +248,6 @@
82C374FB2514DEC700E391EE /* EndpointManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82C374FA2514DEC700E391EE /* EndpointManager.swift */; };
82CAB808255A9ACB00BB08EF /* InAppMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82CAB807255A9ACB00BB08EF /* InAppMessage.swift */; };
82CAB809255A9ACB00BB08EF /* InAppMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82CAB807255A9ACB00BB08EF /* InAppMessage.swift */; };
82CAB86A255AE6F100BB08EF /* Client+Messages.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82CAB869255AE6F100BB08EF /* Client+Messages.swift */; };
82CAB86B255AE6F100BB08EF /* Client+Messages.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82CAB869255AE6F100BB08EF /* Client+Messages.swift */; };
82DDD5302539CFDC0049E79E /* DIPTokenKeychainTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82DDD52F2539CFDC0049E79E /* DIPTokenKeychainTests.swift */; };
82E20B1124F652ED0065EFE3 /* AccountInfo+Kotlin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82E20B1024F652ED0065EFE3 /* AccountInfo+Kotlin.swift */; };
82E20B1224F652ED0065EFE3 /* AccountInfo+Kotlin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82E20B1024F652ED0065EFE3 /* AccountInfo+Kotlin.swift */; };
......@@ -573,7 +571,6 @@
82C374F62514DC7200E391EE /* server.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = server.json; sourceTree = "<group>"; };
82C374FA2514DEC700E391EE /* EndpointManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EndpointManager.swift; sourceTree = "<group>"; };
82CAB807255A9ACB00BB08EF /* InAppMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InAppMessage.swift; sourceTree = "<group>"; };
82CAB869255AE6F100BB08EF /* Client+Messages.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Client+Messages.swift"; sourceTree = "<group>"; };
82DDD52F2539CFDC0049E79E /* DIPTokenKeychainTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DIPTokenKeychainTests.swift; sourceTree = "<group>"; };
82E20B1024F652ED0065EFE3 /* AccountInfo+Kotlin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AccountInfo+Kotlin.swift"; sourceTree = "<group>"; };
82E20B1524F6AA110065EFE3 /* RegionData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegionData.swift; sourceTree = "<group>"; };
......@@ -1117,7 +1114,6 @@
0EBBC6DB1F9F64E700B8BD21 /* Client+Environment.swift */,
0ED2B5121F82444E00C9DB2B /* Client+Preferences.swift */,
0EF14E4A1FEAE6350007485A /* Client+Providers.swift */,
82CAB869255AE6F100BB08EF /* Client+Messages.swift */,
0EE78AEF1F818767002E4CDD /* ClientError.swift */,
0EE261DF1FEFD69F00E11955 /* Notification+Library.swift */,
);
......@@ -1725,7 +1721,6 @@
0E2ADCEA1FE0843000BB170C /* Macros+Pinger.swift in Sources */,
0E7BC6F71F96B1120035C8B2 /* WebServices.swift in Sources */,
0E7BC6E71F96B1000035C8B2 /* ClientError.swift in Sources */,
82CAB86B255AE6F100BB08EF /* Client+Messages.swift in Sources */,
0E53A8541FE5D73F000C2A18 /* Client+Mock.swift in Sources */,
0E2ADCDE1FE072ED00BB170C /* Pinger.m in Sources */,
0EB9667F1FDF36490086ABC2 /* GlossParser.swift in Sources */,
......@@ -1942,7 +1937,6 @@
DDFCFAB021E925B60081F235 /* Tileable.swift in Sources */,
0E4D4EA01FA4CA7A007DA6DA /* Validator.swift in Sources */,
0E0E5B111F8297D200022CD0 /* UserDefaultsStore.swift in Sources */,
82CAB86A255AE6F100BB08EF /* Client+Messages.swift in Sources */,
0E3D13D61F9E272B00434A48 /* GlossPayment.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
......
......@@ -144,7 +144,13 @@ public protocol AccountProvider: class {
*/
func featureFlags(_ callback: SuccessLibraryCallback?)
/**
Returns the available messages from the API.
- Parameter callback: Returns `nil` on success.
*/
func inAppMessages(_ callback: SuccessLibraryCallback?)
#if os(iOS)
/**
Lists the available plans with their corresponding product to purchase in order to get them.
......
......@@ -72,4 +72,7 @@ protocol WebServices: class {
func featureFlags(_ callback: LibraryCallback<[String]>?)
// MARK: Messages
func messages(_ callback: SuccessLibraryCallback?)
}
......@@ -328,6 +328,12 @@ class DefaultAccountProvider: AccountProvider, ConfigurationAccess, DatabaseAcce
}
}
func inAppMessages(_ callback: SuccessLibraryCallback?) {
webServices.messages { (error) in
callback?(nil)
}
}
#if os(iOS)
func subscriptionInformation(_ callback: LibraryCallback<AppStoreInformation>?) {
log.debug("Fetching available product keys...")
......
//
// Client+Messages.swift
// PIALibrary
//
// Created by Jose Blaya on 10/11/2020.
// Copyright © 2020 Private Internet Access, Inc.
//
// This file is part of the Private Internet Access iOS Client.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
import Foundation
......@@ -309,4 +309,8 @@ public class MockAccountProvider: AccountProvider, WebServicesConsumer {
public func featureFlags(_ callback: SuccessLibraryCallback?) {
callback?(nil)
}
public func inAppMessages(_ callback: SuccessLibraryCallback?) {
callback?(nil)
}
}
......@@ -134,5 +134,8 @@ class MockWebServices: WebServices {
func featureFlags(_ callback: LibraryCallback<[String]>?) {
callback?(["mock-test"], nil)
}
func messages(_ callback: SuccessLibraryCallback?) {
callback?(nil)
}
}
......@@ -434,4 +434,8 @@ class EphemeralAccountProvider: AccountProvider, ProvidersAccess, InAppAccess {
callback?(nil)
}
func inAppMessages(_ callback: SuccessLibraryCallback?) {
callback?(nil)
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment