Skip to content

Commit

Permalink
Merge pull request #956 from Shopify/develop
Browse files Browse the repository at this point in the history
SDK 3.3
  • Loading branch information
dbart01 authored Dec 21, 2018
2 parents 1fc6253 + f56bbe4 commit 7c5bc5a
Show file tree
Hide file tree
Showing 61 changed files with 2,254 additions and 76 deletions.
104 changes: 88 additions & 16 deletions Buy.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

168 changes: 168 additions & 0 deletions Buy/Generated/Storefront/AutomaticDiscountApplication.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
//
// AutomaticDiscountApplication.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 {
/// Automatic discount applications capture the intentions of a discount that
/// was automatically applied.
open class AutomaticDiscountApplicationQuery: GraphQL.AbstractQuery, GraphQLQuery {
public typealias Response = AutomaticDiscountApplication

/// The method by which the discount's value is allocated to its entitled
/// items.
@discardableResult
open func allocationMethod(alias: String? = nil) -> AutomaticDiscountApplicationQuery {
addField(field: "allocationMethod", aliasSuffix: alias)
return self
}

/// Which lines of targetType that the discount is allocated over.
@discardableResult
open func targetSelection(alias: String? = nil) -> AutomaticDiscountApplicationQuery {
addField(field: "targetSelection", aliasSuffix: alias)
return self
}

/// The type of line that the discount is applicable towards.
@discardableResult
open func targetType(alias: String? = nil) -> AutomaticDiscountApplicationQuery {
addField(field: "targetType", aliasSuffix: alias)
return self
}

/// The title of the application.
@discardableResult
open func title(alias: String? = nil) -> AutomaticDiscountApplicationQuery {
addField(field: "title", aliasSuffix: alias)
return self
}

/// The value of the discount application.
@discardableResult
open func value(alias: String? = nil, _ subfields: (PricingValueQuery) -> Void) -> AutomaticDiscountApplicationQuery {
let subquery = PricingValueQuery()
subfields(subquery)

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

/// Automatic discount applications capture the intentions of a discount that
/// was automatically applied.
open class AutomaticDiscountApplication: GraphQL.AbstractResponse, GraphQLObject, DiscountApplication {
public typealias Query = AutomaticDiscountApplicationQuery

internal override func deserializeValue(fieldName: String, value: Any) throws -> Any? {
let fieldValue = value
switch fieldName {
case "allocationMethod":
guard let value = value as? String else {
throw SchemaViolationError(type: AutomaticDiscountApplication.self, field: fieldName, value: fieldValue)
}
return DiscountApplicationAllocationMethod(rawValue: value) ?? .unknownValue

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

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

case "title":
guard let value = value as? String else {
throw SchemaViolationError(type: AutomaticDiscountApplication.self, field: fieldName, value: fieldValue)
}
return value

case "value":
guard let value = value as? [String: Any] else {
throw SchemaViolationError(type: AutomaticDiscountApplication.self, field: fieldName, value: fieldValue)
}
return try UnknownPricingValue.create(fields: value)

default:
throw SchemaViolationError(type: AutomaticDiscountApplication.self, field: fieldName, value: fieldValue)
}
}

/// The method by which the discount's value is allocated to its entitled
/// items.
open var allocationMethod: Storefront.DiscountApplicationAllocationMethod {
return internalGetAllocationMethod()
}

func internalGetAllocationMethod(alias: String? = nil) -> Storefront.DiscountApplicationAllocationMethod {
return field(field: "allocationMethod", aliasSuffix: alias) as! Storefront.DiscountApplicationAllocationMethod
}

/// Which lines of targetType that the discount is allocated over.
open var targetSelection: Storefront.DiscountApplicationTargetSelection {
return internalGetTargetSelection()
}

func internalGetTargetSelection(alias: String? = nil) -> Storefront.DiscountApplicationTargetSelection {
return field(field: "targetSelection", aliasSuffix: alias) as! Storefront.DiscountApplicationTargetSelection
}

/// The type of line that the discount is applicable towards.
open var targetType: Storefront.DiscountApplicationTargetType {
return internalGetTargetType()
}

func internalGetTargetType(alias: String? = nil) -> Storefront.DiscountApplicationTargetType {
return field(field: "targetType", aliasSuffix: alias) as! Storefront.DiscountApplicationTargetType
}

/// The title of the application.
open var title: String {
return internalGetTitle()
}

func internalGetTitle(alias: String? = nil) -> String {
return field(field: "title", aliasSuffix: alias) as! String
}

/// The value of the discount application.
open var value: PricingValue {
return internalGetValue()
}

func internalGetValue(alias: String? = nil) -> PricingValue {
return field(field: "value", aliasSuffix: alias) as! PricingValue
}

internal override func childResponseObjectMap() -> [GraphQL.AbstractResponse] {
return []
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import Foundation

extension Storefront {
/// Return type for `checkoutAttributesUpdate` mutation.
open class CheckoutAttributesUpdatePayloadQuery: GraphQL.AbstractQuery, GraphQLQuery {
public typealias Response = CheckoutAttributesUpdatePayload

Expand All @@ -51,6 +52,7 @@ extension Storefront {
}
}

/// Return type for `checkoutAttributesUpdate` mutation.
open class CheckoutAttributesUpdatePayload: GraphQL.AbstractResponse, GraphQLObject {
public typealias Query = CheckoutAttributesUpdatePayloadQuery

Expand Down
35 changes: 35 additions & 0 deletions Buy/Generated/Storefront/CheckoutAttributesUpdateV2Payload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import Foundation

extension Storefront {
/// Return type for `checkoutAttributesUpdateV2` mutation.
open class CheckoutAttributesUpdateV2PayloadQuery: GraphQL.AbstractQuery, GraphQLQuery {
public typealias Response = CheckoutAttributesUpdateV2Payload

Expand All @@ -42,6 +43,17 @@ extension Storefront {

/// List of errors that occurred executing the mutation.
@discardableResult
open func checkoutUserErrors(alias: String? = nil, _ subfields: (CheckoutUserErrorQuery) -> Void) -> CheckoutAttributesUpdateV2PayloadQuery {
let subquery = CheckoutUserErrorQuery()
subfields(subquery)

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

/// List of errors that occurred executing the mutation.
@available(*, deprecated, message:"Use `checkoutUserErrors` instead")
@discardableResult
open func userErrors(alias: String? = nil, _ subfields: (UserErrorQuery) -> Void) -> CheckoutAttributesUpdateV2PayloadQuery {
let subquery = UserErrorQuery()
subfields(subquery)
Expand All @@ -51,6 +63,7 @@ extension Storefront {
}
}

/// Return type for `checkoutAttributesUpdateV2` mutation.
open class CheckoutAttributesUpdateV2Payload: GraphQL.AbstractResponse, GraphQLObject {
public typealias Query = CheckoutAttributesUpdateV2PayloadQuery

Expand All @@ -64,6 +77,12 @@ extension Storefront {
}
return try Checkout(fields: value)

case "checkoutUserErrors":
guard let value = value as? [[String: Any]] else {
throw SchemaViolationError(type: CheckoutAttributesUpdateV2Payload.self, field: fieldName, value: fieldValue)
}
return try value.map { return try CheckoutUserError(fields: $0) }

case "userErrors":
guard let value = value as? [[String: Any]] else {
throw SchemaViolationError(type: CheckoutAttributesUpdateV2Payload.self, field: fieldName, value: fieldValue)
Expand All @@ -85,6 +104,16 @@ extension Storefront {
}

/// List of errors that occurred executing the mutation.
open var checkoutUserErrors: [Storefront.CheckoutUserError] {
return internalGetCheckoutUserErrors()
}

func internalGetCheckoutUserErrors(alias: String? = nil) -> [Storefront.CheckoutUserError] {
return field(field: "checkoutUserErrors", aliasSuffix: alias) as! [Storefront.CheckoutUserError]
}

/// List of errors that occurred executing the mutation.
@available(*, deprecated, message:"Use `checkoutUserErrors` instead")
open var userErrors: [Storefront.UserError] {
return internalGetUserErrors()
}
Expand All @@ -103,6 +132,12 @@ extension Storefront {
response.append(contentsOf: value.childResponseObjectMap())
}

case "checkoutUserErrors":
internalGetCheckoutUserErrors().forEach {
response.append($0)
response.append(contentsOf: $0.childResponseObjectMap())
}

case "userErrors":
internalGetUserErrors().forEach {
response.append($0)
Expand Down
35 changes: 35 additions & 0 deletions Buy/Generated/Storefront/CheckoutCompleteFreePayload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import Foundation

extension Storefront {
/// Return type for `checkoutCompleteFree` mutation.
open class CheckoutCompleteFreePayloadQuery: GraphQL.AbstractQuery, GraphQLQuery {
public typealias Response = CheckoutCompleteFreePayload

Expand All @@ -42,6 +43,17 @@ extension Storefront {

/// List of errors that occurred executing the mutation.
@discardableResult
open func checkoutUserErrors(alias: String? = nil, _ subfields: (CheckoutUserErrorQuery) -> Void) -> CheckoutCompleteFreePayloadQuery {
let subquery = CheckoutUserErrorQuery()
subfields(subquery)

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

/// List of errors that occurred executing the mutation.
@available(*, deprecated, message:"Use `checkoutUserErrors` instead")
@discardableResult
open func userErrors(alias: String? = nil, _ subfields: (UserErrorQuery) -> Void) -> CheckoutCompleteFreePayloadQuery {
let subquery = UserErrorQuery()
subfields(subquery)
Expand All @@ -51,6 +63,7 @@ extension Storefront {
}
}

/// Return type for `checkoutCompleteFree` mutation.
open class CheckoutCompleteFreePayload: GraphQL.AbstractResponse, GraphQLObject {
public typealias Query = CheckoutCompleteFreePayloadQuery

Expand All @@ -64,6 +77,12 @@ extension Storefront {
}
return try Checkout(fields: value)

case "checkoutUserErrors":
guard let value = value as? [[String: Any]] else {
throw SchemaViolationError(type: CheckoutCompleteFreePayload.self, field: fieldName, value: fieldValue)
}
return try value.map { return try CheckoutUserError(fields: $0) }

case "userErrors":
guard let value = value as? [[String: Any]] else {
throw SchemaViolationError(type: CheckoutCompleteFreePayload.self, field: fieldName, value: fieldValue)
Expand All @@ -85,6 +104,16 @@ extension Storefront {
}

/// List of errors that occurred executing the mutation.
open var checkoutUserErrors: [Storefront.CheckoutUserError] {
return internalGetCheckoutUserErrors()
}

func internalGetCheckoutUserErrors(alias: String? = nil) -> [Storefront.CheckoutUserError] {
return field(field: "checkoutUserErrors", aliasSuffix: alias) as! [Storefront.CheckoutUserError]
}

/// List of errors that occurred executing the mutation.
@available(*, deprecated, message:"Use `checkoutUserErrors` instead")
open var userErrors: [Storefront.UserError] {
return internalGetUserErrors()
}
Expand All @@ -103,6 +132,12 @@ extension Storefront {
response.append(contentsOf: value.childResponseObjectMap())
}

case "checkoutUserErrors":
internalGetCheckoutUserErrors().forEach {
response.append($0)
response.append(contentsOf: $0.childResponseObjectMap())
}

case "userErrors":
internalGetUserErrors().forEach {
response.append($0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import Foundation

extension Storefront {
/// Return type for `checkoutCompleteWithCreditCard` mutation.
open class CheckoutCompleteWithCreditCardPayloadQuery: GraphQL.AbstractQuery, GraphQLQuery {
public typealias Response = CheckoutCompleteWithCreditCardPayload

Expand Down Expand Up @@ -61,6 +62,7 @@ extension Storefront {
}
}

/// Return type for `checkoutCompleteWithCreditCard` mutation.
open class CheckoutCompleteWithCreditCardPayload: GraphQL.AbstractResponse, GraphQLObject {
public typealias Query = CheckoutCompleteWithCreditCardPayloadQuery

Expand Down
Loading

0 comments on commit 7c5bc5a

Please sign in to comment.