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:
|
This endpoint provides:
|
||||||
- companyTeaser: public data (no auth required)
|
- kycProfileTeaser: public data (no auth required)
|
||||||
- companyFull: full data (requires authentication)
|
- kycProfileFull: full data (requires authentication)
|
||||||
|
|
||||||
Data is read from MongoDB company_documents collection.
|
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
|
import graphene
|
||||||
@@ -136,29 +136,16 @@ class PublicQuery(graphene.ObjectType):
|
|||||||
"""Public queries - no authentication required."""
|
"""Public queries - no authentication required."""
|
||||||
|
|
||||||
# Query by KYC Profile UUID (preferred - used by frontend)
|
# Query by KYC Profile UUID (preferred - used by frontend)
|
||||||
company_teaser_by_profile = graphene.Field(
|
kyc_profile_teaser = graphene.Field(
|
||||||
CompanyTeaserType,
|
CompanyTeaserType,
|
||||||
profile_uuid=graphene.String(required=True),
|
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,
|
CompanyFullType,
|
||||||
profile_uuid=graphene.String(required=True),
|
profile_uuid=graphene.String(required=True),
|
||||||
description="Get full company data by KYC Profile UUID (requires auth)",
|
description="Get full KYC profile data by 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)",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
health = graphene.String()
|
health = graphene.String()
|
||||||
@@ -166,7 +153,7 @@ class PublicQuery(graphene.ObjectType):
|
|||||||
def resolve_health(self, info):
|
def resolve_health(self, info):
|
||||||
return "ok"
|
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."""
|
"""Return public teaser data by KYC Profile UUID."""
|
||||||
inn = get_inn_by_profile_uuid(profile_uuid)
|
inn = get_inn_by_profile_uuid(profile_uuid)
|
||||||
if not inn:
|
if not inn:
|
||||||
@@ -185,8 +172,8 @@ class PublicQuery(graphene.ObjectType):
|
|||||||
sources_count=len(summary.get("sources", [])),
|
sources_count=len(summary.get("sources", [])),
|
||||||
)
|
)
|
||||||
|
|
||||||
def resolve_company_full_by_profile(self, info, profile_uuid: str):
|
def resolve_kyc_profile_full(self, info, profile_uuid: str):
|
||||||
"""Return full company data by KYC Profile UUID (requires auth)."""
|
"""Return full KYC profile data by UUID (requires auth)."""
|
||||||
# Check authentication
|
# Check authentication
|
||||||
user_id = getattr(info.context, 'user_id', None)
|
user_id = getattr(info.context, 'user_id', None)
|
||||||
if not user_id:
|
if not user_id:
|
||||||
@@ -217,48 +204,5 @@ class PublicQuery(graphene.ObjectType):
|
|||||||
last_updated=summary.get("last_updated"),
|
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)
|
public_schema = graphene.Schema(query=PublicQuery)
|
||||||
|
|||||||
Reference in New Issue
Block a user