cscart_rs/service/
vendor_service.rs

1use crate::prelude::*;
2use crate::service::config::ServiceConfig;
3use crate::types::Vendor;
4use crate::{
5    impl_create_method, impl_delete_by_id_method, impl_get_all_entity_method, impl_get_all_method,
6    impl_get_by_id_method, impl_update_by_id_method,
7};
8use serde::Deserialize;
9use serde_json::Value;
10
11pub struct VendorService {
12    config: ServiceConfig<Authenticated>,
13}
14
15impl VendorService {
16    pub fn with_config(service: ServiceConfig<Authenticated>) -> VendorService {
17        Self { config: service }
18    }
19}
20
21#[derive(Deserialize, Debug)]
22pub struct GetAllVendorResponse {
23    pub vendors: Vec<Vendor>,
24}
25
26#[derive(Deserialize, Debug)]
27pub struct GetAllProductsResponse {
28    pub vendors: Vec<Vendor>,
29}
30
31#[derive(Deserialize, Debug)]
32pub struct CreateVendorResponse {
33    pub company_id: i32,
34    pub message: String,
35}
36
37#[derive(Deserialize, Debug)]
38pub struct UpdateVendorResponse {
39    pub store_id: String,
40}
41
42impl_create_method!(VendorService, CreateVendorResponse);
43impl_get_by_id_method!(VendorService, Vendor);
44impl_get_all_method!(VendorService, GetAllVendorResponse);
45impl_update_by_id_method!(VendorService, UpdateVendorResponse);
46impl_delete_by_id_method!(VendorService, Value);
47impl_get_all_entity_method!(VendorService, GetAllProductsResponse);