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

Fix tripactions pagination #13

Merged
merged 3 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Bump version and build tripactions
  • Loading branch information
augustuswm committed May 5, 2022
commit 50b9f9a6cb07ef380f7c8c515ceea8ab56a02eb2
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ $(TRIPACTIONS_SPEC): $(TRIPACTIONS_SPEC_DIR)
curl -sSL $(TRIPACTIONS_SPEC_REMOTE) -o $@

tripactions: target/debug/generator $(TRIPACTIONS_SPEC)
./target/debug/generator -i $(TRIPACTIONS_SPEC) -v 0.2.2 \
./target/debug/generator -i $(TRIPACTIONS_SPEC) -v 0.2.3 \
-o tripactions \
-n tripactions \
--proper-name "TripActions" \
Expand Down
2 changes: 1 addition & 1 deletion tripactions/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "tripactions"
description = "A fully generated & opinionated API client for the TripActions API."
version = "0.2.2"
version = "0.2.3"
documentation = "https://docs.rs/tripactions/"
repository = "https://github.com/oxidecomputer/third-party-api-clients/tree/main/tripactions"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion tripactions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ To install the library, add the following to your `Cargo.toml` file.

```toml
[dependencies]
tripactions = "0.2.2"
tripactions = "0.2.3"
```

## Basic example
Expand Down
54 changes: 27 additions & 27 deletions tripactions/src/booking_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ impl BookingData {
}

/**
* Your company's bookings.
*
* This function performs a `GET` to the `/v1/bookings` endpoint.
*
* Return booking rows filtered by the parameters you select.
*
* **Parameters:**
*
* * `created_from: &str` -- Filter based on booking created date in epoch seconds.
* * `created_to: &str` -- Filter based on booking created date in epoch seconds.
* * `start_date_from: &str` -- Filter based on travel start date in epoch seconds.
* * `start_date_to: &str` -- Filter based on travel end date in epoch seconds.
* * `booking_status: crate::types::BookingStatus` -- Filter based on booking status.
* * `page: u64` -- Page cursor for use in pagination.
* * `size: i64` -- Number of records returned per page.
* * `booking_type: crate::types::BookingType` -- Filter based on Booking type.
*/
* Your company's bookings.
*
* This function performs a `GET` to the `/v1/bookings` endpoint.
*
* Return booking rows filtered by the parameters you select.
*
* **Parameters:**
*
* * `created_from: &str` -- Filter based on booking created date in epoch seconds.
* * `created_to: &str` -- Filter based on booking created date in epoch seconds.
* * `start_date_from: &str` -- Filter based on travel start date in epoch seconds.
* * `start_date_to: &str` -- Filter based on travel end date in epoch seconds.
* * `booking_status: crate::types::BookingStatus` -- Filter based on booking status.
* * `page: u64` -- Page cursor for use in pagination.
* * `size: i64` -- Number of records returned per page.
* * `booking_type: crate::types::BookingType` -- Filter based on Booking type.
*/
pub async fn get_booking_report(
&self,
created_from: &str,
Expand Down Expand Up @@ -76,14 +76,14 @@ impl BookingData {
}

/**
* Your company's bookings.
*
* This function performs a `GET` to the `/v1/bookings` endpoint.
*
* As opposed to `get_booking_report`, this function returns all the pages of the request at once.
*
* Return booking rows filtered by the parameters you select.
*/
* Your company's bookings.
*
* This function performs a `GET` to the `/v1/bookings` endpoint.
*
* As opposed to `get_booking_report`, this function returns all the pages of the request at once.
*
* Return booking rows filtered by the parameters you select.
*/
pub async fn get_all_booking_report(
&self,
created_from: &str,
Expand Down Expand Up @@ -133,12 +133,12 @@ impl BookingData {
if !url.contains('?') {
resp = self
.client
.get(&format!("{}?page={}", url, page), None)
.get(&format!("{}?page={}&size=100", url, page), None)
.await?;
} else {
resp = self
.client
.get(&format!("{}&page={}", url, page), None)
.get(&format!("{}&page={}&size=100", url, page), None)
.await?;
}

Expand Down
9 changes: 3 additions & 6 deletions tripactions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
//!
//! ```toml
//! [dependencies]
//! tripactions = "0.2.2"
//! tripactions = "0.2.3"
//! ```
//!
//! ## Basic example
Expand Down Expand Up @@ -54,9 +54,7 @@
//! ```
//! use tripactions::Client;
//!
//! let tripactions = Client::new_from_env(
//! String::from("token"),
//! );
//! let tripactions = Client::new_from_env(String::from("token"));
//! ```
//!
//! It is okay to pass an empty value for `token`. In
Expand All @@ -73,7 +71,6 @@
//! let mut access_token = tripactions.get_access_token().await.unwrap();
//! }
//! ```
//!
#![allow(clippy::too_many_arguments)]
#![allow(clippy::nonstandard_macro_braces)]
#![allow(clippy::large_enum_variant)]
Expand Down Expand Up @@ -673,7 +670,7 @@ impl Client {
while !items.is_empty() {
global_items.append(&mut items);
// We need to get the next link.
if let Some(url) = link.as_ref().and_then(crate::utils::next_link) {
if let Some(url) = link.as_ref().and_then(|l| crate::utils::next_link(l)) {
let url = reqwest::Url::parse(&url)?;
let (new_link, new_items) = self.get_pages_url(&url).await?;
link = new_link;
Expand Down
20 changes: 10 additions & 10 deletions tripactions/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,8 @@ pub struct BookingReport {
)]
pub cancellation_reason: String,
/**
* Time at which the object was created.
*/
* Time at which the object was created.
*/
#[serde(
default,
skip_serializing_if = "Option::is_none",
Expand Down Expand Up @@ -613,8 +613,8 @@ pub struct BookingReport {
)]
pub corporate_discount_used: String,
/**
* Time at which the object was created.
*/
* Time at which the object was created.
*/
#[serde(
default,
skip_serializing_if = "Option::is_none",
Expand Down Expand Up @@ -644,8 +644,8 @@ pub struct BookingReport {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub destination: Option<Location>,
/**
* Local date when the booking starts, e.g. checkin date for hotel, date of depart for flight
*/
* Local date when the booking starts, e.g. checkin date for hotel, date of depart for flight
*/
#[serde(
default,
skip_serializing_if = "Option::is_none",
Expand Down Expand Up @@ -736,8 +736,8 @@ pub struct BookingReport {
)]
pub invoice: String,
/**
* Time at which the object was created.
*/
* Time at which the object was created.
*/
#[serde(
default,
skip_serializing_if = "Option::is_none",
Expand Down Expand Up @@ -918,8 +918,8 @@ pub struct BookingReport {
)]
pub segments: Vec<Segment>,
/**
* Local date when the booking starts, e.g. checkin date for hotel, date of depart for flight
*/
* Local date when the booking starts, e.g. checkin date for hotel, date of depart for flight
*/
#[serde(
default,
skip_serializing_if = "Option::is_none",
Expand Down