cscart_rs/types/
resource.rs

1#[derive(Clone, Debug)]
2pub enum Resource {
3    Auth,
4    Blocks,
5    Cart,
6    CallRequest,
7    Category,
8    Discussion,
9    Languages,
10    Langvars,
11    Order,
12    Pages,
13    PaymentMethod,
14    ProductException,
15    ProductFeature,
16    Product,
17    ProductOptionCombination,
18    ProductOption,
19    ProductOptionException,
20    ProductVariation,
21    ProductVariationGroup,
22    Settings,
23    Shipment,
24    ShipmentMethod,
25    Status,
26    Tax,
27    UserGroups,
28    User,
29    Vendor,
30}
31
32pub trait ResourceType {}
33
34impl ResourceType for Resource {}
35
36// /api.php?_d=products for v1 or /api/2.0/products
37
38impl Resource {
39    pub fn path(&self) -> String {
40        match self {
41            Self::Auth => "/api/2.0/auth".to_string(),
42            Self::Cart => "/api/2.0/carts".to_string(),
43            Self::CallRequest => "/api/2.0/call_requests".to_string(),
44            Self::Blocks => "/api/2.0/blocks".to_string(),
45            Self::Category => "/api/2.0/categories".to_string(),
46            Self::Discussion => "/api/2.0/discussions".to_string(),
47            Self::Languages => "/api/2.0/languages".to_string(),
48            Self::Langvars => "/api/2.0/langvars".to_string(),
49            Self::Order => "/api/2.0/orders".to_string(),
50            Self::Pages => "/api/2.0/pages".to_string(),
51            Self::PaymentMethod => "/api/2.0/payments".to_string(),
52            Self::ProductException => "/api/2.0/exceptions".to_string(),
53            Self::ProductFeature => "/api/2.0/features".to_string(),
54            Self::Product => "/api/2.0/products".to_string(),
55            Self::ProductOptionCombination => "/api/2.0/combinations".to_string(),
56            Self::ProductOption => "/api/2.0/options".to_string(),
57            Self::ProductOptionException => "/api/2.0/options".to_string(),
58            Self::ProductVariation => "/api/2.0/product_variation".to_string(),
59            Self::ProductVariationGroup => "/api/2.0/product_variation_groups".to_string(),
60            Self::Settings => "/api/2.0/settings".to_string(),
61            Self::Shipment => "/api/2.0/shipments".to_string(),
62            Self::ShipmentMethod => "/api/2.0/shippings".to_string(),
63            Self::Status => "/api/2.0/statuses".to_string(),
64            Self::Tax => "/api/2.0/taxes".to_string(),
65            Self::UserGroups => "/api/2.0/usergroups".to_string(),
66            Self::User => "/api/2.0/users".to_string(),
67            Self::Vendor => "/api/2.0/vendors".to_string(),
68        }
69    }
70}