-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #868 from Shopify/develop
SDK 3.1.7
- Loading branch information
Showing
9 changed files
with
233 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
Buy/Generated/Storefront/CheckoutDiscountCodeRemovePayload.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
// | ||
// CheckoutDiscountCodeRemovePayload.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 { | ||
open class CheckoutDiscountCodeRemovePayloadQuery: GraphQL.AbstractQuery, GraphQLQuery { | ||
public typealias Response = CheckoutDiscountCodeRemovePayload | ||
|
||
/// The updated checkout object. | ||
@discardableResult | ||
open func checkout(alias: String? = nil, _ subfields: (CheckoutQuery) -> Void) -> CheckoutDiscountCodeRemovePayloadQuery { | ||
let subquery = CheckoutQuery() | ||
subfields(subquery) | ||
|
||
addField(field: "checkout", aliasSuffix: alias, subfields: subquery) | ||
return self | ||
} | ||
|
||
/// List of errors that occurred executing the mutation. | ||
@discardableResult | ||
open func userErrors(alias: String? = nil, _ subfields: (UserErrorQuery) -> Void) -> CheckoutDiscountCodeRemovePayloadQuery { | ||
let subquery = UserErrorQuery() | ||
subfields(subquery) | ||
|
||
addField(field: "userErrors", aliasSuffix: alias, subfields: subquery) | ||
return self | ||
} | ||
} | ||
|
||
open class CheckoutDiscountCodeRemovePayload: GraphQL.AbstractResponse, GraphQLObject { | ||
public typealias Query = CheckoutDiscountCodeRemovePayloadQuery | ||
|
||
internal override func deserializeValue(fieldName: String, value: Any) throws -> Any? { | ||
let fieldValue = value | ||
switch fieldName { | ||
case "checkout": | ||
if value is NSNull { return nil } | ||
guard let value = value as? [String: Any] else { | ||
throw SchemaViolationError(type: CheckoutDiscountCodeRemovePayload.self, field: fieldName, value: fieldValue) | ||
} | ||
return try Checkout(fields: value) | ||
|
||
case "userErrors": | ||
guard let value = value as? [[String: Any]] else { | ||
throw SchemaViolationError(type: CheckoutDiscountCodeRemovePayload.self, field: fieldName, value: fieldValue) | ||
} | ||
return try value.map { return try UserError(fields: $0) } | ||
|
||
default: | ||
throw SchemaViolationError(type: CheckoutDiscountCodeRemovePayload.self, field: fieldName, value: fieldValue) | ||
} | ||
} | ||
|
||
/// The updated checkout object. | ||
open var checkout: Storefront.Checkout? { | ||
return internalGetCheckout() | ||
} | ||
|
||
func internalGetCheckout(alias: String? = nil) -> Storefront.Checkout? { | ||
return field(field: "checkout", aliasSuffix: alias) as! Storefront.Checkout? | ||
} | ||
|
||
/// List of errors that occurred executing the mutation. | ||
open var userErrors: [Storefront.UserError] { | ||
return internalGetUserErrors() | ||
} | ||
|
||
func internalGetUserErrors(alias: String? = nil) -> [Storefront.UserError] { | ||
return field(field: "userErrors", aliasSuffix: alias) as! [Storefront.UserError] | ||
} | ||
|
||
internal override func childResponseObjectMap() -> [GraphQL.AbstractResponse] { | ||
var response: [GraphQL.AbstractResponse] = [] | ||
objectMap.keys.forEach { | ||
switch($0) { | ||
case "checkout": | ||
if let value = internalGetCheckout() { | ||
response.append(value) | ||
response.append(contentsOf: value.childResponseObjectMap()) | ||
} | ||
|
||
case "userErrors": | ||
internalGetUserErrors().forEach { | ||
response.append($0) | ||
response.append(contentsOf: $0.childResponseObjectMap()) | ||
} | ||
|
||
default: | ||
break | ||
} | ||
} | ||
return response | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.