<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/cloud/commerce/consumer/procurement/v1/procurement_service.proto

namespace Google\Cloud\Commerce\Consumer\Procurement\V1\CancelOrderRequest;

use UnexpectedValueException;

/**
 * Indicates the cancellation policy the customer uses to cancel the order.
 *
 * Protobuf type <code>google.cloud.commerce.consumer.procurement.v1.CancelOrderRequest.CancellationPolicy</code>
 */
class CancellationPolicy
{
    /**
     * If unspecified, cancellation will try to cancel the order, if order
     * cannot be immediately cancelled, auto renewal will be turned off.
     * However, caller should avoid using the value as it will yield a
     * non-deterministic result. This is still supported mainly to maintain
     * existing integrated usages and ensure backwards compatibility.
     *
     * Generated from protobuf enum <code>CANCELLATION_POLICY_UNSPECIFIED = 0;</code>
     */
    const CANCELLATION_POLICY_UNSPECIFIED = 0;
    /**
     * Request will cancel the whole order immediately, if order cannot be
     * immediately cancelled, the request will fail.
     *
     * Generated from protobuf enum <code>CANCELLATION_POLICY_CANCEL_IMMEDIATELY = 1;</code>
     */
    const CANCELLATION_POLICY_CANCEL_IMMEDIATELY = 1;
    /**
     * Request will cancel the auto renewal, if order is not subscription based,
     * the request will fail.
     *
     * Generated from protobuf enum <code>CANCELLATION_POLICY_CANCEL_AT_TERM_END = 2;</code>
     */
    const CANCELLATION_POLICY_CANCEL_AT_TERM_END = 2;

    private static $valueToName = [
        self::CANCELLATION_POLICY_UNSPECIFIED => 'CANCELLATION_POLICY_UNSPECIFIED',
        self::CANCELLATION_POLICY_CANCEL_IMMEDIATELY => 'CANCELLATION_POLICY_CANCEL_IMMEDIATELY',
        self::CANCELLATION_POLICY_CANCEL_AT_TERM_END => 'CANCELLATION_POLICY_CANCEL_AT_TERM_END',
    ];

    public static function name($value)
    {
        if (!isset(self::$valueToName[$value])) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no name defined for value %s', __CLASS__, $value));
        }
        return self::$valueToName[$value];
    }


    public static function value($name)
    {
        $const = __CLASS__ . '::' . strtoupper($name);
        if (!defined($const)) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no value defined for name %s', __CLASS__, $name));
        }
        return constant($const);
    }
}


