001// --------------------------------------------------------------------------------
002// Copyright 2002-2025 Echo Three, LLC
003//
004// Licensed under the Apache License, Version 2.0 (the "License");
005// you may not use this file except in compliance with the License.
006// You may obtain a copy of the License at
007//
008//     http://www.apache.org/licenses/LICENSE-2.0
009//
010// Unless required by applicable law or agreed to in writing, software
011// distributed under the License is distributed on an "AS IS" BASIS,
012// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013// See the License for the specific language governing permissions and
014// limitations under the License.
015// --------------------------------------------------------------------------------
016
017package com.echothree.model.control.contact.server.graphql;
018
019import com.echothree.model.control.contact.common.workflow.EmailAddressStatusConstants;
020import com.echothree.model.control.contact.common.workflow.EmailAddressVerificationConstants;
021import com.echothree.model.control.graphql.server.graphql.BaseObject;
022import com.echothree.model.control.workflow.server.graphql.WorkflowEntityStatusObject;
023import com.echothree.model.data.contact.server.entity.ContactEmailAddress;
024import com.echothree.util.common.persistence.BasePK;
025import graphql.annotations.annotationTypes.GraphQLDescription;
026import graphql.annotations.annotationTypes.GraphQLField;
027import graphql.annotations.annotationTypes.GraphQLName;
028import graphql.schema.DataFetchingEnvironment;
029
030@GraphQLDescription("contact email address object")
031@GraphQLName("ContactEmailAddress")
032public class ContactEmailAddressObject
033        extends BaseObject
034        implements ContactMechanismInterface {
035
036    private final BasePK basePrimaryKey; // Always Present
037    private final ContactEmailAddress contactEmailAddress; // Always Present
038
039    public ContactEmailAddressObject(BasePK basePrimaryKey, ContactEmailAddress contactEmailAddress) {
040        this.basePrimaryKey = basePrimaryKey;
041        this.contactEmailAddress = contactEmailAddress;
042    }
043
044    @GraphQLField
045    @GraphQLDescription("email address")
046    public String getEmailAddress() {
047        return contactEmailAddress.getEmailAddress();
048    }
049
050    @GraphQLField
051    @GraphQLDescription("email address status")
052    public WorkflowEntityStatusObject getEmailAddressStatus(final DataFetchingEnvironment env) {
053        return getWorkflowEntityStatusObject(env, basePrimaryKey, EmailAddressStatusConstants.Workflow_EMAIL_ADDRESS_STATUS);
054    }
055
056    @GraphQLField
057    @GraphQLDescription("email address verification")
058    public WorkflowEntityStatusObject getEmailAddressVerification(final DataFetchingEnvironment env) {
059        return getWorkflowEntityStatusObject(env, basePrimaryKey, EmailAddressVerificationConstants.Workflow_EMAIL_ADDRESS_VERIFICATION);
060    }
061
062}