Skip to content
1 change: 1 addition & 0 deletions Modules/Sources/Yosemite/Model/Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public typealias FallibleCancelable = Hardware.FallibleCancelable
public typealias CommentStatus = Networking.CommentStatus
public typealias CompositeComponentOptionType = Networking.CompositeComponentOptionType
public typealias Coupon = Networking.Coupon
public typealias CouponDiscountType = Networking.Coupon.DiscountType
public typealias CouponReport = Networking.CouponReport
public typealias Country = Networking.Country
public typealias CreateAccountResult = Networking.CreateAccountResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public protocol PointOfSaleCouponFetchStrategy {
func fetchLocalCoupons() async throws -> [POSItem]
}

public struct PointOfSaleDefaultCouponFetchStrategy: PointOfSaleCouponFetchStrategy {
struct PointOfSaleDefaultCouponFetchStrategy: PointOfSaleCouponFetchStrategy {
private let siteID: Int64
private let currencySettings: CurrencySettings
private let storage: StorageManagerType
Expand All @@ -24,7 +24,7 @@ public struct PointOfSaleDefaultCouponFetchStrategy: PointOfSaleCouponFetchStrat
self.couponStoreMethods = couponStoreMethods
}

public func fetchCoupons(pageNumber: Int) async throws -> PagedItems<POSItem> {
func fetchCoupons(pageNumber: Int) async throws -> PagedItems<POSItem> {
// Update local storage with data from the remote
let hasMorePages = try await syncCouponsFromRemote(pageNumber: pageNumber)
// Return all local coupons, including updated ones from the remote
Expand All @@ -35,7 +35,7 @@ public struct PointOfSaleDefaultCouponFetchStrategy: PointOfSaleCouponFetchStrat
/// fetchLocalCoupons provides an array of coupons that are stored locally
/// It does not accept any sort of pagination
/// Limited to default page size to match remote results
public func fetchLocalCoupons() async throws -> [POSItem] {
func fetchLocalCoupons() async throws -> [POSItem] {
return await fetchLocalCoupons(limit: Constants.defaultPageSize)
}
}
Expand Down Expand Up @@ -66,7 +66,7 @@ extension PointOfSaleDefaultCouponFetchStrategy {

// MARK: - Search Coupon Strategy

public struct PointOfSaleSearchCouponFetchStrategy: PointOfSaleCouponFetchStrategy {
struct PointOfSaleSearchCouponFetchStrategy: PointOfSaleCouponFetchStrategy {
private let siteID: Int64
private let couponStoreMethods: CouponStoreMethodsProtocol
private let storage: StorageManagerType
Expand All @@ -89,7 +89,7 @@ public struct PointOfSaleSearchCouponFetchStrategy: PointOfSaleCouponFetchStrate
self.analytics = analytics
}

public func fetchCoupons(pageNumber: Int) async throws -> PagedItems<POSItem> {
func fetchCoupons(pageNumber: Int) async throws -> PagedItems<POSItem> {
let startTime = Date()
try await couponStoreMethods.searchCoupons(siteID: siteID,
keyword: searchTerm,
Expand All @@ -116,7 +116,7 @@ public struct PointOfSaleSearchCouponFetchStrategy: PointOfSaleCouponFetchStrate
return resultsController.fetchCoupons(predicate: predicate)
}

public func fetchLocalCoupons() async throws -> [POSItem] {
func fetchLocalCoupons() async throws -> [POSItem] {
// No support for returning local search results
return []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import class Networking.AlamofireNetwork
import struct Combine.AnyPublisher
import struct NetworkingCore.JetpackSite

public struct PointOfSaleCouponFetchStrategyFactory {
public protocol PointOfSaleCouponFetchStrategyFactoryProtocol {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: a protocol was created so that StorageManagerType, a dependency of PointOfSaleCouponFetchStrategyFactory, does not need to be known in the future POS module.

var defaultStrategy: PointOfSaleCouponFetchStrategy { get }
func searchStrategy(searchTerm: String, analytics: POSItemFetchAnalyticsTracking) -> PointOfSaleCouponFetchStrategy
}

public struct PointOfSaleCouponFetchStrategyFactory: PointOfSaleCouponFetchStrategyFactoryProtocol {
private let siteID: Int64
private let currencySettings: CurrencySettings
private let storage: StorageManagerType
Expand All @@ -28,14 +33,14 @@ public struct PointOfSaleCouponFetchStrategyFactory {
self.couponStoreMethods = CouponStoreMethods(storageManager: storage, remote: remote)
}

public var defaultStrategy: PointOfSaleDefaultCouponFetchStrategy {
public var defaultStrategy: PointOfSaleCouponFetchStrategy {
PointOfSaleDefaultCouponFetchStrategy(siteID: siteID,
currencySettings: currencySettings,
storage: storage,
couponStoreMethods: couponStoreMethods)
}

public func searchStrategy(searchTerm: String, analytics: POSItemFetchAnalyticsTracking) -> PointOfSaleSearchCouponFetchStrategy {
public func searchStrategy(searchTerm: String, analytics: POSItemFetchAnalyticsTracking) -> PointOfSaleCouponFetchStrategy {
PointOfSaleSearchCouponFetchStrategy(siteID: siteID,
currencySettings: currencySettings,
storage: storage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ public protocol PointOfSaleItemFetchStrategyFactoryProtocol {

func searchStrategy(searchTerm: String,
analytics: POSItemFetchAnalyticsTracking) -> PointOfSalePurchasableItemFetchStrategy

func popularStrategy(pageSize: Int) -> PointOfSalePurchasableItemFetchStrategy
}

public final class PointOfSaleItemFetchStrategyFactory: PointOfSaleItemFetchStrategyFactoryProtocol {
Expand Down Expand Up @@ -69,8 +67,4 @@ public final class PointOfSaleFixedItemFetchStrategyFactory: PointOfSaleItemFetc
analytics: POSItemFetchAnalyticsTracking) -> PointOfSalePurchasableItemFetchStrategy {
fixedStrategy
}

public func popularStrategy(pageSize: Int) -> PointOfSalePurchasableItemFetchStrategy {
fixedStrategy
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
protocol POSCollectOrderPaymentAnalyticsTracking {
public protocol POSCollectOrderPaymentAnalyticsTracking {
func trackCustomerInteractionStarted()
func trackOrderSyncSuccess()
func trackCardReaderReady()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

struct CardPresentPaymentCardReader: Equatable {
public struct CardPresentPaymentCardReader: Equatable {
let name: String

/// The reader's battery level, if available.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

enum CardPresentPaymentEvent {
public enum CardPresentPaymentEvent {
case idle
case show(eventDetails: CardPresentPaymentEventDetails)
case showOnboarding(factory: CardPresentPaymentOnboardingViewContainer, onCancel: () -> Void)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import struct Yosemite.CardReaderInput

enum CardPresentPaymentEventDetails {
public enum CardPresentPaymentEventDetails {
case scanningForReaders(endSearch: () -> Void)
case scanningFailed(error: Error,
endSearch: () -> Void)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import enum Yosemite.PaymentChannel
import struct Yosemite.Order
import Combine

protocol CardPresentPaymentFacade {
public protocol CardPresentPaymentFacade {
/// `paymentEventPublisher` provides a stream of events relating to a payment, including their view models,
/// for subscribers to display to the user. e.g. onboarding screens, connection progress, payment progress, card reader messages.
/// This is a long lasting stream, and will not finish during the life of the façade, instead it will publish events for each payment attempt.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

enum CardPresentPaymentReaderConnectionResult {
public enum CardPresentPaymentReaderConnectionResult {
case connected(CardPresentPaymentCardReader)
case canceled
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

enum CardPresentPaymentReaderConnectionStatus: Equatable {
public enum CardPresentPaymentReaderConnectionStatus: Equatable {
case disconnected
case connected(CardPresentPaymentCardReader)
case cancellingConnection
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

enum CardPresentPaymentResult {
public enum CardPresentPaymentResult {
case success(CardPresentPaymentTransaction)
case cancellation
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

/// A completed, paid transaction.
struct CardPresentPaymentTransaction {
public struct CardPresentPaymentTransaction {
let receiptURL: URL
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import enum Yosemite.CardReaderServiceError
import enum Yosemite.CardReaderServiceUnderlyingError

enum CardPresentPaymentRetryApproach {
public enum CardPresentPaymentRetryApproach {
case dontRetry
case tryAgain(retryAction: () -> Void)
case tryAnotherPaymentMethod(retryAction: () -> Void)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

enum CardReaderConnectionMethod {
public enum CardReaderConnectionMethod {
case bluetooth
case tapToPay
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SwiftUI

protocol POSEntryPointEligibilityCheckerProtocol {
public protocol POSEntryPointEligibilityCheckerProtocol {
/// Determines whether the site is eligible for POS.
func checkEligibility() async -> POSEligibilityState
/// Refreshes the eligibility state based on the provided ineligible reason.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Observation
import enum Yosemite.POSItem
import enum Yosemite.PointOfSaleCouponServiceError
import protocol Yosemite.PointOfSaleItemServiceProtocol
import protocol Yosemite.PointOfSaleCouponFetchStrategyFactoryProtocol
import protocol Yosemite.PointOfSaleCouponServiceProtocol
import struct Yosemite.PointOfSaleCouponFetchStrategyFactory
import protocol Yosemite.PointOfSaleCouponFetchStrategy
Expand All @@ -19,12 +20,12 @@ protocol PointOfSaleCouponsControllerProtocol: PointOfSaleSearchingItemsControll
private let paginationTracker: AsyncPaginationTracker
private var childPaginationTrackers: [POSItem: AsyncPaginationTracker] = [:]
private let couponProvider: PointOfSaleCouponServiceProtocol
private let fetchStrategyFactory: PointOfSaleCouponFetchStrategyFactory
private let fetchStrategyFactory: PointOfSaleCouponFetchStrategyFactoryProtocol
private var fetchStrategy: PointOfSaleCouponFetchStrategy
private let analyticsProvider: POSAnalyticsProviding

init(itemProvider: PointOfSaleCouponServiceProtocol,
fetchStrategyFactory: PointOfSaleCouponFetchStrategyFactory,
fetchStrategyFactory: PointOfSaleCouponFetchStrategyFactoryProtocol,
analyticsProvider: POSAnalyticsProviding) {
self.couponProvider = itemProvider
self.fetchStrategyFactory = fetchStrategyFactory
Expand Down
4 changes: 2 additions & 2 deletions WooCommerce/Classes/POS/Models/POSIneligibleReason.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import enum WooFoundation.CountryCode
import enum WooFoundation.CurrencyCode

/// Represents the reasons why a site may be ineligible for POS.
enum POSIneligibleReason: Equatable {
public enum POSIneligibleReason: Equatable {
case unsupportedWooCommerceVersion(minimumVersion: String)
case siteSettingsNotAvailable
case wooCommercePluginNotFound
Expand All @@ -13,7 +13,7 @@ enum POSIneligibleReason: Equatable {
}

/// Represents the eligibility state for POS.
enum POSEligibilityState: Equatable {
public enum POSEligibilityState: Equatable {
case eligible
case ineligible(reason: POSIneligibleReason)
}
Loading