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.TelephoneStatusConstants; 020import com.echothree.model.control.geo.server.graphql.GeoCodeObject; 021import com.echothree.model.control.geo.server.graphql.GeoSecurityUtils; 022import com.echothree.model.control.graphql.server.graphql.BaseObject; 023import com.echothree.model.control.workflow.server.graphql.WorkflowEntityStatusObject; 024import com.echothree.model.data.contact.server.entity.ContactTelephone; 025import com.echothree.util.common.persistence.BasePK; 026import graphql.annotations.annotationTypes.GraphQLDescription; 027import graphql.annotations.annotationTypes.GraphQLField; 028import graphql.annotations.annotationTypes.GraphQLName; 029import graphql.annotations.annotationTypes.GraphQLNonNull; 030import graphql.schema.DataFetchingEnvironment; 031 032@GraphQLDescription("contact telephone object") 033@GraphQLName("ContactTelephone") 034public class ContactTelephoneObject 035 extends BaseObject 036 implements ContactMechanismInterface { 037 038 private final BasePK basePrimaryKey; // Always Present 039 private final ContactTelephone contactTelephone; // Always Present 040 041 public ContactTelephoneObject(BasePK basePrimaryKey, ContactTelephone contactTelephone) { 042 this.basePrimaryKey = basePrimaryKey; 043 this.contactTelephone = contactTelephone; 044 } 045 046 @GraphQLField 047 @GraphQLDescription("country geo code") 048 @GraphQLNonNull 049 public GeoCodeObject getCountryGeoCode(final DataFetchingEnvironment env) { 050 if(GeoSecurityUtils.getHasGeoCodeAccess(env)) { 051 return new GeoCodeObject(contactTelephone.getCountryGeoCode()); 052 } else { 053 return null; 054 } 055 } 056 057 @GraphQLField 058 @GraphQLDescription("area code") 059 public String getAreaCode() { 060 return contactTelephone.getAreaCode(); 061 } 062 063 @GraphQLField 064 @GraphQLDescription("telephone number") 065 public String getTelephoneNumber() { 066 return contactTelephone.getTelephoneNumber(); 067 } 068 069 @GraphQLField 070 @GraphQLDescription("telephone extension") 071 public String getTelephoneExtension() { 072 return contactTelephone.getTelephoneExtension(); 073 } 074 075 @GraphQLField 076 @GraphQLDescription("telephone status") 077 public WorkflowEntityStatusObject getTelephoneStatus(final DataFetchingEnvironment env) { 078 return getWorkflowEntityStatusObject(env, basePrimaryKey, TelephoneStatusConstants.Workflow_TELEPHONE_STATUS); 079 } 080 081}