This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
import type { YandexPvzResponse } from '~/server/shared/types/yandex_pvz'
|
||||
import axios from 'axios'
|
||||
import { defineEventHandler, readBody } from 'h3'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
export default defineEventHandler(async (event): Promise<YandexPvzResponse | { error: string }> => {
|
||||
try {
|
||||
const data = await readBody(event)
|
||||
const apiUrl = process.env.VITE_YANDEX_B2B_BASE_URL!
|
||||
const token = process.env.VITE_YANDEX_B2B_TOKEN!
|
||||
|
||||
const response = await axios.post(
|
||||
const response = await axios.post<YandexPvzResponse>(
|
||||
`${apiUrl}/pickup-points/list`,
|
||||
{
|
||||
geo_id: data?.geo_id,
|
||||
|
||||
75
server/shared/types/yandex_pvz.ts
Normal file
75
server/shared/types/yandex_pvz.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
export interface GeoPosition {
|
||||
latitude: number
|
||||
longitude: number
|
||||
}
|
||||
|
||||
export interface PvzAddress {
|
||||
apartment: string
|
||||
building: string
|
||||
comment: string
|
||||
country: string
|
||||
full_address: string
|
||||
geoId: number
|
||||
house: string
|
||||
housing: string
|
||||
locality: string
|
||||
postal_code: string
|
||||
region: string
|
||||
street: string
|
||||
subRegion: string
|
||||
}
|
||||
|
||||
export interface Contact {
|
||||
phone: string
|
||||
}
|
||||
|
||||
export interface TimeObject {
|
||||
hours: number
|
||||
minutes: number
|
||||
}
|
||||
|
||||
export interface ScheduleRestriction {
|
||||
days: number[]
|
||||
time_from: TimeObject
|
||||
time_to: TimeObject
|
||||
}
|
||||
|
||||
export interface Schedule {
|
||||
time_zone: number
|
||||
restrictions: ScheduleRestriction[]
|
||||
}
|
||||
|
||||
export interface PickupServices {
|
||||
is_fitting_allowed: boolean
|
||||
is_partial_refuse_allowed: boolean
|
||||
is_paperless_pickup_allowed: boolean
|
||||
is_unboxing_allowed: boolean
|
||||
}
|
||||
|
||||
export interface PickupPoint {
|
||||
id: string
|
||||
operator_station_id: string
|
||||
operator_id: string
|
||||
name: string
|
||||
type: 'pickup_point'
|
||||
address: PvzAddress
|
||||
position: GeoPosition
|
||||
instruction: string
|
||||
available_for_dropoff: boolean
|
||||
available_for_c2c_dropoff: boolean
|
||||
contact: Contact
|
||||
schedule: Schedule
|
||||
pickup_services: PickupServices
|
||||
payment_methods: string[]
|
||||
is_dark_store: boolean
|
||||
is_market_partner: boolean
|
||||
is_post_office: boolean
|
||||
is_yandex_branded: boolean
|
||||
dayoffs: any[]
|
||||
deactivation_date: string | null
|
||||
deactivation_date_predicted_debt: string | null
|
||||
}
|
||||
|
||||
export interface YandexPvzResponse extends PickupPoint {
|
||||
points: PickupPoint[]
|
||||
}
|
||||
Reference in New Issue
Block a user