bugfix fileapl, more derives for utility
This commit is contained in:
parent
7f9072c4a7
commit
9ef2313c1e
3 changed files with 10 additions and 5 deletions
|
@ -24,7 +24,11 @@ impl APL for FileApl {
|
||||||
async fn set(&self, auth_data: crate::AuthData) -> Result<()> {
|
async fn set(&self, auth_data: crate::AuthData) -> Result<()> {
|
||||||
let path = std::path::Path::new(&self.path);
|
let path = std::path::Path::new(&self.path);
|
||||||
debug!("reading from {:?}", &path);
|
debug!("reading from {:?}", &path);
|
||||||
let mut auths: FileStructure = serde_json::from_str(&std::fs::read_to_string(path)?)?;
|
let mut auths: FileStructure;
|
||||||
|
match path.is_file() {
|
||||||
|
true => auths = serde_json::from_str(&std::fs::read_to_string(path)?)?,
|
||||||
|
false => auths = FileStructure { 0: HashMap::new() },
|
||||||
|
}
|
||||||
|
|
||||||
auths.insert(auth_data.saleor_api_url.clone(), auth_data);
|
auths.insert(auth_data.saleor_api_url.clone(), auth_data);
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,11 @@ pub mod sync_response;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use strum_macros::EnumString;
|
use strum_macros::{AsRefStr, EnumString};
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, EnumString)]
|
#[derive(Debug, Clone, Serialize, Deserialize, EnumString, AsRefStr)]
|
||||||
//kinda annoying that in an apps manifest, the `AsyncWebhookEventType` is in SCREAMING_SNAKE_CASE,
|
//kinda annoying that in an apps manifest, the `AsyncWebhookEventType` is in SCREAMING_SNAKE_CASE,
|
||||||
//but when receiving saleors webhook the header `saleor-event` is in snake_case,
|
//but when receiving saleors webhook the header `saleor-event` is in snake_case,
|
||||||
//have to serialize and deserialize the enum two different ways
|
//have to serialize and deserialize the enum two different ways
|
||||||
|
@ -156,7 +156,7 @@ pub enum AsyncWebhookEventType {
|
||||||
ShopMetadataUpdated,
|
ShopMetadataUpdated,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, EnumString)]
|
#[derive(Debug, Clone, Serialize, Deserialize, EnumString, AsRefStr)]
|
||||||
//kinda annoying that in an apps manifest, the `AsyncWebhookEventType` is in SCREAMING_SNAKE_CASE,
|
//kinda annoying that in an apps manifest, the `AsyncWebhookEventType` is in SCREAMING_SNAKE_CASE,
|
||||||
//but when receiving saleors webhook the header `saleor-event` is in snake_case,
|
//but when receiving saleors webhook the header `saleor-event` is in snake_case,
|
||||||
//have to serialize and deserialize the enum two different ways
|
//have to serialize and deserialize the enum two different ways
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
use http::HeaderMap;
|
use http::HeaderMap;
|
||||||
|
use strum_macros::{AsRefStr, EnumString};
|
||||||
|
|
||||||
use crate::headers::SALEOR_EVENT_HEADER;
|
use crate::headers::SALEOR_EVENT_HEADER;
|
||||||
|
|
||||||
use super::{AsyncWebhookEventType, SyncWebhookEventType};
|
use super::{AsyncWebhookEventType, SyncWebhookEventType};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum EitherWebhookType {
|
pub enum EitherWebhookType {
|
||||||
Sync(SyncWebhookEventType),
|
Sync(SyncWebhookEventType),
|
||||||
Async(AsyncWebhookEventType),
|
Async(AsyncWebhookEventType),
|
||||||
|
|
Loading…
Reference in a new issue