Struct SubscriptionState
- Namespace
- Cloudflare.NET.Subscriptions.Models
- Assembly
- Cloudflare.NET.dll
Represents the state of a subscription.
Subscription states indicate the lifecycle stage of the subscription:
- TrialThe subscription is in a trial period
- ProvisionedThe subscription has been provisioned but not yet paid
- PaidThe subscription is active and paid
- AwaitingPaymentThe subscription is awaiting payment
- CancelledThe subscription has been cancelled
- FailedA payment or provisioning failure occurred
- ExpiredThe subscription has expired
[JsonConverter(typeof(ExtensibleEnumConverter<SubscriptionState>))]
public readonly struct SubscriptionState : IExtensibleEnum<SubscriptionState>, IEquatable<SubscriptionState>
- Implements
- Inherited Members
Examples
// Using a known state with IntelliSense
var state = SubscriptionState.Paid;
// Checking subscription state
if (subscription.State == SubscriptionState.AwaitingPayment) { ... }
// Using implicit conversion from string
SubscriptionState customState = "suspended";
Remarks
This is an extensible enum that provides IntelliSense for known values while allowing custom values for new states that may be added to the Cloudflare API in the future.
Constructors
SubscriptionState(string)
Creates a new SubscriptionState with the specified value.
public SubscriptionState(string value)
Parameters
valuestringThe string value representing the subscription state.
Exceptions
- ArgumentNullException
Thrown when
valueis null.
Properties
AwaitingPayment
The subscription is awaiting payment.
Payment has not been received; the subscription may be suspended if payment is not made.
public static SubscriptionState AwaitingPayment { get; }
Property Value
Cancelled
The subscription has been cancelled.
The subscription is no longer active and features have been disabled.
public static SubscriptionState Cancelled { get; }
Property Value
Expired
The subscription has expired.
The subscription term has ended and needs to be renewed.
public static SubscriptionState Expired { get; }
Property Value
Failed
A payment or provisioning failure occurred.
The subscription could not be activated or renewed due to a failure.
public static SubscriptionState Failed { get; }
Property Value
Paid
The subscription is active and paid.
This is the normal operational state for an active subscription.
public static SubscriptionState Paid { get; }
Property Value
Provisioned
The subscription has been provisioned but not yet paid.
The subscription is active but awaiting initial payment confirmation.
public static SubscriptionState Provisioned { get; }
Property Value
Trial
The subscription is in a trial period.
Trial subscriptions provide temporary access to features before payment is required.
public static SubscriptionState Trial { get; }
Property Value
Value
Gets the underlying string value of this subscription state.
public string Value { get; }
Property Value
Methods
Create(string)
Creates a new instance of the extensible enum from the specified string value.
public static SubscriptionState Create(string value)
Parameters
valuestringThe string value to wrap.
Returns
- SubscriptionState
A new instance of SubscriptionState containing the specified value.
Equals(SubscriptionState)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(SubscriptionState other)
Parameters
otherSubscriptionStateAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Operators
operator ==(SubscriptionState, SubscriptionState)
Determines whether two SubscriptionState values are equal.
public static bool operator ==(SubscriptionState left, SubscriptionState right)
Parameters
leftSubscriptionStaterightSubscriptionState
Returns
implicit operator string(SubscriptionState)
Implicitly converts a SubscriptionState to its string value.
public static implicit operator string(SubscriptionState state)
Parameters
stateSubscriptionStateThe subscription state to convert.
Returns
implicit operator SubscriptionState(string)
Implicitly converts a string to a SubscriptionState.
public static implicit operator SubscriptionState(string value)
Parameters
valuestringThe string value to convert.
Returns
operator !=(SubscriptionState, SubscriptionState)
Determines whether two SubscriptionState values are not equal.
public static bool operator !=(SubscriptionState left, SubscriptionState right)
Parameters
leftSubscriptionStaterightSubscriptionState