type SimplyinCheckEmailOutput {
    success: Boolean! @doc(description: "Whether the operation succeeded")
    message: String @doc(description: "Response message")
    user_exists: Boolean @doc(description: "Whether the user exists in SimplyIN")
    user_used_push_notifications: Boolean @doc(description: "Whether the user uses push notifications")
    notification_token_id: String @doc(description: "Token ID for push notification polling")
    code: String @doc(description: "OTP code hint if available")
    masked_data: String @doc(description: "Masked contact data JSON string")
}

type SimplyinVerifyOtpOutput {
    success: Boolean! @doc(description: "Whether the operation succeeded")
    message: String @doc(description: "Response message")
    auth_token: String @doc(description: "SimplyIN authentication token")
    user_data: SimplyinUserData @doc(description: "User profile data")
}

type SimplyinResendOtpOutput {
    success: Boolean! @doc(description: "Whether the operation succeeded")
    message: String @doc(description: "Response message")
    method: String @doc(description: "Delivery method used: sms or email")
}

type SimplyinCheckPushStatusOutput {
    success: Boolean! @doc(description: "Whether the operation succeeded")
    message: String @doc(description: "Response message")
    approved: Boolean! @doc(description: "Whether the push notification was approved")
    auth_token: String @doc(description: "SimplyIN authentication token if approved")
    refresh_token: String @doc(description: "SimplyIN refresh token if approved")
    user_data: SimplyinUserData @doc(description: "User profile data if approved")
}

type SimplyinCreateAccountOutput {
    success: Boolean! @doc(description: "Whether the operation succeeded")
    message: String @doc(description: "Response message")
    auth_token: String @doc(description: "SimplyIN authentication token")
    requires_otp: Boolean @doc(description: "Whether OTP verification is required")
}

type SimplyinUserData {
    raw_json: String @doc(description: "Full user data object as JSON string")
    email: String @doc(description: "User email address")
    name: String @doc(description: "User first name")
    surname: String @doc(description: "User last name")
    phone: String @doc(description: "User phone number")
}

type SimplyinGetUserDataOutput {
    success: Boolean! @doc(description: "Whether the operation succeeded")
    message: String @doc(description: "Response message")
    user_data: SimplyinUserData @doc(description: "User profile data")
}

type SimplyinPaymentMethod {
    payment_method_id: String @doc(description: "SimplyIN payment method ID")
    type: String @doc(description: "Payment method type e.g. blik, add_card")
    name: String @doc(description: "Payment method display name")
    raw_json: String @doc(description: "Full payment method object as JSON string")
}

type SimplyinGetPaymentMethodsOutput {
    success: Boolean! @doc(description: "Whether the operation succeeded")
    message: String @doc(description: "Response message")
    payment_methods: [SimplyinPaymentMethod] @doc(description: "List of available payment methods")
}

type SimplyinCheckPaymentStatusOutput {
    success: Boolean! @doc(description: "Whether the operation succeeded")
    message: String @doc(description: "Response message")
    payment_id: String @doc(description: "SimplyIN payment ID")
    status: String @doc(description: "Payment status: PENDING, COMPLETED, or FAILED")
    order_id: String @doc(description: "Magento order increment ID")
    order_state: String @doc(description: "Magento order state")
    simplyin_status: String @doc(description: "Raw SimplyIN payment status")
    webhook_received: String @doc(description: "Timestamp when webhook was received")
    error_message: String @doc(description: "Error message if payment failed")
    source: String @doc(description: "Status source: local or api")
}

type SimplyinUpdateOrderPaymentOutput {
    success: Boolean! @doc(description: "Whether the operation succeeded")
    message: String @doc(description: "Response message")
}

type SimplyinVerifyPaymentOutput {
    success: Boolean! @doc(description: "Whether the operation succeeded")
    message: String @doc(description: "Response message")
    payment_raw_json: String @doc(description: "Payment data returned by SimplyIN API as JSON string")
}

type SimplyinPlaceMagentoOrderOutput {
    success: Boolean! @doc(description: "Whether the operation succeeded")
    message: String @doc(description: "Response message")
    order_id: Int @doc(description: "Magento order entity ID")
    increment_id: String @doc(description: "Magento order increment ID")
}

type SimplyinAddress {
    id: String @doc(description: "SimplyIN address ID")
    name: String @doc(description: "First name")
    surname: String @doc(description: "Last name")
    street: String @doc(description: "Street address")
    appartment_number: String @doc(description: "Apartment or unit number")
    city: String @doc(description: "City")
    postal_code: String @doc(description: "Postal code")
    country: String @doc(description: "Country code")
    county: String @doc(description: "State, region or county")
    raw_json: String @doc(description: "Full address object as JSON string")
}

type SimplyinAddressOutput {
    success: Boolean! @doc(description: "Whether the operation succeeded")
    message: String @doc(description: "Response message")
    address: SimplyinAddress @doc(description: "The created or updated address")
}

type SimplyinDeleteAddressOutput {
    success: Boolean! @doc(description: "Whether the operation succeeded")
    message: String @doc(description: "Response message")
}

type SimplyinSearchAddressOutput {
    success: Boolean! @doc(description: "Whether the operation succeeded")
    message: String @doc(description: "Response message")
    addresses_raw_json: String @doc(description: "Address suggestions as JSON array string")
}

type SimplyinParcelLocker {
    locker_id: String @doc(description: "Provider-specific locker ID")
    provider_name: String @doc(description: "Shipping provider name e.g. inpost, orlen, dpd")
    name: String @doc(description: "Locker display name")
    address: String @doc(description: "Locker street address")
    city: String @doc(description: "Locker city")
    postal_code: String @doc(description: "Locker postal code")
    service_type: String @doc(description: "Service type: parcel_machine or pickup_point")
    raw_json: String @doc(description: "Full locker object as JSON string")
}

type SimplyinGetParcelLockersOutput {
    success: Boolean! @doc(description: "Whether the operation succeeded")
    message: String @doc(description: "Response message")
    parcel_machines: [SimplyinParcelLocker] @doc(description: "List of parcel machine lockers")
    pickup_points: [SimplyinParcelLocker] @doc(description: "List of pickup point lockers")
    available_providers: [String] @doc(description: "List of configured provider names")
}

type SimplyinParcelLockerOutput {
    success: Boolean! @doc(description: "Whether the operation succeeded")
    message: String @doc(description: "Response message")
}

type SimplyinSetPickupPointOutput {
    success: Boolean! @doc(description: "Whether the operation succeeded")
    message: String @doc(description: "Response message")
}

type SimplyinUpdateShippingMethodOutput {
    success: Boolean! @doc(description: "Whether the operation succeeded")
    message: String @doc(description: "Response message")
}

input SimplyinAddressInput {
    name: String! @doc(description: "First name")
    surname: String! @doc(description: "Last name")
    street: String! @doc(description: "Street address")
    appartment_number: String @doc(description: "Apartment or unit number")
    city: String! @doc(description: "City")
    postal_code: String! @doc(description: "Postal code")
    country: String! @doc(description: "Country code")
    county: String @doc(description: "State, region or county")
}

input SimplyinAddressUpdateInput {
    name: String @doc(description: "First name")
    surname: String @doc(description: "Last name")
    street: String @doc(description: "Street address")
    appartment_number: String @doc(description: "Apartment or unit number")
    city: String @doc(description: "City")
    postal_code: String @doc(description: "Postal code")
    country: String @doc(description: "Country code")
    county: String @doc(description: "State, region or county")
}

input SimplyinParcelLockerInput {
    locker_id: String! @doc(description: "Provider-specific locker ID")
    provider_name: String! @doc(description: "Shipping provider name")
    name: String @doc(description: "Locker display name")
    address: String @doc(description: "Locker street address")
    city: String @doc(description: "Locker city")
    postal_code: String @doc(description: "Locker postal code")
    service_type: String @doc(description: "Service type: parcel_machine or pickup_point")
}

input SimplyinLockerDataInput {
    locker_id: String @doc(description: "Provider-specific locker ID")
    provider_name: String @doc(description: "Shipping provider name")
    address: String @doc(description: "Locker street address")
    address_name: String @doc(description: "Human-readable address name")
    city: String @doc(description: "Locker city")
    postal_code: String @doc(description: "Locker postal code")
    desc: String @doc(description: "Locker description")
}

input SimplyinCoordinatesInput {
    lat: Float! @doc(description: "Latitude")
    lng: Float! @doc(description: "Longitude")
}

input SimplyinPaymentInfoInput {
    simplyin_payment_id: String @doc(description: "SimplyIN payment ID")
    simplyin_payment_status: String @doc(description: "Payment status")
    simplyin_provider_payment_id: String @doc(description: "Provider payment ID")
    simplyin_redirect_url: String @doc(description: "3DS redirect URL")
    simplyin_registered_at: String @doc(description: "Payment registration timestamp")
    simplyin_redirect_iframe_allowed: Boolean @doc(description: "Whether iframe redirect is allowed")
}

input SimplyinShippingMethodInput {
    carrier_code: String! @doc(description: "Magento carrier code")
    method_code: String! @doc(description: "Magento method code")
    carrier_title: String @doc(description: "Carrier display title")
    method_title: String @doc(description: "Method display title")
    amount: Float @doc(description: "Shipping amount")
    base_amount: Float @doc(description: "Base shipping amount")
}

type SimplyinProcessPaymentOutput {
    success: Boolean! @doc(description: "Whether the operation succeeded")
    message: String @doc(description: "Response message")
    simplyin_order_id: String @doc(description: "SimplyIN order ID, empty in payment-only flow")
    payment_id: String @doc(description: "SimplyIN payment ID")
    provider_payment_id: String @doc(description: "Provider payment/transaction ID")
    payment_status: String @doc(description: "Payment status e.g. PENDING")
    redirect_url: String @doc(description: "3DS redirect URL if required")
    redirect_iframe_allowed: Boolean @doc(description: "Whether the 3DS redirect may be shown in an iframe")
    payment_only: Boolean @doc(description: "Whether this was a payment-only flow (no SimplyIN order)")
    auth_token: String @doc(description: "SimplyIN auth token when an account was created during the flow")
    raw_json: String @doc(description: "Provider payment object as JSON string (provider-specific fields; no order/billing PII)")
}

type SimplyinCreateOrderOutput {
    success: Boolean! @doc(description: "Whether the operation succeeded")
    message: String @doc(description: "Response message")
    simplyin_order_id: String @doc(description: "SimplyIN order ID, empty in payment-only flow")
    payment_id: String @doc(description: "SimplyIN payment ID")
    provider_payment_id: String @doc(description: "Provider payment/transaction ID")
    payment_status: String @doc(description: "Payment status e.g. PENDING")
    redirect_url: String @doc(description: "3DS redirect URL if required")
    redirect_iframe_allowed: Boolean @doc(description: "Whether the 3DS redirect may be shown in an iframe")
    magento_order_id: String @doc(description: "Magento order entity ID that was passed in, if any")
    payment_only: Boolean @doc(description: "Whether this was a payment-only flow (no SimplyIN order)")
    requires_account: Boolean @doc(description: "Whether the flow requires SimplyIN authentication to proceed")
    skip_payment_verification: Boolean @doc(description: "Whether the caller should skip payment verification")
    auth_token: String @doc(description: "SimplyIN auth token when an account was created during the flow")
    raw_json: String @doc(description: "Provider payment object as JSON string (provider-specific fields; no order/billing PII)")
}

type Query {
    simplyinGetPaymentMethods: SimplyinGetPaymentMethodsOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\GetPaymentMethods")
        @doc(description: "Returns available SimplyIN payment methods")

    simplyinGetUserData(
        auth_token: String! @doc(description: "SimplyIN authentication token")
    ): SimplyinGetUserDataOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\GetUserData")
        @doc(description: "Returns SimplyIN user profile data")

    simplyinCheckPaymentStatus(
        payment_id: String @doc(description: "SimplyIN payment ID")
        auth_token: String @doc(description: "SimplyIN authentication token")
        order_id: String @doc(description: "Magento order entity ID or increment ID")
    ): SimplyinCheckPaymentStatusOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\CheckPaymentStatus")
        @doc(description: "Returns current payment status for a SimplyIN payment")

    simplyinGetParcelLockers(
        auth_token: String! @doc(description: "SimplyIN authentication token")
        action: String @doc(description: "getUserLockers or getClosest")
        coordinates: SimplyinCoordinatesInput @doc(description: "Coordinates for getClosest action")
        limit: Int @doc(description: "Maximum number of results for getClosest")
        radius: Int @doc(description: "Search radius in meters for getClosest")
        providers: [String] @doc(description: "Filter by provider names")
    ): SimplyinGetParcelLockersOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\GetParcelLockers")
        @doc(description: "Returns parcel lockers from user profile or closest by coordinates")

    simplyinSearchAddress(
        auth_token: String! @doc(description: "SimplyIN authentication token")
        query: String! @doc(description: "Address search query string")
    ): SimplyinSearchAddressOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\SearchAddress")
        @doc(description: "Returns address suggestions from SimplyIN API")
}

type Mutation {
    simplyinCheckEmail(
        email: String! @doc(description: "Customer email address to check")
    ): SimplyinCheckEmailOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\CheckEmail")
        @doc(description: "Checks if email exists in SimplyIN and sends OTP")

    simplyinVerifyOtp(
        email: String! @doc(description: "Customer email address")
        code: String! @doc(description: "OTP code entered by the customer")
    ): SimplyinVerifyOtpOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\VerifyOtp")
        @doc(description: "Verifies OTP code and returns auth token with user data")

    simplyinResendOtp(
        email: String! @doc(description: "Customer email address")
        method: String @doc(description: "Delivery method: sms (default) or email")
    ): SimplyinResendOtpOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\ResendOtp")
        @doc(description: "Resends OTP via SMS (default) or email")

    simplyinCheckPushStatus(
        email: String! @doc(description: "Customer email address")
        notification_token_id: String! @doc(description: "Notification token ID from checkEmail response")
    ): SimplyinCheckPushStatusOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\CheckPushStatus")
        @doc(description: "Polls push notification approval status")

    simplyinCreateAccount(
        email: String! @doc(description: "Customer email address")
        first_name: String! @doc(description: "Customer first name")
        last_name: String! @doc(description: "Customer last name")
        phone: String! @doc(description: "Customer phone number with country code")
    ): SimplyinCreateAccountOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\CreateAccount")
        @doc(description: "Creates a new SimplyIN account")

    simplyinPlaceMagentoOrder(
        quote_id: String! @doc(description: "Magento quote ID or masked guest quote ID")
        simplyin_order_id: String @doc(description: "SimplyIN order ID")
        simplyin_payment_id: String @doc(description: "SimplyIN payment ID")
        provider_payment_id: String @doc(description: "Payment provider transaction ID")
        payment_status: String @doc(description: "Payment status")
        redirect_url: String @doc(description: "3DS redirect URL")
        redirect_iframe_allowed: Boolean @doc(description: "Whether iframe redirect is allowed")
        card_last4: String @doc(description: "Last 4 digits of card")
        card_brand: String @doc(description: "Card brand e.g. visa, mastercard")
        payment_type: String @doc(description: "Payment type e.g. blik, card")
        auth_token: String @doc(description: "SimplyIN authentication token")
    ): SimplyinPlaceMagentoOrderOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\PlaceMagentoOrder")
        @doc(description: "Places a Magento order using SimplyIN payment data")

    simplyinUpdateOrderPayment(
        order_id: Int! @doc(description: "Magento order entity ID")
        simplyin_order_id: String @doc(description: "SimplyIN order ID")
        payment_info: SimplyinPaymentInfoInput @doc(description: "SimplyIN payment information to store")
    ): SimplyinUpdateOrderPaymentOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\UpdateOrderPayment")
        @doc(description: "Updates Magento order with SimplyIN payment information")

    simplyinSetPickupPoint(
        quote_id: String! @doc(description: "Magento quote ID")
        locker_id: String! @doc(description: "Provider-specific locker ID")
        provider_name: String! @doc(description: "Shipping provider name e.g. inpost, orlen, dpd")
        locker_data: SimplyinLockerDataInput @doc(description: "Additional locker data")
    ): SimplyinSetPickupPointOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\SetPickupPoint")
        @doc(description: "Sets pickup point extension attributes on the quote")

    simplyinAddAddress(
        auth_token: String! @doc(description: "SimplyIN authentication token")
        address: SimplyinAddressInput! @doc(description: "Address data to add")
        address_type: String @doc(description: "Address type: shippingAddresses (default) or billingAddresses")
    ): SimplyinAddressOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\AddAddress")
        @doc(description: "Adds a new address to the SimplyIN user profile")

    simplyinUpdateAddress(
        auth_token: String! @doc(description: "SimplyIN authentication token")
        address_id: String! @doc(description: "SimplyIN address ID to update")
        address: SimplyinAddressUpdateInput! @doc(description: "Address fields to update")
        address_type: String @doc(description: "Address type: shippingAddresses (default) or billingAddresses")
    ): SimplyinAddressOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\UpdateAddress")
        @doc(description: "Updates an existing address in the SimplyIN user profile")

    simplyinDeleteAddress(
        auth_token: String! @doc(description: "SimplyIN authentication token")
        address_id: String! @doc(description: "SimplyIN address ID to delete")
        address_type: String @doc(description: "Address type: shippingAddresses (default) or billingAddresses")
    ): SimplyinDeleteAddressOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\DeleteAddress")
        @doc(description: "Deletes an address from the SimplyIN user profile")

    simplyinAddParcelLocker(
        auth_token: String! @doc(description: "SimplyIN authentication token")
        parcel_locker: SimplyinParcelLockerInput! @doc(description: "Parcel locker data to add")
    ): SimplyinParcelLockerOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\AddParcelLocker")
        @doc(description: "Adds a parcel locker to the SimplyIN user profile")

    simplyinDeleteParcelLocker(
        auth_token: String! @doc(description: "SimplyIN authentication token")
        locker_id: String! @doc(description: "SimplyIN parcel locker ID to delete")
    ): SimplyinParcelLockerOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\DeleteParcelLocker")
        @doc(description: "Deletes a parcel locker from the SimplyIN user profile")

    simplyinUpdateShippingMethod(
        auth_token: String! @doc(description: "SimplyIN authentication token")
        shipping_method: SimplyinShippingMethodInput! @doc(description: "Shipping method data to sync")
    ): SimplyinUpdateShippingMethodOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\UpdateShippingMethod")
        @doc(description: "Syncs selected shipping method to SimplyIN")

    simplyinVerifyPayment(
        magento_order_id: Int! @doc(description: "Magento order entity ID")
        simplyin_order_id: String! @doc(description: "SimplyIN order ID")
        auth_token: String @doc(description: "SimplyIN authentication token")
        payment_data_json: String @doc(description: "Payment payload as JSON string")
    ): SimplyinVerifyPaymentOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\VerifyPayment")
        @doc(description: "Initiates payment verification for an existing order")

    simplyinProcessPayment(
        order_data_json: String! @doc(description: "Order/payment data as a JSON object string (quoteId, billingData, card/BLIK fields, paymentMethod, price, currency, etc.)")
        auth_token: String @doc(description: "SimplyIN authentication token")
        is_new_user: Boolean @doc(description: "Whether the customer is a new SimplyIN user")
        create_account: Boolean @doc(description: "Whether to create a SimplyIN account")
        payment_only: Boolean @doc(description: "Reserved flag mirrored to logging; flow is derived from auth_token/create_account")
    ): SimplyinProcessPaymentOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\ProcessPayment")
        @doc(description: "Processes payment BEFORE a Magento order is created (payment-first flow), so the client can retry on failure. Headless counterpart of the ProcessPayment REST endpoint.")

    simplyinCreateOrder(
        order_data_json: String! @doc(description: "Order/payment data as a JSON object string (magentoOrderId or quoteId, billingData, card/BLIK fields, paymentMethod, price, currency, etc.)")
        auth_token: String @doc(description: "SimplyIN authentication token")
        create_account: Boolean @doc(description: "Whether to create a SimplyIN account")
        is_new_user: Boolean @doc(description: "Whether the customer is a new SimplyIN user")
    ): SimplyinCreateOrderOutput
        @resolver(class: "Simplyin\\Payment\\Model\\Resolver\\CreateOrder")
        @doc(description: "Creates the SimplyIN order (with payment processing) for a placed/placing Magento order. Headless counterpart of the CreateOrder REST endpoint.")
}
