import "common_base.proto";
import "common.proto";

message AccountCartContents {
	repeated .AccountCartLineItem line_items = 1;
	optional .CartAmount subtotal = 2;
	optional bool is_valid = 3;
	optional .AccountCartValidationDetails validation_details = 4;
}

message AccountCartLineItem {
	optional uint64 line_item_id = 1;
	optional int32 type = 2 [(.description) = "enum"];
	optional uint32 packageid = 3;
	optional uint32 bundleid = 4;
	optional bool is_valid = 8;
	optional .AccountCartValidationDetails validation_details = 9;
	optional uint32 time_added = 10;
	optional .CartAmount price_when_added = 11;
	optional .CartGiftInfo gift_info = 12;
	optional .AccountCartLineItemFlags flags = 13;
	optional uint64 gidcoupon_applied = 14;
}

message AccountCartLineItemFlags {
	optional bool is_gift = 1;
	optional bool is_private = 2;
}

message AccountCartValidationDetails {
	optional int32 validation_failure = 1 [default = 0, (.description) = "enum"];
}

message CAccountCart_AddItemsToCart_Request {
	optional string user_country = 1;
	repeated .CAccountCart_AddItemsToCart_Request_ItemToAdd items = 2;
	optional .CUserInterface_NavData navdata = 3;
}

message CAccountCart_AddItemsToCart_Request_ItemToAdd {
	optional uint32 packageid = 1;
	optional uint32 bundleid = 2;
	optional .CartGiftInfo gift_info = 10;
	optional .AccountCartLineItemFlags flags = 11;
}

message CAccountCart_AddItemsToCart_Response {
	repeated uint64 line_item_ids = 1;
	optional .AccountCartContents cart = 2;
	repeated uint32 replaced_packages = 3;
	optional uint64 existing_billing_agreementid = 4;
	optional uint32 new_billing_agreement_recurring_packageid = 5;
}

message CAccountCart_DeleteCart_Request {
}

message CAccountCart_DeleteCart_Response {
}

message CAccountCart_GetCart_Request {
	optional string user_country = 1;
}

message CAccountCart_GetCart_Response {
	optional .AccountCartContents cart = 1;
}

message CAccountCart_GetRelevantCoupons_Request {
	optional uint32 language = 1;
}

message CAccountCart_GetRelevantCoupons_Response {
	repeated .CAccountCart_GetRelevantCoupons_Response_LineItemCoupons line_items = 1;
}

message CAccountCart_GetRelevantCoupons_Response_LineItemCoupons {
	optional uint64 line_item_id = 1;
	repeated .CartCoupon coupons = 2;
}

message CAccountCart_MergeShoppingCartContents_Request {
	optional fixed64 gidshoppingcart = 1;
	optional string user_country = 2;
}

message CAccountCart_MergeShoppingCartContents_Response {
	optional .AccountCartContents cart = 1;
}

message CAccountCart_ModifyLineItem_Request {
	optional uint64 line_item_id = 1;
	optional string user_country = 2;
	optional .CartGiftInfo gift_info = 10;
	optional .AccountCartLineItemFlags flags = 11;
	optional uint64 apply_gidcoupon = 12;
}

message CAccountCart_ModifyLineItem_Response {
	optional .AccountCartContents cart = 1;
}

message CAccountCart_RemoveItemFromCart_Request {
	optional uint64 line_item_id = 1;
	optional string user_country = 2;
}

message CAccountCart_RemoveItemFromCart_Response {
	optional .AccountCartContents cart = 1;
}

service AccountCart {
	// ePrivilege=1
	rpc AddItemsToCart (.CAccountCart_AddItemsToCart_Request) returns (.CAccountCart_AddItemsToCart_Response);
	// ePrivilege=1
	rpc DeleteCart (.CAccountCart_DeleteCart_Request) returns (.CAccountCart_DeleteCart_Response);
	// bConstMethod=true, ePrivilege=1
	rpc GetCart (.CAccountCart_GetCart_Request) returns (.CAccountCart_GetCart_Response);
	// ePrivilege=1
	rpc GetRelevantCoupons (.CAccountCart_GetRelevantCoupons_Request) returns (.CAccountCart_GetRelevantCoupons_Response);
	// ePrivilege=1
	rpc MergeShoppingCartContents (.CAccountCart_MergeShoppingCartContents_Request) returns (.CAccountCart_MergeShoppingCartContents_Response);
	// ePrivilege=1
	rpc ModifyLineItem (.CAccountCart_ModifyLineItem_Request) returns (.CAccountCart_ModifyLineItem_Response);
	// ePrivilege=1
	rpc RemoveItemFromCart (.CAccountCart_RemoveItemFromCart_Request) returns (.CAccountCart_RemoveItemFromCart_Response);
}

