# A participant defines carrier-calculated rates for shipping services
# with a possible merchant-defined fixed fee or a percentage-of-rate fee.
type DeliveryParticipant implements Node {
    # Whether to display new shipping services automatically to the customer when the service becomes available.
    adaptToNewServicesFlag: Boolean!

    # The carrier used for this participant.
    carrierService: DeliveryCarrierService!

    # The merchant-defined fixed fee for this participant.
    fixedFee: MoneyV2

    # A globally-unique identifier.
    id: ID!

    # The carrier-specific services offered by the participant, and whether each service is active.
    participantServices: [DeliveryParticipantService!]!

    # The merchant-defined percentage-of-rate fee for this participant.
    percentageOfRateFee: Float!
}

# Represents the shipping details that the customer chose for their order.
type ShippingLine {
    # A reference to the carrier service that provided the rate.
    # Present when the rate was computed by a third-party carrier service.
    carrierIdentifier: String

    # A reference to the shipping method.
    code: String

    # Whether the shipping line is custom or not.
    custom: Boolean!

    # The general classification of the delivery method.
    deliveryCategory: String

    # The discounts that have been allocated to the shipping line.
    discountAllocations: [DiscountAllocation!]!

    # The pre-tax shipping price with discounts applied.
    discountedPriceSet: MoneyBag!

    # A globally-unique identifier.
    id: ID

    # The pre-tax shipping price without any discounts applied.
    originalPriceSet: MoneyBag!

    # The phone number at the shipping address.
    phone: String

    # The fulfillment service requested for the shipping method.
    # Present if the shipping method requires processing by a third party fulfillment service.
    requestedFulfillmentService: FulfillmentService

    # A unique identifier for the shipping rate. The format can change without notice and is not meant to be shown to users.
    shippingRateHandle: String

    # Returns the rate source for the shipping line.
    source: String

    # The TaxLine objects connected to this shipping line.
    taxLines: [TaxLine!]!

    # Returns the title of the shipping line.
    title: String!
}

# A shipping profile. In Shopify, a shipping profile is a set of shipping rates scoped to a set of products or variants
# that can be shipped from selected locations to zones.
type DeliveryProfile implements Node {
    # The number of active shipping rates for the profile.
    activeMethodDefinitionsCount: Int!

    # Whether this is the default profile.
    default: Boolean!

    # A globally-unique identifier.
    id: ID!

    # Whether this shop has enabled legacy compatibility mode for delivery profiles.
    legacyMode: Boolean!

    # The number of locations without rates defined.
    locationsWithoutRatesCount: Int!

    # The name of the delivery profile.
    name: String!

    # The number of active origin locations for the profile.
    originLocationCount: Int!

    # How many product variants are in this profile.
    productVariantsCountV2: DeliveryProductVariantsCount!

    # The products and variants associated with this profile.
    profileItems(
        first: Int
        after: String
        last: Int
        before: String
        reverse: Boolean = false
    ): DeliveryProfileItemConnection!

    # The location groups and associated zones using this profile.
    profileLocationGroups: [DeliveryProfileLocationGroup!]!

    # Selling plan groups associated with the specified delivery profile.
    sellingPlanGroups(
        first: Int
        after: String
        last: Int
        before: String
        reverse: Boolean = false
    ): SellingPlanGroupConnection!

    # List of locations that have not been assigned to a location group for this profile.
    unassignedLocations: [Location!]!

    # The number of countries with active rates to deliver to.
    zoneCountryCount: Int!
}

# A product and the subset of associated variants that are part of this delivery profile.
type DeliveryProfileItem implements Node {
    # A globally-unique identifier.
    id: ID!

    # A product associated with this profile.
    product: Product!

    # The product variants associated with this delivery profile.
    variants(
        first: Int
        after: String
        last: Int
        before: String
        reverse: Boolean = false
    ): ProductVariantConnection!
}

# How many product variants are in a profile. This count is capped at 500.
type DeliveryProductVariantsCount {
    # Whether the count has reached the cap of 500.
    capped: Boolean!

    # The product variant count.
    count: Int!
}

# Links a location group with zones. Both are associated to a delivery profile.
type DeliveryProfileLocationGroup {
    # The countries already selected in any zone for the specified location group.
    countriesInAnyZone: [DeliveryCountryAndZone!]!

    # The collection of locations that make up the specified location group.
    locationGroup: DeliveryLocationGroup!

    # The applicable zones associated to the specified location group.
    locationGroupZones(
        first: Int
        after: String
        last: Int
        before: String
        reverse: Boolean = false
    ): DeliveryLocationGroupZoneConnection!
}

# A location group is a collection of locations. They share zones and delivery methods across delivery profiles.
type DeliveryLocationGroup implements Node {
    # A globally-unique identifier.
    id: ID!

    # A list of all locations that are part of this location group.
    locations(
        first: Int
        after: String
        last: Int
        before: String
        reverse: Boolean = false
        sortKey: LocationSortKeys = NAME
        query: String
        includeLegacy: Boolean = false
        includeInactive: Boolean = false
    ): LocationConnection!
}

# Links a location group with a zone and the associated method definitions.
type DeliveryLocationGroupZone {
    # The number of method definitions for the zone.
    methodDefinitionCounts: DeliveryMethodDefinitionCounts!

    # The method definitions associated to a zone and location group.
    methodDefinitions(
        eligible: Boolean
        type: DeliveryMethodDefinitionType
        first: Int
        after: String
        last: Int
        before: String
        reverse: Boolean = false
        sortKey: MethodDefinitionSortKeys = ID
    ): DeliveryMethodDefinitionConnection!

    # The zone associated to a location group.
    zone: DeliveryZone!
}

# A zone is a group of countries that have the same shipping rates.
# Customers can order products from a store only if they choose a shipping destination that's included in one of the store's zones.
type DeliveryZone implements Node {
    # The list of countries within the zone.
    countries: [DeliveryCountry!]!

    # A globally-unique identifier.
    id: ID!

    # The name of the zone.
    name: String!
}

# The number of method definitions for a zone, separated into merchant-owned and participant definitions.
type DeliveryMethodDefinitionCounts {
    # The number of participant method definitions for the specified zone.
    participantDefinitionsCount: Int!

    # The number of merchant-defined method definitions for the specified zone.
    rateDefinitionsCount: Int!
}

# The country details and the associated shipping zone.
type DeliveryCountryAndZone {
    # The country details.
    country: DeliveryCountry!

    # The name of the shipping zone.
    zone: String!
}

# A country that is used to define a shipping zone.
type DeliveryCountry implements Node {
    # A two-letter country code in ISO 3166-1 alpha-2 standard.
    # It also includes a flag indicating whether the country should be
    # a part of the 'Rest Of World' shipping zone.
    code: DeliveryCountryCodeOrRestOfWorld!

    # A globally-unique identifier.
    id: ID!

    # The full name of the country.
    name: String!

    # The list of regions associated with this country.
    provinces: [DeliveryProvince!]!

    # The translated name of the country. The translation returned is based on the system's locale.
    translatedName: String!
}

# The country code and whether the country is a part of the 'Rest Of World' shipping zone.
type DeliveryCountryCodeOrRestOfWorld {
    # The country code in the ISO 3166-1 alpha-2 format.
    countryCode: CountryCode

    # Whether the country is a part of the 'Rest of World' shipping zone.
    restOfWorld: Boolean!
}

# A region that is used to define a shipping zone.
type DeliveryProvince implements Node {
    # The code of the region.
    code: String!

    # A globally-unique identifier.
    id: ID!

    # The full name of the region.
    name: String!

    # The translated name of the region. The translation returned is based on the system's locale.
    translatedName: String!
}

# A method definition contains the delivery rate and the conditions that must be met for the method to be applied.
type DeliveryMethodDefinition implements Node {
    # Whether this method definition is active.
    active: Boolean!

    # The description of the method definition.
    description: String

    # A globally-unique identifier.
    id: ID!

    # The method conditions that must pass for this method definition to be applied to an order.
    methodConditions: [DeliveryCondition!]!

    # The name of the method definition.
    name: String!

    # The provided rate for this method definition, from a rate definition or participant.
    rateProvider: DeliveryRateProvider!
}

# A condition that must pass for a delivery method definition to be applied to an order.
type DeliveryCondition implements Node {
    # The value (weight or price) that the condition field is compared to.
    conditionCriteria: DeliveryConditionCriteria!

    # The field to compare the criterion value against, using the operator.
    field: DeliveryConditionField!

    # A globally-unique identifier.
    id: ID!

    # The operator to compare the field and criterion value.
    operator: DeliveryConditionOperator!
}

# The delivery method used by a fulfillment order.
type DeliveryMethod implements Node {
    # A globally-unique identifier.
    id: ID!

    # The maximum date and time by which the delivery is expected to be completed.
    maxDeliveryDateTime: DateTime

    # The type of the delivery method.
    methodType: DeliveryMethodType!

    # The minimum date and time by which the delivery is expected to be completed.
    minDeliveryDateTime: DateTime
}

# The merchant-defined rate of the DeliveryMethodDefinition.
type DeliveryRateDefinition implements Node {
    # A globally-unique identifier.
    id: ID!

    # The price of this rate.
    price: MoneyV2!
}

# A local delivery method, which includes a mailing address and a local delivery option.
type SubscriptionDeliveryMethodLocalDelivery {
    # The address to deliver to.
    address: SubscriptionMailingAddress!

    # The details of the local delivery method to use.
    localDeliveryOption: SubscriptionDeliveryMethodLocalDeliveryOption!
}

# Represents a Mailing Address on a Subscription.
type SubscriptionMailingAddress {
    # The first line of the address. Typically the street address or PO Box number.
    address1: String

    # The second line of the address. Typically the number of the apartment, suite, or unit.
    address2: String

    # The name of the city, district, village, or town.
    city: String

    # The name of the customer's company or organization.
    company: String

    # The name of the country.
    country: String

    # The two-letter code for the country of the address.
    #
    # For example, US.
    countryCode: CountryCode

    # The first name of the customer.
    firstName: String

    # The last name of the customer.
    lastName: String

    # The full name of the customer, based on firstName and lastName.
    name: String

    # A unique phone number for the customer. Formatted using E.164 standard. For example, +16135551111.
    phone: String

    # The region of the address, such as the province, state, or district.
    province: String

    # The two-letter code for the region.
    #
    # For example, ON.
    provinceCode: String

    # The zip or postal code of the address.
    zip: String
}

# The selected delivery option on a subscription contract.
type SubscriptionDeliveryMethodLocalDeliveryOption {
    # A custom reference to the delivery method for use with automations.
    code: String

    # The details displayed to the customer to describe the local delivery option.
    description: String

    # The delivery instructions that the customer can provide to the merchant.
    instructions: String

    # The phone number that the customer provided to the merchant.
    # Formatted using E.164 standard. For example, +16135551111.
    phone: String!

    # The presentment title of the local delivery option.
    presentmentTitle: String

    # The title of the local delivery option.
    title: String
}

# A delivery method with a pickup option.
type SubscriptionDeliveryMethodPickup {
    # The details of the pickup delivery method to use.
    pickupOption: SubscriptionDeliveryMethodPickupOption!
}

# Represents the selected pickup option on a subscription contract.
type SubscriptionDeliveryMethodPickupOption {
    # A custom reference to the delivery method for use with automations.
    code: String

    # The details displayed to the customer to describe the pickup option.
    description: String

    # The location where the customer will pickup the merchandise.
    location: Location!

    # The presentment title of the pickup option.
    presentmentTitle: String

    # The title of the pickup option.
    title: String
}

# Represents a shipping delivery method: a mailing address and a shipping option.
type SubscriptionDeliveryMethodShipping {
    # The address to ship to.
    address: SubscriptionMailingAddress!

    # The details of the shipping method to use.
    shippingOption: SubscriptionDeliveryMethodShippingOption!
}

# Represents the selected shipping option on a subscription contract.
type SubscriptionDeliveryMethodShippingOption {
    # The carrier service of the shipping option.
    carrierService: DeliveryCarrierService

    # The code of the shipping option.
    code: String

    # The description of the shipping option.
    description: String

    # The presentment title of the shipping option.
    presentmentTitle: String

    # The title of the shipping option.
    title: String
}

# A shipping service provider or a carrier account.
type DeliveryCarrierService implements Node {
    # The list of services offered for given destinations.
    availableServicesForCountries(
        origins: [ID!]
        countryCodes: [CountryCode!]
        restOfWorld: Boolean!
    ): [DeliveryAvailableService!]!

    # The properly formatted name of the shipping service provider, ready to display.
    formattedName: String

    # The logo of the service provider.
    icon: Image!

    # A globally-unique identifier.
    id: ID!

    # The name of the shipping service provider.
    name: String
}

# A shipping service and a list of countries that the service is available for.
type DeliveryAvailableService {
    # The countries the service provider ships to.
    countries: DeliveryCountryCodesOrRestOfWorld!

    # The name of the service.
    name: String!
}

# The list of country codes and information whether the countries
# are a part of the 'Rest Of World' shipping zone.
type DeliveryCountryCodesOrRestOfWorld {
    # List of applicable country codes in the ISO 3166-1 alpha-2 format.
    countryCodes: [CountryCode!]!

    # Whether the countries are a part of the 'Rest of World' shipping zone.
    restOfWorld: Boolean!
}

# A mail service provided by the participant.
type DeliveryParticipantService {
    # Whether the service is active.
    active: Boolean!

    # The name of the service.
    name: String!
}

# An auto-generated type for paginating through multiple DeliveryProfileItems.
type DeliveryProfileItemConnection {
    # A list of edges.
    edges: [DeliveryProfileItemEdge!]!

    # A list of the nodes contained in DeliveryProfileItemEdge.
    nodes: [DeliveryProfileItem!]!

    # Information to aid in pagination.
    pageInfo: PageInfo!
}

# An auto-generated type which holds one DeliveryProfileItem and a cursor during pagination.
type DeliveryProfileItemEdge {
    # A cursor for use in pagination.
    cursor: String!

    # The item at the end of DeliveryProfileItemEdge.
    node: DeliveryProfileItem!
}

# An auto-generated type for paginating through multiple DeliveryLocationGroupZones.
type DeliveryLocationGroupZoneConnection {
    # A list of edges.
    edges: [DeliveryLocationGroupZoneEdge!]!

    # A list of the nodes contained in DeliveryLocationGroupZoneEdge.
    nodes: [DeliveryLocationGroupZone!]!

    # Information to aid in pagination.
    pageInfo: PageInfo!
}

# An auto-generated type which holds one DeliveryLocationGroupZone and a cursor during pagination.
type DeliveryLocationGroupZoneEdge {
    # A cursor for use in pagination.
    cursor: String!

    # The item at the end of DeliveryLocationGroupZoneEdge.
    node: DeliveryLocationGroupZone!
}

# An auto-generated type for paginating through multiple DeliveryMethodDefinitions.
type DeliveryMethodDefinitionConnection {
    # A list of edges.
    edges: [DeliveryMethodDefinitionEdge!]!

    # A list of the nodes contained in DeliveryMethodDefinitionEdge.
    nodes: [DeliveryMethodDefinition!]!

    # Information to aid in pagination.
    pageInfo: PageInfo!
}

# An auto-generated type which holds one DeliveryMethodDefinition and a cursor during pagination.
type DeliveryMethodDefinitionEdge {
    # A cursor for use in pagination.
    cursor: String!

    # The item at the end of DeliveryMethodDefinitionEdge.
    node: DeliveryMethodDefinition!
}
