Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/deserialize and certificate parts (#3) #64

Merged
merged 7 commits into from Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/certificate_client.rs
Expand Up @@ -54,7 +54,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let client = new_client()?;

let options = NotificationOptions {
apns_topic: topic.as_ref().map(|s| &**s),
apns_topic: topic.as_deref(),
..Default::default()
};

Expand Down
2 changes: 1 addition & 1 deletion examples/token_client.rs
Expand Up @@ -51,7 +51,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let client = Client::token(&mut private_key, key_id, team_id, endpoint).unwrap();

let options = NotificationOptions {
apns_topic: topic.as_ref().map(|s| &**s),
apns_topic: topic.as_deref(),
..Default::default()
};

Expand Down
2 changes: 1 addition & 1 deletion src/client.rs
Expand Up @@ -149,7 +149,7 @@ impl Client {
builder = builder.header("apns-expiration", apns_expiration.to_string().as_bytes());
}
if let Some(ref apns_collapse_id) = payload.options.apns_collapse_id {
builder = builder.header("apns-collapse-id", apns_collapse_id.value.to_string().as_bytes());
builder = builder.header("apns-collapse-id", apns_collapse_id.value.as_bytes());
}
if let Some(apns_topic) = payload.options.apns_topic {
builder = builder.header("apns-topic", apns_topic.as_bytes());
Expand Down
3 changes: 1 addition & 2 deletions src/error.rs
@@ -1,5 +1,4 @@
//! Error and result module

///! Error and result module
use crate::{response::Response, signer::SignerError};
use std::io;
use thiserror::Error;
Expand Down
3 changes: 1 addition & 2 deletions src/request/notification.rs
@@ -1,5 +1,4 @@
//! The `aps` notification content builders

///! The `aps` notification content builders
mod default;
mod options;
mod web;
Expand Down
2 changes: 1 addition & 1 deletion src/request/notification/default.rs
Expand Up @@ -3,7 +3,7 @@ use crate::request::payload::{APSAlert, Payload, APS};

use std::{borrow::Cow, collections::BTreeMap};

#[derive(Serialize, Debug, Clone)]
#[derive(Deserialize, Serialize, Debug, Clone)]
#[serde(rename_all = "kebab-case")]
pub struct DefaultAlert<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
2 changes: 1 addition & 1 deletion src/request/notification/options.rs
Expand Up @@ -20,7 +20,7 @@ impl<'a> CollapseId<'a> {
}

/// Headers to specify options to the notification.
#[derive(Debug, Clone, Default)]
#[derive(Debug, Default, Clone)]
pub struct NotificationOptions<'a> {
/// A canonical UUID that identifies the notification. If there is an error
/// sending the notification, APNs uses this value to identify the
Expand Down
4 changes: 2 additions & 2 deletions src/request/notification/web.rs
Expand Up @@ -2,7 +2,7 @@ use crate::request::notification::{NotificationBuilder, NotificationOptions};
use crate::request::payload::{APSAlert, Payload, APS};
use std::collections::BTreeMap;

#[derive(Serialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "kebab-case")]
pub struct WebPushAlert<'a> {
pub title: &'a str,
Expand Down Expand Up @@ -104,7 +104,7 @@ mod tests {
title: "Hello",
body: "world",
},
&vec!["arg1"],
&["arg1"],
)
.build("device-token", Default::default())
.to_json_string()
Expand Down
5 changes: 2 additions & 3 deletions src/request/payload.rs
@@ -1,5 +1,4 @@
//! Payload with `aps` and custom data

///! Payload with `aps` and custom data
use crate::error::Error;
use crate::request::notification::{DefaultAlert, NotificationOptions, WebPushAlert};
use erased_serde::Serialize;
Expand Down Expand Up @@ -91,7 +90,7 @@ impl<'a> Payload<'a> {
}

/// The pre-defined notification data.
#[derive(Serialize, Debug, Clone)]
#[derive(Serialize, Default, Debug, Clone)]
#[serde(rename_all = "kebab-case")]
#[allow(clippy::upper_case_acronyms)]
pub struct APS<'a> {
Expand Down