Exemplo n.º 1
0
        internal static PhoneNumberOperation DeserializePhoneNumberOperation(JsonElement element)
        {
            PhoneNumberOperationStatus    status           = default;
            Optional <string>             resourceLocation = default;
            DateTimeOffset                createdDateTime  = default;
            Optional <CommunicationError> error            = default;
            string id = default;
            PhoneNumberOperationType  operationType      = default;
            Optional <DateTimeOffset> lastActionDateTime = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("status"))
                {
                    status = new PhoneNumberOperationStatus(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("resourceLocation"))
                {
                    resourceLocation = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("createdDateTime"))
                {
                    createdDateTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    error = CommunicationError.DeserializeCommunicationError(property.Value);
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("operationType"))
                {
                    operationType = new PhoneNumberOperationType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("lastActionDateTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    lastActionDateTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
            }
            return(new PhoneNumberOperation(status, resourceLocation.Value, createdDateTime, error.Value, id, operationType, Optional.ToNullable(lastActionDateTime)));
        }
 internal CommunicationError(string code, string message, string target, IReadOnlyList <CommunicationError> details, CommunicationError innerError)
 {
     Code       = code;
     Message    = message;
     Target     = target;
     Details    = details;
     InnerError = innerError;
 }
Exemplo n.º 3
0
        internal CommunicationErrorResponse(CommunicationError error)
        {
            if (error == null)
            {
                throw new ArgumentNullException(nameof(error));
            }

            Error = error;
        }
Exemplo n.º 4
0
 internal PhoneNumberOperation(PhoneNumberOperationStatus status, string resourceLocation, DateTimeOffset createdDateTime, CommunicationError error, string id, PhoneNumberOperationType operationType, DateTimeOffset?lastActionDateTime)
 {
     Status           = status;
     ResourceLocation = resourceLocation;
     CreatedDateTime  = createdDateTime;
     Error            = error;
     Id                 = id;
     OperationType      = operationType;
     LastActionDateTime = lastActionDateTime;
 }
Exemplo n.º 5
0
        internal static CommunicationErrorResponse DeserializeCommunicationErrorResponse(JsonElement element)
        {
            CommunicationError error = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("error"))
                {
                    error = CommunicationError.DeserializeCommunicationError(property.Value);
                    continue;
                }
            }
            return(new CommunicationErrorResponse(error));
        }