import gql from 'graphql-tag';

export const RENTAL_BY_ORDERID = gql`
  query RentalByOrderId($input: OrderInput) {
    order(input: $input) {
      totalMonthlyCharge
      totalSubscriptionFee
      totalRentalFee
      items {
        title
        name
        description
        rentalFee
        subscriptionFee
        monthlyCharge
        price
        quantity
      }
      contact {
        address
        msisdn
        name
        ssn
        zip
      }
    }
  }
`;

export const ORDER = gql`
  query order($input: OrderInput) {
    order(input: $input) {
      id
      created
      status
      totalPrice
      totalMonthlyCharge
      expires
      totalSubscriptionFee
      totalRentalFee
      totalDue
      payments {
        id
        status
        transactionId
        authorizationCode
        message
        amount
        transactionTimeStamp
        customerSsn
        cardName
        paymentType
        originId
        paymentInfo {
          maskedCardNumber
          msisdn
        }
        paymentUrl
        challenge {
          type
          url
          html
        }
      }
      items {
        id
        name
        quantity
        description
        price
        monthlyCharge
        variantId
        subscriptionFee
        subscriptionFeeDueNow
        rentalFee
        isCollectedByThirdParty
        orderItemAttributes {
          ... on RefillOrderItemAttributes {
            provider
            extendedTrialDate
          }
          ... on PhoneNumberOrderItemAttributes {
            phoneNumber
            registerToPhoneBook
            numberType
            signUp
            serviceCartItemId
            contractOrderItemId
          }
          ... on SubscriptionOrderItemAttributes {
            contract {
              cartItemId
              orderItemId
              type
            }
            service {
              phoneNumber
              mobileSignupRightHolder {
                nationalId
                email
              }
              isNewNumber
              portInDate
              isUnregisteredPlan
              refillInfo {
                startRefillNextMonth
                refillPaymentDate
              }
              roofAmount
              departmentId
              invoiceExplanation
              user {
                name
                customerId
                nationalId
                email
                phoneNumber
              }
            }
            variantId
            productId
          }
        }
        customAttributes {
          msisdn
          ownerSsn
          mobileConnections {
            subscriptionId
          }
          internetConnections {
            subscriptionId
            fiberMsisdn
          }
          fiberMsisdn
          dependendOn
          oneVisit
          periodStart
          periodEnd
        }
      }
      contact {
        id
        name
        msisdn
        ssn
        address
        zip
        email
      }
      shippingInfo {
        shippingType
        price
        title
        shippingDetails {
          storename
          address
          zip
          postbox
          dropp
          freeProductSetup
          extraInfo
          shippingInstructions {
            count
            type
            message
          }
        }
      }
      paymentMethodRegistration {
        id
        paymentType
        recurringPaymentInfo {
          maskedCardNumber
          msisdn
        }
      }
    }
  }
`;
