Module: ShopifyOracle::Fragments

Defined in:
lib/shopify_oracle/fragments.rb

Constant Summary collapse

SELLING_PLAN_DELIVERY_POLICY =
<<~GRAPHQL
  fragment DeliveryPolicy on SellingPlanDeliveryPolicy {
    interval
    intervalCount
  }
GRAPHQL
SELLING_PLAN =
<<~GRAPHQL
  fragment SellingPlan on SellingPlan {
    id
    createdAt
    description
    name
    options
    position
    billingPolicy {
      ... on SellingPlanRecurringBillingPolicy {
        createdAt
        interval
        intervalCount
        maxCycles
        minCycles
      }
    }
    deliveryPolicy {
      ... on SellingPlanRecurringDeliveryPolicy {
        createdAt
        cutoff
        intent
        interval
        intervalCount
      }
    }
    pricingPolicies {
      ... on SellingPlanRecurringPricingPolicy {
        adjustmentType
        adjustmentValue
        createdAt
        afterCycle
      }
      ... on SellingPlanFixedPricingPolicy {
        adjustmentType
        adjustmentValue {
          ... on MoneyV2 {
            amount
            currencyCode
          }
          ... on SellingPlanPricingPolicyPercentageValue {
            percentage
          }
        }
        createdAt
      }

    }
  }
GRAPHQL
SELLING_PLAN_GROUP =
<<~GRAPHQL.freeze
  #{SELLING_PLAN}

  fragment SellingPlanGroup on SellingPlanGroup {
    createdAt
    id
    description
    merchantCode
    name
    options
    position
    productCount
    products(first: $first) {
      edges {
        node {
          id
        }
      }
    }
    productVariantCount
    productVariants(first: $first) {
      edges {
        node {
          id
        }
      }
    }
    summary
    sellingPlans(first: $first) {
      edges {
        node {
          ...SellingPlan
        }
      }
    }
  }
GRAPHQL
CUSTOMER_PAYMENT_METHOD =
<<~GRAPHQL
  fragment CustomerPaymentMethod on CustomerPaymentMethod {
    id
    instrument
    revokedAt
    revokedReason
  }
GRAPHQL
CUSTOMER =
<<~GRAPHQL.freeze
  #{CUSTOMER_PAYMENT_METHOD}

  fragment Customer on Customer {
    id
    firstName
    lastName
    displayName
    email
    paymentMethods(first: 10) {
      edges {
        node {
          ...CustomerPaymentMethod
        }
      }
    }
  }
GRAPHQL
MONEY =
<<~GRAPHQL
  fragment Money on MoneyV2 {
    amount
    currencyCode
  }
GRAPHQL
PRICING_POLICY =
<<~GRAPHQL
  fragment PricingPolicy on SubscriptionPricingPolicy {
    basePrice {
      ...Money
    }
    cycleDiscounts {
      adjustmentType
      adjustmentValue
      afterCycle
      computedPrice {
        ...Money
      }
    }
  }
GRAPHQL
BILLING_POLICY =
<<~GRAPHQL
  fragment BillingPolicy on SubscriptionBillingPolicy {
    interval
    intervalCount
    maxCycles
    minCycles
  }
GRAPHQL
DELIVERY_POLICY =
<<~GRAPHQL
  fragment DeliveryPolicy on SubscriptionDeliveryPolicy {
    interval
    intervalCount
  }
GRAPHQL
LINE_ADDED =
<<~GRAPHQL.freeze
  #{MONEY}
  #{PRICING_POLICY}

  fragment LineAdded on SubscriptionLine {
    currentPrice {
      ...Money
    }
    discountAllocations {
      amount {
        ...Money
      }
      discount
    }
    id
    pricingPolicy {
      ...PricingPolicy
    }
    productId
    quantity
    requiresShipping
    sellingPlanId
    sellingPlanName
    sku
    taxable
    title
    variantId
    variantImage {
      url
    }
    variantTitle
  }
GRAPHQL
SUBSCRIPTION_DRAFT =
<<~GRAPHQL.freeze
  #{CUSTOMER}
  #{DELIVERY_POLICY}
  #{BILLING_POLICY}
  #{MONEY}

  fragment SubscriptionDraft on SubscriptionDraft {
    currencyCode
    customAttributes {
      key
      value
    }
    customer {
      ...Customer
    }
    customerPaymentMethod {
      id
      instrument
      revokedAt
      revokedReason
    }
    billingPolicy {
      ...BillingPolicy
    }
    deliveryMethod
    deliveryPolicy {
      ...DeliveryPolicy
    }
    deliveryPrice {
      ...Money
    }
    id
    nextBillingDate
    shippingOptions
    status
  }
GRAPHQL
ADDRESS =
<<~GRAPHQL
  fragment Address on SubscriptionMailingAddress {
    address1
    address2
    city
    company
    country
    countryCode
    firstName
    lastName
    name
    phone
    province
    provinceCode
    zip
  }
GRAPHQL
SHIPPING_OPTION =
<<~GRAPHQL
  fragment ShippingOption on SubscriptionDeliveryMethodShippingOption {
    code
    description
    presentmentTitle
    title
  }
GRAPHQL
DELIVERY_METHOD =
<<~GRAPHQL
  #{ADDRESS}
  #{SHIPPING_OPTION}

  fragment DeliveryMethod on SubscriptionDeliveryMethodShipping {
    address {
      ...Address
    }
    shippingOption {
      ...ShippingOption
    }
  }
GRAPHQL
SUBSCRIPTION_CONTRACT =
<<~GRAPHQL
  #{MONEY}
  #{BILLING_POLICY}
  #{DELIVERY_POLICY}
  #{CUSTOMER}
  #{DELIVERY_METHOD}

  fragment SubscriptionContract on SubscriptionContract {
    id
    createdAt
    currencyCode
    deliveryPrice {
      ...Money
    }
    lastPaymentStatus
    lineCount
    note
    status
    appAdminUrl
    nextBillingDate
    customAttributes {
      key
      value
    }
    billingPolicy {
      ...BillingPolicy
    }
    deliveryPolicy {
      ...DeliveryPolicy
    }
    customerPaymentMethod {
      ...CustomerPaymentMethod
    }
    customer {
      ...Customer
    }
    deliveryMethod {
      ... on SubscriptionDeliveryMethodShipping {
        ...DeliveryMethod
      }
    }
  }
GRAPHQL