Skip to content

Commit

Permalink
Merge pull request #471 from buhaytza2005/solutions_and_bookings
Browse files Browse the repository at this point in the history
Solutions and bookings
  • Loading branch information
sreeise authored Jun 8, 2024
2 parents b35f98e + b8ce31d commit c9302cc
Show file tree
Hide file tree
Showing 22 changed files with 548 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/mail_folders_and_messages/messages.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use graph_rs_sdk::*;
use graph_rs_sdk::header::{HeaderValue, CONTENT_LENGTH};
use graph_rs_sdk::*;

static ACCESS_TOKEN: &str = "ACCESS_TOKEN";

Expand Down
58 changes: 58 additions & 0 deletions examples/solutions/business.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
use graph_rs_sdk::*;

//businesses are the equivalent of booking pages
//creating a new business with the name "My Business" will create a booking page and once bookings
//are open, a new alias `[email protected]` will be created. If name already exists, the alias
//will be `[email protected]`.
//
//
//

async fn create_business(){
let client = Graph::new("ACCESS_TOKEN");


let data = serde_json::json!({
"displayName": "My Business"
});

let body = Body::from(data.to_string());

let resp = client
.solutions()
.booking_businesses()
.create_booking_businesses(body)
.send()
.await;

println!("{:#?}", resp);
}

async fn get_businesses() {
let access_token = log_me_in().await.unwrap();
let client = Graph::new(&access_token);
let bus = client.solutions().booking_businesses().list_booking_businesses().send().await.unwrap();

let businesses: serde_json::Value = bus.json().await.unwrap();
println!("{:#}", businesses)
}

async fn get_appointments() {
let access_token = log_me_in().await.unwrap();
let client = Graph::new(&access_token);

let appointments = client
.solutions()
//can be id retrieved from list_booking_businesses or pass the generated alias
.booking_business("[email protected]")
.appointments()
.list_appointments()
.send()
.await
.unwrap();

let app_json: serde_json::Value = appointments.json().await.unwrap();

println!("{:#?}", app_json);
}

2 changes: 1 addition & 1 deletion graph-codegen/src/macros/macro_queue_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ pub trait MacroImplWriter {
}

let resource_api_client_impl = format!(
"resource_api_client!({}, {});\n",
"api_client!({}, {});\n",
client_impl_string,
settings[0].ri.enum_string()
);
Expand Down
34 changes: 32 additions & 2 deletions graph-codegen/src/settings/method_macro_modifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,36 @@ pub fn get_method_macro_modifiers(resource_identity: ResourceIdentity) -> Vec<Me
GeneratedMacroType::FnName("bin_20_ct")
),
],
_ => vec![],
}
ResourceIdentity::Appointments => vec![
MethodMacroModifier::fn_name_and_path(
"appointments", "/appointments/$count",
GeneratedMacroType::FnName("get_appointments_count")
)],
ResourceIdentity::CustomQuestions => vec![
MethodMacroModifier::fn_name_and_path(
"custom_questions", "/customQuestions/$count",
GeneratedMacroType::FnName("get_custom_questions_count")
)],
ResourceIdentity::Customers => vec![
MethodMacroModifier::fn_name_and_path(
"customers", "/customers/$count",
GeneratedMacroType::FnName("get_customers_count")
)],
ResourceIdentity::Services => vec![
MethodMacroModifier::fn_name_and_path(
"services", "/services/$count",
GeneratedMacroType::FnName("get_services_count")
)],
ResourceIdentity::BookingBusinesses => vec![
MethodMacroModifier::fn_name_and_path(
"booking_businesses", "/bookingBusinesses/$count",
GeneratedMacroType::FnName("get_booking_businesses_count")
)],
ResourceIdentity::StaffMembers => vec![
MethodMacroModifier::fn_name_and_path(
"staff_members", "/staff_members/$count",
GeneratedMacroType::FnName("get_staff_members_count")
)],
_ => vec![],
}
}
71 changes: 71 additions & 0 deletions graph-codegen/src/settings/resource_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,40 @@ impl ResourceSettings {
.api_client_links(get_users_api_client_links(ri))
.build()
.unwrap(),
ResourceIdentity::Solutions => ResourceSettings::builder(path_name, ri)
.imports(vec!["crate::solutions::*"])
.api_client_links(vec![
ApiClientLinkSettings(Some("SolutionsApiClient"),
vec![
ApiClientLink::Struct("booking_businesses", "BookingBusinessesApiClient"),
ApiClientLink::StructId("booking_business", "BookingBusinessesIdApiClient"),
]
)
])
.build()
.unwrap(),
ResourceIdentity::BookingBusinesses => ResourceSettings::builder(path_name, ri)
.imports(vec!["crate::solutions::*", "crate::users::*"])
.api_client_links(vec![
ApiClientLinkSettings(Some("BookingBusinessesIdApiClient"),
vec![
ApiClientLink::Struct("appointments", "AppointmentsApiClient"),
ApiClientLink::StructId("appointment", "AppointmentsIdApiClient"),
ApiClientLink::Struct("services", "ServicesApiClient"),
ApiClientLink::StructId("service", "ServicesIdApiClient"),
ApiClientLink::Struct("custom_questions", "CustomQuestionsApiClient"),
ApiClientLink::StructId("custom_question", "CustomQuestionsIdApiClient"),
ApiClientLink::Struct("customers", "CustomersApiClient"),
ApiClientLink::StructId("customer", "CustomersIdApiClient"),
ApiClientLink::Struct("staff_members", "StaffMembersApiClient"),
ApiClientLink::StructId("staff_member", "StaffMembersIdApiClient"),
ApiClientLink::Struct("calendar_views", "CalendarViewApiClient"),
ApiClientLink::StructId("calendar_view", "CalendarViewIdApiClient"),
]
)
])
.build()
.unwrap(),
_ => ResourceSettings::default(path_name, ri),
}
}
Expand Down Expand Up @@ -2658,6 +2692,43 @@ pub fn get_write_configuration(resource_identity: ResourceIdentity) -> WriteConf
.trim_path_start("/users/{user-id}")
.build()
.unwrap(),
ResourceIdentity::Solutions => WriteConfiguration::builder(resource_identity)
.filter_path(vec!["bookingBusinesses", "virtualEvents", "bookingCurrencies"])
.children(vec![
get_write_configuration(ResourceIdentity::BookingBusinesses),
get_write_configuration(ResourceIdentity::Appointments),
get_write_configuration(ResourceIdentity::Services),
get_write_configuration(ResourceIdentity::CustomQuestions),
get_write_configuration(ResourceIdentity::Customers),
get_write_configuration(ResourceIdentity::StaffMembers),
])
.build()
.unwrap(),
ResourceIdentity::BookingBusinesses => WriteConfiguration::second_level_builder(ResourceIdentity::Solutions, resource_identity)
.trim_path_start("/solutions")
.filter_path(vec!["appointments", "calendarView", "customQuestions", "customers", "services", "staffMembers"])
.build()
.unwrap(),
ResourceIdentity::Appointments => WriteConfiguration::second_level_builder(ResourceIdentity::Solutions, resource_identity)
.trim_path_start("/solutions/bookingBusinesses/{bookingBusiness-id}")
.build()
.unwrap(),
ResourceIdentity::Services => WriteConfiguration::second_level_builder(ResourceIdentity::Solutions, resource_identity)
.trim_path_start("/solutions/bookingBusinesses/{bookingBusiness-id}")
.build()
.unwrap(),
ResourceIdentity::CustomQuestions => WriteConfiguration::second_level_builder(ResourceIdentity::Solutions, resource_identity)
.trim_path_start("/solutions/bookingBusinesses/{bookingBusiness-id}")
.build()
.unwrap(),
ResourceIdentity::Customers=> WriteConfiguration::second_level_builder(ResourceIdentity::Solutions, resource_identity)
.trim_path_start("/solutions/bookingBusinesses/{bookingBusiness-id}")
.build()
.unwrap(),
ResourceIdentity::StaffMembers => WriteConfiguration::second_level_builder(ResourceIdentity::Solutions, resource_identity)
.trim_path_start("/solutions/bookingBusinesses/{bookingBusiness-id}")
.build()
.unwrap(),
_ => WriteConfiguration::builder(resource_identity)
.build()
.unwrap(),
Expand Down
6 changes: 6 additions & 0 deletions graph-core/src/resource/resource_identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub enum ResourceIdentity {
Application,
Applications,
ApplicationTemplates,
Appointments,
AppRoleAssignments,
AssignmentPolicies,
AssignmentRequests,
Expand All @@ -49,6 +50,7 @@ pub enum ResourceIdentity {
AuthenticationMethodConfigurations,
AuthenticationMethodsPolicy,
Batch, // Specifically for $batch requests.
BookingBusinesses,
Branding,
Buckets,
CalendarGroups,
Expand Down Expand Up @@ -78,6 +80,8 @@ pub enum ResourceIdentity {
CreatedByUser,
CreatedObjects,
Custom,
Customers,
CustomQuestions,
DataPolicyOperations,
DefaultCalendar,
DefaultManagedAppProtections,
Expand Down Expand Up @@ -200,6 +204,7 @@ pub enum ResourceIdentity {
Security,
ServicePrincipals,
ServicePrincipalsOwners,
Services,
Settings,
SharedWithTeams,
Shares,
Expand All @@ -209,6 +214,7 @@ pub enum ResourceIdentity {
SitesItemsVersions,
SitesLists,
Solutions,
StaffMembers,
SubscribedSkus,
Subscriptions,
Tabs,
Expand Down
3 changes: 3 additions & 0 deletions src/client/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ use crate::reports::ReportsApiClient;
use crate::schema_extensions::{SchemaExtensionsApiClient, SchemaExtensionsIdApiClient};
use crate::service_principals::{ServicePrincipalsApiClient, ServicePrincipalsIdApiClient};
use crate::sites::{SitesApiClient, SitesIdApiClient};
use crate::solutions::SolutionsApiClient;
use crate::subscribed_skus::SubscribedSkusApiClient;
use crate::subscriptions::{SubscriptionsApiClient, SubscriptionsIdApiClient};
use crate::teams::{TeamsApiClient, TeamsIdApiClient};
Expand Down Expand Up @@ -470,6 +471,8 @@ impl GraphClient {

api_client_impl!(sites, SitesApiClient, site, SitesIdApiClient);

api_client_impl!(solutions, SolutionsApiClient);

api_client_impl!(
subscribed_skus,
SubscribedSkusApiClient,
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ pub mod reports;
pub mod schema_extensions;
pub mod service_principals;
pub mod sites;
pub mod solutions;
pub mod subscribed_skus;
pub mod subscriptions;
pub mod teams;
Expand Down
3 changes: 3 additions & 0 deletions src/solutions/appointments/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod request;

pub use request::*;
53 changes: 53 additions & 0 deletions src/solutions/appointments/request.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// GENERATED CODE

use crate::api_default_imports::*;

api_client!(
AppointmentsApiClient,
AppointmentsIdApiClient,
ResourceIdentity::Appointments
);

impl AppointmentsApiClient {
post!(
doc: "Create bookingAppointment",
name: create_appointments,
path: "/appointments",
body: true
);
get!(
doc: "List appointments",
name: list_appointments,
path: "/appointments"
);
get!(
doc: "Get the number of the resource",
name: get_appointments_count,
path: "/appointments/$count"
);
}

impl AppointmentsIdApiClient {
delete!(
doc: "Delete bookingAppointment",
name: delete_appointments,
path: "/appointments/{{RID}}"
);
get!(
doc: "Get bookingAppointment",
name: get_appointments,
path: "/appointments/{{RID}}"
);
patch!(
doc: "Update bookingAppointment",
name: update_appointments,
path: "/appointments/{{RID}}",
body: true
);
post!(
doc: "Invoke action cancel",
name: cancel,
path: "/appointments/{{RID}}/cancel",
body: true
);
}
3 changes: 3 additions & 0 deletions src/solutions/booking_businesses/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod request;

pub use request::*;
Loading

0 comments on commit c9302cc

Please sign in to comment.