mirror of
https://github.com/chirpstack/chirpstack.git
synced 2024-12-19 05:07:54 +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>,
|
vars: &HashMap<String, String>,
|
||||||
attributes: &Payload,
|
attributes: &Payload,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let endpoint = format!(
|
let access_token = vars.get("ThingsBoardAccessToken").cloned().ok_or_else(|| {
|
||||||
"{}/api/v1/{}/attributes",
|
anyhow!("Device does not have ThingsBoardAccessToken variable configured")
|
||||||
self.server,
|
})?;
|
||||||
vars.get("ThingsBoardAccessToken")
|
|
||||||
.cloned()
|
let endpoint = format!("{}/api/v1/{}/attributes", self.server, access_token);
|
||||||
.unwrap_or_default()
|
|
||||||
);
|
|
||||||
let b = serde_json::to_string(&attributes)?;
|
let b = serde_json::to_string(&attributes)?;
|
||||||
|
|
||||||
let client = Client::builder().timeout(self.timeout).build()?;
|
let client = Client::builder().timeout(self.timeout).build()?;
|
||||||
@ -60,15 +58,12 @@ impl Integration {
|
|||||||
vars: &HashMap<String, String>,
|
vars: &HashMap<String, String>,
|
||||||
telemetry: &Payload,
|
telemetry: &Payload,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let endpoint = format!(
|
let access_token = vars.get("ThingsBoardAccessToken").cloned().ok_or_else(|| {
|
||||||
"{}/api/v1/{}/telemetry",
|
anyhow!("Device does not have ThingsBoardAccessToken variable configured")
|
||||||
self.server,
|
})?;
|
||||||
vars.get("ThingsBoardAccessToken")
|
|
||||||
.cloned()
|
let endpoint = format!("{}/api/v1/{}/telemetry", self.server, access_token);
|
||||||
.unwrap_or_default()
|
|
||||||
);
|
|
||||||
let b = serde_json::to_string(&telemetry)?;
|
let b = serde_json::to_string(&telemetry)?;
|
||||||
println!("{}", b);
|
|
||||||
|
|
||||||
let client = Client::builder().timeout(self.timeout).build()?;
|
let client = Client::builder().timeout(self.timeout).build()?;
|
||||||
let mut headers = HeaderMap::new();
|
let mut headers = HeaderMap::new();
|
||||||
|
Loading…
Reference in New Issue
Block a user