// This file is @generated by prost-build.
/// Represents a conversion source owned by a Merchant account. A merchant
/// account can have up to 200 conversion sources.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ConversionSource {
    /// Output only. Identifier. Generated by the Content API upon creation of a
    /// new `ConversionSource`. Format: `\[a-z\]{4}:.+` The four characters before
    /// the colon represent the type of conversion source. Content after the colon
    /// represents the ID of the conversion source within that type. The ID of two
    /// different conversion sources might be the same across different types. The
    /// following type prefixes are supported:
    ///
    /// * `galk`: For GoogleAnalyticsLink sources.
    /// * `mcdn`: For MerchantCenterDestination sources.
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
    /// Output only. Current state of this conversion source. Can't be edited
    /// through the API.
    #[prost(enumeration = "conversion_source::State", tag = "5")]
    pub state: i32,
    /// Output only. The time when an archived conversion source becomes
    /// permanently deleted and is no longer available to undelete.
    #[prost(message, optional, tag = "6")]
    pub expire_time: ::core::option::Option<::prost_types::Timestamp>,
    /// Output only. Controller of the conversion source.
    #[prost(enumeration = "conversion_source::Controller", tag = "7")]
    pub controller: i32,
    /// Required.
    /// Conversion source data specific to each different type of source.
    #[prost(oneof = "conversion_source::SourceData", tags = "3, 4")]
    pub source_data: ::core::option::Option<conversion_source::SourceData>,
}
/// Nested message and enum types in `ConversionSource`.
pub mod conversion_source {
    /// Represents the state of a conversion source.
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum State {
        /// Conversion source has unspecified state.
        Unspecified = 0,
        /// Conversion source is fully functional.
        Active = 1,
        /// Conversion source has been archived in the last 30 days and is currently
        /// not functional. Can be restored using the undelete method.
        Archived = 2,
        /// Conversion source creation has started but not fully finished yet.
        Pending = 3,
    }
    impl State {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                Self::Unspecified => "STATE_UNSPECIFIED",
                Self::Active => "ACTIVE",
                Self::Archived => "ARCHIVED",
                Self::Pending => "PENDING",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "STATE_UNSPECIFIED" => Some(Self::Unspecified),
                "ACTIVE" => Some(Self::Active),
                "ARCHIVED" => Some(Self::Archived),
                "PENDING" => Some(Self::Pending),
                _ => None,
            }
        }
    }
    /// Entity controlling the conversion source.
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum Controller {
        /// Default value. This value is unused.
        Unspecified = 0,
        /// Controlled by the Merchant who owns the Conversion Source.
        Merchant = 1,
        /// Controlled by the Youtube Affiliates program.
        YoutubeAffiliates = 2,
    }
    impl Controller {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                Self::Unspecified => "CONTROLLER_UNSPECIFIED",
                Self::Merchant => "MERCHANT",
                Self::YoutubeAffiliates => "YOUTUBE_AFFILIATES",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "CONTROLLER_UNSPECIFIED" => Some(Self::Unspecified),
                "MERCHANT" => Some(Self::Merchant),
                "YOUTUBE_AFFILIATES" => Some(Self::YoutubeAffiliates),
                _ => None,
            }
        }
    }
    /// Required.
    /// Conversion source data specific to each different type of source.
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum SourceData {
        /// Immutable. Conversion Source of type "Link to Google Analytics Property".
        #[prost(message, tag = "3")]
        GoogleAnalyticsLink(super::GoogleAnalyticsLink),
        /// Conversion Source of type "Merchant Center Tag Destination".
        #[prost(message, tag = "4")]
        MerchantCenterDestination(super::MerchantCenterDestination),
    }
}
/// Represents attribution settings for conversion sources receiving
/// pre-attribution data.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AttributionSettings {
    /// Required. Lookback window (in days) used for attribution in this source.
    /// Supported values are `7`, `30` & `40`.
    #[prost(int32, tag = "1")]
    pub attribution_lookback_window_days: i32,
    /// Required. Attribution model.
    #[prost(enumeration = "attribution_settings::AttributionModel", tag = "2")]
    pub attribution_model: i32,
    /// Immutable. Unordered list. List of different conversion types a conversion
    /// event can be classified as. A standard "purchase" type will be
    /// automatically created if this list is empty at creation time.
    #[prost(message, repeated, tag = "3")]
    pub conversion_type: ::prost::alloc::vec::Vec<attribution_settings::ConversionType>,
}
/// Nested message and enum types in `AttributionSettings`.
pub mod attribution_settings {
    /// Message representing the type of a conversion event.
    #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
    pub struct ConversionType {
        /// Output only. Conversion event name, as it'll be reported by the client.
        #[prost(string, tag = "1")]
        pub name: ::prost::alloc::string::String,
        /// Output only. Option indicating if the type should be included in Merchant
        /// Center reporting.
        #[prost(bool, tag = "2")]
        pub report: bool,
    }
    /// The attribution model used for this source. We support the same set of
    /// [models offered by Google Analytics
    /// 4](<https://support.google.com/analytics/answer/10596866>).
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum AttributionModel {
        /// Unspecified model.
        Unspecified = 0,
        /// Cross-channel Last Click model.
        CrossChannelLastClick = 1,
        /// Ads-preferred Last Click model.
        AdsPreferredLastClick = 2,
        /// Cross-channel Data Driven model.
        CrossChannelDataDriven = 5,
        /// Cross-channel First Click model.
        CrossChannelFirstClick = 6,
        /// Cross-channel Linear model.
        CrossChannelLinear = 7,
        /// Cross-channel Position Based model.
        CrossChannelPositionBased = 8,
        /// Cross-channel Time Decay model.
        CrossChannelTimeDecay = 9,
    }
    impl AttributionModel {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                Self::Unspecified => "ATTRIBUTION_MODEL_UNSPECIFIED",
                Self::CrossChannelLastClick => "CROSS_CHANNEL_LAST_CLICK",
                Self::AdsPreferredLastClick => "ADS_PREFERRED_LAST_CLICK",
                Self::CrossChannelDataDriven => "CROSS_CHANNEL_DATA_DRIVEN",
                Self::CrossChannelFirstClick => "CROSS_CHANNEL_FIRST_CLICK",
                Self::CrossChannelLinear => "CROSS_CHANNEL_LINEAR",
                Self::CrossChannelPositionBased => "CROSS_CHANNEL_POSITION_BASED",
                Self::CrossChannelTimeDecay => "CROSS_CHANNEL_TIME_DECAY",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "ATTRIBUTION_MODEL_UNSPECIFIED" => Some(Self::Unspecified),
                "CROSS_CHANNEL_LAST_CLICK" => Some(Self::CrossChannelLastClick),
                "ADS_PREFERRED_LAST_CLICK" => Some(Self::AdsPreferredLastClick),
                "CROSS_CHANNEL_DATA_DRIVEN" => Some(Self::CrossChannelDataDriven),
                "CROSS_CHANNEL_FIRST_CLICK" => Some(Self::CrossChannelFirstClick),
                "CROSS_CHANNEL_LINEAR" => Some(Self::CrossChannelLinear),
                "CROSS_CHANNEL_POSITION_BASED" => Some(Self::CrossChannelPositionBased),
                "CROSS_CHANNEL_TIME_DECAY" => Some(Self::CrossChannelTimeDecay),
                _ => None,
            }
        }
    }
}
/// "Google Analytics Link" sources can be used to get conversion data from an
/// existing Google Analytics property into the linked Merchant Center account.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GoogleAnalyticsLink {
    /// Required. Immutable. ID of the Google Analytics property the merchant is
    /// linked to.
    #[prost(int64, tag = "1")]
    pub property_id: i64,
    /// Output only. Attribution settings for the linked Google Analytics property.
    #[prost(message, optional, tag = "2")]
    pub attribution_settings: ::core::option::Option<AttributionSettings>,
    /// Output only. Name of the Google Analytics property the merchant is linked
    /// to.
    #[prost(string, tag = "3")]
    pub property: ::prost::alloc::string::String,
}
/// "Merchant Center Destination" sources can be used to send conversion events
/// from an online store using a Google tag directly to a Merchant Center account
/// where the source is created.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MerchantCenterDestination {
    /// Output only. Merchant Center Destination ID.
    #[prost(string, tag = "1")]
    pub destination: ::prost::alloc::string::String,
    /// Required. Attribution settings used for the Merchant Center Destination.
    #[prost(message, optional, tag = "2")]
    pub attribution_settings: ::core::option::Option<AttributionSettings>,
    /// Required. Merchant-specified display name for the destination. This is the
    /// name that identifies the conversion source within the Merchant Center UI.
    /// The maximum length is 64 characters.
    #[prost(string, tag = "3")]
    pub display_name: ::prost::alloc::string::String,
    /// Required. Three-letter currency code (ISO 4217). The currency code defines
    /// in which currency the conversions sent to this destination will be reported
    /// in Merchant Center.
    #[prost(string, tag = "4")]
    pub currency_code: ::prost::alloc::string::String,
}
/// Request message for the CreateConversionSource method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateConversionSourceRequest {
    /// Required. The merchant account that will own the new conversion source.
    /// Format: `accounts/{account}`
    #[prost(string, tag = "1")]
    pub parent: ::prost::alloc::string::String,
    /// Required. The conversion source description. A new ID will be automatically
    /// assigned to it upon creation.
    #[prost(message, optional, tag = "2")]
    pub conversion_source: ::core::option::Option<ConversionSource>,
}
/// Request message for the UpdateConversionSource method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateConversionSourceRequest {
    /// Required. The new version of the conversion source data.
    #[prost(message, optional, tag = "1")]
    pub conversion_source: ::core::option::Option<ConversionSource>,
    /// Optional. List of fields being updated.
    #[prost(message, optional, tag = "2")]
    pub update_mask: ::core::option::Option<::prost_types::FieldMask>,
}
/// Request message for the DeleteConversionSource method.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct DeleteConversionSourceRequest {
    /// Required. The name of the conversion source to be deleted.
    /// Format: `accounts/{account}/conversionSources/{conversion_source}`
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
}
/// Request message for the UndeleteConversionSource method.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct UndeleteConversionSourceRequest {
    /// Required. The name of the conversion source to be undeleted.
    /// Format: `accounts/{account}/conversionSources/{conversion_source}`
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
}
/// Request message for the GetConversionSource method.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetConversionSourceRequest {
    /// Required. The name of the conversion source to be fetched.
    /// Format: `accounts/{account}/conversionSources/{conversion_source}`
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
}
/// Request message for the ListConversionSources method.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ListConversionSourcesRequest {
    /// Required. The merchant account who owns the collection of conversion
    /// sources. Format: `accounts/{account}`
    #[prost(string, tag = "1")]
    pub parent: ::prost::alloc::string::String,
    /// Optional. The maximum number of conversion sources to return in a page.
    /// If no `page_size` is specified, `100` is used as the default value. The
    /// maximum value is `200`. Values above `200` will be coerced to `200`.
    /// Regardless of pagination, at most `200` conversion sources are returned
    /// in total.
    #[prost(int32, tag = "2")]
    pub page_size: i32,
    /// Optional. Page token.
    #[prost(string, tag = "3")]
    pub page_token: ::prost::alloc::string::String,
    /// Optional. Show deleted (archived) conversion sources. By default, deleted
    /// conversion sources are not returned.
    #[prost(bool, tag = "4")]
    pub show_deleted: bool,
}
/// Response message for the ListConversionSources method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListConversionSourcesResponse {
    /// List of conversion sources.
    #[prost(message, repeated, tag = "1")]
    pub conversion_sources: ::prost::alloc::vec::Vec<ConversionSource>,
    /// Token to be used to fetch the next results page.
    #[prost(string, tag = "2")]
    pub next_page_token: ::prost::alloc::string::String,
}
/// Generated client implementations.
pub mod conversion_sources_service_client {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    use tonic::codegen::http::Uri;
    /// Service for managing conversion sources for a merchant account.
    #[derive(Debug, Clone)]
    pub struct ConversionSourcesServiceClient<T> {
        inner: tonic::client::Grpc<T>,
    }
    impl ConversionSourcesServiceClient<tonic::transport::Channel> {
        /// Attempt to create a new client by connecting to a given endpoint.
        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
        where
            D: TryInto<tonic::transport::Endpoint>,
            D::Error: Into<StdError>,
        {
            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
            Ok(Self::new(conn))
        }
    }
    impl<T> ConversionSourcesServiceClient<T>
    where
        T: tonic::client::GrpcService<tonic::body::Body>,
        T::Error: Into<StdError>,
        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
    {
        pub fn new(inner: T) -> Self {
            let inner = tonic::client::Grpc::new(inner);
            Self { inner }
        }
        pub fn with_origin(inner: T, origin: Uri) -> Self {
            let inner = tonic::client::Grpc::with_origin(inner, origin);
            Self { inner }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> ConversionSourcesServiceClient<InterceptedService<T, F>>
        where
            F: tonic::service::Interceptor,
            T::ResponseBody: Default,
            T: tonic::codegen::Service<
                http::Request<tonic::body::Body>,
                Response = http::Response<
                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
                >,
            >,
            <T as tonic::codegen::Service<
                http::Request<tonic::body::Body>,
            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
        {
            ConversionSourcesServiceClient::new(
                InterceptedService::new(inner, interceptor),
            )
        }
        /// Compress requests with the given encoding.
        ///
        /// This requires the server to support it otherwise it might respond with an
        /// error.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.send_compressed(encoding);
            self
        }
        /// Enable decompressing responses.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.accept_compressed(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_decoding_message_size(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_encoding_message_size(limit);
            self
        }
        /// Creates a new conversion source.
        pub async fn create_conversion_source(
            &mut self,
            request: impl tonic::IntoRequest<super::CreateConversionSourceRequest>,
        ) -> std::result::Result<
            tonic::Response<super::ConversionSource>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/google.shopping.merchant.conversions.v1.ConversionSourcesService/CreateConversionSource",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.shopping.merchant.conversions.v1.ConversionSourcesService",
                        "CreateConversionSource",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Updates information of an existing conversion source. Available only for
        /// Merchant Center Destination conversion sources.
        pub async fn update_conversion_source(
            &mut self,
            request: impl tonic::IntoRequest<super::UpdateConversionSourceRequest>,
        ) -> std::result::Result<
            tonic::Response<super::ConversionSource>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/google.shopping.merchant.conversions.v1.ConversionSourcesService/UpdateConversionSource",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.shopping.merchant.conversions.v1.ConversionSourcesService",
                        "UpdateConversionSource",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Archives an existing conversion source. If the conversion source is a
        /// Merchant Center Destination, it will be recoverable for 30 days. If the
        /// conversion source is a Google Analytics Link, it will be deleted
        /// immediately and can be restored by creating a new one.
        pub async fn delete_conversion_source(
            &mut self,
            request: impl tonic::IntoRequest<super::DeleteConversionSourceRequest>,
        ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/google.shopping.merchant.conversions.v1.ConversionSourcesService/DeleteConversionSource",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.shopping.merchant.conversions.v1.ConversionSourcesService",
                        "DeleteConversionSource",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Re-enables an archived conversion source. Only Available for Merchant
        /// Center Destination conversion sources.
        pub async fn undelete_conversion_source(
            &mut self,
            request: impl tonic::IntoRequest<super::UndeleteConversionSourceRequest>,
        ) -> std::result::Result<
            tonic::Response<super::ConversionSource>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/google.shopping.merchant.conversions.v1.ConversionSourcesService/UndeleteConversionSource",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.shopping.merchant.conversions.v1.ConversionSourcesService",
                        "UndeleteConversionSource",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Fetches a conversion source.
        pub async fn get_conversion_source(
            &mut self,
            request: impl tonic::IntoRequest<super::GetConversionSourceRequest>,
        ) -> std::result::Result<
            tonic::Response<super::ConversionSource>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/google.shopping.merchant.conversions.v1.ConversionSourcesService/GetConversionSource",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.shopping.merchant.conversions.v1.ConversionSourcesService",
                        "GetConversionSource",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Retrieves the list of conversion sources the caller has access to.
        pub async fn list_conversion_sources(
            &mut self,
            request: impl tonic::IntoRequest<super::ListConversionSourcesRequest>,
        ) -> std::result::Result<
            tonic::Response<super::ListConversionSourcesResponse>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/google.shopping.merchant.conversions.v1.ConversionSourcesService/ListConversionSources",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.shopping.merchant.conversions.v1.ConversionSourcesService",
                        "ListConversionSources",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
    }
}
