mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-15 07:52:35 +01:00
940 lines
47 KiB
Rust
940 lines
47 KiB
Rust
use std::collections::HashMap;
|
|
use std::cell::RefCell;
|
|
use std::default::Default;
|
|
use std::collections::BTreeSet;
|
|
use std::error::Error as StdError;
|
|
use serde_json as json;
|
|
use std::io;
|
|
use std::fs;
|
|
use std::mem;
|
|
|
|
use hyper::client::connect;
|
|
use tokio::io::{AsyncRead, AsyncWrite};
|
|
use tokio::time::sleep;
|
|
use tower_service;
|
|
use serde::{Serialize, Deserialize};
|
|
|
|
use crate::{client, client::GetToken, client::serde_with};
|
|
|
|
// ##############
|
|
// UTILITIES ###
|
|
// ############
|
|
|
|
/// Identifies the an OAuth2 authorization scope.
|
|
/// A scope is needed when requesting an
|
|
/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
|
|
#[derive(PartialEq, Eq, Hash)]
|
|
pub enum Scope {
|
|
/// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
|
|
CloudPlatform,
|
|
|
|
/// Send messages and manage messaging subscriptions for your Firebase applications
|
|
FirebaseMessaging,
|
|
}
|
|
|
|
impl AsRef<str> for Scope {
|
|
fn as_ref(&self) -> &str {
|
|
match *self {
|
|
Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
|
|
Scope::FirebaseMessaging => "https://www.googleapis.com/auth/firebase.messaging",
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Default for Scope {
|
|
fn default() -> Scope {
|
|
Scope::CloudPlatform
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// ########
|
|
// HUB ###
|
|
// ######
|
|
|
|
/// Central instance to access all FirebaseCloudMessaging related resource activities
|
|
///
|
|
/// # Examples
|
|
///
|
|
/// Instantiate a new hub
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate hyper_rustls;
|
|
/// extern crate google_fcm1 as fcm1;
|
|
/// use fcm1::api::SendMessageRequest;
|
|
/// use fcm1::{Result, Error};
|
|
/// # async fn dox() {
|
|
/// use std::default::Default;
|
|
/// use fcm1::{FirebaseCloudMessaging, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
|
|
/// // `client_secret`, among other things.
|
|
/// let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
|
|
/// // unless you replace `None` with the desired Flow.
|
|
/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
|
|
/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
|
|
/// // retrieve them from storage.
|
|
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// secret,
|
|
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// ).build().await.unwrap();
|
|
/// let mut hub = FirebaseCloudMessaging::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req = SendMessageRequest::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.projects().messages_send(req, "parent")
|
|
/// .doit().await;
|
|
///
|
|
/// match result {
|
|
/// Err(e) => match e {
|
|
/// // The Error enum provides details about what exactly happened.
|
|
/// // You can also just use its `Debug`, `Display` or `Error` traits
|
|
/// Error::HttpError(_)
|
|
/// |Error::Io(_)
|
|
/// |Error::MissingAPIKey
|
|
/// |Error::MissingToken(_)
|
|
/// |Error::Cancelled
|
|
/// |Error::UploadSizeLimitExceeded(_, _)
|
|
/// |Error::Failure(_)
|
|
/// |Error::BadRequest(_)
|
|
/// |Error::FieldClash(_)
|
|
/// |Error::JsonDecodeError(_, _) => println!("{}", e),
|
|
/// },
|
|
/// Ok(res) => println!("Success: {:?}", res),
|
|
/// }
|
|
/// # }
|
|
/// ```
|
|
#[derive(Clone)]
|
|
pub struct FirebaseCloudMessaging<S> {
|
|
pub client: hyper::Client<S, hyper::body::Body>,
|
|
pub auth: Box<dyn client::GetToken>,
|
|
_user_agent: String,
|
|
_base_url: String,
|
|
_root_url: String,
|
|
}
|
|
|
|
impl<'a, S> client::Hub for FirebaseCloudMessaging<S> {}
|
|
|
|
impl<'a, S> FirebaseCloudMessaging<S> {
|
|
|
|
pub fn new<A: 'static + client::GetToken>(client: hyper::Client<S, hyper::body::Body>, auth: A) -> FirebaseCloudMessaging<S> {
|
|
FirebaseCloudMessaging {
|
|
client,
|
|
auth: Box::new(auth),
|
|
_user_agent: "google-api-rust-client/5.0.2-beta-1".to_string(),
|
|
_base_url: "https://fcm.googleapis.com/".to_string(),
|
|
_root_url: "https://fcm.googleapis.com/".to_string(),
|
|
}
|
|
}
|
|
|
|
pub fn projects(&'a self) -> ProjectMethods<'a, S> {
|
|
ProjectMethods { hub: &self }
|
|
}
|
|
|
|
/// Set the user-agent header field to use in all requests to the server.
|
|
/// It defaults to `google-api-rust-client/5.0.2-beta-1`.
|
|
///
|
|
/// Returns the previously set user-agent.
|
|
pub fn user_agent(&mut self, agent_name: String) -> String {
|
|
mem::replace(&mut self._user_agent, agent_name)
|
|
}
|
|
|
|
/// Set the base url to use in all requests to the server.
|
|
/// It defaults to `https://fcm.googleapis.com/`.
|
|
///
|
|
/// Returns the previously set base url.
|
|
pub fn base_url(&mut self, new_base_url: String) -> String {
|
|
mem::replace(&mut self._base_url, new_base_url)
|
|
}
|
|
|
|
/// Set the root url to use in all requests to the server.
|
|
/// It defaults to `https://fcm.googleapis.com/`.
|
|
///
|
|
/// Returns the previously set root url.
|
|
pub fn root_url(&mut self, new_root_url: String) -> String {
|
|
mem::replace(&mut self._root_url, new_root_url)
|
|
}
|
|
}
|
|
|
|
|
|
// ############
|
|
// SCHEMAS ###
|
|
// ##########
|
|
/// Android specific options for messages sent through [FCM connection server](https://goo.gl/4GLdUl).
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct AndroidConfig {
|
|
/// An identifier of a group of messages that can be collapsed, so that only the last message gets sent when delivery can be resumed. A maximum of 4 different collapse keys is allowed at any given time.
|
|
#[serde(rename="collapseKey")]
|
|
|
|
pub collapse_key: Option<String>,
|
|
/// Arbitrary key/value payload. If present, it will override google.firebase.fcm.v1.Message.data.
|
|
|
|
pub data: Option<HashMap<String, String>>,
|
|
/// If set to true, messages will be allowed to be delivered to the app while the device is in direct boot mode. See [Support Direct Boot mode](https://developer.android.com/training/articles/direct-boot).
|
|
#[serde(rename="directBootOk")]
|
|
|
|
pub direct_boot_ok: Option<bool>,
|
|
/// Options for features provided by the FCM SDK for Android.
|
|
#[serde(rename="fcmOptions")]
|
|
|
|
pub fcm_options: Option<AndroidFcmOptions>,
|
|
/// Notification to send to android devices.
|
|
|
|
pub notification: Option<AndroidNotification>,
|
|
/// Message priority. Can take "normal" and "high" values. For more information, see [Setting the priority of a message](https://goo.gl/GjONJv).
|
|
|
|
pub priority: Option<String>,
|
|
/// Package name of the application where the registration token must match in order to receive the message.
|
|
#[serde(rename="restrictedPackageName")]
|
|
|
|
pub restricted_package_name: Option<String>,
|
|
/// How long (in seconds) the message should be kept in FCM storage if the device is offline. The maximum time to live supported is 4 weeks, and the default value is 4 weeks if not set. Set it to 0 if want to send the message immediately. In JSON format, the Duration type is encoded as a string rather than an object, where the string ends in the suffix "s" (indicating seconds) and is preceded by the number of seconds, with nanoseconds expressed as fractional seconds. For example, 3 seconds with 0 nanoseconds should be encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should be expressed in JSON format as "3.000000001s". The ttl will be rounded down to the nearest second.
|
|
|
|
#[serde_as(as = "Option<::client::serde::duration::Wrapper>")]
|
|
pub ttl: Option<client::chrono::Duration>,
|
|
}
|
|
|
|
impl client::Part for AndroidConfig {}
|
|
|
|
|
|
/// Options for features provided by the FCM SDK for Android.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct AndroidFcmOptions {
|
|
/// Label associated with the message's analytics data.
|
|
#[serde(rename="analyticsLabel")]
|
|
|
|
pub analytics_label: Option<String>,
|
|
}
|
|
|
|
impl client::Part for AndroidFcmOptions {}
|
|
|
|
|
|
/// Notification to send to android devices.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct AndroidNotification {
|
|
/// The notification's body text. If present, it will override google.firebase.fcm.v1.Notification.body.
|
|
|
|
pub body: Option<String>,
|
|
/// Variable string values to be used in place of the format specifiers in body_loc_key to use to localize the body text to the user's current localization. See [Formatting and Styling](https://goo.gl/MalYE3) for more information.
|
|
#[serde(rename="bodyLocArgs")]
|
|
|
|
pub body_loc_args: Option<Vec<String>>,
|
|
/// The key to the body string in the app's string resources to use to localize the body text to the user's current localization. See [String Resources](https://goo.gl/NdFZGI) for more information.
|
|
#[serde(rename="bodyLocKey")]
|
|
|
|
pub body_loc_key: Option<String>,
|
|
/// If set, display notifications delivered to the device will be handled by the app instead of the proxy.
|
|
#[serde(rename="bypassProxyNotification")]
|
|
|
|
pub bypass_proxy_notification: Option<bool>,
|
|
/// The [notification's channel id](https://developer.android.com/guide/topics/ui/notifiers/notifications#ManageChannels) (new in Android O). The app must create a channel with this channel ID before any notification with this channel ID is received. If you don't send this channel ID in the request, or if the channel ID provided has not yet been created by the app, FCM uses the channel ID specified in the app manifest.
|
|
#[serde(rename="channelId")]
|
|
|
|
pub channel_id: Option<String>,
|
|
/// The action associated with a user click on the notification. If specified, an activity with a matching intent filter is launched when a user clicks on the notification.
|
|
#[serde(rename="clickAction")]
|
|
|
|
pub click_action: Option<String>,
|
|
/// The notification's icon color, expressed in #rrggbb format.
|
|
|
|
pub color: Option<String>,
|
|
/// If set to true, use the Android framework's default LED light settings for the notification. Default values are specified in [config.xml](https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/config.xml). If `default_light_settings` is set to true and `light_settings` is also set, the user-specified `light_settings` is used instead of the default value.
|
|
#[serde(rename="defaultLightSettings")]
|
|
|
|
pub default_light_settings: Option<bool>,
|
|
/// If set to true, use the Android framework's default sound for the notification. Default values are specified in [config.xml](https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/config.xml).
|
|
#[serde(rename="defaultSound")]
|
|
|
|
pub default_sound: Option<bool>,
|
|
/// If set to true, use the Android framework's default vibrate pattern for the notification. Default values are specified in [config.xml](https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/config.xml). If `default_vibrate_timings` is set to true and `vibrate_timings` is also set, the default value is used instead of the user-specified `vibrate_timings`.
|
|
#[serde(rename="defaultVibrateTimings")]
|
|
|
|
pub default_vibrate_timings: Option<bool>,
|
|
/// Set the time that the event in the notification occurred. Notifications in the panel are sorted by this time. A point in time is represented using [protobuf.Timestamp](https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/Timestamp).
|
|
#[serde(rename="eventTime")]
|
|
|
|
pub event_time: Option<client::chrono::DateTime<client::chrono::offset::Utc>>,
|
|
/// The notification's icon. Sets the notification icon to myicon for drawable resource myicon. If you don't send this key in the request, FCM displays the launcher icon specified in your app manifest.
|
|
|
|
pub icon: Option<String>,
|
|
/// Contains the URL of an image that is going to be displayed in a notification. If present, it will override google.firebase.fcm.v1.Notification.image.
|
|
|
|
pub image: Option<String>,
|
|
/// Settings to control the notification's LED blinking rate and color if LED is available on the device. The total blinking time is controlled by the OS.
|
|
#[serde(rename="lightSettings")]
|
|
|
|
pub light_settings: Option<LightSettings>,
|
|
/// Set whether or not this notification is relevant only to the current device. Some notifications can be bridged to other devices for remote display, such as a Wear OS watch. This hint can be set to recommend this notification not be bridged. See [Wear OS guides](https://developer.android.com/training/wearables/notifications/bridger#existing-method-of-preventing-bridging)
|
|
#[serde(rename="localOnly")]
|
|
|
|
pub local_only: Option<bool>,
|
|
/// Sets the number of items this notification represents. May be displayed as a badge count for launchers that support badging.See [Notification Badge](https://developer.android.com/training/notify-user/badges). For example, this might be useful if you're using just one notification to represent multiple new messages but you want the count here to represent the number of total new messages. If zero or unspecified, systems that support badging use the default, which is to increment a number displayed on the long-press menu each time a new notification arrives.
|
|
#[serde(rename="notificationCount")]
|
|
|
|
pub notification_count: Option<i32>,
|
|
/// Set the relative priority for this notification. Priority is an indication of how much of the user's attention should be consumed by this notification. Low-priority notifications may be hidden from the user in certain situations, while the user might be interrupted for a higher-priority notification. The effect of setting the same priorities may differ slightly on different platforms. Note this priority differs from `AndroidMessagePriority`. This priority is processed by the client after the message has been delivered, whereas [AndroidMessagePriority](https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidmessagepriority) is an FCM concept that controls when the message is delivered.
|
|
#[serde(rename="notificationPriority")]
|
|
|
|
pub notification_priority: Option<String>,
|
|
/// The sound to play when the device receives the notification. Supports "default" or the filename of a sound resource bundled in the app. Sound files must reside in /res/raw/.
|
|
|
|
pub sound: Option<String>,
|
|
/// When set to false or unset, the notification is automatically dismissed when the user clicks it in the panel. When set to true, the notification persists even when the user clicks it.
|
|
|
|
pub sticky: Option<bool>,
|
|
/// Identifier used to replace existing notifications in the notification drawer. If not specified, each request creates a new notification. If specified and a notification with the same tag is already being shown, the new notification replaces the existing one in the notification drawer.
|
|
|
|
pub tag: Option<String>,
|
|
/// Sets the "ticker" text, which is sent to accessibility services. Prior to API level 21 (`Lollipop`), sets the text that is displayed in the status bar when the notification first arrives.
|
|
|
|
pub ticker: Option<String>,
|
|
/// The notification's title. If present, it will override google.firebase.fcm.v1.Notification.title.
|
|
|
|
pub title: Option<String>,
|
|
/// Variable string values to be used in place of the format specifiers in title_loc_key to use to localize the title text to the user's current localization. See [Formatting and Styling](https://goo.gl/MalYE3) for more information.
|
|
#[serde(rename="titleLocArgs")]
|
|
|
|
pub title_loc_args: Option<Vec<String>>,
|
|
/// The key to the title string in the app's string resources to use to localize the title text to the user's current localization. See [String Resources](https://goo.gl/NdFZGI) for more information.
|
|
#[serde(rename="titleLocKey")]
|
|
|
|
pub title_loc_key: Option<String>,
|
|
/// Set the vibration pattern to use. Pass in an array of [protobuf.Duration](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Duration) to turn on or off the vibrator. The first value indicates the `Duration` to wait before turning the vibrator on. The next value indicates the `Duration` to keep the vibrator on. Subsequent values alternate between `Duration` to turn the vibrator off and to turn the vibrator on. If `vibrate_timings` is set and `default_vibrate_timings` is set to `true`, the default value is used instead of the user-specified `vibrate_timings`.
|
|
#[serde(rename="vibrateTimings")]
|
|
|
|
#[serde_as(as = "Option<Vec<::client::serde::duration::Wrapper>>")]
|
|
pub vibrate_timings: Option<Vec<client::chrono::Duration>>,
|
|
/// Set the [Notification.visibility](https://developer.android.com/reference/android/app/Notification.html#visibility) of the notification.
|
|
|
|
pub visibility: Option<String>,
|
|
}
|
|
|
|
impl client::Part for AndroidNotification {}
|
|
|
|
|
|
/// [Apple Push Notification Service](https://goo.gl/MXRTPa) specific options.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ApnsConfig {
|
|
/// Options for features provided by the FCM SDK for iOS.
|
|
#[serde(rename="fcmOptions")]
|
|
|
|
pub fcm_options: Option<ApnsFcmOptions>,
|
|
/// HTTP request headers defined in Apple Push Notification Service. Refer to [APNs request headers](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns) for supported headers such as `apns-expiration` and `apns-priority`. The backend sets a default value for `apns-expiration` of 30 days and a default value for `apns-priority` of 10 if not explicitly set.
|
|
|
|
pub headers: Option<HashMap<String, String>>,
|
|
/// APNs payload as a JSON object, including both `aps` dictionary and custom payload. See [Payload Key Reference](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification). If present, it overrides google.firebase.fcm.v1.Notification.title and google.firebase.fcm.v1.Notification.body.
|
|
|
|
pub payload: Option<HashMap<String, json::Value>>,
|
|
}
|
|
|
|
impl client::Part for ApnsConfig {}
|
|
|
|
|
|
/// Options for features provided by the FCM SDK for iOS.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ApnsFcmOptions {
|
|
/// Label associated with the message's analytics data.
|
|
#[serde(rename="analyticsLabel")]
|
|
|
|
pub analytics_label: Option<String>,
|
|
/// Contains the URL of an image that is going to be displayed in a notification. If present, it will override google.firebase.fcm.v1.Notification.image.
|
|
|
|
pub image: Option<String>,
|
|
}
|
|
|
|
impl client::Part for ApnsFcmOptions {}
|
|
|
|
|
|
/// Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ...
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Color {
|
|
/// The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0).
|
|
|
|
pub alpha: Option<f32>,
|
|
/// The amount of blue in the color as a value in the interval [0, 1].
|
|
|
|
pub blue: Option<f32>,
|
|
/// The amount of green in the color as a value in the interval [0, 1].
|
|
|
|
pub green: Option<f32>,
|
|
/// The amount of red in the color as a value in the interval [0, 1].
|
|
|
|
pub red: Option<f32>,
|
|
}
|
|
|
|
impl client::Part for Color {}
|
|
|
|
|
|
/// Platform independent options for features provided by the FCM SDKs.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct FcmOptions {
|
|
/// Label associated with the message's analytics data.
|
|
#[serde(rename="analyticsLabel")]
|
|
|
|
pub analytics_label: Option<String>,
|
|
}
|
|
|
|
impl client::Part for FcmOptions {}
|
|
|
|
|
|
/// Settings to control notification LED.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct LightSettings {
|
|
/// Required. Set `color` of the LED with [google.type.Color](https://github.com/googleapis/googleapis/blob/master/google/type/color.proto).
|
|
|
|
pub color: Option<Color>,
|
|
/// Required. Along with `light_on_duration `, define the blink rate of LED flashes. Resolution defined by [proto.Duration](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Duration)
|
|
#[serde(rename="lightOffDuration")]
|
|
|
|
#[serde_as(as = "Option<::client::serde::duration::Wrapper>")]
|
|
pub light_off_duration: Option<client::chrono::Duration>,
|
|
/// Required. Along with `light_off_duration`, define the blink rate of LED flashes. Resolution defined by [proto.Duration](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Duration)
|
|
#[serde(rename="lightOnDuration")]
|
|
|
|
#[serde_as(as = "Option<::client::serde::duration::Wrapper>")]
|
|
pub light_on_duration: Option<client::chrono::Duration>,
|
|
}
|
|
|
|
impl client::Part for LightSettings {}
|
|
|
|
|
|
/// Message to send by Firebase Cloud Messaging Service.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [messages send projects](ProjectMessageSendCall) (response)
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Message {
|
|
/// Input only. Android specific options for messages sent through [FCM connection server](https://goo.gl/4GLdUl).
|
|
|
|
pub android: Option<AndroidConfig>,
|
|
/// Input only. [Apple Push Notification Service](https://goo.gl/MXRTPa) specific options.
|
|
|
|
pub apns: Option<ApnsConfig>,
|
|
/// Condition to send a message to, e.g. "'foo' in topics && 'bar' in topics".
|
|
|
|
pub condition: Option<String>,
|
|
/// Input only. Arbitrary key/value payload, which must be UTF-8 encoded. The key should not be a reserved word ("from", "message_type", or any word starting with "google" or "gcm"). When sending payloads containing only data fields to iOS devices, only normal priority (`"apns-priority": "5"`) is allowed in [`ApnsConfig`](/docs/reference/fcm/rest/v1/projects.messages#apnsconfig).
|
|
|
|
pub data: Option<HashMap<String, String>>,
|
|
/// Input only. Template for FCM SDK feature options to use across all platforms.
|
|
#[serde(rename="fcmOptions")]
|
|
|
|
pub fcm_options: Option<FcmOptions>,
|
|
/// Output Only. The identifier of the message sent, in the format of `projects/*/messages/{message_id}`.
|
|
|
|
pub name: Option<String>,
|
|
/// Input only. Basic notification template to use across all platforms.
|
|
|
|
pub notification: Option<Notification>,
|
|
/// Registration token to send a message to.
|
|
|
|
pub token: Option<String>,
|
|
/// Topic name to send a message to, e.g. "weather". Note: "/topics/" prefix should not be provided.
|
|
|
|
pub topic: Option<String>,
|
|
/// Input only. [Webpush protocol](https://tools.ietf.org/html/rfc8030) options.
|
|
|
|
pub webpush: Option<WebpushConfig>,
|
|
}
|
|
|
|
impl client::ResponseResult for Message {}
|
|
|
|
|
|
/// Basic notification template to use across all platforms.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Notification {
|
|
/// The notification's body text.
|
|
|
|
pub body: Option<String>,
|
|
/// Contains the URL of an image that is going to be downloaded on the device and displayed in a notification. JPEG, PNG, BMP have full support across platforms. Animated GIF and video only work on iOS. WebP and HEIF have varying levels of support across platforms and platform versions. Android has 1MB image size limit. Quota usage and implications/costs for hosting image on Firebase Storage: https://firebase.google.com/pricing
|
|
|
|
pub image: Option<String>,
|
|
/// The notification's title.
|
|
|
|
pub title: Option<String>,
|
|
}
|
|
|
|
impl client::Part for Notification {}
|
|
|
|
|
|
/// Request to send a message to specified target.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [messages send projects](ProjectMessageSendCall) (request)
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct SendMessageRequest {
|
|
/// Required. Message to send.
|
|
|
|
pub message: Option<Message>,
|
|
/// Flag for testing the request without actually delivering the message.
|
|
#[serde(rename="validateOnly")]
|
|
|
|
pub validate_only: Option<bool>,
|
|
}
|
|
|
|
impl client::RequestValue for SendMessageRequest {}
|
|
|
|
|
|
/// [Webpush protocol](https://tools.ietf.org/html/rfc8030) options.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct WebpushConfig {
|
|
/// Arbitrary key/value payload. If present, it will override google.firebase.fcm.v1.Message.data.
|
|
|
|
pub data: Option<HashMap<String, String>>,
|
|
/// Options for features provided by the FCM SDK for Web.
|
|
#[serde(rename="fcmOptions")]
|
|
|
|
pub fcm_options: Option<WebpushFcmOptions>,
|
|
/// HTTP headers defined in webpush protocol. Refer to [Webpush protocol](https://tools.ietf.org/html/rfc8030#section-5) for supported headers, e.g. "TTL": "15".
|
|
|
|
pub headers: Option<HashMap<String, String>>,
|
|
/// Web Notification options as a JSON object. Supports Notification instance properties as defined in [Web Notification API](https://developer.mozilla.org/en-US/docs/Web/API/Notification). If present, "title" and "body" fields override [google.firebase.fcm.v1.Notification.title] and [google.firebase.fcm.v1.Notification.body].
|
|
|
|
pub notification: Option<HashMap<String, json::Value>>,
|
|
}
|
|
|
|
impl client::Part for WebpushConfig {}
|
|
|
|
|
|
/// Options for features provided by the FCM SDK for Web.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct WebpushFcmOptions {
|
|
/// Label associated with the message's analytics data.
|
|
#[serde(rename="analyticsLabel")]
|
|
|
|
pub analytics_label: Option<String>,
|
|
/// The link to open when the user clicks on the notification. For all URL values, HTTPS is required.
|
|
|
|
pub link: Option<String>,
|
|
}
|
|
|
|
impl client::Part for WebpushFcmOptions {}
|
|
|
|
|
|
|
|
// ###################
|
|
// MethodBuilders ###
|
|
// #################
|
|
|
|
/// A builder providing access to all methods supported on *project* resources.
|
|
/// It is not used directly, but through the [`FirebaseCloudMessaging`] hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate hyper_rustls;
|
|
/// extern crate google_fcm1 as fcm1;
|
|
///
|
|
/// # async fn dox() {
|
|
/// use std::default::Default;
|
|
/// use fcm1::{FirebaseCloudMessaging, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// secret,
|
|
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// ).build().await.unwrap();
|
|
/// let mut hub = FirebaseCloudMessaging::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `messages_send(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.projects();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectMethods<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a FirebaseCloudMessaging<S>,
|
|
}
|
|
|
|
impl<'a, S> client::MethodsBuilder for ProjectMethods<'a, S> {}
|
|
|
|
impl<'a, S> ProjectMethods<'a, S> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Send a message to specified target (a registration token, topic or condition).
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `parent` - Required. It contains the Firebase project id (i.e. the unique identifier for your Firebase project), in the format of `projects/{project_id}`. For legacy support, the numeric project number with no padding is also supported in the format of `projects/{project_number}`.
|
|
pub fn messages_send(&self, request: SendMessageRequest, parent: &str) -> ProjectMessageSendCall<'a, S> {
|
|
ProjectMessageSendCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_parent: parent.to_string(),
|
|
_delegate: Default::default(),
|
|
_additional_params: Default::default(),
|
|
_scopes: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ###################
|
|
// CallBuilders ###
|
|
// #################
|
|
|
|
/// Send a message to specified target (a registration token, topic or condition).
|
|
///
|
|
/// A builder for the *messages.send* method supported by a *project* resource.
|
|
/// It is not used directly, but through a [`ProjectMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_fcm1 as fcm1;
|
|
/// use fcm1::api::SendMessageRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use fcm1::{FirebaseCloudMessaging, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = FirebaseCloudMessaging::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req = SendMessageRequest::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.projects().messages_send(req, "parent")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectMessageSendCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a FirebaseCloudMessaging<S>,
|
|
_request: SendMessageRequest,
|
|
_parent: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for ProjectMessageSendCall<'a, S> {}
|
|
|
|
impl<'a, S> ProjectMessageSendCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Message)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "fcm.projects.messages.send",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "parent"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::Error::FieldClash(field));
|
|
}
|
|
}
|
|
|
|
let mut params = Params::with_capacity(4 + self._additional_params.len());
|
|
params.push("parent", self._parent);
|
|
|
|
params.extend(self._additional_params.iter());
|
|
|
|
params.push("alt", "json");
|
|
let mut url = self.hub._base_url.clone() + "v1/{+parent}/messages:send";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
|
|
url = params.uri_replacement(url, param_name, find_this, true);
|
|
}
|
|
{
|
|
let to_remove = ["parent"];
|
|
params.remove_params(&to_remove);
|
|
}
|
|
|
|
let url = params.parse_with_url(&url);
|
|
|
|
let mut json_mime_type = mime::APPLICATION_JSON;
|
|
let mut request_value_reader =
|
|
{
|
|
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let client = &self.hub.client;
|
|
dlg.pre_request();
|
|
let mut req_builder = hyper::Request::builder()
|
|
.method(hyper::Method::POST)
|
|
.uri(url.as_str())
|
|
.header(USER_AGENT, self.hub._user_agent.clone());
|
|
|
|
if let Some(token) = token.as_ref() {
|
|
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
|
}
|
|
|
|
|
|
let request = req_builder
|
|
.header(CONTENT_TYPE, json_mime_type.to_string())
|
|
.header(CONTENT_LENGTH, request_size as u64)
|
|
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// Sets the *request* property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn request(mut self, new_value: SendMessageRequest) -> ProjectMessageSendCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. It contains the Firebase project id (i.e. the unique identifier for your Firebase project), in the format of `projects/{project_id}`. For legacy support, the numeric project number with no padding is also supported in the format of `projects/{project_number}`.
|
|
///
|
|
/// Sets the *parent* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn parent(mut self, new_value: &str) -> ProjectMessageSendCall<'a, S> {
|
|
self._parent = new_value.to_string();
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// ````text
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.````
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectMessageSendCall<'a, S> {
|
|
self._delegate = Some(new_value);
|
|
self
|
|
}
|
|
|
|
/// Set any additional parameter of the query string used in the request.
|
|
/// It should be used to set parameters which are not yet available through their own
|
|
/// setters.
|
|
///
|
|
/// Please note that this method must not be used to set any of the known parameters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *$.xgafv* (query-string) - V1 error format.
|
|
/// * *access_token* (query-string) - OAuth access token.
|
|
/// * *alt* (query-string) - Data format for response.
|
|
/// * *callback* (query-string) - JSONP
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
|
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
|
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
|
pub fn param<T>(mut self, name: T, value: T) -> ProjectMessageSendCall<'a, S>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
|
|
/// [`Scope::CloudPlatform`].
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
///
|
|
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
|
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
|
/// sufficient, a read-write scope will do as well.
|
|
pub fn add_scope<St>(mut self, scope: St) -> ProjectMessageSendCall<'a, S>
|
|
where St: AsRef<str> {
|
|
self._scopes.insert(String::from(scope.as_ref()));
|
|
self
|
|
}
|
|
/// Identifies the authorization scope(s) for the method you are building.
|
|
///
|
|
/// See [`Self::add_scope()`] for details.
|
|
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectMessageSendCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
self._scopes
|
|
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
|
self
|
|
}
|
|
|
|
/// Removes all scopes, and no default scope will be used either.
|
|
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
|
/// for details).
|
|
pub fn clear_scopes(mut self) -> ProjectMessageSendCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|