Skip to content

Commit

Permalink
feat: finish api call structure, allow dynamic paths
Browse files Browse the repository at this point in the history
  • Loading branch information
sstelfox committed Feb 18, 2024
1 parent 436d769 commit c361e43
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 8 deletions.
14 changes: 12 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ lto = true
console_error_panic_hook = "^0.1"
getrandom = { version = "^0.2", features = ["js"] }
js-sys = "^0.3"
serde-wasm-bindgen = "^0.6"
tracing-wasm = "^0.2"
wasm-bindgen = { version = "^0.2", features = ["serde-serialize"] }
wasm-bindgen = { version = "^0.2" }
wasm-bindgen-futures = "^0.4"
web-sys = { version = "^0.3", default-features = false, features = [
"Storage",
Expand Down
2 changes: 1 addition & 1 deletion src/api/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl ApiClient {
return Err(ApiError::RequiresAuth);
}

let full_url = self.base_url.join(request.path())?;
let full_url = self.base_url.join(&request.path())?;
let mut request_builder = self.client.request(request.method(), full_url);

if let Some(auth) = &self.auth {
Expand Down
2 changes: 1 addition & 1 deletion src/api/client/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub(crate) trait ApiRequest {
Method::GET
}

fn path(&self) -> &str;
fn path(&self) -> String;

fn payload(&self) -> Option<Self::Payload>;

Expand Down
5 changes: 3 additions & 2 deletions src/api/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use serde::Deserialize;
use crate::api::client::{ApiRequest, ApiResponse};

#[derive(Debug, Deserialize)]
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
pub struct ApiDrive {
id: String,
name: String,
Expand All @@ -20,8 +21,8 @@ impl ApiRequest for GetAllDrivesRequest {

type Payload = ();

fn path(&self) -> &str {
"/api/v1/buckets"
fn path(&self) -> String {
"/api/v1/buckets".to_string()
}

fn payload(&self) -> Option<Self::Payload> {
Expand Down
4 changes: 3 additions & 1 deletion src/wasm/tomb_compat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ impl TombCompat {
.send_platform_request(crate::api::platform::GetAllDrivesRequest)
.await?;

todo!()
let bucket_list = serde_wasmbindgen::to_value(&all_buckets)?;

Ok(bucket_list)
}

// checked, returns list of WasmBucketKey instances
Expand Down

0 comments on commit c361e43

Please sign in to comment.