#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Order {
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub user_id: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub currency_code: ::prost::alloc::string::String,
#[prost(uint64, tag = "4")]
pub subtotal_cents: u64,
#[prost(uint64, tag = "5")]
pub shipping_cents: u64,
#[prost(uint64, tag = "6")]
pub tax_cents: u64,
#[prost(uint64, tag = "7")]
pub discount_cents: u64,
#[prost(uint64, tag = "8")]
pub total_cents: u64,
#[prost(string, tag = "9")]
pub payment_provider: ::prost::alloc::string::String,
#[prost(string, tag = "10")]
pub payment_transaction_id: ::prost::alloc::string::String,
#[prost(string, tag = "11")]
pub payment_status: ::prost::alloc::string::String,
#[prost(message, optional, tag = "12")]
pub payment_provider_response: ::core::option::Option<
super::super::shared::v1::Struct,
>,
#[prost(uint64, tag = "13")]
pub payment_fee_cents: u64,
#[prost(string, tag = "14")]
pub inventory_reservation_status: ::prost::alloc::string::String,
#[prost(string, tag = "15")]
pub product_source: ::prost::alloc::string::String,
#[prost(message, optional, tag = "16")]
pub shipping_address: ::core::option::Option<super::super::shared::v1::Struct>,
#[prost(message, optional, tag = "17")]
pub billing_address: ::core::option::Option<super::super::shared::v1::Struct>,
#[prost(message, optional, tag = "18")]
pub metadata: ::core::option::Option<super::super::shared::v1::Struct>,
#[prost(string, tag = "19")]
pub status: ::prost::alloc::string::String,
#[prost(uint64, tag = "20")]
pub created_at: u64,
#[prost(uint64, optional, tag = "21")]
pub updated_at: ::core::option::Option<u64>,
#[prost(uint64, optional, tag = "22")]
pub deleted_at: ::core::option::Option<u64>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum PaymentStatus {
PaymentUnknown = 0,
PaymentAuthorized = 1,
PaymentCaptured = 2,
PaymentFailed = 3,
}
impl PaymentStatus {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::PaymentUnknown => "PAYMENT_UNKNOWN",
Self::PaymentAuthorized => "PAYMENT_AUTHORIZED",
Self::PaymentCaptured => "PAYMENT_CAPTURED",
Self::PaymentFailed => "PAYMENT_FAILED",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"PAYMENT_UNKNOWN" => Some(Self::PaymentUnknown),
"PAYMENT_AUTHORIZED" => Some(Self::PaymentAuthorized),
"PAYMENT_CAPTURED" => Some(Self::PaymentCaptured),
"PAYMENT_FAILED" => Some(Self::PaymentFailed),
_ => None,
}
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum OrderStatus {
Created = 0,
Confirmed = 1,
Shipped = 2,
Delivered = 3,
Cancelled = 4,
Refunded = 5,
RefundRequested = 6,
PaymentSucceeded = 7,
PaymentFailed = 8,
}
impl OrderStatus {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Created => "ORDER_STATUS_CREATED",
Self::Confirmed => "ORDER_STATUS_CONFIRMED",
Self::Shipped => "ORDER_STATUS_SHIPPED",
Self::Delivered => "ORDER_STATUS_DELIVERED",
Self::Cancelled => "ORDER_STATUS_CANCELLED",
Self::Refunded => "ORDER_STATUS_REFUNDED",
Self::RefundRequested => "ORDER_STATUS_REFUND_REQUESTED",
Self::PaymentSucceeded => "ORDER_STATUS_PAYMENT_SUCCEEDED",
Self::PaymentFailed => "ORDER_STATUS_PAYMENT_FAILED",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ORDER_STATUS_CREATED" => Some(Self::Created),
"ORDER_STATUS_CONFIRMED" => Some(Self::Confirmed),
"ORDER_STATUS_SHIPPED" => Some(Self::Shipped),
"ORDER_STATUS_DELIVERED" => Some(Self::Delivered),
"ORDER_STATUS_CANCELLED" => Some(Self::Cancelled),
"ORDER_STATUS_REFUNDED" => Some(Self::Refunded),
"ORDER_STATUS_REFUND_REQUESTED" => Some(Self::RefundRequested),
"ORDER_STATUS_PAYMENT_SUCCEEDED" => Some(Self::PaymentSucceeded),
"ORDER_STATUS_PAYMENT_FAILED" => Some(Self::PaymentFailed),
_ => None,
}
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrderCancelRequest {
#[prost(string, tag = "1")]
pub order_id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub reason: ::prost::alloc::string::String,
#[prost(bool, tag = "3")]
pub refund: bool,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrderCancelResponse {
#[prost(oneof = "order_cancel_response::Response", tags = "1, 2")]
pub response: ::core::option::Option<order_cancel_response::Response>,
}
pub mod order_cancel_response {
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Response {
#[prost(message, tag = "1")]
Data(super::super::super::shared::v1::SuccessResponseData),
#[prost(message, tag = "2")]
Error(super::super::super::shared::v1::AppError),
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrderCreateRequest {
#[prost(string, tag = "1")]
pub idempotency_key: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub currency_code: ::prost::alloc::string::String,
#[prost(map = "string, string", tag = "4")]
pub metadata: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
#[prost(message, optional, tag = "5")]
pub shipping_address: ::core::option::Option<super::super::shared::v1::Struct>,
#[prost(message, optional, tag = "6")]
pub billing_address: ::core::option::Option<super::super::shared::v1::Struct>,
#[prost(message, repeated, tag = "7")]
pub items: ::prost::alloc::vec::Vec<OrderLineItemRequest>,
#[prost(string, tag = "8")]
pub shipping_method: ::prost::alloc::string::String,
#[prost(string, repeated, tag = "9")]
pub promotion_codes: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(string, tag = "10")]
pub payment_method_token: ::prost::alloc::string::String,
#[prost(string, tag = "11")]
pub customer_note: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrderLineItemRequest {
#[prost(string, tag = "1")]
pub product_id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub variant_id: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub sku: ::prost::alloc::string::String,
#[prost(uint32, tag = "4")]
pub quantity: u32,
#[prost(uint64, optional, tag = "5")]
pub unit_price_cents_client: ::core::option::Option<u64>,
#[prost(map = "string, string", tag = "6")]
pub metadata: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrderCreateResponse {
#[prost(oneof = "order_create_response::Response", tags = "1, 2")]
pub response: ::core::option::Option<order_create_response::Response>,
}
pub mod order_create_response {
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Response {
#[prost(message, tag = "1")]
Data(super::super::super::shared::v1::SuccessResponseData),
#[prost(message, tag = "2")]
Error(super::super::super::shared::v1::AppError),
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrderEvent {
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub order_id: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub event_type: ::prost::alloc::string::String,
#[prost(message, optional, tag = "4")]
pub event_payload: ::core::option::Option<super::super::shared::v1::Struct>,
#[prost(uint64, tag = "5")]
pub created_at: u64,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum OrderEventType {
OrderEventUnknown = 0,
OrderEventOrderCreated = 1,
OrderEventPaymentCaptured = 2,
OrderEventPaymentFailed = 3,
OrderEventOrderShipped = 4,
OrderEventOrderDelivered = 5,
OrderEventOrderCancelled = 6,
OrderEventOrderRefunded = 7,
OrderEventInventoryReserved = 8,
OrderEventInventoryReleased = 9,
}
impl OrderEventType {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::OrderEventUnknown => "ORDER_EVENT_UNKNOWN",
Self::OrderEventOrderCreated => "ORDER_EVENT_ORDER_CREATED",
Self::OrderEventPaymentCaptured => "ORDER_EVENT_PAYMENT_CAPTURED",
Self::OrderEventPaymentFailed => "ORDER_EVENT_PAYMENT_FAILED",
Self::OrderEventOrderShipped => "ORDER_EVENT_ORDER_SHIPPED",
Self::OrderEventOrderDelivered => "ORDER_EVENT_ORDER_DELIVERED",
Self::OrderEventOrderCancelled => "ORDER_EVENT_ORDER_CANCELLED",
Self::OrderEventOrderRefunded => "ORDER_EVENT_ORDER_REFUNDED",
Self::OrderEventInventoryReserved => "ORDER_EVENT_INVENTORY_RESERVED",
Self::OrderEventInventoryReleased => "ORDER_EVENT_INVENTORY_RELEASED",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ORDER_EVENT_UNKNOWN" => Some(Self::OrderEventUnknown),
"ORDER_EVENT_ORDER_CREATED" => Some(Self::OrderEventOrderCreated),
"ORDER_EVENT_PAYMENT_CAPTURED" => Some(Self::OrderEventPaymentCaptured),
"ORDER_EVENT_PAYMENT_FAILED" => Some(Self::OrderEventPaymentFailed),
"ORDER_EVENT_ORDER_SHIPPED" => Some(Self::OrderEventOrderShipped),
"ORDER_EVENT_ORDER_DELIVERED" => Some(Self::OrderEventOrderDelivered),
"ORDER_EVENT_ORDER_CANCELLED" => Some(Self::OrderEventOrderCancelled),
"ORDER_EVENT_ORDER_REFUNDED" => Some(Self::OrderEventOrderRefunded),
"ORDER_EVENT_INVENTORY_RESERVED" => Some(Self::OrderEventInventoryReserved),
"ORDER_EVENT_INVENTORY_RELEASED" => Some(Self::OrderEventInventoryReleased),
_ => None,
}
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrderLineItem {
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub order_id: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub product_id: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub variant_id: ::prost::alloc::string::String,
#[prost(string, tag = "5")]
pub sku: ::prost::alloc::string::String,
#[prost(string, tag = "6")]
pub title: ::prost::alloc::string::String,
#[prost(map = "string, string", tag = "7")]
pub attributes: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
#[prost(int32, tag = "8")]
pub quantity: i32,
#[prost(uint64, tag = "9")]
pub unit_price_cents: u64,
#[prost(uint64, optional, tag = "10")]
pub list_price_cents: ::core::option::Option<u64>,
#[prost(uint64, optional, tag = "11")]
pub sale_price_cents: ::core::option::Option<u64>,
#[prost(uint64, optional, tag = "12")]
pub discount_cents: ::core::option::Option<u64>,
#[prost(uint64, tag = "13")]
pub tax_cents: u64,
#[prost(uint64, tag = "14")]
pub total_cents: u64,
#[prost(string, repeated, tag = "15")]
pub applied_offer_ids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(message, optional, tag = "16")]
pub product_snapshot: ::core::option::Option<super::super::shared::v1::Struct>,
#[prost(uint64, tag = "17")]
pub created_at: u64,
#[prost(uint64, optional, tag = "18")]
pub updated_at: ::core::option::Option<u64>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrderItem {
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
#[prost(uint64, tag = "3")]
pub subtotal_cents: u64,
#[prost(uint64, tag = "4")]
pub shipping_cents: u64,
#[prost(uint64, tag = "5")]
pub tax_cents: u64,
#[prost(uint64, tag = "6")]
pub discount_cents: u64,
#[prost(uint64, tag = "7")]
pub total_cents: u64,
#[prost(string, tag = "8")]
pub currency_code: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "9")]
pub line_items: ::prost::alloc::vec::Vec<OrderLineItem>,
#[prost(message, optional, tag = "10")]
pub shipping_address: ::core::option::Option<super::super::shared::v1::Struct>,
#[prost(message, optional, tag = "11")]
pub billing_address: ::core::option::Option<super::super::shared::v1::Struct>,
#[prost(message, optional, tag = "12")]
pub payment: ::core::option::Option<PaymentSnapshot>,
#[prost(
enumeration = "super::super::inventory::v1::InventoryReservationStatus",
tag = "13"
)]
pub inventory_reservation_status: i32,
#[prost(string, tag = "14")]
pub status: ::prost::alloc::string::String,
#[prost(uint64, tag = "15")]
pub created_at: u64,
#[prost(uint64, optional, tag = "16")]
pub updated_at: ::core::option::Option<u64>,
#[prost(string, tag = "17")]
pub product_source: ::prost::alloc::string::String,
#[prost(string, tag = "18")]
pub product_version: ::prost::alloc::string::String,
#[prost(map = "string, string", tag = "19")]
pub metadata: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PaymentSnapshot {
#[prost(string, tag = "1")]
pub provider: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub transaction_id: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub status: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub payment_method: ::prost::alloc::string::String,
#[prost(message, optional, tag = "5")]
pub provider_response: ::core::option::Option<super::super::shared::v1::Struct>,
#[prost(uint64, optional, tag = "6")]
pub fee_cents: ::core::option::Option<u64>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrderGetRequest {
#[prost(string, tag = "1")]
pub order_id: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrderGetResponse {
#[prost(oneof = "order_get_response::Response", tags = "1, 2")]
pub response: ::core::option::Option<order_get_response::Response>,
}
pub mod order_get_response {
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Response {
#[prost(message, tag = "1")]
Data(super::OrderItem),
#[prost(message, tag = "2")]
Error(super::super::super::shared::v1::AppError),
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrderIdempotencyKey {
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub idempotency_key: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub user_id: ::prost::alloc::string::String,
#[prost(string, optional, tag = "4")]
pub order_id: ::core::option::Option<::prost::alloc::string::String>,
#[prost(string, tag = "5")]
pub status: ::prost::alloc::string::String,
#[prost(uint64, tag = "6")]
pub created_at: u64,
#[prost(uint64, optional, tag = "7")]
pub updated_at: ::core::option::Option<u64>,
#[prost(uint64, tag = "8")]
pub expires_at: u64,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum OrderIdempotencyKeyStatus {
Unspecified = 0,
InProgress = 1,
Completed = 2,
Failed = 3,
}
impl OrderIdempotencyKeyStatus {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "ORDER_IDEMPOTENCY_KEY_STATUS_UNSPECIFIED",
Self::InProgress => "ORDER_IDEMPOTENCY_KEY_STATUS_IN_PROGRESS",
Self::Completed => "ORDER_IDEMPOTENCY_KEY_STATUS_COMPLETED",
Self::Failed => "ORDER_IDEMPOTENCY_KEY_STATUS_FAILED",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ORDER_IDEMPOTENCY_KEY_STATUS_UNSPECIFIED" => Some(Self::Unspecified),
"ORDER_IDEMPOTENCY_KEY_STATUS_IN_PROGRESS" => Some(Self::InProgress),
"ORDER_IDEMPOTENCY_KEY_STATUS_COMPLETED" => Some(Self::Completed),
"ORDER_IDEMPOTENCY_KEY_STATUS_FAILED" => Some(Self::Failed),
_ => None,
}
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrderRefundResponse {
#[prost(oneof = "order_refund_response::Response", tags = "1, 2")]
pub response: ::core::option::Option<order_refund_response::Response>,
}
pub mod order_refund_response {
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Response {
#[prost(message, tag = "1")]
Data(super::super::super::shared::v1::SuccessResponseData),
#[prost(message, tag = "2")]
Error(super::super::super::shared::v1::AppError),
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrderRefundRequest {
#[prost(string, tag = "1")]
pub order_id: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "2")]
pub line_items: ::prost::alloc::vec::Vec<RefundLineItemRefund>,
#[prost(string, tag = "3")]
pub reason: ::prost::alloc::string::String,
#[prost(bool, tag = "4")]
pub refund_shipping: bool,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RefundLineItemRefund {
#[prost(string, tag = "1")]
pub line_id: ::prost::alloc::string::String,
#[prost(uint32, tag = "2")]
pub quantity: u32,
#[prost(uint64, optional, tag = "3")]
pub amount_cents: ::core::option::Option<u64>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrdersListRequest {
#[prost(message, optional, tag = "1")]
pub pagination: ::core::option::Option<super::super::shared::v1::PaginationRequest>,
#[prost(string, repeated, tag = "2")]
pub status: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrdersListResponse {
#[prost(oneof = "orders_list_response::Response", tags = "1, 2")]
pub response: ::core::option::Option<orders_list_response::Response>,
}
pub mod orders_list_response {
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Response {
#[prost(message, tag = "1")]
Data(super::OrdersListResponseData),
#[prost(message, tag = "2")]
Error(super::super::super::shared::v1::AppError),
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrdersListResponseData {
#[prost(message, repeated, tag = "1")]
pub orders: ::prost::alloc::vec::Vec<OrderListItem>,
#[prost(message, optional, tag = "2")]
pub pagination: ::core::option::Option<super::super::shared::v1::PaginationResponse>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrderListItem {
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
#[prost(int64, tag = "2")]
pub shipping_cents: i64,
#[prost(int64, tag = "3")]
pub total_cents: i64,
#[prost(string, tag = "4")]
pub currency_code: ::prost::alloc::string::String,
#[prost(
enumeration = "super::super::inventory::v1::InventoryReservationStatus",
tag = "5"
)]
pub inventory_reservation_status: i32,
#[prost(string, tag = "6")]
pub status: ::prost::alloc::string::String,
#[prost(uint64, tag = "7")]
pub created_at: u64,
}
pub mod orders_service_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct OrdersServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl OrdersServiceClient<tonic::transport::Channel> {
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> OrdersServiceClient<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,
) -> OrdersServiceClient<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,
{
OrdersServiceClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn order_create(
&mut self,
request: impl tonic::IntoRequest<super::OrderCreateRequest>,
) -> std::result::Result<
tonic::Response<super::OrderCreateResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/orders.v1.OrdersService/OrderCreate",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("orders.v1.OrdersService", "OrderCreate"));
self.inner.unary(req, path, codec).await
}
pub async fn order_get(
&mut self,
request: impl tonic::IntoRequest<super::OrderGetRequest>,
) -> std::result::Result<
tonic::Response<super::OrderGetResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/orders.v1.OrdersService/OrderGet",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("orders.v1.OrdersService", "OrderGet"));
self.inner.unary(req, path, codec).await
}
pub async fn orders_list(
&mut self,
request: impl tonic::IntoRequest<super::OrdersListRequest>,
) -> std::result::Result<
tonic::Response<super::OrdersListResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/orders.v1.OrdersService/OrdersList",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("orders.v1.OrdersService", "OrdersList"));
self.inner.unary(req, path, codec).await
}
pub async fn order_cancel(
&mut self,
request: impl tonic::IntoRequest<super::OrderCancelRequest>,
) -> std::result::Result<
tonic::Response<super::OrderCancelResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/orders.v1.OrdersService/OrderCancel",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("orders.v1.OrdersService", "OrderCancel"));
self.inner.unary(req, path, codec).await
}
pub async fn order_refund(
&mut self,
request: impl tonic::IntoRequest<super::OrderRefundRequest>,
) -> std::result::Result<
tonic::Response<super::OrderRefundResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/orders.v1.OrdersService/OrderRefund",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("orders.v1.OrdersService", "OrderRefund"));
self.inner.unary(req, path, codec).await
}
}
}
pub mod orders_service_server {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
#[async_trait]
pub trait OrdersService: std::marker::Send + std::marker::Sync + 'static {
async fn order_create(
&self,
request: tonic::Request<super::OrderCreateRequest>,
) -> std::result::Result<
tonic::Response<super::OrderCreateResponse>,
tonic::Status,
>;
async fn order_get(
&self,
request: tonic::Request<super::OrderGetRequest>,
) -> std::result::Result<
tonic::Response<super::OrderGetResponse>,
tonic::Status,
>;
async fn orders_list(
&self,
request: tonic::Request<super::OrdersListRequest>,
) -> std::result::Result<
tonic::Response<super::OrdersListResponse>,
tonic::Status,
>;
async fn order_cancel(
&self,
request: tonic::Request<super::OrderCancelRequest>,
) -> std::result::Result<
tonic::Response<super::OrderCancelResponse>,
tonic::Status,
>;
async fn order_refund(
&self,
request: tonic::Request<super::OrderRefundRequest>,
) -> std::result::Result<
tonic::Response<super::OrderRefundResponse>,
tonic::Status,
>;
}
#[derive(Debug)]
pub struct OrdersServiceServer<T> {
inner: Arc<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
impl<T> OrdersServiceServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
max_decoding_message_size: None,
max_encoding_message_size: None,
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.max_encoding_message_size = Some(limit);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for OrdersServiceServer<T>
where
T: OrdersService,
B: Body + std::marker::Send + 'static,
B::Error: Into<StdError> + std::marker::Send + 'static,
{
type Response = http::Response<tonic::body::Body>;
type Error = std::convert::Infallible;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<std::result::Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
match req.uri().path() {
"/orders.v1.OrdersService/OrderCreate" => {
#[allow(non_camel_case_types)]
struct OrderCreateSvc<T: OrdersService>(pub Arc<T>);
impl<
T: OrdersService,
> tonic::server::UnaryService<super::OrderCreateRequest>
for OrderCreateSvc<T> {
type Response = super::OrderCreateResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::OrderCreateRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as OrdersService>::order_create(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = OrderCreateSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/orders.v1.OrdersService/OrderGet" => {
#[allow(non_camel_case_types)]
struct OrderGetSvc<T: OrdersService>(pub Arc<T>);
impl<
T: OrdersService,
> tonic::server::UnaryService<super::OrderGetRequest>
for OrderGetSvc<T> {
type Response = super::OrderGetResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::OrderGetRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as OrdersService>::order_get(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = OrderGetSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/orders.v1.OrdersService/OrdersList" => {
#[allow(non_camel_case_types)]
struct OrdersListSvc<T: OrdersService>(pub Arc<T>);
impl<
T: OrdersService,
> tonic::server::UnaryService<super::OrdersListRequest>
for OrdersListSvc<T> {
type Response = super::OrdersListResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::OrdersListRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as OrdersService>::orders_list(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = OrdersListSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/orders.v1.OrdersService/OrderCancel" => {
#[allow(non_camel_case_types)]
struct OrderCancelSvc<T: OrdersService>(pub Arc<T>);
impl<
T: OrdersService,
> tonic::server::UnaryService<super::OrderCancelRequest>
for OrderCancelSvc<T> {
type Response = super::OrderCancelResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::OrderCancelRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as OrdersService>::order_cancel(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = OrderCancelSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/orders.v1.OrdersService/OrderRefund" => {
#[allow(non_camel_case_types)]
struct OrderRefundSvc<T: OrdersService>(pub Arc<T>);
impl<
T: OrdersService,
> tonic::server::UnaryService<super::OrderRefundRequest>
for OrderRefundSvc<T> {
type Response = super::OrderRefundResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::OrderRefundRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as OrdersService>::order_refund(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = OrderRefundSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
let mut response = http::Response::new(
tonic::body::Body::default(),
);
let headers = response.headers_mut();
headers
.insert(
tonic::Status::GRPC_STATUS,
(tonic::Code::Unimplemented as i32).into(),
);
headers
.insert(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
);
Ok(response)
})
}
}
}
}
impl<T> Clone for OrdersServiceServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
max_decoding_message_size: self.max_decoding_message_size,
max_encoding_message_size: self.max_encoding_message_size,
}
}
}
pub const SERVICE_NAME: &str = "orders.v1.OrdersService";
impl<T> tonic::server::NamedService for OrdersServiceServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}