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.3
23 *
24 * Generated by: https://openapi-generator.tech
25 */
26
27#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
28pub struct Membership {
29 /// Membership plan ID.
30 #[serde(rename = "membershipId")]
31 pub membership_id: i32,
32 /// Membership plan name.
33 #[serde(rename = "title")]
34 pub title: String,
35 /// Membership plan description.
36 #[serde(rename = "description")]
37 pub description: String,
38 /// List of membership plan perks.
39 #[serde(rename = "benefits")]
40 pub benefits: Vec<String>,
41 /// Monthly fee for membership plan. (e.g. 1500.00)
42 #[serde(rename = "price")]
43 pub price: f64,
44 /// The currency of membership.price.
45 #[serde(rename = "currency")]
46 pub currency: Currency,
47 /// Number of members subscribed to the membership plan.
48 #[serde(rename = "memberCount")]
49 pub member_count: i32,
50 /// The upper limit of members who can subscribe. If no upper limit is set, it will be null.
51 #[serde(rename = "memberLimit", deserialize_with = "Option::deserialize")]
52 pub member_limit: Option<i32>,
53 /// Payment method for users who subscribe to a membership plan.
54 #[serde(rename = "isInAppPurchase")]
55 pub is_in_app_purchase: bool,
56 /// Membership plan status.
57 #[serde(rename = "isPublished")]
58 pub is_published: bool,
59}
60
61impl Membership {
62 pub fn new(
63 membership_id: i32,
64 title: String,
65 description: String,
66 benefits: Vec<String>,
67 price: f64,
68 currency: Currency,
69 member_count: i32,
70 member_limit: Option<i32>,
71 is_in_app_purchase: bool,
72 is_published: bool,
73 ) -> Membership {
74 Membership {
75 membership_id,
76 title,
77 description,
78 benefits,
79 price,
80 currency,
81 member_count,
82 member_limit,
83 is_in_app_purchase,
84 is_published,
85 }
86 }
87}
88
89/// The currency of membership.price.
90#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
91pub enum Currency {
92 #[serde(rename = "JPY")]
93 Jpy,
94 #[serde(rename = "TWD")]
95 Twd,
96 #[serde(rename = "THB")]
97 Thb,
98}
99
100impl Default for Currency {
101 fn default() -> Currency {
102 Self::Jpy
103 }
104}