Rename GraphQL endpoints: companyTeaser → kycProfileTeaser, companyFull → kycProfileFull
All checks were successful
Build Docker Image / build (push) Successful in 2m14s
All checks were successful
Build Docker Image / build (push) Successful in 2m14s
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
"""
|
||||
Public GraphQL Schema for company data.
|
||||
Public GraphQL Schema for KYC profile data.
|
||||
|
||||
This endpoint provides:
|
||||
- companyTeaser: public data (no auth required)
|
||||
- companyFull: full data (requires authentication)
|
||||
- kycProfileTeaser: public data (no auth required)
|
||||
- kycProfileFull: full data (requires authentication)
|
||||
|
||||
Data is read from MongoDB company_documents collection.
|
||||
Queries can be by INN (direct) or by KYC Profile UUID.
|
||||
Queries are by KYC Profile UUID.
|
||||
"""
|
||||
|
||||
import graphene
|
||||
@@ -136,29 +136,16 @@ class PublicQuery(graphene.ObjectType):
|
||||
"""Public queries - no authentication required."""
|
||||
|
||||
# Query by KYC Profile UUID (preferred - used by frontend)
|
||||
company_teaser_by_profile = graphene.Field(
|
||||
kyc_profile_teaser = graphene.Field(
|
||||
CompanyTeaserType,
|
||||
profile_uuid=graphene.String(required=True),
|
||||
description="Get public company teaser data by KYC Profile UUID",
|
||||
description="Get public KYC profile teaser data by UUID",
|
||||
)
|
||||
|
||||
company_full_by_profile = graphene.Field(
|
||||
kyc_profile_full = graphene.Field(
|
||||
CompanyFullType,
|
||||
profile_uuid=graphene.String(required=True),
|
||||
description="Get full company data by KYC Profile UUID (requires auth)",
|
||||
)
|
||||
|
||||
# Query by INN (legacy/direct)
|
||||
company_teaser = graphene.Field(
|
||||
CompanyTeaserType,
|
||||
inn=graphene.String(required=True),
|
||||
description="Get public company teaser data by INN",
|
||||
)
|
||||
|
||||
company_full = graphene.Field(
|
||||
CompanyFullType,
|
||||
inn=graphene.String(required=True),
|
||||
description="Get full company data by INN (requires auth)",
|
||||
description="Get full KYC profile data by UUID (requires auth)",
|
||||
)
|
||||
|
||||
health = graphene.String()
|
||||
@@ -166,7 +153,7 @@ class PublicQuery(graphene.ObjectType):
|
||||
def resolve_health(self, info):
|
||||
return "ok"
|
||||
|
||||
def resolve_company_teaser_by_profile(self, info, profile_uuid: str):
|
||||
def resolve_kyc_profile_teaser(self, info, profile_uuid: str):
|
||||
"""Return public teaser data by KYC Profile UUID."""
|
||||
inn = get_inn_by_profile_uuid(profile_uuid)
|
||||
if not inn:
|
||||
@@ -185,8 +172,8 @@ class PublicQuery(graphene.ObjectType):
|
||||
sources_count=len(summary.get("sources", [])),
|
||||
)
|
||||
|
||||
def resolve_company_full_by_profile(self, info, profile_uuid: str):
|
||||
"""Return full company data by KYC Profile UUID (requires auth)."""
|
||||
def resolve_kyc_profile_full(self, info, profile_uuid: str):
|
||||
"""Return full KYC profile data by UUID (requires auth)."""
|
||||
# Check authentication
|
||||
user_id = getattr(info.context, 'user_id', None)
|
||||
if not user_id:
|
||||
@@ -217,48 +204,5 @@ class PublicQuery(graphene.ObjectType):
|
||||
last_updated=summary.get("last_updated"),
|
||||
)
|
||||
|
||||
def resolve_company_teaser(self, info, inn: str):
|
||||
"""Return public teaser data by INN (no auth required)."""
|
||||
documents = get_company_documents(inn)
|
||||
if not documents:
|
||||
return None
|
||||
|
||||
summary = aggregate_company_data(documents)
|
||||
|
||||
return CompanyTeaserType(
|
||||
company_type=summary.get("company_type"),
|
||||
registration_year=summary.get("registration_year"),
|
||||
is_active=summary.get("is_active", True),
|
||||
sources_count=len(summary.get("sources", [])),
|
||||
)
|
||||
|
||||
def resolve_company_full(self, info, inn: str):
|
||||
"""Return full company data by INN (requires auth)."""
|
||||
# Check authentication
|
||||
user_id = getattr(info.context, 'user_id', None)
|
||||
if not user_id:
|
||||
return None # Not authenticated
|
||||
|
||||
documents = get_company_documents(inn)
|
||||
if not documents:
|
||||
return None
|
||||
|
||||
summary = aggregate_company_data(documents)
|
||||
|
||||
return CompanyFullType(
|
||||
inn=summary.get("inn"),
|
||||
ogrn=summary.get("ogrn"),
|
||||
name=summary.get("name"),
|
||||
company_type=summary.get("company_type"),
|
||||
registration_year=summary.get("registration_year"),
|
||||
is_active=summary.get("is_active", True),
|
||||
address=summary.get("address"),
|
||||
director=summary.get("director"),
|
||||
capital=summary.get("capital"),
|
||||
activities=summary.get("activities", []),
|
||||
sources=summary.get("sources", []),
|
||||
last_updated=summary.get("last_updated"),
|
||||
)
|
||||
|
||||
|
||||
public_schema = graphene.Schema(query=PublicQuery)
|
||||
|
||||
Reference in New Issue
Block a user