RideWithGpsClient

Struct RideWithGpsClient 

Source
pub struct RideWithGpsClient { /* private fields */ }
Expand description

Main client for the RideWithGPS API

Implementations§

Source§

impl RideWithGpsClient

Source

pub fn create_auth_token( &self, email: &str, password: &str, ) -> Result<AuthToken>

Create an authentication token using email and password

§Arguments
  • email - User email address
  • password - 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

Source

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());
Source

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);
    }
}
Source

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

Source

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());
Source

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);
Source

pub fn get_event(&self, id: u64) -> Result<Event>

Get a specific event by ID

§Arguments
  • id - The event ID
§Example
use ridewithgps_client::RideWithGpsClient;

let client = RideWithGpsClient::new(
    "https://ridewithgps.com",
    "your-api-key",
    None
);

let event = client.get_event(12345).unwrap();
println!("Event: {:?}", event);
Source

pub fn update_event(&self, id: u64, event: &EventRequest) -> Result<Event>

Update an event

§Arguments
  • id - The event ID
  • event - 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

pub fn delete_event(&self, id: u64) -> Result<()>

Delete an event

§Arguments
  • id - The event ID
§Example
use ridewithgps_client::RideWithGpsClient;

let client = RideWithGpsClient::new(
    "https://ridewithgps.com",
    "your-api-key",
    Some("your-auth-token")
);

client.delete_event(12345).unwrap();
Source§

impl RideWithGpsClient

Source

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());
Source

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);
Source

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 ID
  • member - 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

Source

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());
Source

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);
Source

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);
Source

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 ID
  • poi - 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);
Source

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();
Source

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 ID
  • route_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();
Source

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 ID
  • route_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

Source

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(&params)).unwrap();
println!("Found {} routes", routes.results.len());
Source

pub fn get_route(&self, id: u64) -> Result<Route>

Get a specific route by ID

§Arguments
  • id - The route ID
§Example
use ridewithgps_client::RideWithGpsClient;

let client = RideWithGpsClient::new(
    "https://ridewithgps.com",
    "your-api-key",
    Some("your-auth-token")
);

let route = client.get_route(12345).unwrap();
println!("Route: {:?}", route);
Source

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

pub fn delete_route(&self, id: u64) -> Result<()>

Delete a route

§Arguments
  • id - The route ID
§Example
use ridewithgps_client::RideWithGpsClient;

let client = RideWithGpsClient::new(
    "https://ridewithgps.com",
    "your-api-key",
    Some("your-auth-token")
);

client.delete_route(12345).unwrap();
Source§

impl RideWithGpsClient

Source

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

Source

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(&params)).unwrap();
println!("Found {} trips", trips.results.len());
Source

pub fn get_trip(&self, id: u64) -> Result<Trip>

Get a specific trip by ID

§Arguments
  • id - The trip ID
§Example
use ridewithgps_client::RideWithGpsClient;

let client = RideWithGpsClient::new(
    "https://ridewithgps.com",
    "your-api-key",
    Some("your-auth-token")
);

let trip = client.get_trip(12345).unwrap();
println!("Trip: {:?}", trip);
Source

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

pub fn delete_trip(&self, id: u64) -> Result<()>

Delete a trip

§Arguments
  • id - The trip ID
§Example
use ridewithgps_client::RideWithGpsClient;

let client = RideWithGpsClient::new(
    "https://ridewithgps.com",
    "your-api-key",
    Some("your-auth-token")
);

client.delete_trip(12345).unwrap();
Source§

impl RideWithGpsClient

Source

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

Source

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 key
  • auth_token - Optional authentication token for user-specific operations
§Example
use ridewithgps_client::RideWithGpsClient;

let client = RideWithGpsClient::new(
    "https://ridewithgps.com",
    "your-api-key",
    None
);
Source

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 API
  • api_key - Your API key
  • email - User email
  • password - User password
Source

pub fn set_auth_token(&mut self, token: &str)

Set the authentication token

Source

pub fn auth_token(&self) -> Option<&str>

Get the authentication token

Trait Implementations§

Source§

impl Debug for RideWithGpsClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more