diff --git a/openapi/src/metadata.rs b/openapi/src/metadata.rs index f58b39454..319ff7851 100644 --- a/openapi/src/metadata.rs +++ b/openapi/src/metadata.rs @@ -209,6 +209,9 @@ pub fn metadata_requests<'a>( // special case for usage_records (_, _, Some("usage_records")) => "usage_records".to_string(), + // special case: terminal is a resource, not an object + (Some("terminal"), Some(x), _) => format!("terminal.{}", x), + (Some(x), _, _) => x.to_string(), _ => { // this should never happen diff --git a/src/resources/generated/terminal_configuration.rs b/src/resources/generated/terminal_configuration.rs index 8d0fde73c..bdf26ba45 100644 --- a/src/resources/generated/terminal_configuration.rs +++ b/src/resources/generated/terminal_configuration.rs @@ -4,8 +4,9 @@ use serde::{Deserialize, Serialize}; +use crate::client::{Client, Response}; use crate::ids::TerminalConfigurationId; -use crate::params::{Expandable, Object}; +use crate::params::{Expand, Expandable, List, Object, Paginable}; use crate::resources::File; /// The resource representing a Stripe "TerminalConfigurationConfiguration". @@ -41,6 +42,24 @@ pub struct TerminalConfiguration { pub verifone_p400: Option, } +impl TerminalConfiguration { + /// Returns a list of `Configuration` objects. + pub fn list( + client: &Client, + params: &ListTerminalConfigurations<'_>, + ) -> Response> { + client.get_query("/terminal/configurations", ¶ms) + } + + /// Creates a new `Configuration` object. + pub fn create( + client: &Client, + params: CreateTerminalConfiguration<'_>, + ) -> Response { + client.post_form("/terminal/configurations", ¶ms) + } +} + impl Object for TerminalConfiguration { type Id = TerminalConfigurationId; fn id(&self) -> Self::Id { @@ -125,3 +144,379 @@ pub struct TerminalConfigurationConfigurationResourceCurrencySpecificConfig { #[serde(skip_serializing_if = "Option::is_none")] pub smart_tip_threshold: Option, } + +/// The parameters for `TerminalConfiguration::create`. +#[derive(Clone, Debug, Serialize, Default)] +pub struct CreateTerminalConfiguration<'a> { + /// An object containing device type specific settings for BBPOS WisePOS E readers. + #[serde(skip_serializing_if = "Option::is_none")] + pub bbpos_wisepos_e: Option, + + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Expand::is_empty")] + pub expand: &'a [&'a str], + + /// Configurations for collecting transactions offline. + #[serde(skip_serializing_if = "Option::is_none")] + pub offline: Option, + + /// Tipping configurations for readers supporting on-reader tips. + #[serde(skip_serializing_if = "Option::is_none")] + pub tipping: Option, + + /// An object containing device type specific settings for Verifone P400 readers. + #[serde(skip_serializing_if = "Option::is_none")] + pub verifone_p400: Option, +} + +impl<'a> CreateTerminalConfiguration<'a> { + pub fn new() -> Self { + CreateTerminalConfiguration { + bbpos_wisepos_e: Default::default(), + expand: Default::default(), + offline: Default::default(), + tipping: Default::default(), + verifone_p400: Default::default(), + } + } +} + +/// The parameters for `TerminalConfiguration::list`. +#[derive(Clone, Debug, Serialize, Default)] +pub struct ListTerminalConfigurations<'a> { + /// A cursor for use in pagination. + /// + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option, + + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Expand::is_empty")] + pub expand: &'a [&'a str], + + /// if present, only return the account default or non-default configurations. + #[serde(skip_serializing_if = "Option::is_none")] + pub is_account_default: Option, + + /// A limit on the number of objects to be returned. + /// + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option, + + /// A cursor for use in pagination. + /// + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option, +} + +impl<'a> ListTerminalConfigurations<'a> { + pub fn new() -> Self { + ListTerminalConfigurations { + ending_before: Default::default(), + expand: Default::default(), + is_account_default: Default::default(), + limit: Default::default(), + starting_after: Default::default(), + } + } +} +impl Paginable for ListTerminalConfigurations<'_> { + type O = TerminalConfiguration; + fn set_last(&mut self, item: Self::O) { + self.starting_after = Some(item.id()); + } +} +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +pub struct CreateTerminalConfigurationBbposWiseposE { + /// A File ID representing an image you would like displayed on the reader. + #[serde(skip_serializing_if = "Option::is_none")] + pub splashscreen: Option, +} + +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +pub struct CreateTerminalConfigurationOffline { + /// Determines whether to allow transactions to be collected while reader is offline. + /// + /// Defaults to false. + pub enabled: bool, +} + +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +pub struct CreateTerminalConfigurationTipping { + /// Tipping configuration for AUD. + #[serde(skip_serializing_if = "Option::is_none")] + pub aud: Option, + + /// Tipping configuration for CAD. + #[serde(skip_serializing_if = "Option::is_none")] + pub cad: Option, + + /// Tipping configuration for CHF. + #[serde(skip_serializing_if = "Option::is_none")] + pub chf: Option, + + /// Tipping configuration for CZK. + #[serde(skip_serializing_if = "Option::is_none")] + pub czk: Option, + + /// Tipping configuration for DKK. + #[serde(skip_serializing_if = "Option::is_none")] + pub dkk: Option, + + /// Tipping configuration for EUR. + #[serde(skip_serializing_if = "Option::is_none")] + pub eur: Option, + + /// Tipping configuration for GBP. + #[serde(skip_serializing_if = "Option::is_none")] + pub gbp: Option, + + /// Tipping configuration for HKD. + #[serde(skip_serializing_if = "Option::is_none")] + pub hkd: Option, + + /// Tipping configuration for MYR. + #[serde(skip_serializing_if = "Option::is_none")] + pub myr: Option, + + /// Tipping configuration for NOK. + #[serde(skip_serializing_if = "Option::is_none")] + pub nok: Option, + + /// Tipping configuration for NZD. + #[serde(skip_serializing_if = "Option::is_none")] + pub nzd: Option, + + /// Tipping configuration for SEK. + #[serde(skip_serializing_if = "Option::is_none")] + pub sek: Option, + + /// Tipping configuration for SGD. + #[serde(skip_serializing_if = "Option::is_none")] + pub sgd: Option, + + /// Tipping configuration for USD. + #[serde(skip_serializing_if = "Option::is_none")] + pub usd: Option, +} + +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +pub struct CreateTerminalConfigurationVerifoneP400 { + /// A File ID representing an image you would like displayed on the reader. + #[serde(skip_serializing_if = "Option::is_none")] + pub splashscreen: Option, +} + +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +pub struct CreateTerminalConfigurationTippingAud { + /// Fixed amounts displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub fixed_amounts: Option>, + + /// Percentages displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub percentages: Option>, + + /// Below this amount, fixed amounts will be displayed; above it, percentages will be displayed. + #[serde(skip_serializing_if = "Option::is_none")] + pub smart_tip_threshold: Option, +} + +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +pub struct CreateTerminalConfigurationTippingCad { + /// Fixed amounts displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub fixed_amounts: Option>, + + /// Percentages displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub percentages: Option>, + + /// Below this amount, fixed amounts will be displayed; above it, percentages will be displayed. + #[serde(skip_serializing_if = "Option::is_none")] + pub smart_tip_threshold: Option, +} + +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +pub struct CreateTerminalConfigurationTippingChf { + /// Fixed amounts displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub fixed_amounts: Option>, + + /// Percentages displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub percentages: Option>, + + /// Below this amount, fixed amounts will be displayed; above it, percentages will be displayed. + #[serde(skip_serializing_if = "Option::is_none")] + pub smart_tip_threshold: Option, +} + +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +pub struct CreateTerminalConfigurationTippingCzk { + /// Fixed amounts displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub fixed_amounts: Option>, + + /// Percentages displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub percentages: Option>, + + /// Below this amount, fixed amounts will be displayed; above it, percentages will be displayed. + #[serde(skip_serializing_if = "Option::is_none")] + pub smart_tip_threshold: Option, +} + +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +pub struct CreateTerminalConfigurationTippingDkk { + /// Fixed amounts displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub fixed_amounts: Option>, + + /// Percentages displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub percentages: Option>, + + /// Below this amount, fixed amounts will be displayed; above it, percentages will be displayed. + #[serde(skip_serializing_if = "Option::is_none")] + pub smart_tip_threshold: Option, +} + +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +pub struct CreateTerminalConfigurationTippingEur { + /// Fixed amounts displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub fixed_amounts: Option>, + + /// Percentages displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub percentages: Option>, + + /// Below this amount, fixed amounts will be displayed; above it, percentages will be displayed. + #[serde(skip_serializing_if = "Option::is_none")] + pub smart_tip_threshold: Option, +} + +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +pub struct CreateTerminalConfigurationTippingGbp { + /// Fixed amounts displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub fixed_amounts: Option>, + + /// Percentages displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub percentages: Option>, + + /// Below this amount, fixed amounts will be displayed; above it, percentages will be displayed. + #[serde(skip_serializing_if = "Option::is_none")] + pub smart_tip_threshold: Option, +} + +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +pub struct CreateTerminalConfigurationTippingHkd { + /// Fixed amounts displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub fixed_amounts: Option>, + + /// Percentages displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub percentages: Option>, + + /// Below this amount, fixed amounts will be displayed; above it, percentages will be displayed. + #[serde(skip_serializing_if = "Option::is_none")] + pub smart_tip_threshold: Option, +} + +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +pub struct CreateTerminalConfigurationTippingMyr { + /// Fixed amounts displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub fixed_amounts: Option>, + + /// Percentages displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub percentages: Option>, + + /// Below this amount, fixed amounts will be displayed; above it, percentages will be displayed. + #[serde(skip_serializing_if = "Option::is_none")] + pub smart_tip_threshold: Option, +} + +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +pub struct CreateTerminalConfigurationTippingNok { + /// Fixed amounts displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub fixed_amounts: Option>, + + /// Percentages displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub percentages: Option>, + + /// Below this amount, fixed amounts will be displayed; above it, percentages will be displayed. + #[serde(skip_serializing_if = "Option::is_none")] + pub smart_tip_threshold: Option, +} + +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +pub struct CreateTerminalConfigurationTippingNzd { + /// Fixed amounts displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub fixed_amounts: Option>, + + /// Percentages displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub percentages: Option>, + + /// Below this amount, fixed amounts will be displayed; above it, percentages will be displayed. + #[serde(skip_serializing_if = "Option::is_none")] + pub smart_tip_threshold: Option, +} + +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +pub struct CreateTerminalConfigurationTippingSek { + /// Fixed amounts displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub fixed_amounts: Option>, + + /// Percentages displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub percentages: Option>, + + /// Below this amount, fixed amounts will be displayed; above it, percentages will be displayed. + #[serde(skip_serializing_if = "Option::is_none")] + pub smart_tip_threshold: Option, +} + +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +pub struct CreateTerminalConfigurationTippingSgd { + /// Fixed amounts displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub fixed_amounts: Option>, + + /// Percentages displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub percentages: Option>, + + /// Below this amount, fixed amounts will be displayed; above it, percentages will be displayed. + #[serde(skip_serializing_if = "Option::is_none")] + pub smart_tip_threshold: Option, +} + +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +pub struct CreateTerminalConfigurationTippingUsd { + /// Fixed amounts displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub fixed_amounts: Option>, + + /// Percentages displayed when collecting a tip. + #[serde(skip_serializing_if = "Option::is_none")] + pub percentages: Option>, + + /// Below this amount, fixed amounts will be displayed; above it, percentages will be displayed. + #[serde(skip_serializing_if = "Option::is_none")] + pub smart_tip_threshold: Option, +} diff --git a/src/resources/generated/terminal_connection_token.rs b/src/resources/generated/terminal_connection_token.rs index e38051d1f..3d3eff1f3 100644 --- a/src/resources/generated/terminal_connection_token.rs +++ b/src/resources/generated/terminal_connection_token.rs @@ -4,7 +4,8 @@ use serde::{Deserialize, Serialize}; -use crate::params::Object; +use crate::client::{Client, Response}; +use crate::params::{Expand, Object}; /// The resource representing a Stripe "TerminalConnectionToken". /// @@ -22,6 +23,18 @@ pub struct TerminalConnectionToken { pub secret: String, } +impl TerminalConnectionToken { + /// To connect to a reader the Stripe Terminal SDK needs to retrieve a short-lived connection token from Stripe, proxied through your server. + /// + /// On your backend, add an endpoint that creates and returns a connection token. + pub fn create( + client: &Client, + params: CreateTerminalConnectionToken<'_>, + ) -> Response { + client.post_form("/terminal/connection_tokens", ¶ms) + } +} + impl Object for TerminalConnectionToken { type Id = (); fn id(&self) -> Self::Id {} @@ -29,3 +42,25 @@ impl Object for TerminalConnectionToken { "terminal.connection_token" } } + +/// The parameters for `TerminalConnectionToken::create`. +#[derive(Clone, Debug, Serialize, Default)] +pub struct CreateTerminalConnectionToken<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Expand::is_empty")] + pub expand: &'a [&'a str], + + /// The id of the location that this connection token is scoped to. + /// + /// If specified the connection token will only be usable with readers assigned to that location, otherwise the connection token will be usable with all readers. + /// Note that location scoping only applies to internet-connected readers. + /// For more details, see [the docs on scoping connection tokens](https://stripe.com/docs/terminal/fleet/locations#connection-tokens). + #[serde(skip_serializing_if = "Option::is_none")] + pub location: Option<&'a str>, +} + +impl<'a> CreateTerminalConnectionToken<'a> { + pub fn new() -> Self { + CreateTerminalConnectionToken { expand: Default::default(), location: Default::default() } + } +} diff --git a/src/resources/generated/terminal_location.rs b/src/resources/generated/terminal_location.rs index 0c2fa311f..e8c28dd23 100644 --- a/src/resources/generated/terminal_location.rs +++ b/src/resources/generated/terminal_location.rs @@ -4,8 +4,9 @@ use serde::{Deserialize, Serialize}; +use crate::client::{Client, Response}; use crate::ids::TerminalLocationId; -use crate::params::{Metadata, Object}; +use crate::params::{Expand, List, Metadata, Object, Paginable}; use crate::resources::Address; /// The resource representing a Stripe "TerminalLocationLocation". @@ -42,6 +43,25 @@ pub struct TerminalLocation { pub metadata: Option, } +impl TerminalLocation { + /// Returns a list of `Location` objects. + pub fn list( + client: &Client, + params: &ListTerminalLocations<'_>, + ) -> Response> { + client.get_query("/terminal/locations", ¶ms) + } + + /// Creates a new `Location` object. + /// For further details, including which address fields are required in each country, see the [Manage locations](https://stripe.com/docs/terminal/fleet/locations) guide. + pub fn create( + client: &Client, + params: CreateTerminalLocation<'_>, + ) -> Response { + client.post_form("/terminal/locations", ¶ms) + } +} + impl Object for TerminalLocation { type Id = TerminalLocationId; fn id(&self) -> Self::Id { @@ -51,3 +71,111 @@ impl Object for TerminalLocation { "terminal.location" } } + +/// The parameters for `TerminalLocation::create`. +#[derive(Clone, Debug, Serialize)] +pub struct CreateTerminalLocation<'a> { + /// The full address of the location. + pub address: CreateTerminalLocationAddress, + + /// The ID of a configuration that will be used to customize all readers in this location. + #[serde(skip_serializing_if = "Option::is_none")] + pub configuration_overrides: Option<&'a str>, + + /// A name for the location. + pub display_name: &'a str, + + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Expand::is_empty")] + pub expand: &'a [&'a str], + + /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. + /// + /// This can be useful for storing additional information about the object in a structured format. + /// Individual keys can be unset by posting an empty value to them. + /// All keys can be unset by posting an empty value to `metadata`. + #[serde(skip_serializing_if = "Option::is_none")] + pub metadata: Option, +} + +impl<'a> CreateTerminalLocation<'a> { + pub fn new(address: CreateTerminalLocationAddress, display_name: &'a str) -> Self { + CreateTerminalLocation { + address, + configuration_overrides: Default::default(), + display_name, + expand: Default::default(), + metadata: Default::default(), + } + } +} + +/// The parameters for `TerminalLocation::list`. +#[derive(Clone, Debug, Serialize, Default)] +pub struct ListTerminalLocations<'a> { + /// A cursor for use in pagination. + /// + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option, + + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Expand::is_empty")] + pub expand: &'a [&'a str], + + /// A limit on the number of objects to be returned. + /// + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option, + + /// A cursor for use in pagination. + /// + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option, +} + +impl<'a> ListTerminalLocations<'a> { + pub fn new() -> Self { + ListTerminalLocations { + ending_before: Default::default(), + expand: Default::default(), + limit: Default::default(), + starting_after: Default::default(), + } + } +} +impl Paginable for ListTerminalLocations<'_> { + type O = TerminalLocation; + fn set_last(&mut self, item: Self::O) { + self.starting_after = Some(item.id()); + } +} +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +pub struct CreateTerminalLocationAddress { + /// City, district, suburb, town, or village. + #[serde(skip_serializing_if = "Option::is_none")] + pub city: Option, + + /// Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + pub country: String, + + /// Address line 1 (e.g., street, PO Box, or company name). + #[serde(skip_serializing_if = "Option::is_none")] + pub line1: Option, + + /// Address line 2 (e.g., apartment, suite, unit, or building). + #[serde(skip_serializing_if = "Option::is_none")] + pub line2: Option, + + /// ZIP or postal code. + #[serde(skip_serializing_if = "Option::is_none")] + pub postal_code: Option, + + /// State, county, province, or region. + #[serde(skip_serializing_if = "Option::is_none")] + pub state: Option, +} diff --git a/src/resources/generated/terminal_reader.rs b/src/resources/generated/terminal_reader.rs index 3a7d54c12..4d5e625a0 100644 --- a/src/resources/generated/terminal_reader.rs +++ b/src/resources/generated/terminal_reader.rs @@ -4,8 +4,9 @@ use serde::{Deserialize, Serialize}; +use crate::client::{Client, Response}; use crate::ids::TerminalReaderId; -use crate::params::{Expandable, Metadata, Object}; +use crate::params::{Expand, Expandable, List, Metadata, Object, Paginable}; use crate::resources::{Charge, Currency, PaymentIntent, Refund, SetupIntent, TerminalLocation}; /// The resource representing a Stripe "TerminalReaderReader". @@ -63,6 +64,21 @@ pub struct TerminalReader { pub status: Option, } +impl TerminalReader { + /// Returns a list of `Reader` objects. + pub fn list( + client: &Client, + params: &ListTerminalReaders<'_>, + ) -> Response> { + client.get_query("/terminal/readers", ¶ms) + } + + /// Creates a new `Reader` object. + pub fn create(client: &Client, params: CreateTerminalReader<'_>) -> Response { + client.post_form("/terminal/readers", ¶ms) + } +} + impl Object for TerminalReader { type Id = TerminalReaderId; fn id(&self) -> Self::Id { @@ -236,6 +252,111 @@ pub struct TerminalReaderReaderResourceTippingConfig { pub amount_eligible: Option, } +/// The parameters for `TerminalReader::create`. +#[derive(Clone, Debug, Serialize)] +pub struct CreateTerminalReader<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Expand::is_empty")] + pub expand: &'a [&'a str], + + /// Custom label given to the reader for easier identification. + /// + /// If no label is specified, the registration code will be used. + #[serde(skip_serializing_if = "Option::is_none")] + pub label: Option<&'a str>, + + /// The location to assign the reader to. + #[serde(skip_serializing_if = "Option::is_none")] + pub location: Option<&'a str>, + + /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. + /// + /// This can be useful for storing additional information about the object in a structured format. + /// Individual keys can be unset by posting an empty value to them. + /// All keys can be unset by posting an empty value to `metadata`. + #[serde(skip_serializing_if = "Option::is_none")] + pub metadata: Option, + + /// A code generated by the reader used for registering to an account. + pub registration_code: &'a str, +} + +impl<'a> CreateTerminalReader<'a> { + pub fn new(registration_code: &'a str) -> Self { + CreateTerminalReader { + expand: Default::default(), + label: Default::default(), + location: Default::default(), + metadata: Default::default(), + registration_code, + } + } +} + +/// The parameters for `TerminalReader::list`. +#[derive(Clone, Debug, Serialize, Default)] +pub struct ListTerminalReaders<'a> { + /// Filters readers by device type. + #[serde(skip_serializing_if = "Option::is_none")] + pub device_type: Option, + + /// A cursor for use in pagination. + /// + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option, + + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Expand::is_empty")] + pub expand: &'a [&'a str], + + /// A limit on the number of objects to be returned. + /// + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option, + + /// A location ID to filter the response list to only readers at the specific location. + #[serde(skip_serializing_if = "Option::is_none")] + pub location: Option<&'a str>, + + /// Filters readers by serial number. + #[serde(skip_serializing_if = "Option::is_none")] + pub serial_number: Option<&'a str>, + + /// A cursor for use in pagination. + /// + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option, + + /// A status filter to filter readers to only offline or online readers. + #[serde(skip_serializing_if = "Option::is_none")] + pub status: Option, +} + +impl<'a> ListTerminalReaders<'a> { + pub fn new() -> Self { + ListTerminalReaders { + device_type: Default::default(), + ending_before: Default::default(), + expand: Default::default(), + limit: Default::default(), + location: Default::default(), + serial_number: Default::default(), + starting_after: Default::default(), + status: Default::default(), + } + } +} +impl Paginable for ListTerminalReaders<'_> { + type O = TerminalReader; + fn set_last(&mut self, item: Self::O) { + self.starting_after = Some(item.id()); + } +} /// An enum representing the possible values of an `TerminalReader`'s `device_type` field. #[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)] #[serde(rename_all = "snake_case")] @@ -426,3 +547,37 @@ impl std::default::Default for TerminalReaderReaderResourceSetReaderDisplayActio Self::Cart } } + +/// An enum representing the possible values of an `ListTerminalReaders`'s `status` field. +#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)] +#[serde(rename_all = "snake_case")] +pub enum TerminalReaderStatus { + Offline, + Online, +} + +impl TerminalReaderStatus { + pub fn as_str(self) -> &'static str { + match self { + TerminalReaderStatus::Offline => "offline", + TerminalReaderStatus::Online => "online", + } + } +} + +impl AsRef for TerminalReaderStatus { + fn as_ref(&self) -> &str { + self.as_str() + } +} + +impl std::fmt::Display for TerminalReaderStatus { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + self.as_str().fmt(f) + } +} +impl std::default::Default for TerminalReaderStatus { + fn default() -> Self { + Self::Offline + } +}