Skip to content

Commit

Permalink
Merge branch 'issue/14522-fetch-cached-packages' into issue/14522-edi…
Browse files Browse the repository at this point in the history
…t-selected-package
  • Loading branch information
rachelmcr committed Dec 19, 2024
2 parents ae2fca9 + 7a09bb7 commit b16aa65
Show file tree
Hide file tree
Showing 129 changed files with 3,157 additions and 710 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/screenshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ jobs:

steps:
- name: "Check out Project"
uses: actions/checkout@v1
uses: actions/checkout@v4
- name: "Set up Ruby"
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Restore CocoaPods Dependency Cache
id: restore-cocoapods-dependency-cache
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: Pods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
Expand All @@ -37,13 +37,13 @@ jobs:
run: bundle exec fastlane build_screenshots

- name: Archive App
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: screenshot-app
path: fastlane/DerivedData/Build/Products/Debug-iphonesimulator/WooCommerce.app

- name: Archive Runner
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: screenshot-runner
path: fastlane/DerivedData/Build/Products/Debug-iphonesimulator/WooCommerceScreenshots-Runner.app
Expand All @@ -58,7 +58,7 @@ jobs:
language: [ar, de-DE, en-US, es-ES, fr-FR, he, id, it, ja, ko, nl-NL, pt-BR, ru, sv, tr, zh-Hans, zh-Hant]
mode: [dark, light]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: "Set up Ruby"
uses: ruby/setup-ruby@v1
with:
Expand All @@ -68,13 +68,13 @@ jobs:
run: bundle exec fastlane run configure_apply

- name: Download Screenshot App
uses: actions/download-artifact@v1
uses: actions/download-artifact@v4
with:
name: screenshot-app
path: fastlane/DerivedData/Build/Products/Debug-iphonesimulator/WooCommerce.app

- name: Download Screenshot Runner
uses: actions/download-artifact@v1
uses: actions/download-artifact@v4
with:
name: screenshot-runner
path: fastlane/DerivedData/Build/Products/Debug-iphonesimulator/WooCommerceScreenshots-Runner.app
Expand All @@ -85,7 +85,7 @@ jobs:
- name: Store Logs
if: always()
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: "screenshot-log-${{ matrix.language }}-${{ matrix.mode }}"
path: fastlane/logs
Expand All @@ -101,7 +101,7 @@ jobs:
runs-on: macos-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Install Native Dependencies
run: |
Expand Down Expand Up @@ -130,7 +130,7 @@ jobs:
aws s3 cp fastlane/screenshots/screenshots.html s3://$S3_BUCKET/$GITHUB_RUN_ID/screenshots/screenshots.html
- name: Archive Raw Screenshots
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: raw-screenshots
path: fastlane/screenshots
Expand Down Expand Up @@ -159,7 +159,7 @@ jobs:
bundle exec fastlane create_promo_screenshots force:true
- name: Archive Promo Screenshots
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: promo-screenshots
path: fastlane/promo_screenshots
8 changes: 6 additions & 2 deletions Experiments/Experiments/DefaultFeatureFlagService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,17 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
case .paymentsOnboardingInPointOfSale:
return true
case .sendReceiptAfterPayment:
return false
return true
case .sendReceiptsForPointOfSale:
return true
case .acceptCashForPointOfSale:
return false
case .tapToPayEducation:
return false
return true
case .variableProductsInPointOfSale:
return buildConfig == .localDeveloper || buildConfig == .alpha
case .hideSitesInStorePicker:
return buildConfig == .localDeveloper || buildConfig == .alpha
default:
return true
}
Expand Down
8 changes: 8 additions & 0 deletions Experiments/Experiments/FeatureFlag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,19 @@ public enum FeatureFlag: Int {
///
case sendReceiptsForPointOfSale

/// Adds support for accepting cash as payment for POS
///
case acceptCashForPointOfSale

/// Enables new Tap to Pay onboarding and education features
///
case tapToPayEducation

/// Supports variable products in POS.
///
case variableProductsInPointOfSale

/// Supports hiding sites from the store picker
///
case hideSitesInStorePicker
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Codegen
/// The status of shipping label refund.
public enum ShippingLabelRefundStatus: GeneratedFakeable {
case pending
case unknown
}

/// RawRepresentable Conformance
Expand All @@ -15,8 +16,8 @@ extension ShippingLabelRefundStatus: RawRepresentable {
case Keys.pending:
self = .pending
default:
assertionFailure("Unexpected value for `ShippingLabelRefundStatus`: \(rawValue)")
self = .pending
DDLogError("⛔️ Unexpected value for `ShippingLabelRefundStatus`: \(rawValue)")
self = .unknown
}
}

Expand All @@ -26,6 +27,8 @@ extension ShippingLabelRefundStatus: RawRepresentable {
switch self {
case .pending:
return Keys.pending
case .unknown:
return ""
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public enum ShippingLabelStatus: GeneratedFakeable {
case purchased
case purchaseError
case purchaseInProgress
case unknown
}

/// RawRepresentable Conformance
Expand All @@ -21,8 +22,8 @@ extension ShippingLabelStatus: RawRepresentable {
case Keys.purchaseError:
self = .purchaseError
default:
assertionFailure("Unexpected value for `ShippingLabelStatus`: \(rawValue)")
self = .purchased
DDLogError("⛔️ Unexpected value for `ShippingLabelStatus`: \(rawValue)")
self = .unknown
}
}

Expand All @@ -36,6 +37,8 @@ extension ShippingLabelStatus: RawRepresentable {
return Keys.purchaseInProgress
case .purchaseError:
return Keys.purchaseError
case .unknown:
return ""
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Networking/Networking/Model/Site.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Codegen

/// Represents a WordPress.com Site.
///
public struct Site: Decodable, Equatable, GeneratedFakeable, GeneratedCopiable {
public struct Site: Decodable, Equatable, Hashable, GeneratedFakeable, GeneratedCopiable {

/// WordPress.com Site Identifier.
///
Expand Down
44 changes: 42 additions & 2 deletions Networking/Networking/Remote/ProductVariationsRemote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ public protocol ProductVariationsRemoteProtocol {
pageNumber: Int,
pageSize: Int,
completion: @escaping ([ProductVariation]?, Error?) -> Void)
func loadVariationsForPointOfSale(for siteID: Int64,
parentProductID: Int64,
pageNumber: Int,
pageSize: Int) async throws -> [ProductVariation]
func loadProductVariation(for siteID: Int64, productID: Int64, variationID: Int64, completion: @escaping (Result<ProductVariation, Error>) -> Void)
func createProductVariation(for siteID: Int64,
productID: Int64,
Expand Down Expand Up @@ -57,6 +61,43 @@ public class ProductVariationsRemote: Remote, ProductVariationsRemoteProtocol {
pageNumber: Int = Default.pageNumber,
pageSize: Int = Default.pageSize,
completion: @escaping ([ProductVariation]?, Error?) -> Void) {
let request = productVariationsRequest(for: siteID,
productID: productID,
variationIDs: variationIDs,
context: context,
pageNumber: pageNumber,
pageSize: pageSize)
let mapper = ProductVariationListMapper(siteID: siteID, productID: productID)
enqueue(request, mapper: mapper, completion: completion)
}

/// Retrieves all of the `ProductVariation`s available in POS.
/// - Parameters:
/// - siteID: Site for which we'll fetch remote product variations.
/// - parentProductID: Product for which we'll fetch remote product variations.
/// - pageNumber: Number of page that should be retrieved.
/// - pageSize: Number of product variations to be retrieved per page.
/// - Returns: Variations for the provided parent product.
public func loadVariationsForPointOfSale(for siteID: Int64,
parentProductID: Int64,
pageNumber: Int = Default.pageNumber,
pageSize: Int = Default.pageSize) async throws -> [ProductVariation] {
let request = productVariationsRequest(for: siteID,
productID: parentProductID,
variationIDs: [],
context: nil,
pageNumber: pageNumber,
pageSize: pageSize)
let mapper = ProductVariationListMapper(siteID: siteID, productID: parentProductID)
return try await enqueue(request, mapper: mapper)
}

private func productVariationsRequest(for siteID: Int64,
productID: Int64,
variationIDs: [Int64],
context: String?,
pageNumber: Int,
pageSize: Int) -> JetpackRequest {
let stringOfVariationIDs = variationIDs.map { String($0) }
.joined(separator: ",")
let parameters = [
Expand All @@ -74,8 +115,7 @@ public class ProductVariationsRemote: Remote, ProductVariationsRemoteProtocol {
path: path,
parameters: parameters,
availableAsRESTRequest: true)
let mapper = ProductVariationListMapper(siteID: siteID, productID: productID)
enqueue(request, mapper: mapper, completion: completion)
return request
}

/// Retrieves a specific `ProductVariation`.
Expand Down
24 changes: 24 additions & 0 deletions Networking/Networking/Remote/WooShippingRemote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ public protocol WooShippingRemoteProtocol {
customPackage: WooShippingCustomPackage?,
predefinedOption: WooShippingPredefinedSavedOption?,
completion: @escaping (Result<WooShippingCreatePackageResponse, Error>) -> Void)
func deletePackage(siteID: Int64,
packageID: String,
completion: @escaping (Result<WooShippingCreatePackageResponse, Error>) -> Void)
func loadLabelRates(siteID: Int64,
orderID: Int64,
originAddress: ShippingLabelAddress,
Expand Down Expand Up @@ -78,6 +81,27 @@ public final class WooShippingRemote: Remote, WooShippingRemoteProtocol {
}
}

public func deletePackage(siteID: Int64,
packageID: String,
completion: @escaping (Result<WooShippingCreatePackageResponse, Error>) -> Void) {
do {
let path = "\(Path.packages)/\(packageID)"

let request = JetpackRequest(wooApiVersion: .wooShipping,
method: .delete,
siteID: siteID,
path: path,
parameters: nil,
availableAsRESTRequest: true)

let mapper = WooShippingCreatePackageMapper()

enqueue(request, mapper: mapper, completion: completion)
} catch {
completion(.failure(error))
}
}

/// Loads shipping rates for a given order.
/// - Parameters:
/// - siteID: Remote ID of the site.
Expand Down
Loading

0 comments on commit b16aa65

Please sign in to comment.