style: use 2-space indentation across entire codebase
Add rustfmt.toml with tab_spaces = 2 and reformat all source files, tests, and README code examples to use 2-space indentation.
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
tab_spaces = 2
|
||||||
@@ -13,20 +13,23 @@ impl OnspringClient {
|
|||||||
query.push(("PageSize", p.page_size.to_string()));
|
query.push(("PageSize", p.page_size.to_string()));
|
||||||
}
|
}
|
||||||
let query_refs: Vec<(&str, String)> = query.iter().map(|(k, v)| (*k, v.clone())).collect();
|
let query_refs: Vec<(&str, String)> = query.iter().map(|(k, v)| (*k, v.clone())).collect();
|
||||||
self.request(Method::GET, "/Apps", &query_refs, Option::<&()>::None)
|
self
|
||||||
|
.request(Method::GET, "/Apps", &query_refs, Option::<&()>::None)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets an app by its identifier.
|
/// Gets an app by its identifier.
|
||||||
pub async fn get_app(&self, app_id: i32) -> Result<App> {
|
pub async fn get_app(&self, app_id: i32) -> Result<App> {
|
||||||
let path = format!("/Apps/id/{}", app_id);
|
let path = format!("/Apps/id/{}", app_id);
|
||||||
self.request(Method::GET, &path, &[], Option::<&()>::None)
|
self
|
||||||
|
.request(Method::GET, &path, &[], Option::<&()>::None)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets up to 100 apps by their identifiers.
|
/// Gets up to 100 apps by their identifiers.
|
||||||
pub async fn batch_get_apps(&self, ids: &[i32]) -> Result<CollectionResponse<App>> {
|
pub async fn batch_get_apps(&self, ids: &[i32]) -> Result<CollectionResponse<App>> {
|
||||||
self.request(Method::POST, "/Apps/batch-get", &[], Some(&ids))
|
self
|
||||||
|
.request(Method::POST, "/Apps/batch-get", &[], Some(&ids))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,13 +8,15 @@ impl OnspringClient {
|
|||||||
/// Gets a field by its identifier.
|
/// Gets a field by its identifier.
|
||||||
pub async fn get_field(&self, field_id: i32) -> Result<Field> {
|
pub async fn get_field(&self, field_id: i32) -> Result<Field> {
|
||||||
let path = format!("/Fields/id/{}", field_id);
|
let path = format!("/Fields/id/{}", field_id);
|
||||||
self.request(Method::GET, &path, &[], Option::<&()>::None)
|
self
|
||||||
|
.request(Method::GET, &path, &[], Option::<&()>::None)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets up to 100 fields by their identifiers.
|
/// Gets up to 100 fields by their identifiers.
|
||||||
pub async fn batch_get_fields(&self, ids: &[i32]) -> Result<CollectionResponse<Field>> {
|
pub async fn batch_get_fields(&self, ids: &[i32]) -> Result<CollectionResponse<Field>> {
|
||||||
self.request(Method::POST, "/Fields/batch-get", &[], Some(&ids))
|
self
|
||||||
|
.request(Method::POST, "/Fields/batch-get", &[], Some(&ids))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +33,8 @@ impl OnspringClient {
|
|||||||
query.push(("PageSize", p.page_size.to_string()));
|
query.push(("PageSize", p.page_size.to_string()));
|
||||||
}
|
}
|
||||||
let query_refs: Vec<(&str, String)> = query.iter().map(|(k, v)| (*k, v.clone())).collect();
|
let query_refs: Vec<(&str, String)> = query.iter().map(|(k, v)| (*k, v.clone())).collect();
|
||||||
self.request(Method::GET, &path, &query_refs, Option::<&()>::None)
|
self
|
||||||
|
.request(Method::GET, &path, &query_refs, Option::<&()>::None)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ impl OnspringClient {
|
|||||||
"/Files/recordId/{}/fieldId/{}/fileId/{}",
|
"/Files/recordId/{}/fieldId/{}/fileId/{}",
|
||||||
record_id, field_id, file_id
|
record_id, field_id, file_id
|
||||||
);
|
);
|
||||||
self.request(Method::GET, &path, &[], Option::<&()>::None)
|
self
|
||||||
|
.request(Method::GET, &path, &[], Option::<&()>::None)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +83,8 @@ impl OnspringClient {
|
|||||||
"/Files/recordId/{}/fieldId/{}/fileId/{}",
|
"/Files/recordId/{}/fieldId/{}/fileId/{}",
|
||||||
record_id, field_id, file_id
|
record_id, field_id, file_id
|
||||||
);
|
);
|
||||||
self.request_no_content(Method::DELETE, &path, &[], Option::<&()>::None)
|
self
|
||||||
|
.request_no_content(Method::DELETE, &path, &[], Option::<&()>::None)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ impl OnspringClient {
|
|||||||
/// Deletes a list item from the specified list.
|
/// Deletes a list item from the specified list.
|
||||||
pub async fn delete_list_item(&self, list_id: i32, item_id: Uuid) -> Result<()> {
|
pub async fn delete_list_item(&self, list_id: i32, item_id: Uuid) -> Result<()> {
|
||||||
let path = format!("/Lists/id/{}/itemId/{}", list_id, item_id);
|
let path = format!("/Lists/id/{}/itemId/{}", list_id, item_id);
|
||||||
self.request_no_content(Method::DELETE, &path, &[], Option::<&()>::None)
|
self
|
||||||
|
.request_no_content(Method::DELETE, &path, &[], Option::<&()>::None)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ use crate::error::Result;
|
|||||||
impl OnspringClient {
|
impl OnspringClient {
|
||||||
/// Checks if the Onspring API is reachable.
|
/// Checks if the Onspring API is reachable.
|
||||||
pub async fn ping(&self) -> Result<()> {
|
pub async fn ping(&self) -> Result<()> {
|
||||||
self.request_no_content(Method::GET, "/Ping", &[], Option::<&()>::None)
|
self
|
||||||
|
.request_no_content(Method::GET, "/Ping", &[], Option::<&()>::None)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-10
@@ -3,9 +3,8 @@ use reqwest::Method;
|
|||||||
use crate::client::OnspringClient;
|
use crate::client::OnspringClient;
|
||||||
use crate::error::Result;
|
use crate::error::Result;
|
||||||
use crate::models::{
|
use crate::models::{
|
||||||
BatchDeleteRecordsRequest, BatchGetRecordsRequest, CollectionResponse, DataFormat,
|
BatchDeleteRecordsRequest, BatchGetRecordsRequest, CollectionResponse, DataFormat, PagedResponse,
|
||||||
PagedResponse, PagingRequest, QueryRecordsRequest, Record, SaveRecordRequest,
|
PagingRequest, QueryRecordsRequest, Record, SaveRecordRequest, SaveRecordResponse,
|
||||||
SaveRecordResponse,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
impl OnspringClient {
|
impl OnspringClient {
|
||||||
@@ -35,7 +34,8 @@ impl OnspringClient {
|
|||||||
query.push(("dataFormat", format!("{:?}", fmt)));
|
query.push(("dataFormat", format!("{:?}", fmt)));
|
||||||
}
|
}
|
||||||
let query_refs: Vec<(&str, String)> = query.iter().map(|(k, v)| (*k, v.clone())).collect();
|
let query_refs: Vec<(&str, String)> = query.iter().map(|(k, v)| (*k, v.clone())).collect();
|
||||||
self.request(Method::GET, &path, &query_refs, Option::<&()>::None)
|
self
|
||||||
|
.request(Method::GET, &path, &query_refs, Option::<&()>::None)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,20 +61,23 @@ impl OnspringClient {
|
|||||||
query.push(("dataFormat", format!("{:?}", fmt)));
|
query.push(("dataFormat", format!("{:?}", fmt)));
|
||||||
}
|
}
|
||||||
let query_refs: Vec<(&str, String)> = query.iter().map(|(k, v)| (*k, v.clone())).collect();
|
let query_refs: Vec<(&str, String)> = query.iter().map(|(k, v)| (*k, v.clone())).collect();
|
||||||
self.request(Method::GET, &path, &query_refs, Option::<&()>::None)
|
self
|
||||||
|
.request(Method::GET, &path, &query_refs, Option::<&()>::None)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates or updates a record.
|
/// Creates or updates a record.
|
||||||
pub async fn save_record(&self, request: SaveRecordRequest) -> Result<SaveRecordResponse> {
|
pub async fn save_record(&self, request: SaveRecordRequest) -> Result<SaveRecordResponse> {
|
||||||
self.request(Method::PUT, "/Records", &[], Some(&request))
|
self
|
||||||
|
.request(Method::PUT, "/Records", &[], Some(&request))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deletes a record by its identifier.
|
/// Deletes a record by its identifier.
|
||||||
pub async fn delete_record(&self, app_id: i32, record_id: i32) -> Result<()> {
|
pub async fn delete_record(&self, app_id: i32, record_id: i32) -> Result<()> {
|
||||||
let path = format!("/Records/appId/{}/recordId/{}", app_id, record_id);
|
let path = format!("/Records/appId/{}/recordId/{}", app_id, record_id);
|
||||||
self.request_no_content(Method::DELETE, &path, &[], Option::<&()>::None)
|
self
|
||||||
|
.request_no_content(Method::DELETE, &path, &[], Option::<&()>::None)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +86,8 @@ impl OnspringClient {
|
|||||||
&self,
|
&self,
|
||||||
request: BatchGetRecordsRequest,
|
request: BatchGetRecordsRequest,
|
||||||
) -> Result<CollectionResponse<Record>> {
|
) -> Result<CollectionResponse<Record>> {
|
||||||
self.request(Method::POST, "/Records/batch-get", &[], Some(&request))
|
self
|
||||||
|
.request(Method::POST, "/Records/batch-get", &[], Some(&request))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,13 +103,15 @@ impl OnspringClient {
|
|||||||
query.push(("PageSize", p.page_size.to_string()));
|
query.push(("PageSize", p.page_size.to_string()));
|
||||||
}
|
}
|
||||||
let query_refs: Vec<(&str, String)> = query.iter().map(|(k, v)| (*k, v.clone())).collect();
|
let query_refs: Vec<(&str, String)> = query.iter().map(|(k, v)| (*k, v.clone())).collect();
|
||||||
self.request(Method::POST, "/Records/Query", &query_refs, Some(&request))
|
self
|
||||||
|
.request(Method::POST, "/Records/Query", &query_refs, Some(&request))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deletes a batch of records.
|
/// Deletes a batch of records.
|
||||||
pub async fn batch_delete_records(&self, request: BatchDeleteRecordsRequest) -> Result<()> {
|
pub async fn batch_delete_records(&self, request: BatchDeleteRecordsRequest) -> Result<()> {
|
||||||
self.request_no_content(Method::POST, "/Records/batch-delete", &[], Some(&request))
|
self
|
||||||
|
.request_no_content(Method::POST, "/Records/batch-delete", &[], Some(&request))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ impl OnspringClient {
|
|||||||
query.push(("dataType", format!("{:?}", dt)));
|
query.push(("dataType", format!("{:?}", dt)));
|
||||||
}
|
}
|
||||||
let query_refs: Vec<(&str, String)> = query.iter().map(|(k, v)| (*k, v.clone())).collect();
|
let query_refs: Vec<(&str, String)> = query.iter().map(|(k, v)| (*k, v.clone())).collect();
|
||||||
self.request(Method::GET, &path, &query_refs, Option::<&()>::None)
|
self
|
||||||
|
.request(Method::GET, &path, &query_refs, Option::<&()>::None)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +41,8 @@ impl OnspringClient {
|
|||||||
query.push(("PageSize", p.page_size.to_string()));
|
query.push(("PageSize", p.page_size.to_string()));
|
||||||
}
|
}
|
||||||
let query_refs: Vec<(&str, String)> = query.iter().map(|(k, v)| (*k, v.clone())).collect();
|
let query_refs: Vec<(&str, String)> = query.iter().map(|(k, v)| (*k, v.clone())).collect();
|
||||||
self.request(Method::GET, &path, &query_refs, Option::<&()>::None)
|
self
|
||||||
|
.request(Method::GET, &path, &query_refs, Option::<&()>::None)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user