mirror of
https://github.com/chirpstack/chirpstack.git
synced 2024-12-22 06:27:49 +00:00
Return err if ThingsBoardAccessToken is missing.
Before this would default to an empty string, which would return in an invalid URL. Fixes #277.
This commit is contained in:
parent
687d0b1c62
commit
8797df2e05
@ -32,13 +32,11 @@ impl Integration {
|
||||
vars: &HashMap<String, String>,
|
||||
attributes: &Payload,
|
||||
) -> Result<()> {
|
||||
let endpoint = format!(
|
||||
"{}/api/v1/{}/attributes",
|
||||
self.server,
|
||||
vars.get("ThingsBoardAccessToken")
|
||||
.cloned()
|
||||
.unwrap_or_default()
|
||||
);
|
||||
let access_token = vars.get("ThingsBoardAccessToken").cloned().ok_or_else(|| {
|
||||
anyhow!("Device does not have ThingsBoardAccessToken variable configured")
|
||||
})?;
|
||||
|
||||
let endpoint = format!("{}/api/v1/{}/attributes", self.server, access_token);
|
||||
let b = serde_json::to_string(&attributes)?;
|
||||
|
||||
let client = Client::builder().timeout(self.timeout).build()?;
|
||||
@ -60,15 +58,12 @@ impl Integration {
|
||||
vars: &HashMap<String, String>,
|
||||
telemetry: &Payload,
|
||||
) -> Result<()> {
|
||||
let endpoint = format!(
|
||||
"{}/api/v1/{}/telemetry",
|
||||
self.server,
|
||||
vars.get("ThingsBoardAccessToken")
|
||||
.cloned()
|
||||
.unwrap_or_default()
|
||||
);
|
||||
let access_token = vars.get("ThingsBoardAccessToken").cloned().ok_or_else(|| {
|
||||
anyhow!("Device does not have ThingsBoardAccessToken variable configured")
|
||||
})?;
|
||||
|
||||
let endpoint = format!("{}/api/v1/{}/telemetry", self.server, access_token);
|
||||
let b = serde_json::to_string(&telemetry)?;
|
||||
println!("{}", b);
|
||||
|
||||
let client = Client::builder().timeout(self.timeout).build()?;
|
||||
let mut headers = HeaderMap::new();
|
||||
|
Loading…
Reference in New Issue
Block a user