pub struct RideWithGpsClient { /* private fields */ }Expand description
Main client for the RideWithGPS API
Implementations§
Source§impl RideWithGpsClient
impl RideWithGpsClient
Sourcepub fn create_auth_token(
&self,
email: &str,
password: &str,
) -> Result<AuthToken>
pub fn create_auth_token( &self, email: &str, password: &str, ) -> Result<AuthToken>
Create an authentication token using email and password
§Arguments
email- User email addresspassword- User password
§Example
use ridewithgps_client::RideWithGpsClient;
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
None
);
let auth = client.create_auth_token("user@example.com", "password").unwrap();
println!("Auth token: {}", auth.auth_token);Source§impl RideWithGpsClient
impl RideWithGpsClient
Sourcepub fn list_collections(
&self,
params: Option<&ListCollectionsParams>,
) -> Result<PaginatedResponse<Collection>>
pub fn list_collections( &self, params: Option<&ListCollectionsParams>, ) -> Result<PaginatedResponse<Collection>>
List collections
§Arguments
params- Optional parameters for filtering and pagination
§Example
use ridewithgps_client::RideWithGpsClient;
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
let collections = client.list_collections(None).unwrap();
println!("Found {} collections", collections.results.len());Sourcepub fn get_collection(&self, id: u64) -> Result<Collection>
pub fn get_collection(&self, id: u64) -> Result<Collection>
Get a specific collection by ID
This returns the full collection including its routes and trips.
§Arguments
id- The collection ID
§Example
use ridewithgps_client::RideWithGpsClient;
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
None
);
let collection = client.get_collection(12345).unwrap();
println!("Collection: {:?}", collection);
// Access routes within the collection
if let Some(routes) = &collection.routes {
for route in routes {
println!("Route: {} - {:?}", route.id, route.name);
}
}
// Access trips within the collection
if let Some(trips) = &collection.trips {
for trip in trips {
println!("Trip: {} - {:?}", trip.id, trip.name);
}
}Sourcepub fn get_pinned_collection(&self) -> Result<Collection>
pub fn get_pinned_collection(&self) -> Result<Collection>
Get the pinned collection
§Example
use ridewithgps_client::RideWithGpsClient;
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
let collection = client.get_pinned_collection().unwrap();
println!("Pinned collection: {:?}", collection);Source§impl RideWithGpsClient
impl RideWithGpsClient
Sourcepub fn list_events(
&self,
params: Option<&ListEventsParams>,
) -> Result<PaginatedResponse<Event>>
pub fn list_events( &self, params: Option<&ListEventsParams>, ) -> Result<PaginatedResponse<Event>>
List events
§Arguments
params- Optional parameters for filtering and pagination
§Example
use ridewithgps_client::{RideWithGpsClient, ListEventsParams};
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
let events = client.list_events(None).unwrap();
println!("Found {} events", events.results.len());Sourcepub fn create_event(&self, event: &EventRequest) -> Result<Event>
pub fn create_event(&self, event: &EventRequest) -> Result<Event>
Create a new event
§Arguments
event- The event data
§Example
use ridewithgps_client::{RideWithGpsClient, EventRequest, Visibility};
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
let event_req = EventRequest {
name: Some("My Event".to_string()),
description: Some("A great ride".to_string()),
location: Some("San Francisco, CA".to_string()),
visibility: Some(Visibility::Public),
starts_at: Some("2025-06-01T09:00:00".to_string()),
ends_at: Some("2025-06-01T17:00:00".to_string()),
registration_opens_at: None,
registration_closes_at: None,
registration_required: Some(false),
max_attendees: None,
};
let event = client.create_event(&event_req).unwrap();
println!("Created event: {}", event.id);Sourcepub fn update_event(&self, id: u64, event: &EventRequest) -> Result<Event>
pub fn update_event(&self, id: u64, event: &EventRequest) -> Result<Event>
Update an event
§Arguments
id- The event IDevent- The updated event data
§Example
use ridewithgps_client::{RideWithGpsClient, EventRequest};
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
let event_req = EventRequest {
name: Some("Updated Event Name".to_string()),
description: None,
location: None,
visibility: None,
starts_at: None,
ends_at: None,
registration_opens_at: None,
registration_closes_at: None,
registration_required: None,
max_attendees: None,
};
let event = client.update_event(12345, &event_req).unwrap();
println!("Updated event: {:?}", event);Source§impl RideWithGpsClient
impl RideWithGpsClient
Sourcepub fn list_members(
&self,
params: Option<&ListMembersParams>,
) -> Result<PaginatedResponse<Member>>
pub fn list_members( &self, params: Option<&ListMembersParams>, ) -> Result<PaginatedResponse<Member>>
List club members
Note: This endpoint is only available to organization accounts.
§Arguments
params- Optional parameters for filtering and pagination
§Example
use ridewithgps_client::RideWithGpsClient;
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
let members = client.list_members(None).unwrap();
println!("Found {} members", members.results.len());Sourcepub fn get_member(&self, id: u64) -> Result<Member>
pub fn get_member(&self, id: u64) -> Result<Member>
Get a specific member by ID
Note: This endpoint is only available to organization accounts.
§Arguments
id- The member ID
§Example
use ridewithgps_client::RideWithGpsClient;
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
let member = client.get_member(12345).unwrap();
println!("Member: {:?}", member);Sourcepub fn update_member(
&self,
id: u64,
member: &UpdateMemberRequest,
) -> Result<Member>
pub fn update_member( &self, id: u64, member: &UpdateMemberRequest, ) -> Result<Member>
Update a member’s permissions or status
Note: This endpoint is only available to organization accounts.
§Arguments
id- The member IDmember- The updated member data
§Example
use ridewithgps_client::{RideWithGpsClient, UpdateMemberRequest, MemberPermissions};
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
let member_req = UpdateMemberRequest {
role: Some("admin".to_string()),
status: Some("active".to_string()),
permissions: Some(MemberPermissions {
manage_routes: Some(true),
manage_events: Some(true),
manage_members: Some(true),
view_analytics: Some(true),
}),
};
let member = client.update_member(12345, &member_req).unwrap();
println!("Updated member: {:?}", member);Source§impl RideWithGpsClient
impl RideWithGpsClient
Sourcepub fn list_points_of_interest(
&self,
params: Option<&ListPointsOfInterestParams>,
) -> Result<PaginatedResponse<PointOfInterest>>
pub fn list_points_of_interest( &self, params: Option<&ListPointsOfInterestParams>, ) -> Result<PaginatedResponse<PointOfInterest>>
List points of interest
Note: This endpoint is only available to organization accounts.
§Arguments
params- Optional parameters for filtering and pagination
§Example
use ridewithgps_client::RideWithGpsClient;
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
let pois = client.list_points_of_interest(None).unwrap();
println!("Found {} POIs", pois.results.len());Sourcepub fn create_point_of_interest(
&self,
poi: &PointOfInterestRequest,
) -> Result<PointOfInterest>
pub fn create_point_of_interest( &self, poi: &PointOfInterestRequest, ) -> Result<PointOfInterest>
Create a new point of interest
Note: This endpoint is only available to organization accounts.
§Arguments
poi- The POI data
§Example
use ridewithgps_client::{RideWithGpsClient, PointOfInterestRequest};
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
let poi_req = PointOfInterestRequest {
name: Some("Coffee Shop".to_string()),
description: Some("Great coffee stop".to_string()),
latitude: Some(37.7749),
longitude: Some(-122.4194),
poi_type: Some("cafe".to_string()),
icon: Some("coffee".to_string()),
address: None,
phone: None,
website: None,
};
let poi = client.create_point_of_interest(&poi_req).unwrap();
println!("Created POI: {}", poi.id);Sourcepub fn get_point_of_interest(&self, id: u64) -> Result<PointOfInterest>
pub fn get_point_of_interest(&self, id: u64) -> Result<PointOfInterest>
Get a specific point of interest by ID
Note: This endpoint is only available to organization accounts.
§Arguments
id- The POI ID
§Example
use ridewithgps_client::RideWithGpsClient;
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
let poi = client.get_point_of_interest(12345).unwrap();
println!("POI: {:?}", poi);Sourcepub fn update_point_of_interest(
&self,
id: u64,
poi: &PointOfInterestRequest,
) -> Result<PointOfInterest>
pub fn update_point_of_interest( &self, id: u64, poi: &PointOfInterestRequest, ) -> Result<PointOfInterest>
Update a point of interest
Note: This endpoint is only available to organization accounts.
§Arguments
id- The POI IDpoi- The updated POI data
§Example
use ridewithgps_client::{RideWithGpsClient, PointOfInterestRequest};
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
let poi_req = PointOfInterestRequest {
name: Some("Updated Coffee Shop".to_string()),
description: None,
latitude: None,
longitude: None,
poi_type: None,
icon: None,
address: None,
phone: None,
website: None,
};
let poi = client.update_point_of_interest(12345, &poi_req).unwrap();
println!("Updated POI: {:?}", poi);Sourcepub fn delete_point_of_interest(&self, id: u64) -> Result<()>
pub fn delete_point_of_interest(&self, id: u64) -> Result<()>
Delete a point of interest
Note: This endpoint is only available to organization accounts.
§Arguments
id- The POI ID
§Example
use ridewithgps_client::RideWithGpsClient;
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
client.delete_point_of_interest(12345).unwrap();Sourcepub fn associate_poi_with_route(&self, poi_id: u64, route_id: u64) -> Result<()>
pub fn associate_poi_with_route(&self, poi_id: u64, route_id: u64) -> Result<()>
Associate a point of interest with a route
Note: This endpoint is only available to organization accounts.
§Arguments
poi_id- The POI IDroute_id- The route ID
§Example
use ridewithgps_client::RideWithGpsClient;
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
client.associate_poi_with_route(12345, 67890).unwrap();Sourcepub fn disassociate_poi_from_route(
&self,
poi_id: u64,
route_id: u64,
) -> Result<()>
pub fn disassociate_poi_from_route( &self, poi_id: u64, route_id: u64, ) -> Result<()>
Disassociate a point of interest from a route
Note: This endpoint is only available to organization accounts.
§Arguments
poi_id- The POI IDroute_id- The route ID
§Example
use ridewithgps_client::RideWithGpsClient;
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
client.disassociate_poi_from_route(12345, 67890).unwrap();Source§impl RideWithGpsClient
impl RideWithGpsClient
Sourcepub fn list_routes(
&self,
params: Option<&ListRoutesParams>,
) -> Result<PaginatedResponse<Route>>
pub fn list_routes( &self, params: Option<&ListRoutesParams>, ) -> Result<PaginatedResponse<Route>>
List routes for the authenticated user
§Arguments
params- Optional parameters for filtering and pagination
§Example
use ridewithgps_client::{RideWithGpsClient, ListRoutesParams};
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
let params = ListRoutesParams {
min_distance: Some(10000.0), // 10km
..Default::default()
};
let routes = client.list_routes(Some(¶ms)).unwrap();
println!("Found {} routes", routes.results.len());Sourcepub fn get_route_polyline(&self, id: u64) -> Result<Polyline>
pub fn get_route_polyline(&self, id: u64) -> Result<Polyline>
Get the polyline for a specific route
§Arguments
id- The route ID
§Example
use ridewithgps_client::RideWithGpsClient;
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
None
);
let polyline = client.get_route_polyline(12345).unwrap();
println!("Polyline: {}", polyline.polyline);Source§impl RideWithGpsClient
impl RideWithGpsClient
Sourcepub fn sync(&self, since: &DateTime<Utc>) -> Result<SyncResponse>
pub fn sync(&self, since: &DateTime<Utc>) -> Result<SyncResponse>
Get items that have changed since a specific datetime
This endpoint is useful for efficiently synchronizing a local library with the server by only fetching items that have changed.
§Arguments
since- DateTime since which to fetch changes
§Example
use ridewithgps_client::RideWithGpsClient;
use chrono::{Utc, TimeZone};
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
// Get all changes since January 1, 2025
let since = Utc.with_ymd_and_hms(2025, 1, 1, 0, 0, 0).unwrap();
let sync = client.sync(&since).unwrap();
println!("Found {} changed items", sync.items.len());
for item in sync.items {
println!("{:?} {} updated at {}",
item.item_type, item.id, item.updated_at);
}
// Use server_datetime for next sync
let next_sync = client.sync(&sync.server_datetime).unwrap();Source§impl RideWithGpsClient
impl RideWithGpsClient
Sourcepub fn list_trips(
&self,
params: Option<&ListTripsParams>,
) -> Result<PaginatedResponse<Trip>>
pub fn list_trips( &self, params: Option<&ListTripsParams>, ) -> Result<PaginatedResponse<Trip>>
List trips for the authenticated user
§Arguments
params- Optional parameters for filtering and pagination
§Example
use ridewithgps_client::{RideWithGpsClient, ListTripsParams};
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
let params = ListTripsParams {
min_distance: Some(20000.0), // 20km
..Default::default()
};
let trips = client.list_trips(Some(¶ms)).unwrap();
println!("Found {} trips", trips.results.len());Sourcepub fn get_trip_polyline(&self, id: u64) -> Result<Polyline>
pub fn get_trip_polyline(&self, id: u64) -> Result<Polyline>
Get the polyline for a specific trip
§Arguments
id- The trip ID
§Example
use ridewithgps_client::RideWithGpsClient;
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
None
);
let polyline = client.get_trip_polyline(12345).unwrap();
println!("Polyline: {}", polyline.polyline);Source§impl RideWithGpsClient
impl RideWithGpsClient
Sourcepub fn get_current_user(&self) -> Result<User>
pub fn get_current_user(&self) -> Result<User>
Get the current authenticated user’s information
Requires an auth token to be set.
§Example
use ridewithgps_client::RideWithGpsClient;
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
let user = client.get_current_user().unwrap();
println!("User: {:?}", user);Source§impl RideWithGpsClient
impl RideWithGpsClient
Sourcepub fn new(base_url: &str, api_key: &str, auth_token: Option<&str>) -> Self
pub fn new(base_url: &str, api_key: &str, auth_token: Option<&str>) -> Self
Create a new RideWithGPS API client
§Arguments
base_url- The base URL for the API (e.g., “https://ridewithgps.com”)api_key- Your API keyauth_token- Optional authentication token for user-specific operations
§Example
use ridewithgps_client::RideWithGpsClient;
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
None
);Sourcepub fn with_credentials(
base_url: &str,
api_key: &str,
email: &str,
password: &str,
) -> Result<Self>
pub fn with_credentials( base_url: &str, api_key: &str, email: &str, password: &str, ) -> Result<Self>
Create a new client with authentication credentials
This will create a client and authenticate using email and password to obtain an auth token.
§Arguments
base_url- The base URL for the APIapi_key- Your API keyemail- User emailpassword- User password
Sourcepub fn set_auth_token(&mut self, token: &str)
pub fn set_auth_token(&mut self, token: &str)
Set the authentication token
Sourcepub fn auth_token(&self) -> Option<&str>
pub fn auth_token(&self) -> Option<&str>
Get the authentication token