Skip to content

Commit

Permalink
Merge pull request #1230 from Shopify/release/2024-04-auto-generated
Browse files Browse the repository at this point in the history
Update Schema to `2024-04` Release
  • Loading branch information
cocoahero authored Apr 2, 2024
2 parents 3a6ecdc + b90ba4a commit 6bd23c2
Show file tree
Hide file tree
Showing 39 changed files with 2,379 additions and 28 deletions.
104 changes: 104 additions & 0 deletions Buy.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Buy/Generated/Storefront.Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@

extension Storefront {
enum Schema {
static let version = "2024-01"
static let version = "2024-04"
}
}
83 changes: 83 additions & 0 deletions Buy/Generated/Storefront/BuyerInput.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
//
// BuyerInput.swift
// Buy
//
// Created by Shopify.
// Copyright (c) 2017 Shopify Inc. All rights reserved.
//
// 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

extension Storefront {
/// The input fields for obtaining the buyer's identity.
open class BuyerInput {
/// The storefront customer access token retrieved from the [Customer Accounts
/// API](https://shopify.dev/docs/api/customer/reference/mutations/storefrontCustomerAccessTokenCreate).
open var customerAccessToken: String

/// The identifier of the company location.
open var companyLocationId: Input<GraphQL.ID>

/// Creates the input object.
///
/// - parameters:
/// - customerAccessToken: The storefront customer access token retrieved from the [Customer Accounts API](https://shopify.dev/docs/api/customer/reference/mutations/storefrontCustomerAccessTokenCreate).
/// - companyLocationId: The identifier of the company location.
///
public static func create(customerAccessToken: String, companyLocationId: Input<GraphQL.ID> = .undefined) -> BuyerInput {
return BuyerInput(customerAccessToken: customerAccessToken, companyLocationId: companyLocationId)
}

private init(customerAccessToken: String, companyLocationId: Input<GraphQL.ID> = .undefined) {
self.customerAccessToken = customerAccessToken
self.companyLocationId = companyLocationId
}

/// Creates the input object.
///
/// - parameters:
/// - customerAccessToken: The storefront customer access token retrieved from the [Customer Accounts API](https://shopify.dev/docs/api/customer/reference/mutations/storefrontCustomerAccessTokenCreate).
/// - companyLocationId: The identifier of the company location.
///
@available(*, deprecated, message: "Use the static create() method instead.")
public convenience init(customerAccessToken: String, companyLocationId: GraphQL.ID? = nil) {
self.init(customerAccessToken: customerAccessToken, companyLocationId: companyLocationId.orUndefined)
}

internal func serialize() -> String {
var fields: [String] = []

fields.append("customerAccessToken:\(GraphQL.quoteString(input: customerAccessToken))")

switch companyLocationId {
case .value(let companyLocationId):
guard let companyLocationId = companyLocationId else {
fields.append("companyLocationId:null")
break
}
fields.append("companyLocationId:\(GraphQL.quoteString(input: "\(companyLocationId.rawValue)"))")
case .undefined: break
}

return "{\(fields.joined(separator: ","))}"
}
}
}
32 changes: 32 additions & 0 deletions Buy/Generated/Storefront/CartBuyerIdentity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ extension Storefront {
return self
}

/// The purchasing company associated with the cart.
@discardableResult
open func purchasingCompany(alias: String? = nil, _ subfields: (PurchasingCompanyQuery) -> Void) -> CartBuyerIdentityQuery {
let subquery = PurchasingCompanyQuery()
subfields(subquery)

addField(field: "purchasingCompany", aliasSuffix: alias, subfields: subquery)
return self
}

/// A set of wallet preferences tied to the buyer that is interacting with the
/// cart. Preferences can be used to populate relevant payment fields in the
/// checkout flow.
Expand Down Expand Up @@ -126,6 +136,13 @@ extension Storefront {
}
return value

case "purchasingCompany":
if value is NSNull { return nil }
guard let value = value as? [String: Any] else {
throw SchemaViolationError(type: CartBuyerIdentity.self, field: fieldName, value: fieldValue)
}
return try PurchasingCompany(fields: value)

case "walletPreferences":
guard let value = value as? [String] else {
throw SchemaViolationError(type: CartBuyerIdentity.self, field: fieldName, value: fieldValue)
Expand Down Expand Up @@ -185,6 +202,15 @@ extension Storefront {
return field(field: "phone", aliasSuffix: alias) as! String?
}

/// The purchasing company associated with the cart.
open var purchasingCompany: Storefront.PurchasingCompany? {
return internalGetPurchasingCompany()
}

func internalGetPurchasingCompany(alias: String? = nil) -> Storefront.PurchasingCompany? {
return field(field: "purchasingCompany", aliasSuffix: alias) as! Storefront.PurchasingCompany?
}

/// A set of wallet preferences tied to the buyer that is interacting with the
/// cart. Preferences can be used to populate relevant payment fields in the
/// checkout flow.
Expand Down Expand Up @@ -212,6 +238,12 @@ extension Storefront {
response.append(contentsOf: ($0 as! GraphQL.AbstractResponse).childResponseObjectMap())
}

case "purchasingCompany":
if let value = internalGetPurchasingCompany() {
response.append(value)
response.append(contentsOf: value.childResponseObjectMap())
}

default:
break
}
Expand Down
26 changes: 21 additions & 5 deletions Buy/Generated/Storefront/CartBuyerIdentityInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ extension Storefront {
/// The phone number of the buyer that is interacting with the cart.
open var phone: Input<String>

/// The company location of the buyer that is interacting with the cart.
open var companyLocationId: Input<GraphQL.ID>

/// The country where the buyer is located.
open var countryCode: Input<CountryCode>

Expand All @@ -62,18 +65,20 @@ extension Storefront {
/// - parameters:
/// - email: The email address of the buyer that is interacting with the cart.
/// - phone: The phone number of the buyer that is interacting with the cart.
/// - companyLocationId: The company location of the buyer that is interacting with the cart.
/// - countryCode: The country where the buyer is located.
/// - customerAccessToken: The access token used to identify the customer associated with the cart.
/// - deliveryAddressPreferences: An ordered set of delivery addresses tied to the buyer that is interacting with the cart. The rank of the preferences is determined by the order of the addresses in the array. Preferences can be used to populate relevant fields in the checkout flow. The input must not contain more than `250` values.
/// - walletPreferences: A set of wallet preferences tied to the buyer that is interacting with the cart. Preferences can be used to populate relevant payment fields in the checkout flow. Accepted value: `["shop_pay"]`. The input must not contain more than `250` values.
///
public static func create(email: Input<String> = .undefined, phone: Input<String> = .undefined, countryCode: Input<CountryCode> = .undefined, customerAccessToken: Input<String> = .undefined, deliveryAddressPreferences: Input<[DeliveryAddressInput]> = .undefined, walletPreferences: Input<[String]> = .undefined) -> CartBuyerIdentityInput {
return CartBuyerIdentityInput(email: email, phone: phone, countryCode: countryCode, customerAccessToken: customerAccessToken, deliveryAddressPreferences: deliveryAddressPreferences, walletPreferences: walletPreferences)
public static func create(email: Input<String> = .undefined, phone: Input<String> = .undefined, companyLocationId: Input<GraphQL.ID> = .undefined, countryCode: Input<CountryCode> = .undefined, customerAccessToken: Input<String> = .undefined, deliveryAddressPreferences: Input<[DeliveryAddressInput]> = .undefined, walletPreferences: Input<[String]> = .undefined) -> CartBuyerIdentityInput {
return CartBuyerIdentityInput(email: email, phone: phone, companyLocationId: companyLocationId, countryCode: countryCode, customerAccessToken: customerAccessToken, deliveryAddressPreferences: deliveryAddressPreferences, walletPreferences: walletPreferences)
}

private init(email: Input<String> = .undefined, phone: Input<String> = .undefined, countryCode: Input<CountryCode> = .undefined, customerAccessToken: Input<String> = .undefined, deliveryAddressPreferences: Input<[DeliveryAddressInput]> = .undefined, walletPreferences: Input<[String]> = .undefined) {
private init(email: Input<String> = .undefined, phone: Input<String> = .undefined, companyLocationId: Input<GraphQL.ID> = .undefined, countryCode: Input<CountryCode> = .undefined, customerAccessToken: Input<String> = .undefined, deliveryAddressPreferences: Input<[DeliveryAddressInput]> = .undefined, walletPreferences: Input<[String]> = .undefined) {
self.email = email
self.phone = phone
self.companyLocationId = companyLocationId
self.countryCode = countryCode
self.customerAccessToken = customerAccessToken
self.deliveryAddressPreferences = deliveryAddressPreferences
Expand All @@ -85,14 +90,15 @@ extension Storefront {
/// - parameters:
/// - email: The email address of the buyer that is interacting with the cart.
/// - phone: The phone number of the buyer that is interacting with the cart.
/// - companyLocationId: The company location of the buyer that is interacting with the cart.
/// - countryCode: The country where the buyer is located.
/// - customerAccessToken: The access token used to identify the customer associated with the cart.
/// - deliveryAddressPreferences: An ordered set of delivery addresses tied to the buyer that is interacting with the cart. The rank of the preferences is determined by the order of the addresses in the array. Preferences can be used to populate relevant fields in the checkout flow. The input must not contain more than `250` values.
/// - walletPreferences: A set of wallet preferences tied to the buyer that is interacting with the cart. Preferences can be used to populate relevant payment fields in the checkout flow. Accepted value: `["shop_pay"]`. The input must not contain more than `250` values.
///
@available(*, deprecated, message: "Use the static create() method instead.")
public convenience init(email: String? = nil, phone: String? = nil, countryCode: CountryCode? = nil, customerAccessToken: String? = nil, deliveryAddressPreferences: [DeliveryAddressInput]? = nil, walletPreferences: [String]? = nil) {
self.init(email: email.orUndefined, phone: phone.orUndefined, countryCode: countryCode.orUndefined, customerAccessToken: customerAccessToken.orUndefined, deliveryAddressPreferences: deliveryAddressPreferences.orUndefined, walletPreferences: walletPreferences.orUndefined)
public convenience init(email: String? = nil, phone: String? = nil, companyLocationId: GraphQL.ID? = nil, countryCode: CountryCode? = nil, customerAccessToken: String? = nil, deliveryAddressPreferences: [DeliveryAddressInput]? = nil, walletPreferences: [String]? = nil) {
self.init(email: email.orUndefined, phone: phone.orUndefined, companyLocationId: companyLocationId.orUndefined, countryCode: countryCode.orUndefined, customerAccessToken: customerAccessToken.orUndefined, deliveryAddressPreferences: deliveryAddressPreferences.orUndefined, walletPreferences: walletPreferences.orUndefined)
}

internal func serialize() -> String {
Expand All @@ -118,6 +124,16 @@ extension Storefront {
case .undefined: break
}

switch companyLocationId {
case .value(let companyLocationId):
guard let companyLocationId = companyLocationId else {
fields.append("companyLocationId:null")
break
}
fields.append("companyLocationId:\(GraphQL.quoteString(input: "\(companyLocationId.rawValue)"))")
case .undefined: break
}

switch countryCode {
case .value(let countryCode):
guard let countryCode = countryCode else {
Expand Down
22 changes: 22 additions & 0 deletions Buy/Generated/Storefront/CartDeliveryGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ extension Storefront {
return self
}

/// The type of merchandise in the delivery group.
@discardableResult
open func groupType(alias: String? = nil) -> CartDeliveryGroupQuery {
addField(field: "groupType", aliasSuffix: alias)
return self
}

/// The ID for the delivery group.
@discardableResult
open func id(alias: String? = nil) -> CartDeliveryGroupQuery {
Expand Down Expand Up @@ -138,6 +145,12 @@ extension Storefront {
}
return try value.map { return try CartDeliveryOption(fields: $0) }

case "groupType":
guard let value = value as? String else {
throw SchemaViolationError(type: CartDeliveryGroup.self, field: fieldName, value: fieldValue)
}
return CartDeliveryGroupType(rawValue: value) ?? .unknownValue

case "id":
guard let value = value as? String else {
throw SchemaViolationError(type: CartDeliveryGroup.self, field: fieldName, value: fieldValue)
Expand Down Expand Up @@ -187,6 +200,15 @@ extension Storefront {
return field(field: "deliveryOptions", aliasSuffix: alias) as! [Storefront.CartDeliveryOption]
}

/// The type of merchandise in the delivery group.
open var groupType: Storefront.CartDeliveryGroupType {
return internalGetGroupType()
}

func internalGetGroupType(alias: String? = nil) -> Storefront.CartDeliveryGroupType {
return field(field: "groupType", aliasSuffix: alias) as! Storefront.CartDeliveryGroupType
}

/// The ID for the delivery group.
open var id: GraphQL.ID {
return internalGetId()
Expand Down
41 changes: 41 additions & 0 deletions Buy/Generated/Storefront/CartDeliveryGroupType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// CartDeliveryGroupType.swift
// Buy
//
// Created by Shopify.
// Copyright (c) 2017 Shopify Inc. All rights reserved.
//
// 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

extension Storefront {
/// Defines what type of merchandise is in the delivery group.
public enum CartDeliveryGroupType: String {
/// The delivery group only contains merchandise that is either a one time
/// purchase or a first delivery of subscription merchandise.
case oneTimePurchase = "ONE_TIME_PURCHASE"

/// The delivery group only contains subscription merchandise.
case subscription = "SUBSCRIPTION"

case unknownValue = ""
}
}
48 changes: 48 additions & 0 deletions Buy/Generated/Storefront/CartErrorCode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,39 @@ import Foundation
extension Storefront {
/// Possible error codes that can be returned by `CartUserError`.
public enum CartErrorCode: String {
/// The specified address field contains emojis.
case addressFieldContainsEmojis = "ADDRESS_FIELD_CONTAINS_EMOJIS"

/// The specified address field contains HTML tags.
case addressFieldContainsHtmlTags = "ADDRESS_FIELD_CONTAINS_HTML_TAGS"

/// The specified address field contains a URL.
case addressFieldContainsUrl = "ADDRESS_FIELD_CONTAINS_URL"

/// The specified address field does not match the expected pattern.
case addressFieldDoesNotMatchExpectedPattern = "ADDRESS_FIELD_DOES_NOT_MATCH_EXPECTED_PATTERN"

/// The specified address field is required.
case addressFieldIsRequired = "ADDRESS_FIELD_IS_REQUIRED"

/// The specified address field is too long.
case addressFieldIsTooLong = "ADDRESS_FIELD_IS_TOO_LONG"

/// The input value is invalid.
case invalid = "INVALID"

/// Company location not found or not allowed.
case invalidCompanyLocation = "INVALID_COMPANY_LOCATION"

/// Delivery group was not found in cart.
case invalidDeliveryGroup = "INVALID_DELIVERY_GROUP"

/// Delivery option was not valid.
case invalidDeliveryOption = "INVALID_DELIVERY_OPTION"

/// The quantity must be a multiple of the specified increment.
case invalidIncrement = "INVALID_INCREMENT"

/// Merchandise line was not found in cart.
case invalidMerchandiseLine = "INVALID_MERCHANDISE_LINE"

Expand All @@ -50,9 +74,24 @@ extension Storefront {
/// Cannot update payment on an empty cart
case invalidPaymentEmptyCart = "INVALID_PAYMENT_EMPTY_CART"

/// The given zip code is invalid for the provided country.
case invalidZipCodeForCountry = "INVALID_ZIP_CODE_FOR_COUNTRY"

/// The given zip code is invalid for the provided province.
case invalidZipCodeForProvince = "INVALID_ZIP_CODE_FOR_PROVINCE"

/// The input value should be less than the maximum value allowed.
case lessThan = "LESS_THAN"

/// The quantity must be below the specified maximum for the item.
case maximumExceeded = "MAXIMUM_EXCEEDED"

/// The quantity must be above the specified minimum for the item.
case minimumNotMet = "MINIMUM_NOT_MET"

/// The customer access token is required when setting a company location.
case missingCustomerAccessToken = "MISSING_CUSTOMER_ACCESS_TOKEN"

/// Missing discount code.
case missingDiscountCode = "MISSING_DISCOUNT_CODE"

Expand All @@ -62,9 +101,18 @@ extension Storefront {
/// The payment method is not supported.
case paymentMethodNotSupported = "PAYMENT_METHOD_NOT_SUPPORTED"

/// The given province cannot be found.
case provinceNotFound = "PROVINCE_NOT_FOUND"

/// A general error occurred during address validation.
case unspecifiedAddressError = "UNSPECIFIED_ADDRESS_ERROR"

/// Validation failed.
case validationCustom = "VALIDATION_CUSTOM"

/// The given zip code is unsupported.
case zipCodeNotSupported = "ZIP_CODE_NOT_SUPPORTED"

case unknownValue = ""
}
}
Loading

0 comments on commit 6bd23c2

Please sign in to comment.