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

chore: enable various clippy warnings #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/api_configs/associations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct AssociationTypes {
/// A struct for creating new associations.
#[derive(Serialize, Debug)]
pub struct AssociationCreationDetails {
/// Whether the association type was created by HubSpot or a user (HUBSPOT_DEFINED and USER_DEFINED)
/// Whether the association type was created by `HubSpot` or a user (`HUBSPOT_DEFINED` an`USER_DEFINED`ED)
#[serde(rename = "associationCategory")]
pub category: String,
/// The numeric ID for that association type.
Expand Down Expand Up @@ -81,7 +81,7 @@ impl<T> AssociationsApiCollection<T>
where
T: ToPath,
{
/// Constructs a new AssociationsApiCollection for an object type.
/// Constructs a new `AssociationsApiCollection` for an object type.
pub fn new(name: T, client: Arc<HubspotClient>) -> Self {
Self(name, client)
}
Expand Down
21 changes: 10 additions & 11 deletions src/api_configs/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ struct BatchInputs<I> {
}

impl<I> BatchInputs<I> {
/// Constructs a new BatchInput
pub fn new(inputs: Vec<I>) -> BatchInputs<I> {
/// Constructs a new `BatchInput`
fn new(inputs: Vec<I>) -> BatchInputs<I> {
BatchInputs { inputs }
}
}
Expand All @@ -32,19 +32,16 @@ struct BatchUpdateInput<Properties> {
}

impl<Properties: Clone> BatchUpdateInput<Properties> {
/// Constructs a new BatchUpdateInput
pub fn new(id: &str, properties: Properties) -> BatchUpdateInput<Properties> {
/// Constructs a new `BatchUpdateInput`
fn new(id: &str, properties: Properties) -> BatchUpdateInput<Properties> {
BatchUpdateInput {
id: id.to_string(),
properties,
}
}

/// Constructs a new vec of BatchUpdateInputs from a list of record IDs.
pub fn new_batch(
ids: Vec<String>,
properties: Properties,
) -> Vec<BatchUpdateInput<Properties>> {
/// Constructs a new vec of `BatchUpdateInputs` from a list of record IDs.
fn new_batch(ids: Vec<String>, properties: Properties) -> Vec<BatchUpdateInput<Properties>> {
ids.iter()
.map(|id| BatchUpdateInput::new(id, properties.clone()))
.collect()
Expand Down Expand Up @@ -128,7 +125,7 @@ impl<T> BatchApiCollection<T>
where
T: ToPath,
{
/// Constructs a new BatchApiCollection for a Hubspot Object
/// Constructs a new `BatchApiCollection` for a Hubspot Object
pub fn new(name: T, client: Arc<HubspotClient>) -> Self {
Self(name, client)
}
Expand All @@ -145,7 +142,9 @@ where
.json::<BatchInputs<BatchIdInput>>(&BatchInputs::<BatchIdInput> {
inputs: ids
.iter()
.map(|i| BatchIdInput { id: i.to_string() })
.map(|i| BatchIdInput {
id: (*i).to_string(),
})
.collect(),
}),
)
Expand Down
14 changes: 6 additions & 8 deletions src/api_configs/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
mod associations;
mod batch;
pub mod query;
pub(crate) mod query;
pub mod types;

use std::sync::Arc;

pub use associations::{AssociationCreationDetails, AssociationTypes};

pub use types::{
AssociationLinks, AssociationType, CreateAssociation, HubspotRecord, OptionNotDesired,
};
pub(crate) use types::{CreateAssociation, HubspotRecord, OptionNotDesired};

use crate::client::HubspotClient;

Expand Down Expand Up @@ -69,7 +67,7 @@ where
/// Properties: A struct of the properties to be returned in the response.
/// If the requested object doesn't have a value for a property, it will not appear in the response.
///
/// PropertiesWithHistory: A struct of the properties with history to be returned in the response.
/// `PropertiesWithHistory`: A struct of the properties with history to be returned in the response.
/// If the requested object doesn't have a value for a property, it will not appear in the response.
///
/// Associations: A struct of the associations to be returned in the response.
Expand Down Expand Up @@ -113,7 +111,7 @@ where
/// Properties: A struct of the properties to be returned in the response.
/// If the requested object doesn't have a value for a property, it will not appear in the response.
///
/// PropertiesWithHistory: A struct of the properties with history to be returned in the response.
/// `PropertiesWithHistory`: A struct of the properties with history to be returned in the response.
/// If the requested object doesn't have a value for a property, it will not appear in the response.
///
/// Associations: A struct of the associations to be returned in the response.
Expand Down Expand Up @@ -143,7 +141,7 @@ where
/// Properties: A struct of the properties to be returned in the response.
/// If the requested object doesn't have a value for a property, it will not appear in the response.
///
/// PropertiesWithHistory: A struct of the properties with history to be returned in the response.
/// `PropertiesWithHistory`: A struct of the properties with history to be returned in the response.
/// If the requested object doesn't have a value for a property, it will not appear in the response.
///
/// Associations: A struct of the associations to be returned in the response.
Expand Down Expand Up @@ -184,7 +182,7 @@ where
/// Properties: A struct of the properties to be updated and returned in the response.
/// If the requested object doesn't have a value for a property, it will not be updated or appear in the response.
///
/// PropertiesWithHistory: A struct of the properties with history to be returned in the response.
/// `PropertiesWithHistory`: A struct of the properties with history to be returned in the response.
/// If the requested object doesn't have a value for a property, it will not appear in the response.
pub async fn update<Properties, PropertiesWithHistory>(
&self,
Expand Down
16 changes: 8 additions & 8 deletions src/api_configs/query.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// Check if query has begun.
pub fn query_begun_check(checkpoint: bool) -> (String, bool) {
fn query_begun_check(checkpoint: bool) -> (String, bool) {
if checkpoint {
("&".to_string(), checkpoint)
} else {
Expand All @@ -8,13 +8,13 @@ pub fn query_begun_check(checkpoint: bool) -> (String, bool) {
}

/// Build the query for hubspot paging.
pub fn build_paging_query(limit: Option<i32>, after: Option<&str>) -> (String, bool) {
pub(crate) fn build_paging_query(limit: Option<i32>, after: Option<&str>) -> (String, bool) {
let mut query_begun = false;

let limit_query = match limit {
Some(limit) => {
query_begun = true;
format!("?limit={}", limit)
format!("?limit={limit}")
}
None => String::new(),
};
Expand All @@ -28,11 +28,11 @@ pub fn build_paging_query(limit: Option<i32>, after: Option<&str>) -> (String, b
None => String::new(),
};

(format!("{}{}", limit_query, after_query), query_begun)
(format!("{limit_query}{after_query}"), query_begun)
}

/// Build a query string from properties, properties_with_history, associations, and archived
pub fn build_query_string(
/// Build a query string from properties, `properties_with_history`, associations, and archived
pub(crate) fn build_query_string(
query_already_begun: bool,
properties: &[&str],
properties_with_history: &[&str],
Expand Down Expand Up @@ -67,9 +67,9 @@ pub fn build_query_string(
format!("{}associations={}", query_check.0, associations.join(","))
};
let archived_query = if query_begun {
format!("&archived={}", archived)
format!("&archived={archived}")
} else {
format!("?archived={}", archived)
format!("?archived={archived}")
};

format!("{property_query}{properties_with_history_query}{associations_query}{archived_query}")
Expand Down
33 changes: 20 additions & 13 deletions src/api_configs/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;

use crate::client::HubspotClient;

/// ToPath trait represents a Hubspot object's path.
/// `ToPath` trait represents a Hubspot object's path.
pub trait ToPath {
/// Returns the object's path for the api routes.
fn to_path(&self) -> String;
Expand Down Expand Up @@ -53,9 +53,9 @@ pub struct HubspotRecord<Properties, PropertiesWithHistory, Associations> {
pub archived_at: Option<String>,
}

/// Implementation of HubspotRecord where only Properties are required.
/// Implementation of `HubspotRecord` where only Properties are required.
impl<Properties> HubspotRecord<Properties, OptionNotDesired, OptionNotDesired> {
/// Create a new HubspotRecord with the given properties and default values for all other fields.
/// Create a new `HubspotRecord` with the given properties and default values for all other fields.
/// Suggested use for the Core Update endpoint.
pub fn with_properties(
properties: Properties,
Expand All @@ -73,10 +73,10 @@ impl<Properties> HubspotRecord<Properties, OptionNotDesired, OptionNotDesired> {
}
}

/// Implementation of HubspotRecord where Properties and AssociationsToCreate are required.
/// Implementation of `HubspotRecord` where Properties and `AssociationsToCreate` are required.
/// Recommended use for the base create endpoint.
impl<Properties> HubspotRecord<Properties, OptionNotDesired, Vec<CreateAssociation>> {
/// Create a new HubspotRecord with the given properties. Initializes a vec for associations to create. Default values for all other fields.
/// Create a new `HubspotRecord` with the given properties. Initializes a vec for associations to create. Default values for all other fields.
/// Suggested use for the Core New endpoint.
pub fn with_properties_and_associations(
properties: Properties,
Expand All @@ -94,27 +94,29 @@ impl<Properties> HubspotRecord<Properties, OptionNotDesired, Vec<CreateAssociati
}

/// Attach multiple associations of the same known built in associations
#[must_use]
pub fn attach_built_in_associations(
mut self,
association_type: AssociationLinks,
ids: Vec<String>,
) -> Self {
for id in ids {
self.associations
.push(CreateAssociation::new_built_in(id, &association_type))
.push(CreateAssociation::new_built_in(id, &association_type));
}
self
}

/// Attach multiple associations of the same custom association type
#[must_use]
pub fn attach_associations(
mut self,
association_type: AssociationType,
ids: Vec<String>,
) -> Self {
for id in ids {
self.associations
.push(CreateAssociation::new(id, &association_type))
.push(CreateAssociation::new(id, &association_type));
}
self
}
Expand Down Expand Up @@ -190,22 +192,25 @@ pub struct PagingNext {

/// An enum of Built In Hubspot Associations.
/// To be built upon in the future.
#[derive(Debug)]
pub enum AssociationLinks {
NoteToContact,
NoteToCompany,
NoteToDeal,
}

/// Implementation of CreateAssociation
/// Implementation of `CreateAssociation`
impl CreateAssociation {
/// Create a new association using the AssociationLinks
/// Create a new association using the `AssociationLinks`
#[must_use]
pub fn new_built_in(id: String, association_type: &AssociationLinks) -> Self {
Self {
to: AssociationTo { id },
types: vec![association_type.build()],
}
}

#[must_use]
pub fn new(id: String, association_type: &AssociationType) -> Self {
Self {
to: AssociationTo { id },
Expand All @@ -214,9 +219,10 @@ impl CreateAssociation {
}
}

/// Implementation of AssociationLinks
/// Implementation of `AssociationLinks`
impl AssociationLinks {
/// Build a new AssociationType from the given AssociationLinks
/// Build a new `AssociationType` from the give`AssociationLinks`ks
#[must_use]
pub fn build(&self) -> AssociationType {
AssociationType {
id: match self {
Expand All @@ -229,9 +235,10 @@ impl AssociationLinks {
}
}

/// Implementation of AssociationType
/// Implementation of `AssociationType`
impl AssociationType {
/// Constructs a new AssociationType
/// Constructs a new `AssociationType`
#[must_use]
pub fn new(id: &str, category: &str) -> Self {
Self {
id: id.to_string(),
Expand Down
12 changes: 6 additions & 6 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::Hubspot;
use super::client::HubspotClient;

/// Hubspot api interface.
#[derive(Default)]
#[derive(Default, Debug)]
pub struct HubspotBuilder {
client: Option<Client>,
domain: Option<String>,
Expand All @@ -17,9 +17,9 @@ pub struct HubspotBuilder {
}

impl HubspotBuilder {
/// Create an instance of the HubSpot API builder.
/// Create an instance of the `HubSpot` API builder.
pub fn new() -> Self {
Default::default()
HubspotBuilder::default()
}

/// Build the Hubspot API Library.
Expand Down Expand Up @@ -77,11 +77,11 @@ impl HubspotBuilder {
#[allow(clippy::enum_variant_names)]
#[derive(Debug, PartialOrd, PartialEq)]
pub enum HubspotBuilderError {
/// Indicates builder didn't set [HubspotBuilder::domain].
/// Indicates builder didn't set [`HubspotBuilder::domain`].
MissingDomain,
/// Indicates builder didn't set [HubspotBuilder::token].
/// Indicates builder didn't set [`HubspotBuilder::token`].
MissingToken,
/// Indicates builder didn't set [HubspotBuilder::portal_id].
/// Indicates builder didn't set [`HubspotBuilder::portal_id`].
MissingPortalId,
}

Expand Down
3 changes: 2 additions & 1 deletion src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ pub struct HubspotClient {
}

impl HubspotClient {
/// Create HubspotClient
/// Create `HubspotClient`
#[must_use]
pub fn new(client: Client, domain: &str, token: &str, portal_id: &str) -> Self {
Self {
client,
Expand Down
2 changes: 1 addition & 1 deletion src/engagements/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl ToPath for EngagementType {
/// For example, if you call a prospect, you can log a call to the contact record,
/// and also associate the call with their associated company.
/// Possible activities include notes, tasks, meetings, emails, calls, postal mail,
/// SMS, LinkedIn messages, and WhatsApp messaged.
/// SMS, `LinkedIn` messages, an`WhatsApp`pp messaged.
#[derive(Clone, Debug)]
pub struct EngagementsManager {
/// Notes add information to the record timeline.
Expand Down
1 change: 1 addition & 0 deletions src/engagements/notes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub struct NoteProperties {
}

impl NoteProperties {
#[must_use]
pub fn new(body: String) -> Self {
Self {
body,
Expand Down
20 changes: 20 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
#![deny(
unreachable_pub,
missing_debug_implementations,
rustdoc::broken_intra_doc_links,
clippy::all,
clippy::perf,
clippy::pedantic,
clippy::fn_to_numeric_cast_any
)]
#![allow(
clippy::missing_errors_doc,
clippy::needless_pass_by_value,
clippy::match_same_arms,
clippy::module_name_repetitions,
clippy::missing_panics_doc,
clippy::similar_names
)]

use std::sync::Arc;

use builder::HubspotBuilder;
Expand Down Expand Up @@ -36,6 +54,7 @@ pub struct Hubspot {

impl Hubspot {
/// Create hubspot api
#[must_use]
pub fn new(client: HubspotClient) -> Self {
let portal_id = client.portal_id.clone();
let client = Arc::new(client);
Expand All @@ -49,6 +68,7 @@ impl Hubspot {
}

/// Create Hubspot client
#[must_use]
pub fn builder() -> HubspotBuilder {
HubspotBuilder::new()
}
Expand Down
Loading