-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use crate::endpoint; | ||
use crate::file::model::RequestParameters; | ||
|
||
// なぜかファイルが見つからない | ||
// TODO: ↑を直す | ||
pub async fn get(query: &RequestParameters) -> Result<bytes::Bytes, Box<dyn std::error::Error>> { | ||
let client = reqwest::Client::new(); | ||
|
||
let resp = client.get(endpoint::FILE).query(query).send().await?; | ||
|
||
//let status = resp.status(); | ||
|
||
//println!("{}", resp.text().await?); | ||
|
||
//Ok(()) | ||
Ok(resp.bytes().await?) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mod client; | ||
mod model; | ||
|
||
pub use self::client::get; | ||
pub use self::model::RequestParameters; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//! 添付ファイル(PDF)取得APIのデータモデル | ||
//! | ||
//! 技術基準適合証明等を受けた機器の検索Web-APIのリクエスト条件一覧(Ver.1.1.1) | ||
//! | ||
//! https://www.tele.soumu.go.jp/resource/j/giteki/webapi/gk_req_conditions.pdf | ||
use serde::Serialize; | ||
|
||
/// 添付ファイル(PDF)取得APIのリクエストパラメータ | ||
#[derive(Serialize)] | ||
pub struct RequestParameters { | ||
/// 添付ファイル取得キー | ||
/// | ||
/// 一覧詳細情報取得APIで取得した添付ファイル取得キーを指定。 | ||
#[serde(rename = "AFK")] | ||
pub afk: String, | ||
|
||
/// 添付ファイル種別 | ||
/// | ||
/// 添付ファイルの種別を指定。 | ||
/// | ||
/// 1:外観写真等 | ||
/// | ||
/// 2:特性試験の結果 | ||
#[serde(rename = "AFT")] | ||
pub aft: Option<u8>, | ||
|
||
/// 取得形式 | ||
/// | ||
/// 添付ファイル種別件数を元に対象添付ファイルの番号を指定。 | ||
/// 添付ファイル番号を指定する場合、添付ファイル種別の指定が必要。 | ||
#[serde(rename = "AFN")] | ||
pub afn: Option<u8>, | ||
} | ||
|
||
impl RequestParameters { | ||
pub fn new<S: Into<String>>(afk: S) -> RequestParameters { | ||
RequestParameters { | ||
afk: afk.into(), | ||
aft: None, | ||
afn: None, | ||
} | ||
} | ||
|
||
pub fn set_aft<T: Into<u8>>(&mut self, aft: T) { | ||
self.aft = Option::from(aft.into()); | ||
} | ||
|
||
pub fn set_afn<T: Into<u8>>(&mut self, afn: T) { | ||
self.afn = Option::from(afn.into()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod endpoint; | ||
mod file; | ||
pub mod list; | ||
pub mod num; |