Skip to content

Commit

Permalink
Merge branch 'develop' into issue/4598-add-payment-method-in-shipping…
Browse files Browse the repository at this point in the history
…-labels
  • Loading branch information
pmusolino committed Sep 13, 2021
2 parents 533ea27 + 6966ca1 commit 53012e8
Show file tree
Hide file tree
Showing 146 changed files with 8,059 additions and 1,010 deletions.
1 change: 1 addition & 0 deletions Fakes/Fakes/Fakes.generated.swift
Expand Up @@ -1179,6 +1179,7 @@ extension ShippingLabelPredefinedOption {
public static func fake() -> ShippingLabelPredefinedOption {
.init(
title: .fake(),
providerID: .fake(),
predefinedPackages: .fake()
)
}
Expand Down
42 changes: 22 additions & 20 deletions Gemfile.lock
Expand Up @@ -14,21 +14,21 @@ GEM
json (>= 1.5.1)
artifactory (3.0.15)
atomos (0.1.3)
aws-eventstream (1.1.1)
aws-partitions (1.484.0)
aws-sdk-core (3.119.0)
aws-eventstream (1.2.0)
aws-partitions (1.496.0)
aws-sdk-core (3.121.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-kms (1.46.0)
aws-sdk-core (~> 3, >= 3.119.0)
aws-sdk-kms (1.48.0)
aws-sdk-core (~> 3, >= 3.120.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.98.0)
aws-sdk-core (~> 3, >= 3.119.0)
aws-sdk-s3 (1.102.0)
aws-sdk-core (~> 3, >= 3.120.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.2.4)
aws-sigv4 (~> 1.4)
aws-sigv4 (1.4.0)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
bigdecimal (1.4.4)
Expand Down Expand Up @@ -89,7 +89,7 @@ GEM
ethon (0.14.0)
ffi (>= 1.15.0)
excon (0.85.0)
faraday (1.7.0)
faraday (1.7.1)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
Expand All @@ -113,8 +113,8 @@ GEM
faraday-rack (1.0.0)
faraday_middleware (1.1.0)
faraday (~> 1.0)
fastimage (2.2.4)
fastlane (2.191.0)
fastimage (2.2.5)
fastlane (2.193.1)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
Expand All @@ -140,6 +140,7 @@ GEM
mini_magick (>= 4.9.4, < 5.0.0)
multipart-post (~> 2.0.0)
naturally (~> 2.2)
optparse (~> 0.1.1)
plist (>= 3.1.0, < 4.0.0)
rubyzip (>= 2.0.0, < 3.0.0)
security (= 0.1.3)
Expand Down Expand Up @@ -182,7 +183,7 @@ GEM
gh_inspector (1.1.3)
git (1.9.1)
rchardet (~> 1.8)
google-apis-androidpublisher_v3 (0.10.0)
google-apis-androidpublisher_v3 (0.11.0)
google-apis-core (>= 0.4, < 2.a)
google-apis-core (0.4.1)
addressable (~> 2.5, >= 2.5.1)
Expand All @@ -193,7 +194,7 @@ GEM
retriable (>= 2.0, < 4.a)
rexml
webrick
google-apis-iamcredentials_v1 (0.6.0)
google-apis-iamcredentials_v1 (0.7.0)
google-apis-core (>= 0.4, < 2.a)
google-apis-playcustomapp_v1 (0.5.0)
google-apis-core (>= 0.4, < 2.a)
Expand All @@ -213,13 +214,13 @@ GEM
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
googleauth (0.17.0)
googleauth (0.17.1)
faraday (>= 0.17.3, < 2.0)
jwt (>= 1.4, < 3.0)
memoist (~> 0.16)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (~> 0.14)
signet (~> 0.15)
highline (2.0.3)
http-cookie (1.0.4)
domain_name (~> 0.5)
Expand All @@ -234,7 +235,7 @@ GEM
jwt (2.2.3)
memoist (0.16.2)
mini_magick (4.11.0)
mini_mime (1.1.0)
mini_mime (1.1.1)
minitest (5.14.4)
molinillo (0.6.6)
multi_json (1.15.0)
Expand All @@ -251,6 +252,7 @@ GEM
oj (3.13.0)
optimist (3.0.1)
options (2.3.2)
optparse (0.1.1)
os (1.1.1)
parallel (1.20.1)
plist (3.6.0)
Expand Down Expand Up @@ -278,8 +280,8 @@ GEM
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
security (0.1.3)
signet (0.15.0)
addressable (~> 2.3)
signet (0.16.0)
addressable (~> 2.8)
faraday (>= 0.17.3, < 2.0)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
Expand Down Expand Up @@ -344,4 +346,4 @@ DEPENDENCIES
xcpretty-travis-formatter

BUNDLED WITH
2.2.23
2.2.25
2 changes: 1 addition & 1 deletion Hardware/Hardware/CardReader/CardReaderServiceError.swift
Expand Up @@ -306,7 +306,7 @@ updating the application or using a different reader
return NSLocalizedString("The card reader session has expired - please disconnect and reconnect the card reader and then try again",
comment: "Error message when the card reader session has timed out.")
case .internalServiceError:
return NSLocalizedString("The system experienced an unexpected internal error - please try again",
return NSLocalizedString("Sorry, this payment couldn’t be processed",
comment: "Error message when the card reader service experiences an unexpected internal service error.")
}
}
Expand Down
40 changes: 39 additions & 1 deletion Networking/Networking/Model/Address.swift
Expand Up @@ -3,7 +3,7 @@ import Codegen

/// Represents an Address Entity.
///
public struct Address: Decodable, Equatable, GeneratedFakeable {
public struct Address: Decodable, GeneratedFakeable {
public let firstName: String
public let lastName: String
public let company: String?
Expand Down Expand Up @@ -69,8 +69,46 @@ public struct Address: Decodable, Equatable, GeneratedFakeable {
phone: phone,
email: email)
}

public static var empty: Address {
self.init(firstName: "",
lastName: "",
company: nil,
address1: "",
address2: nil,
city: "",
state: "",
postcode: "",
country: "",
phone: nil,
email: nil)
}
}

extension Address: Equatable {
// custom implementation to handle empty strings and `nil` comparison
public static func ==(lhs: Address, rhs: Address) -> Bool {
return lhs.firstName == rhs.firstName &&
lhs.lastName == rhs.lastName &&
(lhs.company == rhs.company ||
lhs.company == nil && rhs.company?.isEmpty == true ||
lhs.company?.isEmpty == true && rhs.company == nil) &&
lhs.address1 == rhs.address1 &&
(lhs.address2 == rhs.address2 ||
lhs.address2 == nil && rhs.address2?.isEmpty == true ||
lhs.address2?.isEmpty == true && rhs.address2 == nil) &&
lhs.city == rhs.city &&
lhs.state == rhs.state &&
lhs.postcode == rhs.postcode &&
lhs.country == rhs.country &&
(lhs.phone == rhs.phone ||
lhs.phone == nil && rhs.phone?.isEmpty == true ||
lhs.phone?.isEmpty == true && rhs.phone == nil) &&
(lhs.email == rhs.email ||
lhs.email == nil && rhs.email?.isEmpty == true ||
lhs.email?.isEmpty == true && rhs.email == nil)
}
}

/// Defines all of the Address's CodingKeys.
///
Expand Down
Expand Up @@ -1006,6 +1006,27 @@ extension ShippingLabelCustomsForm.Item {
}
}

extension ShippingLabelPackagesResponse {
public func copy(
storeOptions: CopiableProp<ShippingLabelStoreOptions> = .copy,
customPackages: CopiableProp<[ShippingLabelCustomPackage]> = .copy,
predefinedOptions: CopiableProp<[ShippingLabelPredefinedOption]> = .copy,
unactivatedPredefinedOptions: CopiableProp<[ShippingLabelPredefinedOption]> = .copy
) -> ShippingLabelPackagesResponse {
let storeOptions = storeOptions ?? self.storeOptions
let customPackages = customPackages ?? self.customPackages
let predefinedOptions = predefinedOptions ?? self.predefinedOptions
let unactivatedPredefinedOptions = unactivatedPredefinedOptions ?? self.unactivatedPredefinedOptions

return ShippingLabelPackagesResponse(
storeOptions: storeOptions,
customPackages: customPackages,
predefinedOptions: predefinedOptions,
unactivatedPredefinedOptions: unactivatedPredefinedOptions
)
}
}

extension ShippingLabelPaymentMethod {
public func copy(
paymentMethodID: CopiableProp<Int64> = .copy,
Expand Down
15 changes: 11 additions & 4 deletions Networking/Networking/Model/Product/ProductType.swift
Expand Up @@ -8,6 +8,7 @@ public enum ProductType: Codable, Hashable, GeneratedFakeable {
case grouped
case affiliate
case variable
case subscription
case custom(String) // in case there are extensions modifying product types
}

Expand All @@ -28,6 +29,8 @@ extension ProductType: RawRepresentable {
self = .affiliate
case Keys.variable:
self = .variable
case Keys.subscription:
self = .subscription
default:
self = .custom(rawValue)
}
Expand All @@ -41,6 +44,7 @@ extension ProductType: RawRepresentable {
case .grouped: return Keys.grouped
case .affiliate: return Keys.affiliate
case .variable: return Keys.variable
case .subscription: return Keys.subscription
case .custom(let payload): return payload
}
}
Expand All @@ -57,6 +61,8 @@ extension ProductType: RawRepresentable {
return NSLocalizedString("External/Affiliate", comment: "Display label for affiliate product type.")
case .variable:
return NSLocalizedString("Variable", comment: "Display label for variable product type.")
case .subscription:
return NSLocalizedString("Subscription", comment: "Display label for subscription product type.")
case .custom(let payload):
return payload // unable to localize at runtime.
}
Expand All @@ -67,8 +73,9 @@ extension ProductType: RawRepresentable {
/// Enum containing the 'Known' ProductType Keys
///
private enum Keys {
static let simple = "simple"
static let grouped = "grouped"
static let affiliate = "external"
static let variable = "variable"
static let simple = "simple"
static let grouped = "grouped"
static let affiliate = "external"
static let variable = "variable"
static let subscription = "subscription"
}
Expand Up @@ -8,12 +8,16 @@ public struct ShippingLabelPredefinedOption: Equatable, GeneratedFakeable {
/// The title of the predefined option. It works like an ID, and it is unique.
public let title: String

/// The ID of the predefined option (shipping provider), e.g. "usps". This is required for activating predefined packages remotely.
public let providerID: String

/// List of predefined packages
public let predefinedPackages: [ShippingLabelPredefinedPackage]


public init(title: String, predefinedPackages: [ShippingLabelPredefinedPackage]) {
public init(title: String, providerID: String, predefinedPackages: [ShippingLabelPredefinedPackage]) {
self.title = title
self.providerID = providerID
self.predefinedPackages = predefinedPackages
}
}
Expand All @@ -25,12 +29,14 @@ extension ShippingLabelPredefinedOption: Decodable {

let title = try container.decode(String.self, forKey: .title)
let predefinedPackages = try container.decodeIfPresent([ShippingLabelPredefinedPackage].self, forKey: .predefinedPackages) ?? []
let providerID = try container.decodeIfPresent(String.self, forKey: .providerID) ?? ""

self.init(title: title, predefinedPackages: predefinedPackages)
self.init(title: title, providerID: providerID, predefinedPackages: predefinedPackages)
}

private enum CodingKeys: String, CodingKey {
case title
case predefinedPackages
case providerID
}
}
Expand Up @@ -3,7 +3,7 @@ import Codegen

/// Represents a list of Shipping Label Packages (custom and predefined).
///
public struct ShippingLabelPackagesResponse: Equatable, GeneratedFakeable {
public struct ShippingLabelPackagesResponse: Equatable, GeneratedFakeable, GeneratedCopiable {

/// The options of the store, like currency symbol and origin country.
public let storeOptions: ShippingLabelStoreOptions
Expand Down Expand Up @@ -67,15 +67,15 @@ extension ShippingLabelPackagesResponse: Decodable {

if !activatedPredefinedPackages.isEmpty {
let titleOption: String = providerValueDict?["title"] as? String ?? ""
let option = ShippingLabelPredefinedOption(title: titleOption, predefinedPackages: activatedPredefinedPackages)
let option = ShippingLabelPredefinedOption(title: titleOption, providerID: key, predefinedPackages: activatedPredefinedPackages)
predefinedOptions.append(option)
}

let unactivatedPredefinedPackages = packages.filter({ !activatedPredefinedPackages.contains($0) })

if !unactivatedPredefinedPackages.isEmpty {
let titleOption: String = providerValueDict?["title"] as? String ?? ""
let option = ShippingLabelPredefinedOption(title: titleOption, predefinedPackages: unactivatedPredefinedPackages)
let option = ShippingLabelPredefinedOption(title: titleOption, providerID: key, predefinedPackages: unactivatedPredefinedPackages)
unactivatedPredefinedOptions.append(option)
}
})
Expand Down

0 comments on commit 53012e8

Please sign in to comment.