Skip to main content

sip2/
params.rs

1#![allow(dead_code)]
2use crate::spec;
3
4/// Collection of friendly-named SIP request parameters for common tasks.
5///
6/// This is not a complete set of friendly-ified parameters.  Just a start.
7#[derive(Debug, Clone)]
8pub struct ParamSet {
9    institution: Option<String>,
10    terminal_pwd: Option<String>,
11    sip_user: Option<String>,
12    sip_pass: Option<String>,
13    location: Option<String>,
14    current_location: Option<String>, // AP field
15    patron_id: Option<String>,
16    patron_pwd: Option<String>,
17    item_id: Option<String>,
18    start_item: Option<usize>,
19    end_item: Option<usize>,
20
21    /// Fee Paid amount
22    pay_amount: Option<String>,
23
24    pay_type: Option<spec::PayType>,
25
26    fee_type: Option<spec::FeeType>,
27
28    /// Fee Paid ILS Transaction ID
29    fee_id: Option<String>,
30
31    /// Fee Paid SIP Client / External Transaction ID
32    transaction_id: Option<String>,
33
34    /// Indicates which position (if any) of the patron summary string
35    /// that should be set to 'Y' (i.e. activated).  Only one summary
36    /// index may be activated per message.  Positions are zero-based.
37    summary: Option<usize>,
38}
39
40impl Default for ParamSet {
41    fn default() -> Self {
42        Self::new()
43    }
44}
45
46impl ParamSet {
47    pub fn new() -> Self {
48        ParamSet {
49            institution: None,
50            terminal_pwd: None,
51            sip_user: None,
52            sip_pass: None,
53            location: None,
54            current_location: None,
55            patron_id: None,
56            patron_pwd: None,
57            item_id: None,
58            start_item: None,
59            end_item: None,
60            summary: None,
61            pay_amount: None,
62            transaction_id: None,
63            fee_id: None,
64            pay_type: None,
65            fee_type: None,
66        }
67    }
68
69    pub fn institution(&self) -> Option<&str> {
70        self.institution.as_deref()
71    }
72    pub fn terminal_pwd(&self) -> Option<&str> {
73        self.terminal_pwd.as_deref()
74    }
75    pub fn sip_user(&self) -> Option<&str> {
76        self.sip_user.as_deref()
77    }
78    pub fn sip_pass(&self) -> Option<&str> {
79        self.sip_pass.as_deref()
80    }
81    pub fn location(&self) -> Option<&str> {
82        self.location.as_deref()
83    }
84    pub fn current_location(&self) -> Option<&str> {
85        self.current_location.as_deref()
86    }
87
88    pub fn patron_id(&self) -> Option<&str> {
89        self.patron_id.as_deref()
90    }
91    pub fn patron_pwd(&self) -> Option<&str> {
92        self.patron_pwd.as_deref()
93    }
94    pub fn item_id(&self) -> Option<&str> {
95        self.item_id.as_deref()
96    }
97    pub fn start_item(&self) -> Option<usize> {
98        self.start_item
99    }
100    pub fn end_item(&self) -> Option<usize> {
101        self.end_item
102    }
103    pub fn summary(&self) -> Option<usize> {
104        self.summary
105    }
106    pub fn pay_amount(&self) -> Option<&str> {
107        self.pay_amount.as_deref()
108    }
109    pub fn transaction_id(&self) -> Option<&str> {
110        self.transaction_id.as_deref()
111    }
112    pub fn fee_id(&self) -> Option<&str> {
113        self.fee_id.as_deref()
114    }
115    pub fn pay_type(&self) -> Option<spec::PayType> {
116        self.pay_type
117    }
118    pub fn fee_type(&self) -> Option<spec::FeeType> {
119        self.fee_type
120    }
121
122    // ---
123
124    pub fn set_institution(&mut self, value: &str) -> &mut Self {
125        self.institution = Some(value.to_string());
126        self
127    }
128    pub fn set_terminal_pwd(&mut self, value: &str) -> &mut Self {
129        self.terminal_pwd = Some(value.to_string());
130        self
131    }
132    pub fn set_sip_user(&mut self, value: &str) -> &mut Self {
133        self.sip_user = Some(value.to_string());
134        self
135    }
136    pub fn set_sip_pass(&mut self, value: &str) -> &mut Self {
137        self.sip_pass = Some(value.to_string());
138        self
139    }
140    pub fn set_location(&mut self, value: &str) -> &mut Self {
141        self.location = Some(value.to_string());
142        self
143    }
144    pub fn set_current_location(&mut self, value: &str) -> &mut Self {
145        self.current_location = Some(value.to_string());
146        self
147    }
148
149    pub fn set_patron_id(&mut self, value: &str) -> &mut Self {
150        self.patron_id = Some(value.to_string());
151        self
152    }
153    pub fn set_patron_pwd(&mut self, value: &str) -> &mut Self {
154        self.patron_pwd = Some(value.to_string());
155        self
156    }
157    pub fn set_item_id(&mut self, value: &str) -> &mut Self {
158        self.item_id = Some(value.to_string());
159        self
160    }
161    pub fn set_start_item(&mut self, value: usize) -> &mut Self {
162        self.start_item = Some(value);
163        self
164    }
165    pub fn set_end_item(&mut self, value: usize) -> &mut Self {
166        self.end_item = Some(value);
167        self
168    }
169    pub fn set_summary(&mut self, value: usize) -> &mut Self {
170        self.summary = Some(value);
171        self
172    }
173    pub fn set_pay_amount(&mut self, amount: &str) -> &mut Self {
174        self.pay_amount = Some(amount.to_string());
175        self
176    }
177    pub fn set_transaction_id(&mut self, id: &str) -> &mut Self {
178        self.transaction_id = Some(id.to_string());
179        self
180    }
181    pub fn set_fee_id(&mut self, id: &str) -> &mut Self {
182        self.fee_id = Some(id.to_string());
183        self
184    }
185    pub fn set_pay_type(&mut self, pt: spec::PayType) -> &mut Self {
186        self.pay_type = Some(pt);
187        self
188    }
189    pub fn set_fee_type(&mut self, pt: spec::FeeType) -> &mut Self {
190        self.fee_type = Some(pt);
191        self
192    }
193}