kenall_rs/model.rs
1//! Data structure for postal parcel record.
2//!
3//! You can check the data type of response [here](https://www.notion.so/API-47ab1a425d9e48aaad5b34b4f703c718#72bcd8015613468abb39567d2b620344).
4//!
5use serde::Deserialize;
6
7#[derive(Debug, Deserialize, PartialEq)]
8pub struct PostalBlock {
9 /// JIS code
10 pub jisx0402: String,
11 /// Old postal code (ex: 100)
12 pub old_code: String,
13 /// Latest postal code.7digits.(ex: 1008105)
14 pub postal_code: String,
15 /// Prefectures described with full width kana (ex: トウキョウト)
16 pub prefecture_kana: String,
17 /// City described with full width kana (ex: チヨダク)
18 pub city_kana: String,
19 /// Town described with full width kana (ex: チヨダ)
20 /// It has a [know issue](https://www.notion.so/a75d99e4ce864ada9ad627a6ff8558f1#6fba9308958a480cbbebefb11f332054)
21 pub town_kana: String,
22 /// Town on the postal code database that described by full width kana (ex: チヨダ)
23 pub town_kana_raw: String,
24 /// Prefecture (ex: 東京都)
25 pub prefecture: String,
26 /// Municipality
27 pub city: String,
28 /// Based on a name of the town with brackets excluded and joined multiple lines
29 pub town: String,
30 /// Koaza (ex: 2丁目)
31 pub koaza: String,
32 /// Kyoto specific street
33 pub kyoto_street: String,
34 /// Name of the building (ex: オフィスタワーX)
35 pub building: String,
36 /// Floor of the building (ex: 3階)
37 pub floor: String,
38 /// If the area of the town has more then 2 postal code, return `true`.
39 pub town_partial: bool,
40 /// Wide town area (大域) has multiple Koaza(小字) and each Koaza has specific `house number`,
41 /// thus people can not specify the address from postcal code and an address.
42 pub town_addressed_koaza: bool,
43 /// Town area(町域) that owns district number(丁目)
44 pub town_chome: bool,
45 /// In some case, single postal code has multiple wotn area(町域) and return true in that case
46 pub town_multi: bool,
47 /// Name of the town area on postcal code database
48 pub town_raw: String,
49 /// If the data matches [individual corporate number](https://www.post.japanpost.jp/zipcode/dl/jigyosyo/readme.html),
50 /// an additional data will be returned.
51 pub corporation: Option<Corporation>,
52}
53
54#[derive(Debug, Deserialize, PartialEq)]
55pub struct Corporation {
56 /// Name of the office
57 pub name: String,
58 /// Name of the office with Kana
59 pub name_kana: String,
60 /// Block lot
61 pub block_lot: String,
62 pub post_office: String,
63 /// Code type is desribed with `0` or `1`.
64 /// 0: 大口事業所
65 /// 1: 私書箱
66 pub code_type: u8,
67}
68
69/// `GET /postalcode/:postal_code`
70#[derive(Debug, Deserialize, PartialEq)]
71pub struct PostalCodeResponse {
72 /// Version of the data.
73 pub version: String,
74 /// Data is returned with json in array.
75 pub data: Vec<PostalBlock>,
76}