Files
google-apis-rs/gen/content2_sandbox/src/lib.rs.in
2016-04-10 14:08:43 +02:00

5997 lines
250 KiB
Rust

// DO NOT EDIT !
// This file was generated automatically from 'src/mako/api/lib.rs.in.mako'
// DO NOT EDIT !
extern crate hyper;
extern crate serde;
extern crate serde_json;
extern crate yup_oauth2 as oauth2;
extern crate mime;
extern crate url;
mod cmn;
use std::collections::HashMap;
use std::cell::RefCell;
use std::borrow::BorrowMut;
use std::default::Default;
use std::collections::BTreeMap;
use serde_json as json;
use std::io;
use std::fs;
use std::thread::sleep;
use std::time::Duration;
pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part,
ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder,
Resource, ErrorResponse, remove_json_null_values};
// ##############
// 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 {
/// Manage your product listings and accounts for Google Shopping
Full,
}
impl AsRef<str> for Scope {
fn as_ref(&self) -> &str {
match *self {
Scope::Full => "https://www.googleapis.com/auth/content",
}
}
}
impl Default for Scope {
fn default() -> Scope {
Scope::Full
}
}
// ########
// HUB ###
// ######
/// Central instance to access all ShoppingContent related resource activities
///
/// # Examples
///
/// Instantiate a new hub
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate yup_oauth2 as oauth2;
/// extern crate google_content2_sandbox as content2_sandbox;
/// use content2_sandbox::{Result, Error};
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use content2_sandbox::ShoppingContent;
///
/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
/// // `client_secret`, among other things.
/// let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = ShoppingContent::new(hyper::Client::new(), auth);
/// // 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.orders().list("merchantId")
/// .add_statuses("justo")
/// .placed_date_start("amet.")
/// .placed_date_end("erat")
/// .page_token("labore")
/// .order_by("sea")
/// .max_results(11)
/// .acknowledged(true)
/// .doit();
///
/// 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::MissingAPIKey
/// |Error::MissingToken(_)
/// |Error::Cancelled
/// |Error::UploadSizeLimitExceeded(_, _)
/// |Error::Failure(_)
/// |Error::BadRequest(_)
/// |Error::FieldClash(_)
/// |Error::JsonDecodeError(_, _) => println!("{}", e),
/// },
/// Ok(res) => println!("Success: {:?}", res),
/// }
/// # }
/// ```
pub struct ShoppingContent<C, A> {
client: RefCell<C>,
auth: RefCell<A>,
_user_agent: String,
}
impl<'a, C, A> Hub for ShoppingContent<C, A> {}
impl<'a, C, A> ShoppingContent<C, A>
where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
pub fn new(client: C, authenticator: A) -> ShoppingContent<C, A> {
ShoppingContent {
client: RefCell::new(client),
auth: RefCell::new(authenticator),
_user_agent: "google-api-rust-client/0.1.13".to_string(),
}
}
pub fn orders(&'a self) -> OrderMethods<'a, C, A> {
OrderMethods { hub: &self }
}
/// Set the user-agent header field to use in all requests to the server.
/// It defaults to `google-api-rust-client/0.1.13`.
///
/// Returns the previously set user-agent.
pub fn user_agent(&mut self, agent_name: String) -> String {
let prev = self._user_agent.clone();
self._user_agent = agent_name;
prev
}
}
// ############
// SCHEMAS ###
// ##########
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrderLineItemShippingDetailsMethod {
/// Minimum transit time.
#[serde(rename="minDaysInTransit")]
pub min_days_in_transit: Option<u32>,
/// The carrier for the shipping. Optional.
pub carrier: Option<String>,
/// The name of the shipping method.
#[serde(rename="methodName")]
pub method_name: Option<String>,
/// Maximum transit time.
#[serde(rename="maxDaysInTransit")]
pub max_days_in_transit: Option<u32>,
}
impl Part for OrderLineItemShippingDetailsMethod {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrderReturn {
/// Quantity that is returned.
pub quantity: Option<u32>,
/// The reason for the return.
pub reason: Option<String>,
/// Date on which the item has been created, in ISO 8601 format.
#[serde(rename="creationDate")]
pub creation_date: Option<String>,
/// The actor that created the refund.
pub actor: Option<String>,
/// The explanation of the reason.
#[serde(rename="reasonText")]
pub reason_text: Option<String>,
}
impl Part for OrderReturn {}
/// A list of errors returned by a failed batch entry.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Errors {
/// The message of the first error in errors.
pub message: Option<String>,
/// The HTTP status of the first error in errors.
pub code: Option<u32>,
/// A list of errors.
pub errors: Option<Vec<ErrorType>>,
}
impl Part for Errors {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [advancetestorder orders](struct.OrderAdvancetestorderCall.html) (response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersAdvanceTestOrderResponse {
/// Identifies what kind of resource this is. Value: the fixed string "content#ordersAdvanceTestOrderResponse".
pub kind: Option<String>,
}
impl ResponseResult for OrdersAdvanceTestOrderResponse {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersCustomBatchRequestEntryUpdateShipment {
/// New status for the shipment. Not updated if missing.
pub status: Option<String>,
/// The carrier handling the shipment. Not updated if missing.
pub carrier: Option<String>,
/// The tracking id for the shipment. Not updated if missing.
#[serde(rename="trackingId")]
pub tracking_id: Option<String>,
/// The ID of the shipment.
#[serde(rename="shipmentId")]
pub shipment_id: Option<String>,
}
impl Part for OrdersCustomBatchRequestEntryUpdateShipment {}
/// An error returned by the API.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct ErrorType {
/// The error code.
pub reason: Option<String>,
/// A description of the error.
pub message: Option<String>,
/// The domain of the error.
pub domain: Option<String>,
}
impl Part for ErrorType {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [custombatch orders](struct.OrderCustombatchCall.html) (request)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersCustomBatchRequest {
/// The request entries to be processed in the batch.
pub entries: Option<Vec<OrdersCustomBatchRequestEntry>>,
}
impl RequestValue for OrdersCustomBatchRequest {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [shiplineitems orders](struct.OrderShiplineitemCall.html) (request)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersShipLineItemsRequest {
/// The ID of the operation. Unique across all operations for a given order.
#[serde(rename="operationId")]
pub operation_id: Option<String>,
/// Line items to ship.
#[serde(rename="lineItems")]
pub line_items: Option<Vec<OrderShipmentLineItemShipment>>,
/// The carrier handling the shipment.
pub carrier: Option<String>,
/// The tracking id for the shipment.
#[serde(rename="trackingId")]
pub tracking_id: Option<String>,
/// The ID of the shipment.
#[serde(rename="shipmentId")]
pub shipment_id: Option<String>,
}
impl RequestValue for OrdersShipLineItemsRequest {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrderShipment {
/// The status of the shipment.
pub status: Option<String>,
/// Date on which the shipment has been created, in ISO 8601 format.
#[serde(rename="creationDate")]
pub creation_date: Option<String>,
/// The carrier handling the shipment.
pub carrier: Option<String>,
/// The tracking id for the shipment.
#[serde(rename="trackingId")]
pub tracking_id: Option<String>,
/// Date on which the shipment has been delivered, in ISO 8601 format. Present only if status is delievered
#[serde(rename="deliveryDate")]
pub delivery_date: Option<String>,
/// The line items that are shipped.
#[serde(rename="lineItems")]
pub line_items: Option<Vec<OrderShipmentLineItemShipment>>,
/// The id of the shipment.
pub id: Option<String>,
}
impl Part for OrderShipment {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct TestOrderLineItem {
/// Details of the return policy for the line item.
#[serde(rename="returnInfo")]
pub return_info: Option<OrderLineItemReturnInfo>,
/// Product data from the time of the order placement.
pub product: Option<TestOrderLineItemProduct>,
/// Unit tax for the line item.
#[serde(rename="unitTax")]
pub unit_tax: Option<Price>,
/// Number of items ordered.
#[serde(rename="quantityOrdered")]
pub quantity_ordered: Option<u32>,
/// Details of the requested shipping for the line item.
#[serde(rename="shippingDetails")]
pub shipping_details: Option<OrderLineItemShippingDetails>,
}
impl Part for TestOrderLineItem {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [updatemerchantorderid orders](struct.OrderUpdatemerchantorderidCall.html) (response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersUpdateMerchantOrderIdResponse {
/// Identifies what kind of resource this is. Value: the fixed string "content#ordersUpdateMerchantOrderIdResponse".
pub kind: Option<String>,
/// The status of the execution.
#[serde(rename="executionStatus")]
pub execution_status: Option<String>,
}
impl ResponseResult for OrdersUpdateMerchantOrderIdResponse {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [updateshipment orders](struct.OrderUpdateshipmentCall.html) (response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersUpdateShipmentResponse {
/// Identifies what kind of resource this is. Value: the fixed string "content#ordersUpdateShipmentResponse".
pub kind: Option<String>,
/// The status of the execution.
#[serde(rename="executionStatus")]
pub execution_status: Option<String>,
}
impl ResponseResult for OrdersUpdateShipmentResponse {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrderRefund {
/// The amount that is refunded.
pub amount: Option<Price>,
/// Date on which the item has been created, in ISO 8601 format.
#[serde(rename="creationDate")]
pub creation_date: Option<String>,
/// The reason for the refund.
pub reason: Option<String>,
/// The actor that created the refund.
pub actor: Option<String>,
/// The explanation of the reason.
#[serde(rename="reasonText")]
pub reason_text: Option<String>,
}
impl Part for OrderRefund {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrderLineItemShippingDetails {
/// The delivery by date, in ISO 8601 format.
#[serde(rename="deliverByDate")]
pub deliver_by_date: Option<String>,
/// Details of the shipping method.
pub method: Option<OrderLineItemShippingDetailsMethod>,
/// The ship by date, in ISO 8601 format.
#[serde(rename="shipByDate")]
pub ship_by_date: Option<String>,
}
impl Part for OrderLineItemShippingDetails {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Price {
/// The currency of the price.
pub currency: Option<String>,
/// The price represented as a number.
pub value: Option<String>,
}
impl Part for Price {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [get orders](struct.OrderGetCall.html) (response)
/// * [list orders](struct.OrderListCall.html) (none)
/// * [updateshipment orders](struct.OrderUpdateshipmentCall.html) (none)
/// * [advancetestorder orders](struct.OrderAdvancetestorderCall.html) (none)
/// * [updatemerchantorderid orders](struct.OrderUpdatemerchantorderidCall.html) (none)
/// * [returnlineitem orders](struct.OrderReturnlineitemCall.html) (none)
/// * [gettestordertemplate orders](struct.OrderGettestordertemplateCall.html) (none)
/// * [createtestorder orders](struct.OrderCreatetestorderCall.html) (none)
/// * [refund orders](struct.OrderRefundCall.html) (none)
/// * [custombatch orders](struct.OrderCustombatchCall.html) (none)
/// * [cancellineitem orders](struct.OrderCancellineitemCall.html) (none)
/// * [getbymerchantorderid orders](struct.OrderGetbymerchantorderidCall.html) (none)
/// * [acknowledge orders](struct.OrderAcknowledgeCall.html) (none)
/// * [cancel orders](struct.OrderCancelCall.html) (none)
/// * [shiplineitems orders](struct.OrderShiplineitemCall.html) (none)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Order {
/// Shipments of the order.
pub shipments: Option<Vec<OrderShipment>>,
/// The details of the customer who placed the order.
pub customer: Option<OrderCustomer>,
/// The status of the payment.
#[serde(rename="paymentStatus")]
pub payment_status: Option<String>,
/// The net amount for the order. For example, if an order was originally for a grand total of $100 and a refund was issued for $20, the net amount will be $80.
#[serde(rename="netAmount")]
pub net_amount: Option<Price>,
/// The REST id of the order. Globally unique.
pub id: Option<String>,
/// The details of the merchant provided promotions applied to the order. More details about the program are here.
pub promotions: Option<Vec<OrderPromotion>>,
/// Identifies what kind of resource this is. Value: the fixed string "content#order".
pub kind: Option<String>,
/// Line items that are ordered.
#[serde(rename="lineItems")]
pub line_items: Option<Vec<OrderLineItem>>,
/// Refunds for the order.
pub refunds: Option<Vec<OrderRefund>>,
/// Whether the order was acknowledged.
pub acknowledged: Option<bool>,
/// The total cost of shipping for all items.
#[serde(rename="shippingCost")]
pub shipping_cost: Option<Price>,
/// no description provided
#[serde(rename="merchantId")]
pub merchant_id: Option<String>,
/// Merchant-provided id of the order.
#[serde(rename="merchantOrderId")]
pub merchant_order_id: Option<String>,
/// The requested shipping option.
#[serde(rename="shippingOption")]
pub shipping_option: Option<String>,
/// The status of the order.
pub status: Option<String>,
/// The details for the delivery.
#[serde(rename="deliveryDetails")]
pub delivery_details: Option<OrderDeliveryDetails>,
/// The date when the order was placed, in ISO 8601 format.
#[serde(rename="placedDate")]
pub placed_date: Option<String>,
/// The tax for the total shipping cost.
#[serde(rename="shippingCostTax")]
pub shipping_cost_tax: Option<Price>,
/// The details of the payment method.
#[serde(rename="paymentMethod")]
pub payment_method: Option<OrderPaymentMethod>,
}
impl Resource for Order {}
impl ResponseResult for Order {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct TestOrderPaymentMethod {
/// The card expiration month (January = 1, February = 2 etc.).
#[serde(rename="expirationMonth")]
pub expiration_month: Option<i32>,
/// The last four digits of the card number.
#[serde(rename="lastFourDigits")]
pub last_four_digits: Option<String>,
/// The card expiration year (4-digit, e.g. 2015).
#[serde(rename="expirationYear")]
pub expiration_year: Option<i32>,
/// The type of instrument. Note that real orders might have different values than the four values accepted by createTestOrder.
#[serde(rename="type")]
pub type_: Option<String>,
/// The billing address.
#[serde(rename="predefinedBillingAddress")]
pub predefined_billing_address: Option<String>,
}
impl Part for TestOrderPaymentMethod {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct TestOrderLineItemProduct {
/// The CLDR territory code of the target country of the product.
#[serde(rename="targetCountry")]
pub target_country: Option<i64>,
/// The two-letter ISO 639-1 language code for the item.
#[serde(rename="contentLanguage")]
pub content_language: Option<String>,
/// The title of the product.
pub title: Option<String>,
/// Manufacturer Part Number (MPN) of the item. Optional.
pub mpn: Option<String>,
/// Variant attributes for the item. Optional.
#[serde(rename="variantAttributes")]
pub variant_attributes: Option<Vec<OrderLineItemProductVariantAttribute>>,
/// Brand of the item.
pub brand: Option<String>,
/// URL of an image of the item.
#[serde(rename="imageLink")]
pub image_link: Option<String>,
/// An identifier of the item.
#[serde(rename="offerId")]
pub offer_id: Option<String>,
/// Shared identifier for all variants of the same product. Optional.
#[serde(rename="itemGroupId")]
pub item_group_id: Option<String>,
/// Global Trade Item Number (GTIN) of the item. Optional.
pub gtin: Option<String>,
/// Condition or state of the item.
pub condition: Option<String>,
/// The price for the product.
pub price: Option<Price>,
/// The item's channel.
pub channel: Option<String>,
}
impl Part for TestOrderLineItemProduct {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrderPromotionBenefit {
/// The OfferId(s) that were purchased in this order and map to this specific benefit of the promotion.
#[serde(rename="offerIds")]
pub offer_ids: Option<Vec<String>>,
/// The discount in the order price when the promotion is applied.
pub discount: Option<Price>,
/// Describes whether the promotion applies to products (e.g. 20% off) or to shipping (e.g. Free Shipping).
#[serde(rename="type")]
pub type_: Option<String>,
/// The impact on tax when the promotion is applied.
#[serde(rename="taxImpact")]
pub tax_impact: Option<Price>,
/// Further describes the benefit of the promotion. Note that we will expand on this enumeration as we support new promotion sub-types.
#[serde(rename="subType")]
pub sub_type: Option<String>,
}
impl Part for OrderPromotionBenefit {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [getbymerchantorderid orders](struct.OrderGetbymerchantorderidCall.html) (response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersGetByMerchantOrderIdResponse {
/// Identifies what kind of resource this is. Value: the fixed string "content#ordersGetByMerchantOrderIdResponse".
pub kind: Option<String>,
/// The requested order.
pub order: Option<Order>,
}
impl ResponseResult for OrdersGetByMerchantOrderIdResponse {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [cancellineitem orders](struct.OrderCancellineitemCall.html) (response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersCancelLineItemResponse {
/// Identifies what kind of resource this is. Value: the fixed string "content#ordersCancelLineItemResponse".
pub kind: Option<String>,
/// The status of the execution.
#[serde(rename="executionStatus")]
pub execution_status: Option<String>,
}
impl ResponseResult for OrdersCancelLineItemResponse {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrderCancellation {
/// The quantity that was canceled.
pub quantity: Option<u32>,
/// The reason for the cancellation.
pub reason: Option<String>,
/// Date on which the cancellation has been created, in ISO 8601 format.
#[serde(rename="creationDate")]
pub creation_date: Option<String>,
/// The actor that created the cancellation.
pub actor: Option<String>,
/// The explanation of the reason.
#[serde(rename="reasonText")]
pub reason_text: Option<String>,
}
impl Part for OrderCancellation {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrderAddress {
/// City, town or commune. May also include dependent localities or sublocalities (e.g. neighborhoods or suburbs).
pub locality: Option<String>,
/// CLDR country code (e.g. "US").
pub country: Option<String>,
/// Strings representing the lines of the printed label for mailing the order, for example:
/// John Smith
/// 1600 Amphitheatre Parkway
/// Mountain View, CA, 94043
/// United States
#[serde(rename="fullAddress")]
pub full_address: Option<Vec<String>>,
/// Street-level part of the address.
#[serde(rename="streetAddress")]
pub street_address: Option<Vec<String>>,
/// Postal Code or ZIP (e.g. "94043").
#[serde(rename="postalCode")]
pub postal_code: Option<String>,
/// Name of the recipient.
#[serde(rename="recipientName")]
pub recipient_name: Option<String>,
/// Whether the address is a post office box.
#[serde(rename="isPostOfficeBox")]
pub is_post_office_box: Option<bool>,
/// Top-level administrative subdivision of the country (e.g. "CA").
pub region: Option<String>,
}
impl Part for OrderAddress {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersCustomBatchRequestEntry {
/// The ID of the order. Required for all methods beside getByMerchantOrderId.
#[serde(rename="orderId")]
pub order_id: Option<String>,
/// An entry ID, unique within the batch request.
#[serde(rename="batchId")]
pub batch_id: Option<u32>,
/// Required for shipLineItems method.
#[serde(rename="shipLineItems")]
pub ship_line_items: Option<OrdersCustomBatchRequestEntryShipLineItems>,
/// Required for updateShipment method.
#[serde(rename="updateShipment")]
pub update_shipment: Option<OrdersCustomBatchRequestEntryUpdateShipment>,
/// The ID of the managing account.
#[serde(rename="merchantId")]
pub merchant_id: Option<String>,
/// The merchant order id. Required for updateMerchantOrderId and getByMerchantOrderId methods.
#[serde(rename="merchantOrderId")]
pub merchant_order_id: Option<String>,
/// Required for cancelLineItem method.
#[serde(rename="cancelLineItem")]
pub cancel_line_item: Option<OrdersCustomBatchRequestEntryCancelLineItem>,
/// Required for refund method.
pub refund: Option<OrdersCustomBatchRequestEntryRefund>,
/// Required for cancel method.
pub cancel: Option<OrdersCustomBatchRequestEntryCancel>,
/// The ID of the operation. Unique across all operations for a given order. Required for all methods beside get and getByMerchantOrderId.
#[serde(rename="operationId")]
pub operation_id: Option<String>,
/// The method to apply.
pub method: Option<String>,
/// Required for returnLineItem method.
#[serde(rename="returnLineItem")]
pub return_line_item: Option<OrdersCustomBatchRequestEntryReturnLineItem>,
}
impl Part for OrdersCustomBatchRequestEntry {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrderLineItemProduct {
/// The CLDR territory code of the target country of the product.
#[serde(rename="targetCountry")]
pub target_country: Option<i64>,
/// URL to the cached image shown to the user when order was placed.
#[serde(rename="shownImage")]
pub shown_image: Option<String>,
/// The two-letter ISO 639-1 language code for the item.
#[serde(rename="contentLanguage")]
pub content_language: Option<String>,
/// The title of the product.
pub title: Option<String>,
/// Manufacturer Part Number (MPN) of the item.
pub mpn: Option<String>,
/// Variant attributes for the item. These are dimensions of the product, such as color, gender, material, pattern, and size. You can find a comprehensive list of variant attributes here.
#[serde(rename="variantAttributes")]
pub variant_attributes: Option<Vec<OrderLineItemProductVariantAttribute>>,
/// Brand of the item.
pub brand: Option<String>,
/// URL of an image of the item.
#[serde(rename="imageLink")]
pub image_link: Option<String>,
/// An identifier of the item.
#[serde(rename="offerId")]
pub offer_id: Option<String>,
/// The REST id of the product.
pub id: Option<String>,
/// Shared identifier for all variants of the same product.
#[serde(rename="itemGroupId")]
pub item_group_id: Option<String>,
/// Global Trade Item Number (GTIN) of the item.
pub gtin: Option<String>,
/// Condition or state of the item.
pub condition: Option<String>,
/// Price of the item.
pub price: Option<Price>,
/// The item's channel (online or local).
pub channel: Option<String>,
}
impl Part for OrderLineItemProduct {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [cancellineitem orders](struct.OrderCancellineitemCall.html) (request)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersCancelLineItemRequest {
/// Amount to refund for the cancelation. Optional. If not set, Google will calculate the default based on the price and tax of the items involved. The amount must not be larger than the net amount left on the order.
pub amount: Option<Price>,
/// The explanation of the reason.
#[serde(rename="reasonText")]
pub reason_text: Option<String>,
/// The ID of the line item to cancel.
#[serde(rename="lineItemId")]
pub line_item_id: Option<String>,
/// The ID of the operation. Unique across all operations for a given order.
#[serde(rename="operationId")]
pub operation_id: Option<String>,
/// The reason for the cancellation.
pub reason: Option<String>,
/// The quantity to cancel.
pub quantity: Option<u32>,
}
impl RequestValue for OrdersCancelLineItemRequest {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrderPromotion {
/// The full title of the promotion.
#[serde(rename="longTitle")]
pub long_title: Option<String>,
/// Optional. The text code that corresponds to the promotion when applied on the retailer?s website.
#[serde(rename="genericRedemptionCode")]
pub generic_redemption_code: Option<String>,
/// no description provided
pub benefits: Option<Vec<OrderPromotionBenefit>>,
/// Indicates that the promotion is valid online.
#[serde(rename="redemptionChannel")]
pub redemption_channel: Option<String>,
/// Whether the promotion is applicable to all products or only specific products.
#[serde(rename="productApplicability")]
pub product_applicability: Option<String>,
/// The date and time frame when the promotion is active and ready for validation review. Note that the promotion live time may be delayed for a few hours due to the validation review.
/// Start date and end date are separated by a forward slash (/). The start date is specified by the format (YYYY-MM-DD), followed by the letter ?T?, the time of the day when the sale starts (in Greenwich Mean Time, GMT), followed by an expression of the time zone for the sale. The end date is in the same format.
#[serde(rename="effectiveDates")]
pub effective_dates: Option<String>,
/// The unique ID of the promotion.
pub id: Option<String>,
}
impl Part for OrderPromotion {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrderLineItemProductVariantAttribute {
/// The dimension of the variant.
pub dimension: Option<String>,
/// The value for the dimension.
pub value: Option<String>,
}
impl Part for OrderLineItemProductVariantAttribute {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [returnlineitem orders](struct.OrderReturnlineitemCall.html) (request)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersReturnLineItemRequest {
/// The ID of the operation. Unique across all operations for a given order.
#[serde(rename="operationId")]
pub operation_id: Option<String>,
/// The reason for the return.
pub reason: Option<String>,
/// The explanation of the reason.
#[serde(rename="reasonText")]
pub reason_text: Option<String>,
/// The ID of the line item to return.
#[serde(rename="lineItemId")]
pub line_item_id: Option<String>,
/// The quantity to return.
pub quantity: Option<u32>,
}
impl RequestValue for OrdersReturnLineItemRequest {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [custombatch orders](struct.OrderCustombatchCall.html) (response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersCustomBatchResponse {
/// Identifies what kind of resource this is. Value: the fixed string "content#ordersCustomBatchResponse".
pub kind: Option<String>,
/// The result of the execution of the batch requests.
pub entries: Option<Vec<OrdersCustomBatchResponseEntry>>,
}
impl ResponseResult for OrdersCustomBatchResponse {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrderCustomer {
/// If set, this indicates the user had a choice to opt in or out of providing marketing rights to the merchant. If unset, this indicates the user has already made this choice in a previous purchase, and was thus not shown the marketing right opt in/out checkbox during the Purchases on Google checkout flow.
#[serde(rename="explicitMarketingPreference")]
pub explicit_marketing_preference: Option<bool>,
/// Full name of the customer.
#[serde(rename="fullName")]
pub full_name: Option<String>,
/// Email address of the customer.
pub email: Option<String>,
}
impl Part for OrderCustomer {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [cancel orders](struct.OrderCancelCall.html) (request)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersCancelRequest {
/// The reason for the cancellation.
pub reason: Option<String>,
/// The explanation of the reason.
#[serde(rename="reasonText")]
pub reason_text: Option<String>,
/// The ID of the operation. Unique across all operations for a given order.
#[serde(rename="operationId")]
pub operation_id: Option<String>,
}
impl RequestValue for OrdersCancelRequest {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [list orders](struct.OrderListCall.html) (response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersListResponse {
/// The token for the retrieval of the next page of orders.
#[serde(rename="nextPageToken")]
pub next_page_token: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "content#ordersListResponse".
pub kind: Option<String>,
/// no description provided
pub resources: Option<Vec<Order>>,
}
impl ResponseResult for OrdersListResponse {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrderShipmentLineItemShipment {
/// The id of the line item that is shipped.
#[serde(rename="lineItemId")]
pub line_item_id: Option<String>,
/// The quantity that is shipped.
pub quantity: Option<u32>,
}
impl Part for OrderShipmentLineItemShipment {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [createtestorder orders](struct.OrderCreatetestorderCall.html) (response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersCreateTestOrderResponse {
/// The ID of the newly created test order.
#[serde(rename="orderId")]
pub order_id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "content#ordersCreateTestOrderResponse".
pub kind: Option<String>,
}
impl ResponseResult for OrdersCreateTestOrderResponse {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [gettestordertemplate orders](struct.OrderGettestordertemplateCall.html) (response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersGetTestOrderTemplateResponse {
/// Identifies what kind of resource this is. Value: the fixed string "content#ordersGetTestOrderTemplateResponse".
pub kind: Option<String>,
/// The requested test order template.
pub template: Option<TestOrder>,
}
impl ResponseResult for OrdersGetTestOrderTemplateResponse {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [refund orders](struct.OrderRefundCall.html) (request)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersRefundRequest {
/// The amount that is refunded.
pub amount: Option<Price>,
/// The explanation of the reason.
#[serde(rename="reasonText")]
pub reason_text: Option<String>,
/// The reason for the refund.
pub reason: Option<String>,
/// The ID of the operation. Unique across all operations for a given order.
#[serde(rename="operationId")]
pub operation_id: Option<String>,
}
impl RequestValue for OrdersRefundRequest {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct TestOrderCustomer {
/// If set, this indicates the user had a choice to opt in or out of providing marketing rights to the merchant. If unset, this indicates the user has already made this choice in a previous purchase, and was thus not shown the marketing right opt in/out checkbox during the Purchases on Google checkout flow. Optional.
#[serde(rename="explicitMarketingPreference")]
pub explicit_marketing_preference: Option<bool>,
/// Full name of the customer.
#[serde(rename="fullName")]
pub full_name: Option<String>,
/// Email address of the customer.
pub email: Option<String>,
}
impl Part for TestOrderCustomer {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersCustomBatchRequestEntryCancel {
/// The reason for the cancellation.
pub reason: Option<String>,
/// The explanation of the reason.
#[serde(rename="reasonText")]
pub reason_text: Option<String>,
}
impl Part for OrdersCustomBatchRequestEntryCancel {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrderLineItem {
/// Product data from the time of the order placement.
pub product: Option<OrderLineItemProduct>,
/// Number of items delivered.
#[serde(rename="quantityDelivered")]
pub quantity_delivered: Option<u32>,
/// Details of the return policy for the line item.
#[serde(rename="returnInfo")]
pub return_info: Option<OrderLineItemReturnInfo>,
/// Total price for the line item. For example, if two items for $10 are purchased, the total price will be $20.
pub price: Option<Price>,
/// Number of items pending.
#[serde(rename="quantityPending")]
pub quantity_pending: Option<u32>,
/// Total tax amount for the line item. For example, if two items are purchased, and each have a cost tax of $2, the total tax amount will be $4.
pub tax: Option<Price>,
/// Cancellations of the line item.
pub cancellations: Option<Vec<OrderCancellation>>,
/// Number of items canceled.
#[serde(rename="quantityCanceled")]
pub quantity_canceled: Option<u32>,
/// The id of the line item.
pub id: Option<String>,
/// Returns of the line item.
pub returns: Option<Vec<OrderReturn>>,
/// Number of items shipped.
#[serde(rename="quantityShipped")]
pub quantity_shipped: Option<u32>,
/// Number of items returned.
#[serde(rename="quantityReturned")]
pub quantity_returned: Option<u32>,
/// Number of items ordered.
#[serde(rename="quantityOrdered")]
pub quantity_ordered: Option<u32>,
/// Details of the requested shipping for the line item.
#[serde(rename="shippingDetails")]
pub shipping_details: Option<OrderLineItemShippingDetails>,
}
impl Part for OrderLineItem {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersCustomBatchRequestEntryCancelLineItem {
/// Amount to refund for the cancelation. Optional. If not set, Google will calculate the default based on the price and tax of the items involved. The amount must not be larger than the net amount left on the order.
pub amount: Option<Price>,
/// The explanation of the reason.
#[serde(rename="reasonText")]
pub reason_text: Option<String>,
/// The reason for the cancellation.
pub reason: Option<String>,
/// The ID of the line item to cancel.
#[serde(rename="lineItemId")]
pub line_item_id: Option<String>,
/// The quantity to cancel.
pub quantity: Option<u32>,
}
impl Part for OrdersCustomBatchRequestEntryCancelLineItem {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [acknowledge orders](struct.OrderAcknowledgeCall.html) (request)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersAcknowledgeRequest {
/// The ID of the operation. Unique across all operations for a given order.
#[serde(rename="operationId")]
pub operation_id: Option<String>,
}
impl RequestValue for OrdersAcknowledgeRequest {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersCustomBatchRequestEntryReturnLineItem {
/// The reason for the return.
pub reason: Option<String>,
/// The explanation of the reason.
#[serde(rename="reasonText")]
pub reason_text: Option<String>,
/// The ID of the line item to return.
#[serde(rename="lineItemId")]
pub line_item_id: Option<String>,
/// The quantity to return.
pub quantity: Option<u32>,
}
impl Part for OrdersCustomBatchRequestEntryReturnLineItem {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [returnlineitem orders](struct.OrderReturnlineitemCall.html) (response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersReturnLineItemResponse {
/// Identifies what kind of resource this is. Value: the fixed string "content#ordersReturnLineItemResponse".
pub kind: Option<String>,
/// The status of the execution.
#[serde(rename="executionStatus")]
pub execution_status: Option<String>,
}
impl ResponseResult for OrdersReturnLineItemResponse {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [refund orders](struct.OrderRefundCall.html) (response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersRefundResponse {
/// Identifies what kind of resource this is. Value: the fixed string "content#ordersRefundResponse".
pub kind: Option<String>,
/// The status of the execution.
#[serde(rename="executionStatus")]
pub execution_status: Option<String>,
}
impl ResponseResult for OrdersRefundResponse {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [acknowledge orders](struct.OrderAcknowledgeCall.html) (response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersAcknowledgeResponse {
/// Identifies what kind of resource this is. Value: the fixed string "content#ordersAcknowledgeResponse".
pub kind: Option<String>,
/// The status of the execution.
#[serde(rename="executionStatus")]
pub execution_status: Option<String>,
}
impl ResponseResult for OrdersAcknowledgeResponse {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrderDeliveryDetails {
/// The phone number of the person receiving the delivery.
#[serde(rename="phoneNumber")]
pub phone_number: Option<String>,
/// The delivery address
pub address: Option<OrderAddress>,
}
impl Part for OrderDeliveryDetails {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersCustomBatchRequestEntryShipLineItems {
/// Line items to ship.
#[serde(rename="lineItems")]
pub line_items: Option<Vec<OrderShipmentLineItemShipment>>,
/// The carrier handling the shipment.
pub carrier: Option<String>,
/// The tracking id for the shipment.
#[serde(rename="trackingId")]
pub tracking_id: Option<String>,
/// The ID of the shipment.
#[serde(rename="shipmentId")]
pub shipment_id: Option<String>,
}
impl Part for OrdersCustomBatchRequestEntryShipLineItems {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [updatemerchantorderid orders](struct.OrderUpdatemerchantorderidCall.html) (request)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersUpdateMerchantOrderIdRequest {
/// The merchant order id to be assigned to the order. Must be unique per merchant.
#[serde(rename="merchantOrderId")]
pub merchant_order_id: Option<String>,
/// The ID of the operation. Unique across all operations for a given order.
#[serde(rename="operationId")]
pub operation_id: Option<String>,
}
impl RequestValue for OrdersUpdateMerchantOrderIdRequest {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [createtestorder orders](struct.OrderCreatetestorderCall.html) (request)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersCreateTestOrderRequest {
/// The test order to create.
#[serde(rename="testOrder")]
pub test_order: Option<TestOrder>,
/// The test order template to use. Specify as an alternative to testOrder as a shortcut for retrieving a template and then creating an order using that template.
#[serde(rename="templateName")]
pub template_name: Option<String>,
}
impl RequestValue for OrdersCreateTestOrderRequest {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrderPaymentMethod {
/// The card expiration month (January = 1, February = 2 etc.).
#[serde(rename="expirationMonth")]
pub expiration_month: Option<i32>,
/// The card expiration year (4-digit, e.g. 2015).
#[serde(rename="expirationYear")]
pub expiration_year: Option<i32>,
/// The billing phone number.
#[serde(rename="phoneNumber")]
pub phone_number: Option<String>,
/// The billing address.
#[serde(rename="billingAddress")]
pub billing_address: Option<OrderAddress>,
/// The type of instrument (VISA, Mastercard, etc).
#[serde(rename="type")]
pub type_: Option<String>,
/// The last four digits of the card number.
#[serde(rename="lastFourDigits")]
pub last_four_digits: Option<String>,
}
impl Part for OrderPaymentMethod {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [shiplineitems orders](struct.OrderShiplineitemCall.html) (response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersShipLineItemsResponse {
/// Identifies what kind of resource this is. Value: the fixed string "content#ordersShipLineItemsResponse".
pub kind: Option<String>,
/// The status of the execution.
#[serde(rename="executionStatus")]
pub execution_status: Option<String>,
}
impl ResponseResult for OrdersShipLineItemsResponse {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [cancel orders](struct.OrderCancelCall.html) (response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersCancelResponse {
/// Identifies what kind of resource this is. Value: the fixed string "content#ordersCancelResponse".
pub kind: Option<String>,
/// The status of the execution.
#[serde(rename="executionStatus")]
pub execution_status: Option<String>,
}
impl ResponseResult for OrdersCancelResponse {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [updateshipment orders](struct.OrderUpdateshipmentCall.html) (request)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersUpdateShipmentRequest {
/// New status for the shipment. Not updated if missing.
pub status: Option<String>,
/// The carrier handling the shipment. Not updated if missing.
pub carrier: Option<String>,
/// The ID of the operation. Unique across all operations for a given order.
#[serde(rename="operationId")]
pub operation_id: Option<String>,
/// The tracking id for the shipment. Not updated if missing.
#[serde(rename="trackingId")]
pub tracking_id: Option<String>,
/// The ID of the shipment.
#[serde(rename="shipmentId")]
pub shipment_id: Option<String>,
}
impl RequestValue for OrdersUpdateShipmentRequest {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrderLineItemReturnInfo {
/// URL of the item return policy.
#[serde(rename="policyUrl")]
pub policy_url: Option<String>,
/// Whether the item is returnable.
#[serde(rename="isReturnable")]
pub is_returnable: Option<bool>,
/// How many days later the item can be returned.
#[serde(rename="daysToReturn")]
pub days_to_return: Option<i32>,
}
impl Part for OrderLineItemReturnInfo {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersCustomBatchRequestEntryRefund {
/// The amount that is refunded.
pub amount: Option<Price>,
/// The explanation of the reason.
#[serde(rename="reasonText")]
pub reason_text: Option<String>,
/// The reason for the refund.
pub reason: Option<String>,
}
impl Part for OrdersCustomBatchRequestEntryRefund {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct TestOrder {
/// The details of the customer who placed the order.
pub customer: Option<TestOrderCustomer>,
/// The details of the merchant provided promotions applied to the order. More details about the program are here.
pub promotions: Option<Vec<OrderPromotion>>,
/// Identifies what kind of resource this is. Value: the fixed string "content#testOrder".
pub kind: Option<String>,
/// Line items that are ordered. At least one line item must be provided.
#[serde(rename="lineItems")]
pub line_items: Option<Vec<TestOrderLineItem>>,
/// Identifier of one of the predefined delivery addresses for the delivery.
#[serde(rename="predefinedDeliveryAddress")]
pub predefined_delivery_address: Option<String>,
/// The total cost of shipping for all items.
#[serde(rename="shippingCost")]
pub shipping_cost: Option<Price>,
/// The requested shipping option.
#[serde(rename="shippingOption")]
pub shipping_option: Option<String>,
/// The tax for the total shipping cost.
#[serde(rename="shippingCostTax")]
pub shipping_cost_tax: Option<Price>,
/// The details of the payment method.
#[serde(rename="paymentMethod")]
pub payment_method: Option<TestOrderPaymentMethod>,
}
impl Part for TestOrder {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OrdersCustomBatchResponseEntry {
/// The ID of the request entry this entry responds to.
#[serde(rename="batchId")]
pub batch_id: Option<u32>,
/// Identifies what kind of resource this is. Value: the fixed string "content#ordersCustomBatchResponseEntry".
pub kind: Option<String>,
/// A list of errors defined if and only if the request failed.
pub errors: Option<Errors>,
/// The retrieved order. Only defined if the method is get and if the request was successful.
pub order: Option<Order>,
/// The status of the execution. Only defined if the method is not get or getByMerchantOrderId and if the request was successful.
#[serde(rename="executionStatus")]
pub execution_status: Option<String>,
}
impl Part for OrdersCustomBatchResponseEntry {}
// ###################
// MethodBuilders ###
// #################
/// A builder providing access to all methods supported on *order* resources.
/// It is not used directly, but through the `ShoppingContent` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate yup_oauth2 as oauth2;
/// extern crate google_content2_sandbox as content2_sandbox;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use content2_sandbox::ShoppingContent;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = ShoppingContent::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `acknowledge(...)`, `advancetestorder(...)`, `cancel(...)`, `cancellineitem(...)`, `createtestorder(...)`, `custombatch(...)`, `get(...)`, `getbymerchantorderid(...)`, `gettestordertemplate(...)`, `list(...)`, `refund(...)`, `returnlineitem(...)`, `shiplineitems(...)`, `updatemerchantorderid(...)` and `updateshipment(...)`
/// // to build up your call.
/// let rb = hub.orders();
/// # }
/// ```
pub struct OrderMethods<'a, C, A>
where C: 'a, A: 'a {
hub: &'a ShoppingContent<C, A>,
}
impl<'a, C, A> MethodsBuilder for OrderMethods<'a, C, A> {}
impl<'a, C, A> OrderMethods<'a, C, A> {
/// Create a builder to help you perform the following task:
///
/// Retrieves an order from your Merchant Center account.
///
/// # Arguments
///
/// * `merchantId` - The ID of the managing account.
/// * `orderId` - The ID of the order.
pub fn get(&self, merchant_id: &str, order_id: &str) -> OrderGetCall<'a, C, A> {
OrderGetCall {
hub: self.hub,
_merchant_id: merchant_id.to_string(),
_order_id: order_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Lists the orders in your Merchant Center account.
///
/// # Arguments
///
/// * `merchantId` - The ID of the managing account.
pub fn list(&self, merchant_id: &str) -> OrderListCall<'a, C, A> {
OrderListCall {
hub: self.hub,
_merchant_id: merchant_id.to_string(),
_statuses: Default::default(),
_placed_date_start: Default::default(),
_placed_date_end: Default::default(),
_page_token: Default::default(),
_order_by: Default::default(),
_max_results: Default::default(),
_acknowledged: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates a shipment's status, carrier, and/or tracking ID.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `merchantId` - The ID of the managing account.
/// * `orderId` - The ID of the order.
pub fn updateshipment(&self, request: OrdersUpdateShipmentRequest, merchant_id: &str, order_id: &str) -> OrderUpdateshipmentCall<'a, C, A> {
OrderUpdateshipmentCall {
hub: self.hub,
_request: request,
_merchant_id: merchant_id.to_string(),
_order_id: order_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Sandbox only. Moves a test order from state "inProgress" to state "pendingShipment".
///
/// # Arguments
///
/// * `merchantId` - The ID of the managing account.
/// * `orderId` - The ID of the test order to modify.
pub fn advancetestorder(&self, merchant_id: &str, order_id: &str) -> OrderAdvancetestorderCall<'a, C, A> {
OrderAdvancetestorderCall {
hub: self.hub,
_merchant_id: merchant_id.to_string(),
_order_id: order_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates the merchant order ID for a given order.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `merchantId` - The ID of the managing account.
/// * `orderId` - The ID of the order.
pub fn updatemerchantorderid(&self, request: OrdersUpdateMerchantOrderIdRequest, merchant_id: &str, order_id: &str) -> OrderUpdatemerchantorderidCall<'a, C, A> {
OrderUpdatemerchantorderidCall {
hub: self.hub,
_request: request,
_merchant_id: merchant_id.to_string(),
_order_id: order_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Returns a line item.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `merchantId` - The ID of the managing account.
/// * `orderId` - The ID of the order.
pub fn returnlineitem(&self, request: OrdersReturnLineItemRequest, merchant_id: &str, order_id: &str) -> OrderReturnlineitemCall<'a, C, A> {
OrderReturnlineitemCall {
hub: self.hub,
_request: request,
_merchant_id: merchant_id.to_string(),
_order_id: order_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Sandbox only. Retrieves an order template that can be used to quickly create a new order in sandbox.
///
/// # Arguments
///
/// * `merchantId` - The ID of the managing account.
/// * `templateName` - The name of the template to retrieve.
pub fn gettestordertemplate(&self, merchant_id: &str, template_name: &str) -> OrderGettestordertemplateCall<'a, C, A> {
OrderGettestordertemplateCall {
hub: self.hub,
_merchant_id: merchant_id.to_string(),
_template_name: template_name.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Sandbox only. Creates a test order.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `merchantId` - The ID of the managing account.
pub fn createtestorder(&self, request: OrdersCreateTestOrderRequest, merchant_id: &str) -> OrderCreatetestorderCall<'a, C, A> {
OrderCreatetestorderCall {
hub: self.hub,
_request: request,
_merchant_id: merchant_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Refund a portion of the order, up to the full amount paid.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `merchantId` - The ID of the managing account.
/// * `orderId` - The ID of the order to refund.
pub fn refund(&self, request: OrdersRefundRequest, merchant_id: &str, order_id: &str) -> OrderRefundCall<'a, C, A> {
OrderRefundCall {
hub: self.hub,
_request: request,
_merchant_id: merchant_id.to_string(),
_order_id: order_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Retrieves or modifies multiple orders in a single request.
///
/// # Arguments
///
/// * `request` - No description provided.
pub fn custombatch(&self, request: OrdersCustomBatchRequest) -> OrderCustombatchCall<'a, C, A> {
OrderCustombatchCall {
hub: self.hub,
_request: request,
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Cancels a line item.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `merchantId` - The ID of the managing account.
/// * `orderId` - The ID of the order.
pub fn cancellineitem(&self, request: OrdersCancelLineItemRequest, merchant_id: &str, order_id: &str) -> OrderCancellineitemCall<'a, C, A> {
OrderCancellineitemCall {
hub: self.hub,
_request: request,
_merchant_id: merchant_id.to_string(),
_order_id: order_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Retrieves an order using merchant order id.
///
/// # Arguments
///
/// * `merchantId` - The ID of the managing account.
/// * `merchantOrderId` - The merchant order id to be looked for.
pub fn getbymerchantorderid(&self, merchant_id: &str, merchant_order_id: &str) -> OrderGetbymerchantorderidCall<'a, C, A> {
OrderGetbymerchantorderidCall {
hub: self.hub,
_merchant_id: merchant_id.to_string(),
_merchant_order_id: merchant_order_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Marks an order as acknowledged.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `merchantId` - The ID of the managing account.
/// * `orderId` - The ID of the order.
pub fn acknowledge(&self, request: OrdersAcknowledgeRequest, merchant_id: &str, order_id: &str) -> OrderAcknowledgeCall<'a, C, A> {
OrderAcknowledgeCall {
hub: self.hub,
_request: request,
_merchant_id: merchant_id.to_string(),
_order_id: order_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Cancels all line items in an order.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `merchantId` - The ID of the managing account.
/// * `orderId` - The ID of the order to cancel.
pub fn cancel(&self, request: OrdersCancelRequest, merchant_id: &str, order_id: &str) -> OrderCancelCall<'a, C, A> {
OrderCancelCall {
hub: self.hub,
_request: request,
_merchant_id: merchant_id.to_string(),
_order_id: order_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Marks line item(s) as shipped.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `merchantId` - The ID of the managing account.
/// * `orderId` - The ID of the order.
pub fn shiplineitems(&self, request: OrdersShipLineItemsRequest, merchant_id: &str, order_id: &str) -> OrderShiplineitemCall<'a, C, A> {
OrderShiplineitemCall {
hub: self.hub,
_request: request,
_merchant_id: merchant_id.to_string(),
_order_id: order_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
// ###################
// CallBuilders ###
// #################
/// Retrieves an order from your Merchant Center account.
///
/// A builder for the *get* method supported by a *order* resource.
/// It is not used directly, but through a `OrderMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_content2_sandbox as content2_sandbox;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use content2_sandbox::ShoppingContent;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = ShoppingContent::new(hyper::Client::new(), auth);
/// // 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.orders().get("merchantId", "orderId")
/// .doit();
/// # }
/// ```
pub struct OrderGetCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a ShoppingContent<C, A>,
_merchant_id: String,
_order_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrderGetCall<'a, C, A> {}
impl<'a, C, A> OrderGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, Order)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "content.orders.get",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("merchantId", self._merchant_id.to_string()));
params.push(("orderId", self._order_id.to_string()));
for &field in ["alt", "merchantId", "orderId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/content/v2sandbox/{merchantId}/orders/{orderId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["orderId", "merchantId"].iter() {
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
indices_for_removal.push(index);
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params));
}
loop {
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
Ok(token) => token,
Err(err) => {
match dlg.token(&*err) {
Some(token) => token,
None => {
dlg.finished(false);
return Err(Error::MissingToken(err))
}
}
}
};
let auth_header = Authorization(Bearer { token: token.access_token });
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url)
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep(d);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
json::from_str(&json_err).ok(),
json::from_str(&json_err).ok()) {
sleep(d);
continue;
}
dlg.finished(false);
return match json::from_str::<ErrorResponse>(&json_err){
Err(_) => Err(Error::Failure(res)),
Ok(serr) => Err(Error::BadRequest(serr))
}
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(json_response, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// The ID of the managing account.
///
/// Sets the *merchant id* 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 merchant_id(mut self, new_value: &str) -> OrderGetCall<'a, C, A> {
self._merchant_id = new_value.to_string();
self
}
/// The ID of the order.
///
/// Sets the *order id* 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 order_id(mut self, new_value: &str) -> OrderGetCall<'a, C, A> {
self._order_id = 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.
///
/// 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 Delegate) -> OrderGetCall<'a, C, A> {
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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrderGetCall<'a, C, A>
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 the default `Scope` variant
/// `Scope::Full`.
///
/// 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<T>(mut self, scope: T) -> OrderGetCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Lists the orders in your Merchant Center account.
///
/// A builder for the *list* method supported by a *order* resource.
/// It is not used directly, but through a `OrderMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_content2_sandbox as content2_sandbox;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use content2_sandbox::ShoppingContent;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = ShoppingContent::new(hyper::Client::new(), auth);
/// // 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.orders().list("merchantId")
/// .add_statuses("ea")
/// .placed_date_start("no")
/// .placed_date_end("justo")
/// .page_token("justo")
/// .order_by("et")
/// .max_results(84)
/// .acknowledged(true)
/// .doit();
/// # }
/// ```
pub struct OrderListCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a ShoppingContent<C, A>,
_merchant_id: String,
_statuses: Vec<String>,
_placed_date_start: Option<String>,
_placed_date_end: Option<String>,
_page_token: Option<String>,
_order_by: Option<String>,
_max_results: Option<u32>,
_acknowledged: Option<bool>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrderListCall<'a, C, A> {}
impl<'a, C, A> OrderListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, OrdersListResponse)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "content.orders.list",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len()));
params.push(("merchantId", self._merchant_id.to_string()));
if self._statuses.len() > 0 {
for f in self._statuses.iter() {
params.push(("statuses", f.to_string()));
}
}
if let Some(value) = self._placed_date_start {
params.push(("placedDateStart", value.to_string()));
}
if let Some(value) = self._placed_date_end {
params.push(("placedDateEnd", value.to_string()));
}
if let Some(value) = self._page_token {
params.push(("pageToken", value.to_string()));
}
if let Some(value) = self._order_by {
params.push(("orderBy", value.to_string()));
}
if let Some(value) = self._max_results {
params.push(("maxResults", value.to_string()));
}
if let Some(value) = self._acknowledged {
params.push(("acknowledged", value.to_string()));
}
for &field in ["alt", "merchantId", "statuses", "placedDateStart", "placedDateEnd", "pageToken", "orderBy", "maxResults", "acknowledged"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/content/v2sandbox/{merchantId}/orders".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{merchantId}", "merchantId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["merchantId"].iter() {
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
indices_for_removal.push(index);
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params));
}
loop {
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
Ok(token) => token,
Err(err) => {
match dlg.token(&*err) {
Some(token) => token,
None => {
dlg.finished(false);
return Err(Error::MissingToken(err))
}
}
}
};
let auth_header = Authorization(Bearer { token: token.access_token });
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url)
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep(d);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
json::from_str(&json_err).ok(),
json::from_str(&json_err).ok()) {
sleep(d);
continue;
}
dlg.finished(false);
return match json::from_str::<ErrorResponse>(&json_err){
Err(_) => Err(Error::Failure(res)),
Ok(serr) => Err(Error::BadRequest(serr))
}
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(json_response, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// The ID of the managing account.
///
/// Sets the *merchant id* 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 merchant_id(mut self, new_value: &str) -> OrderListCall<'a, C, A> {
self._merchant_id = new_value.to_string();
self
}
/// Obtains orders that match any of the specified statuses. Multiple values can be specified with comma separation. Additionally, please note that active is a shortcut for pendingShipment and partiallyShipped, and completed is a shortcut for shipped , partiallyDelivered, delivered, partiallyReturned, returned, and canceled.
///
/// Append the given value to the *statuses* query property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
pub fn add_statuses(mut self, new_value: &str) -> OrderListCall<'a, C, A> {
self._statuses.push(new_value.to_string());
self
}
/// Obtains orders placed after this date (inclusively), in ISO 8601 format.
///
/// Sets the *placed date start* query property to the given value.
pub fn placed_date_start(mut self, new_value: &str) -> OrderListCall<'a, C, A> {
self._placed_date_start = Some(new_value.to_string());
self
}
/// Obtains orders placed before this date (exclusively), in ISO 8601 format.
///
/// Sets the *placed date end* query property to the given value.
pub fn placed_date_end(mut self, new_value: &str) -> OrderListCall<'a, C, A> {
self._placed_date_end = Some(new_value.to_string());
self
}
/// The token returned by the previous request.
///
/// Sets the *page token* query property to the given value.
pub fn page_token(mut self, new_value: &str) -> OrderListCall<'a, C, A> {
self._page_token = Some(new_value.to_string());
self
}
/// The ordering of the returned list. The only supported value are placedDate desc and placedDate asc for now, which returns orders sorted by placement date. "placedDate desc" stands for listing orders by placement date, from oldest to most recent. "placedDate asc" stands for listing orders by placement date, from most recent to oldest. In future releases we'll support other sorting criteria.
///
/// Sets the *order by* query property to the given value.
pub fn order_by(mut self, new_value: &str) -> OrderListCall<'a, C, A> {
self._order_by = Some(new_value.to_string());
self
}
/// The maximum number of orders to return in the response, used for paging. The default value is 25 orders per page, and the maximum allowed value is 250 orders per page.
/// Known issue: All List calls will return all Orders without limit regardless of the value of this field.
///
/// Sets the *max results* query property to the given value.
pub fn max_results(mut self, new_value: u32) -> OrderListCall<'a, C, A> {
self._max_results = Some(new_value);
self
}
/// Obtains orders that match the acknowledgement status. When set to true, obtains orders that have been acknowledged. When false, obtains orders that have not been acknowledged.
/// We recommend using this filter set to false, in conjunction with the acknowledge call, such that only un-acknowledged orders are returned.
///
/// Sets the *acknowledged* query property to the given value.
pub fn acknowledged(mut self, new_value: bool) -> OrderListCall<'a, C, A> {
self._acknowledged = Some(new_value);
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// 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 Delegate) -> OrderListCall<'a, C, A> {
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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrderListCall<'a, C, A>
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 the default `Scope` variant
/// `Scope::Full`.
///
/// 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<T>(mut self, scope: T) -> OrderListCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Updates a shipment's status, carrier, and/or tracking ID.
///
/// A builder for the *updateshipment* method supported by a *order* resource.
/// It is not used directly, but through a `OrderMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_content2_sandbox as content2_sandbox;
/// use content2_sandbox::OrdersUpdateShipmentRequest;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use content2_sandbox::ShoppingContent;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = ShoppingContent::new(hyper::Client::new(), 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 = OrdersUpdateShipmentRequest::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.orders().updateshipment(req, "merchantId", "orderId")
/// .doit();
/// # }
/// ```
pub struct OrderUpdateshipmentCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a ShoppingContent<C, A>,
_request: OrdersUpdateShipmentRequest,
_merchant_id: String,
_order_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrderUpdateshipmentCall<'a, C, A> {}
impl<'a, C, A> OrderUpdateshipmentCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, OrdersUpdateShipmentResponse)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "content.orders.updateshipment",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("merchantId", self._merchant_id.to_string()));
params.push(("orderId", self._order_id.to_string()));
for &field in ["alt", "merchantId", "orderId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/content/v2sandbox/{merchantId}/orders/{orderId}/updateShipment".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["orderId", "merchantId"].iter() {
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
indices_for_removal.push(index);
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader =
{
let mut value = json::value::to_value(&self._request);
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.borrow_mut().token(self._scopes.keys()) {
Ok(token) => token,
Err(err) => {
match dlg.token(&*err) {
Some(token) => token,
None => {
dlg.finished(false);
return Err(Error::MissingToken(err))
}
}
}
};
let auth_header = Authorization(Bearer { token: token.access_token });
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url)
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone())
.header(ContentType(json_mime_type.clone()))
.header(ContentLength(request_size as u64))
.body(&mut request_value_reader);
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep(d);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
json::from_str(&json_err).ok(),
json::from_str(&json_err).ok()) {
sleep(d);
continue;
}
dlg.finished(false);
return match json::from_str::<ErrorResponse>(&json_err){
Err(_) => Err(Error::Failure(res)),
Ok(serr) => Err(Error::BadRequest(serr))
}
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(json_response, 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: OrdersUpdateShipmentRequest) -> OrderUpdateshipmentCall<'a, C, A> {
self._request = new_value;
self
}
/// The ID of the managing account.
///
/// Sets the *merchant id* 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 merchant_id(mut self, new_value: &str) -> OrderUpdateshipmentCall<'a, C, A> {
self._merchant_id = new_value.to_string();
self
}
/// The ID of the order.
///
/// Sets the *order id* 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 order_id(mut self, new_value: &str) -> OrderUpdateshipmentCall<'a, C, A> {
self._order_id = 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.
///
/// 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 Delegate) -> OrderUpdateshipmentCall<'a, C, A> {
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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrderUpdateshipmentCall<'a, C, A>
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 the default `Scope` variant
/// `Scope::Full`.
///
/// 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<T>(mut self, scope: T) -> OrderUpdateshipmentCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Sandbox only. Moves a test order from state "inProgress" to state "pendingShipment".
///
/// A builder for the *advancetestorder* method supported by a *order* resource.
/// It is not used directly, but through a `OrderMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_content2_sandbox as content2_sandbox;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use content2_sandbox::ShoppingContent;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = ShoppingContent::new(hyper::Client::new(), auth);
/// // 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.orders().advancetestorder("merchantId", "orderId")
/// .doit();
/// # }
/// ```
pub struct OrderAdvancetestorderCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a ShoppingContent<C, A>,
_merchant_id: String,
_order_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrderAdvancetestorderCall<'a, C, A> {}
impl<'a, C, A> OrderAdvancetestorderCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, OrdersAdvanceTestOrderResponse)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "content.orders.advancetestorder",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("merchantId", self._merchant_id.to_string()));
params.push(("orderId", self._order_id.to_string()));
for &field in ["alt", "merchantId", "orderId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/content/v2sandbox/{merchantId}/testorders/{orderId}/advance".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["orderId", "merchantId"].iter() {
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
indices_for_removal.push(index);
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params));
}
loop {
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
Ok(token) => token,
Err(err) => {
match dlg.token(&*err) {
Some(token) => token,
None => {
dlg.finished(false);
return Err(Error::MissingToken(err))
}
}
}
};
let auth_header = Authorization(Bearer { token: token.access_token });
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url)
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep(d);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
json::from_str(&json_err).ok(),
json::from_str(&json_err).ok()) {
sleep(d);
continue;
}
dlg.finished(false);
return match json::from_str::<ErrorResponse>(&json_err){
Err(_) => Err(Error::Failure(res)),
Ok(serr) => Err(Error::BadRequest(serr))
}
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(json_response, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// The ID of the managing account.
///
/// Sets the *merchant id* 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 merchant_id(mut self, new_value: &str) -> OrderAdvancetestorderCall<'a, C, A> {
self._merchant_id = new_value.to_string();
self
}
/// The ID of the test order to modify.
///
/// Sets the *order id* 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 order_id(mut self, new_value: &str) -> OrderAdvancetestorderCall<'a, C, A> {
self._order_id = 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.
///
/// 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 Delegate) -> OrderAdvancetestorderCall<'a, C, A> {
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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrderAdvancetestorderCall<'a, C, A>
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 the default `Scope` variant
/// `Scope::Full`.
///
/// 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<T>(mut self, scope: T) -> OrderAdvancetestorderCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Updates the merchant order ID for a given order.
///
/// A builder for the *updatemerchantorderid* method supported by a *order* resource.
/// It is not used directly, but through a `OrderMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_content2_sandbox as content2_sandbox;
/// use content2_sandbox::OrdersUpdateMerchantOrderIdRequest;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use content2_sandbox::ShoppingContent;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = ShoppingContent::new(hyper::Client::new(), 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 = OrdersUpdateMerchantOrderIdRequest::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.orders().updatemerchantorderid(req, "merchantId", "orderId")
/// .doit();
/// # }
/// ```
pub struct OrderUpdatemerchantorderidCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a ShoppingContent<C, A>,
_request: OrdersUpdateMerchantOrderIdRequest,
_merchant_id: String,
_order_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrderUpdatemerchantorderidCall<'a, C, A> {}
impl<'a, C, A> OrderUpdatemerchantorderidCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, OrdersUpdateMerchantOrderIdResponse)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "content.orders.updatemerchantorderid",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("merchantId", self._merchant_id.to_string()));
params.push(("orderId", self._order_id.to_string()));
for &field in ["alt", "merchantId", "orderId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/content/v2sandbox/{merchantId}/orders/{orderId}/updateMerchantOrderId".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["orderId", "merchantId"].iter() {
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
indices_for_removal.push(index);
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader =
{
let mut value = json::value::to_value(&self._request);
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.borrow_mut().token(self._scopes.keys()) {
Ok(token) => token,
Err(err) => {
match dlg.token(&*err) {
Some(token) => token,
None => {
dlg.finished(false);
return Err(Error::MissingToken(err))
}
}
}
};
let auth_header = Authorization(Bearer { token: token.access_token });
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url)
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone())
.header(ContentType(json_mime_type.clone()))
.header(ContentLength(request_size as u64))
.body(&mut request_value_reader);
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep(d);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
json::from_str(&json_err).ok(),
json::from_str(&json_err).ok()) {
sleep(d);
continue;
}
dlg.finished(false);
return match json::from_str::<ErrorResponse>(&json_err){
Err(_) => Err(Error::Failure(res)),
Ok(serr) => Err(Error::BadRequest(serr))
}
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(json_response, 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: OrdersUpdateMerchantOrderIdRequest) -> OrderUpdatemerchantorderidCall<'a, C, A> {
self._request = new_value;
self
}
/// The ID of the managing account.
///
/// Sets the *merchant id* 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 merchant_id(mut self, new_value: &str) -> OrderUpdatemerchantorderidCall<'a, C, A> {
self._merchant_id = new_value.to_string();
self
}
/// The ID of the order.
///
/// Sets the *order id* 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 order_id(mut self, new_value: &str) -> OrderUpdatemerchantorderidCall<'a, C, A> {
self._order_id = 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.
///
/// 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 Delegate) -> OrderUpdatemerchantorderidCall<'a, C, A> {
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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrderUpdatemerchantorderidCall<'a, C, A>
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 the default `Scope` variant
/// `Scope::Full`.
///
/// 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<T>(mut self, scope: T) -> OrderUpdatemerchantorderidCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Returns a line item.
///
/// A builder for the *returnlineitem* method supported by a *order* resource.
/// It is not used directly, but through a `OrderMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_content2_sandbox as content2_sandbox;
/// use content2_sandbox::OrdersReturnLineItemRequest;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use content2_sandbox::ShoppingContent;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = ShoppingContent::new(hyper::Client::new(), 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 = OrdersReturnLineItemRequest::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.orders().returnlineitem(req, "merchantId", "orderId")
/// .doit();
/// # }
/// ```
pub struct OrderReturnlineitemCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a ShoppingContent<C, A>,
_request: OrdersReturnLineItemRequest,
_merchant_id: String,
_order_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrderReturnlineitemCall<'a, C, A> {}
impl<'a, C, A> OrderReturnlineitemCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, OrdersReturnLineItemResponse)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "content.orders.returnlineitem",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("merchantId", self._merchant_id.to_string()));
params.push(("orderId", self._order_id.to_string()));
for &field in ["alt", "merchantId", "orderId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/content/v2sandbox/{merchantId}/orders/{orderId}/returnLineItem".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["orderId", "merchantId"].iter() {
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
indices_for_removal.push(index);
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader =
{
let mut value = json::value::to_value(&self._request);
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.borrow_mut().token(self._scopes.keys()) {
Ok(token) => token,
Err(err) => {
match dlg.token(&*err) {
Some(token) => token,
None => {
dlg.finished(false);
return Err(Error::MissingToken(err))
}
}
}
};
let auth_header = Authorization(Bearer { token: token.access_token });
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url)
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone())
.header(ContentType(json_mime_type.clone()))
.header(ContentLength(request_size as u64))
.body(&mut request_value_reader);
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep(d);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
json::from_str(&json_err).ok(),
json::from_str(&json_err).ok()) {
sleep(d);
continue;
}
dlg.finished(false);
return match json::from_str::<ErrorResponse>(&json_err){
Err(_) => Err(Error::Failure(res)),
Ok(serr) => Err(Error::BadRequest(serr))
}
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(json_response, 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: OrdersReturnLineItemRequest) -> OrderReturnlineitemCall<'a, C, A> {
self._request = new_value;
self
}
/// The ID of the managing account.
///
/// Sets the *merchant id* 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 merchant_id(mut self, new_value: &str) -> OrderReturnlineitemCall<'a, C, A> {
self._merchant_id = new_value.to_string();
self
}
/// The ID of the order.
///
/// Sets the *order id* 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 order_id(mut self, new_value: &str) -> OrderReturnlineitemCall<'a, C, A> {
self._order_id = 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.
///
/// 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 Delegate) -> OrderReturnlineitemCall<'a, C, A> {
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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrderReturnlineitemCall<'a, C, A>
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 the default `Scope` variant
/// `Scope::Full`.
///
/// 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<T>(mut self, scope: T) -> OrderReturnlineitemCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Sandbox only. Retrieves an order template that can be used to quickly create a new order in sandbox.
///
/// A builder for the *gettestordertemplate* method supported by a *order* resource.
/// It is not used directly, but through a `OrderMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_content2_sandbox as content2_sandbox;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use content2_sandbox::ShoppingContent;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = ShoppingContent::new(hyper::Client::new(), auth);
/// // 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.orders().gettestordertemplate("merchantId", "templateName")
/// .doit();
/// # }
/// ```
pub struct OrderGettestordertemplateCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a ShoppingContent<C, A>,
_merchant_id: String,
_template_name: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrderGettestordertemplateCall<'a, C, A> {}
impl<'a, C, A> OrderGettestordertemplateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, OrdersGetTestOrderTemplateResponse)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "content.orders.gettestordertemplate",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("merchantId", self._merchant_id.to_string()));
params.push(("templateName", self._template_name.to_string()));
for &field in ["alt", "merchantId", "templateName"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/content/v2sandbox/{merchantId}/testordertemplates/{templateName}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{templateName}", "templateName")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["templateName", "merchantId"].iter() {
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
indices_for_removal.push(index);
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params));
}
loop {
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
Ok(token) => token,
Err(err) => {
match dlg.token(&*err) {
Some(token) => token,
None => {
dlg.finished(false);
return Err(Error::MissingToken(err))
}
}
}
};
let auth_header = Authorization(Bearer { token: token.access_token });
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url)
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep(d);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
json::from_str(&json_err).ok(),
json::from_str(&json_err).ok()) {
sleep(d);
continue;
}
dlg.finished(false);
return match json::from_str::<ErrorResponse>(&json_err){
Err(_) => Err(Error::Failure(res)),
Ok(serr) => Err(Error::BadRequest(serr))
}
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(json_response, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// The ID of the managing account.
///
/// Sets the *merchant id* 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 merchant_id(mut self, new_value: &str) -> OrderGettestordertemplateCall<'a, C, A> {
self._merchant_id = new_value.to_string();
self
}
/// The name of the template to retrieve.
///
/// Sets the *template name* 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 template_name(mut self, new_value: &str) -> OrderGettestordertemplateCall<'a, C, A> {
self._template_name = 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.
///
/// 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 Delegate) -> OrderGettestordertemplateCall<'a, C, A> {
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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrderGettestordertemplateCall<'a, C, A>
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 the default `Scope` variant
/// `Scope::Full`.
///
/// 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<T>(mut self, scope: T) -> OrderGettestordertemplateCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Sandbox only. Creates a test order.
///
/// A builder for the *createtestorder* method supported by a *order* resource.
/// It is not used directly, but through a `OrderMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_content2_sandbox as content2_sandbox;
/// use content2_sandbox::OrdersCreateTestOrderRequest;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use content2_sandbox::ShoppingContent;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = ShoppingContent::new(hyper::Client::new(), 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 = OrdersCreateTestOrderRequest::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.orders().createtestorder(req, "merchantId")
/// .doit();
/// # }
/// ```
pub struct OrderCreatetestorderCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a ShoppingContent<C, A>,
_request: OrdersCreateTestOrderRequest,
_merchant_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrderCreatetestorderCall<'a, C, A> {}
impl<'a, C, A> OrderCreatetestorderCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, OrdersCreateTestOrderResponse)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "content.orders.createtestorder",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("merchantId", self._merchant_id.to_string()));
for &field in ["alt", "merchantId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/content/v2sandbox/{merchantId}/testorders".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{merchantId}", "merchantId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
for param_name in ["merchantId"].iter() {
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
indices_for_removal.push(index);
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader =
{
let mut value = json::value::to_value(&self._request);
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.borrow_mut().token(self._scopes.keys()) {
Ok(token) => token,
Err(err) => {
match dlg.token(&*err) {
Some(token) => token,
None => {
dlg.finished(false);
return Err(Error::MissingToken(err))
}
}
}
};
let auth_header = Authorization(Bearer { token: token.access_token });
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url)
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone())
.header(ContentType(json_mime_type.clone()))
.header(ContentLength(request_size as u64))
.body(&mut request_value_reader);
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep(d);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
json::from_str(&json_err).ok(),
json::from_str(&json_err).ok()) {
sleep(d);
continue;
}
dlg.finished(false);
return match json::from_str::<ErrorResponse>(&json_err){
Err(_) => Err(Error::Failure(res)),
Ok(serr) => Err(Error::BadRequest(serr))
}
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(json_response, 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: OrdersCreateTestOrderRequest) -> OrderCreatetestorderCall<'a, C, A> {
self._request = new_value;
self
}
/// The ID of the managing account.
///
/// Sets the *merchant id* 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 merchant_id(mut self, new_value: &str) -> OrderCreatetestorderCall<'a, C, A> {
self._merchant_id = 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.
///
/// 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 Delegate) -> OrderCreatetestorderCall<'a, C, A> {
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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrderCreatetestorderCall<'a, C, A>
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 the default `Scope` variant
/// `Scope::Full`.
///
/// 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<T>(mut self, scope: T) -> OrderCreatetestorderCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Refund a portion of the order, up to the full amount paid.
///
/// A builder for the *refund* method supported by a *order* resource.
/// It is not used directly, but through a `OrderMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_content2_sandbox as content2_sandbox;
/// use content2_sandbox::OrdersRefundRequest;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use content2_sandbox::ShoppingContent;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = ShoppingContent::new(hyper::Client::new(), 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 = OrdersRefundRequest::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.orders().refund(req, "merchantId", "orderId")
/// .doit();
/// # }
/// ```
pub struct OrderRefundCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a ShoppingContent<C, A>,
_request: OrdersRefundRequest,
_merchant_id: String,
_order_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrderRefundCall<'a, C, A> {}
impl<'a, C, A> OrderRefundCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, OrdersRefundResponse)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "content.orders.refund",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("merchantId", self._merchant_id.to_string()));
params.push(("orderId", self._order_id.to_string()));
for &field in ["alt", "merchantId", "orderId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/content/v2sandbox/{merchantId}/orders/{orderId}/refund".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["orderId", "merchantId"].iter() {
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
indices_for_removal.push(index);
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader =
{
let mut value = json::value::to_value(&self._request);
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.borrow_mut().token(self._scopes.keys()) {
Ok(token) => token,
Err(err) => {
match dlg.token(&*err) {
Some(token) => token,
None => {
dlg.finished(false);
return Err(Error::MissingToken(err))
}
}
}
};
let auth_header = Authorization(Bearer { token: token.access_token });
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url)
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone())
.header(ContentType(json_mime_type.clone()))
.header(ContentLength(request_size as u64))
.body(&mut request_value_reader);
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep(d);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
json::from_str(&json_err).ok(),
json::from_str(&json_err).ok()) {
sleep(d);
continue;
}
dlg.finished(false);
return match json::from_str::<ErrorResponse>(&json_err){
Err(_) => Err(Error::Failure(res)),
Ok(serr) => Err(Error::BadRequest(serr))
}
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(json_response, 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: OrdersRefundRequest) -> OrderRefundCall<'a, C, A> {
self._request = new_value;
self
}
/// The ID of the managing account.
///
/// Sets the *merchant id* 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 merchant_id(mut self, new_value: &str) -> OrderRefundCall<'a, C, A> {
self._merchant_id = new_value.to_string();
self
}
/// The ID of the order to refund.
///
/// Sets the *order id* 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 order_id(mut self, new_value: &str) -> OrderRefundCall<'a, C, A> {
self._order_id = 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.
///
/// 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 Delegate) -> OrderRefundCall<'a, C, A> {
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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrderRefundCall<'a, C, A>
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 the default `Scope` variant
/// `Scope::Full`.
///
/// 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<T>(mut self, scope: T) -> OrderRefundCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Retrieves or modifies multiple orders in a single request.
///
/// A builder for the *custombatch* method supported by a *order* resource.
/// It is not used directly, but through a `OrderMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_content2_sandbox as content2_sandbox;
/// use content2_sandbox::OrdersCustomBatchRequest;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use content2_sandbox::ShoppingContent;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = ShoppingContent::new(hyper::Client::new(), 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 = OrdersCustomBatchRequest::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.orders().custombatch(req)
/// .doit();
/// # }
/// ```
pub struct OrderCustombatchCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a ShoppingContent<C, A>,
_request: OrdersCustomBatchRequest,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrderCustombatchCall<'a, C, A> {}
impl<'a, C, A> OrderCustombatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, OrdersCustomBatchResponse)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "content.orders.custombatch",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
for &field in ["alt"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/content/v2sandbox/orders/batch".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader =
{
let mut value = json::value::to_value(&self._request);
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.borrow_mut().token(self._scopes.keys()) {
Ok(token) => token,
Err(err) => {
match dlg.token(&*err) {
Some(token) => token,
None => {
dlg.finished(false);
return Err(Error::MissingToken(err))
}
}
}
};
let auth_header = Authorization(Bearer { token: token.access_token });
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url)
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone())
.header(ContentType(json_mime_type.clone()))
.header(ContentLength(request_size as u64))
.body(&mut request_value_reader);
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep(d);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
json::from_str(&json_err).ok(),
json::from_str(&json_err).ok()) {
sleep(d);
continue;
}
dlg.finished(false);
return match json::from_str::<ErrorResponse>(&json_err){
Err(_) => Err(Error::Failure(res)),
Ok(serr) => Err(Error::BadRequest(serr))
}
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(json_response, 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: OrdersCustomBatchRequest) -> OrderCustombatchCall<'a, C, A> {
self._request = new_value;
self
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// 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 Delegate) -> OrderCustombatchCall<'a, C, A> {
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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrderCustombatchCall<'a, C, A>
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 the default `Scope` variant
/// `Scope::Full`.
///
/// 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<T>(mut self, scope: T) -> OrderCustombatchCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Cancels a line item.
///
/// A builder for the *cancellineitem* method supported by a *order* resource.
/// It is not used directly, but through a `OrderMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_content2_sandbox as content2_sandbox;
/// use content2_sandbox::OrdersCancelLineItemRequest;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use content2_sandbox::ShoppingContent;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = ShoppingContent::new(hyper::Client::new(), 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 = OrdersCancelLineItemRequest::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.orders().cancellineitem(req, "merchantId", "orderId")
/// .doit();
/// # }
/// ```
pub struct OrderCancellineitemCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a ShoppingContent<C, A>,
_request: OrdersCancelLineItemRequest,
_merchant_id: String,
_order_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrderCancellineitemCall<'a, C, A> {}
impl<'a, C, A> OrderCancellineitemCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, OrdersCancelLineItemResponse)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "content.orders.cancellineitem",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("merchantId", self._merchant_id.to_string()));
params.push(("orderId", self._order_id.to_string()));
for &field in ["alt", "merchantId", "orderId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/content/v2sandbox/{merchantId}/orders/{orderId}/cancelLineItem".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["orderId", "merchantId"].iter() {
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
indices_for_removal.push(index);
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader =
{
let mut value = json::value::to_value(&self._request);
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.borrow_mut().token(self._scopes.keys()) {
Ok(token) => token,
Err(err) => {
match dlg.token(&*err) {
Some(token) => token,
None => {
dlg.finished(false);
return Err(Error::MissingToken(err))
}
}
}
};
let auth_header = Authorization(Bearer { token: token.access_token });
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url)
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone())
.header(ContentType(json_mime_type.clone()))
.header(ContentLength(request_size as u64))
.body(&mut request_value_reader);
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep(d);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
json::from_str(&json_err).ok(),
json::from_str(&json_err).ok()) {
sleep(d);
continue;
}
dlg.finished(false);
return match json::from_str::<ErrorResponse>(&json_err){
Err(_) => Err(Error::Failure(res)),
Ok(serr) => Err(Error::BadRequest(serr))
}
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(json_response, 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: OrdersCancelLineItemRequest) -> OrderCancellineitemCall<'a, C, A> {
self._request = new_value;
self
}
/// The ID of the managing account.
///
/// Sets the *merchant id* 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 merchant_id(mut self, new_value: &str) -> OrderCancellineitemCall<'a, C, A> {
self._merchant_id = new_value.to_string();
self
}
/// The ID of the order.
///
/// Sets the *order id* 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 order_id(mut self, new_value: &str) -> OrderCancellineitemCall<'a, C, A> {
self._order_id = 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.
///
/// 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 Delegate) -> OrderCancellineitemCall<'a, C, A> {
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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrderCancellineitemCall<'a, C, A>
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 the default `Scope` variant
/// `Scope::Full`.
///
/// 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<T>(mut self, scope: T) -> OrderCancellineitemCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Retrieves an order using merchant order id.
///
/// A builder for the *getbymerchantorderid* method supported by a *order* resource.
/// It is not used directly, but through a `OrderMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_content2_sandbox as content2_sandbox;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use content2_sandbox::ShoppingContent;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = ShoppingContent::new(hyper::Client::new(), auth);
/// // 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.orders().getbymerchantorderid("merchantId", "merchantOrderId")
/// .doit();
/// # }
/// ```
pub struct OrderGetbymerchantorderidCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a ShoppingContent<C, A>,
_merchant_id: String,
_merchant_order_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrderGetbymerchantorderidCall<'a, C, A> {}
impl<'a, C, A> OrderGetbymerchantorderidCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, OrdersGetByMerchantOrderIdResponse)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "content.orders.getbymerchantorderid",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("merchantId", self._merchant_id.to_string()));
params.push(("merchantOrderId", self._merchant_order_id.to_string()));
for &field in ["alt", "merchantId", "merchantOrderId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/content/v2sandbox/{merchantId}/ordersbymerchantid/{merchantOrderId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{merchantOrderId}", "merchantOrderId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["merchantOrderId", "merchantId"].iter() {
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
indices_for_removal.push(index);
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params));
}
loop {
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
Ok(token) => token,
Err(err) => {
match dlg.token(&*err) {
Some(token) => token,
None => {
dlg.finished(false);
return Err(Error::MissingToken(err))
}
}
}
};
let auth_header = Authorization(Bearer { token: token.access_token });
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Get, &url)
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep(d);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
json::from_str(&json_err).ok(),
json::from_str(&json_err).ok()) {
sleep(d);
continue;
}
dlg.finished(false);
return match json::from_str::<ErrorResponse>(&json_err){
Err(_) => Err(Error::Failure(res)),
Ok(serr) => Err(Error::BadRequest(serr))
}
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(json_response, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// The ID of the managing account.
///
/// Sets the *merchant id* 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 merchant_id(mut self, new_value: &str) -> OrderGetbymerchantorderidCall<'a, C, A> {
self._merchant_id = new_value.to_string();
self
}
/// The merchant order id to be looked for.
///
/// Sets the *merchant order id* 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 merchant_order_id(mut self, new_value: &str) -> OrderGetbymerchantorderidCall<'a, C, A> {
self._merchant_order_id = 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.
///
/// 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 Delegate) -> OrderGetbymerchantorderidCall<'a, C, A> {
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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrderGetbymerchantorderidCall<'a, C, A>
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 the default `Scope` variant
/// `Scope::Full`.
///
/// 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<T>(mut self, scope: T) -> OrderGetbymerchantorderidCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Marks an order as acknowledged.
///
/// A builder for the *acknowledge* method supported by a *order* resource.
/// It is not used directly, but through a `OrderMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_content2_sandbox as content2_sandbox;
/// use content2_sandbox::OrdersAcknowledgeRequest;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use content2_sandbox::ShoppingContent;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = ShoppingContent::new(hyper::Client::new(), 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 = OrdersAcknowledgeRequest::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.orders().acknowledge(req, "merchantId", "orderId")
/// .doit();
/// # }
/// ```
pub struct OrderAcknowledgeCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a ShoppingContent<C, A>,
_request: OrdersAcknowledgeRequest,
_merchant_id: String,
_order_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrderAcknowledgeCall<'a, C, A> {}
impl<'a, C, A> OrderAcknowledgeCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, OrdersAcknowledgeResponse)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "content.orders.acknowledge",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("merchantId", self._merchant_id.to_string()));
params.push(("orderId", self._order_id.to_string()));
for &field in ["alt", "merchantId", "orderId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/content/v2sandbox/{merchantId}/orders/{orderId}/acknowledge".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["orderId", "merchantId"].iter() {
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
indices_for_removal.push(index);
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader =
{
let mut value = json::value::to_value(&self._request);
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.borrow_mut().token(self._scopes.keys()) {
Ok(token) => token,
Err(err) => {
match dlg.token(&*err) {
Some(token) => token,
None => {
dlg.finished(false);
return Err(Error::MissingToken(err))
}
}
}
};
let auth_header = Authorization(Bearer { token: token.access_token });
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url)
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone())
.header(ContentType(json_mime_type.clone()))
.header(ContentLength(request_size as u64))
.body(&mut request_value_reader);
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep(d);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
json::from_str(&json_err).ok(),
json::from_str(&json_err).ok()) {
sleep(d);
continue;
}
dlg.finished(false);
return match json::from_str::<ErrorResponse>(&json_err){
Err(_) => Err(Error::Failure(res)),
Ok(serr) => Err(Error::BadRequest(serr))
}
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(json_response, 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: OrdersAcknowledgeRequest) -> OrderAcknowledgeCall<'a, C, A> {
self._request = new_value;
self
}
/// The ID of the managing account.
///
/// Sets the *merchant id* 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 merchant_id(mut self, new_value: &str) -> OrderAcknowledgeCall<'a, C, A> {
self._merchant_id = new_value.to_string();
self
}
/// The ID of the order.
///
/// Sets the *order id* 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 order_id(mut self, new_value: &str) -> OrderAcknowledgeCall<'a, C, A> {
self._order_id = 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.
///
/// 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 Delegate) -> OrderAcknowledgeCall<'a, C, A> {
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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrderAcknowledgeCall<'a, C, A>
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 the default `Scope` variant
/// `Scope::Full`.
///
/// 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<T>(mut self, scope: T) -> OrderAcknowledgeCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Cancels all line items in an order.
///
/// A builder for the *cancel* method supported by a *order* resource.
/// It is not used directly, but through a `OrderMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_content2_sandbox as content2_sandbox;
/// use content2_sandbox::OrdersCancelRequest;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use content2_sandbox::ShoppingContent;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = ShoppingContent::new(hyper::Client::new(), 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 = OrdersCancelRequest::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.orders().cancel(req, "merchantId", "orderId")
/// .doit();
/// # }
/// ```
pub struct OrderCancelCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a ShoppingContent<C, A>,
_request: OrdersCancelRequest,
_merchant_id: String,
_order_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrderCancelCall<'a, C, A> {}
impl<'a, C, A> OrderCancelCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, OrdersCancelResponse)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "content.orders.cancel",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("merchantId", self._merchant_id.to_string()));
params.push(("orderId", self._order_id.to_string()));
for &field in ["alt", "merchantId", "orderId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/content/v2sandbox/{merchantId}/orders/{orderId}/cancel".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["orderId", "merchantId"].iter() {
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
indices_for_removal.push(index);
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader =
{
let mut value = json::value::to_value(&self._request);
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.borrow_mut().token(self._scopes.keys()) {
Ok(token) => token,
Err(err) => {
match dlg.token(&*err) {
Some(token) => token,
None => {
dlg.finished(false);
return Err(Error::MissingToken(err))
}
}
}
};
let auth_header = Authorization(Bearer { token: token.access_token });
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url)
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone())
.header(ContentType(json_mime_type.clone()))
.header(ContentLength(request_size as u64))
.body(&mut request_value_reader);
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep(d);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
json::from_str(&json_err).ok(),
json::from_str(&json_err).ok()) {
sleep(d);
continue;
}
dlg.finished(false);
return match json::from_str::<ErrorResponse>(&json_err){
Err(_) => Err(Error::Failure(res)),
Ok(serr) => Err(Error::BadRequest(serr))
}
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(json_response, 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: OrdersCancelRequest) -> OrderCancelCall<'a, C, A> {
self._request = new_value;
self
}
/// The ID of the managing account.
///
/// Sets the *merchant id* 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 merchant_id(mut self, new_value: &str) -> OrderCancelCall<'a, C, A> {
self._merchant_id = new_value.to_string();
self
}
/// The ID of the order to cancel.
///
/// Sets the *order id* 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 order_id(mut self, new_value: &str) -> OrderCancelCall<'a, C, A> {
self._order_id = 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.
///
/// 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 Delegate) -> OrderCancelCall<'a, C, A> {
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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrderCancelCall<'a, C, A>
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 the default `Scope` variant
/// `Scope::Full`.
///
/// 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<T>(mut self, scope: T) -> OrderCancelCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Marks line item(s) as shipped.
///
/// A builder for the *shiplineitems* method supported by a *order* resource.
/// It is not used directly, but through a `OrderMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_content2_sandbox as content2_sandbox;
/// use content2_sandbox::OrdersShipLineItemsRequest;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use content2_sandbox::ShoppingContent;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = ShoppingContent::new(hyper::Client::new(), 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 = OrdersShipLineItemsRequest::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.orders().shiplineitems(req, "merchantId", "orderId")
/// .doit();
/// # }
/// ```
pub struct OrderShiplineitemCall<'a, C, A>
where C: 'a, A: 'a {
hub: &'a ShoppingContent<C, A>,
_request: OrdersShipLineItemsRequest,
_merchant_id: String,
_order_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, A> CallBuilder for OrderShiplineitemCall<'a, C, A> {}
impl<'a, C, A> OrderShiplineitemCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, OrdersShipLineItemsResponse)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "content.orders.shiplineitems",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("merchantId", self._merchant_id.to_string()));
params.push(("orderId", self._order_id.to_string()));
for &field in ["alt", "merchantId", "orderId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/content/v2sandbox/{merchantId}/orders/{orderId}/shipLineItems".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{merchantId}", "merchantId"), ("{orderId}", "orderId")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["orderId", "merchantId"].iter() {
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
indices_for_removal.push(index);
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader =
{
let mut value = json::value::to_value(&self._request);
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.borrow_mut().token(self._scopes.keys()) {
Ok(token) => token,
Err(err) => {
match dlg.token(&*err) {
Some(token) => token,
None => {
dlg.finished(false);
return Err(Error::MissingToken(err))
}
}
}
};
let auth_header = Authorization(Bearer { token: token.access_token });
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url)
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone())
.header(ContentType(json_mime_type.clone()))
.header(ContentLength(request_size as u64))
.body(&mut request_value_reader);
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep(d);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
json::from_str(&json_err).ok(),
json::from_str(&json_err).ok()) {
sleep(d);
continue;
}
dlg.finished(false);
return match json::from_str::<ErrorResponse>(&json_err){
Err(_) => Err(Error::Failure(res)),
Ok(serr) => Err(Error::BadRequest(serr))
}
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(json_response, 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: OrdersShipLineItemsRequest) -> OrderShiplineitemCall<'a, C, A> {
self._request = new_value;
self
}
/// The ID of the managing account.
///
/// Sets the *merchant id* 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 merchant_id(mut self, new_value: &str) -> OrderShiplineitemCall<'a, C, A> {
self._merchant_id = new_value.to_string();
self
}
/// The ID of the order.
///
/// Sets the *order id* 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 order_id(mut self, new_value: &str) -> OrderShiplineitemCall<'a, C, A> {
self._order_id = 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.
///
/// 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 Delegate) -> OrderShiplineitemCall<'a, C, A> {
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 paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *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. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *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.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> OrderShiplineitemCall<'a, C, A>
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 the default `Scope` variant
/// `Scope::Full`.
///
/// 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<T>(mut self, scope: T) -> OrderShiplineitemCall<'a, C, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}