1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// this file is @generated
#![allow(clippy::doc_markdown, clippy::default_trait_access)]
#[allow(unused_imports, clippy::wildcard_imports)]
use crate::{error::Result, models::*, Configuration};
/// Query and header parameters of [`CreditUnitsPrices::list`].
#[derive(Clone, Debug, Default)]
#[non_exhaustive]
pub struct CreditUnitsPricesListOptions {
/// Include archived prices. Defaults to false.
pub include_archived: Option<bool>,
}
impl CreditUnitsPricesListOptions {
/// Options with no parameter set.
#[must_use]
pub fn new() -> Self {
Self {
include_archived: None,
}
}
/// Sets the `include_archived` query parameter.
#[must_use]
pub fn include_archived(mut self, include_archived: impl Into<bool>) -> Self {
self.include_archived = Some(include_archived.into());
self
}
/// Sets the `include_archived` query parameter, or unsets it with `None`.
#[must_use]
pub fn maybe_include_archived(mut self, include_archived: Option<bool>) -> Self {
self.include_archived = include_archived;
self
}
}
/// The credit units prices API, from
/// [`CreditUnits::prices`](crate::api::CreditUnits::prices).
#[derive(Clone)]
pub struct CreditUnitsPrices {
cfg: std::sync::Arc<Configuration>,
options: crate::api::RequestOptions,
}
impl std::fmt::Debug for CreditUnitsPrices {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("CreditUnitsPrices")
.field("options", &self.options)
.finish_non_exhaustive()
}
}
impl CreditUnitsPrices {
pub(super) fn new(cfg: std::sync::Arc<Configuration>) -> Self {
Self {
cfg,
options: crate::api::RequestOptions::default(),
}
}
/// Applies `options` (headers, timeout, retries, idempotency key) to the calls made
/// through the returned value.
#[must_use]
pub fn with_options(mut self, options: crate::api::RequestOptions) -> Self {
self.options = options;
self
}
/// List a credit unit's selling prices
///
/// The active price per currency, and archived ones when asked, newest first.
///
/// `GET /api/v1/credit-units/{id}/prices`.
///
/// # Errors
///
/// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (401, 404, 429, 500).
pub fn list(
&self,
id: &str,
options: impl Into<Option<CreditUnitsPricesListOptions>>,
) -> crate::api::Call<crate::models::CreditUnitPriceListResponse> {
let CreditUnitsPricesListOptions { include_archived } = options.into().unwrap_or_default();
crate::request::Request::new(http::Method::GET, "/api/v1/credit-units/{id}/prices")
.with_path_param("id", id)
.with_optional_query_param("include_archived", include_archived)
.with_options(&self.options)
.json(&self.cfg)
}
/// Set a credit unit's selling price
///
/// The price of one credit in a currency, used to sell the unit through top-ups and automatic
/// top-ups (taxed at purchase under the unit's `product_id`). Replaces the active price in that
/// currency, which is archived: a top-up already priced keeps its terms.
///
/// `PUT /api/v1/credit-units/{id}/prices/{currency}`.
///
/// # Errors
///
/// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (400, 401, 404, 409, 429, 500).
pub fn update(
&self,
id: &str,
currency: &str,
credit_unit_price_set_request: crate::models::CreditUnitPriceSetRequest,
) -> crate::api::Call<crate::models::CreditUnitPrice> {
crate::request::Request::new(
http::Method::PUT,
"/api/v1/credit-units/{id}/prices/{currency}",
)
.with_path_param("id", id)
.with_path_param("currency", currency)
.with_body_param(credit_unit_price_set_request)
.with_options(&self.options)
.json(&self.cfg)
}
/// Remove a credit unit's selling price
///
/// Archives the active price in a currency: the unit can no longer be sold in it (top-ups and
/// automatic top-ups included) until a new price is set.
///
/// `DELETE /api/v1/credit-units/{id}/prices/{currency}`.
///
/// # Errors
///
/// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (401, 404, 429, 500).
pub fn archive(
&self,
id: &str,
currency: &str,
) -> crate::api::Call<crate::models::CreditUnitPrice> {
crate::request::Request::new(
http::Method::DELETE,
"/api/v1/credit-units/{id}/prices/{currency}",
)
.with_path_param("id", id)
.with_path_param("currency", currency)
.with_options(&self.options)
.json(&self.cfg)
}
}