line_messaging_api/models/membership.rs
1/*
2* Copyright (C) 2016 LINE Corp.
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8* http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*/
16
17/*
18 * LINE Messaging API
19 *
20 * This document describes LINE Messaging API.
21 *
22 * The version of the OpenAPI document: 0.0.4
23 *
24 * Generated by: https://openapi-generator.tech
25 */
26
27use crate::models;
28use serde::{Deserialize, Serialize};
29
30#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
31pub struct Membership {
32 /// Membership plan ID.
33 #[serde(rename = "membershipId")]
34 pub membership_id: i32,
35 /// Membership plan name.
36 #[serde(rename = "title")]
37 pub title: String,
38 /// Membership plan description.
39 #[serde(rename = "description")]
40 pub description: String,
41 /// List of membership plan perks.
42 #[serde(rename = "benefits")]
43 pub benefits: Vec<String>,
44 /// Monthly fee for membership plan. (e.g. 1500.00)
45 #[serde(rename = "price")]
46 pub price: f64,
47 /// The currency of membership.price.
48 #[serde(rename = "currency")]
49 pub currency: Currency,
50 /// Number of members subscribed to the membership plan.
51 #[serde(rename = "memberCount")]
52 pub member_count: i32,
53 /// The upper limit of members who can subscribe. If no upper limit is set, it will be null.
54 #[serde(rename = "memberLimit", deserialize_with = "Option::deserialize")]
55 pub member_limit: Option<i32>,
56 /// Payment method for users who subscribe to a membership plan.
57 #[serde(rename = "isInAppPurchase")]
58 pub is_in_app_purchase: bool,
59 /// Membership plan status.
60 #[serde(rename = "isPublished")]
61 pub is_published: bool,
62}
63
64impl Membership {
65 pub fn new(
66 membership_id: i32,
67 title: String,
68 description: String,
69 benefits: Vec<String>,
70 price: f64,
71 currency: Currency,
72 member_count: i32,
73 member_limit: Option<i32>,
74 is_in_app_purchase: bool,
75 is_published: bool,
76 ) -> Membership {
77 Membership {
78 membership_id,
79 title,
80 description,
81 benefits,
82 price,
83 currency,
84 member_count,
85 member_limit,
86 is_in_app_purchase,
87 is_published,
88 }
89 }
90}
91/// The currency of membership.price.
92#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
93pub enum Currency {
94 #[serde(rename = "JPY")]
95 Jpy,
96 #[serde(rename = "TWD")]
97 Twd,
98 #[serde(rename = "THB")]
99 Thb,
100}
101
102impl Default for Currency {
103 fn default() -> Currency {
104 Self::Jpy
105 }
106}