Skip to content

Commit 9028968

Browse files
committed
implemented decommission route
1 parent 60163a6 commit 9028968

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/endpoints/terminal.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,33 @@ impl<'a> TerminalEndpoints<'a> {
172172
}
173173
}
174174

175+
/// Unlink your debug device from your integration
175176
///
176-
pub async fn decommission_terminal() {}
177+
/// - serial_number: Device Serial Number.
178+
pub async fn decommission_terminal(
179+
&self,
180+
serial_number: &str,
181+
) -> PaystackResult<TerminalResponseWithNoData> {
182+
let url = format!("{}/decommission_device", BASE_URL);
183+
184+
let decommission_body = Body {
185+
serial_number: serial_number.to_string(),
186+
};
187+
188+
match post_request(self.api_key, &url, decommission_body).await {
189+
Ok(response) => match response.status() {
190+
StatusCode::Ok => match response.json::<TerminalResponseWithNoData>().await {
191+
Ok(content) => Ok(content),
192+
Err(err) => Err(Error::Terminal(err.to_string())),
193+
},
194+
_ => Err(Error::RequestNotSuccessful(
195+
response.status().to_string(),
196+
response.text().await?,
197+
)),
198+
},
199+
Err(err) => Err(Error::FailedRequest(err.to_string())),
200+
}
201+
}
177202
}
178203

179204
/// creating body here because it is redundant to create a dedicated type for this.

0 commit comments

Comments
 (0)