syntax = "proto3";

package wix.catalog.api.v1;

import "google/api/annotations.proto";
import "wix/api/validations.proto";
import "wix/api/annotations.proto";
import "wix/api/permissions.proto";
import "wix/catalog/api/v1/query.proto";
import "wix/catalog/api/v1/productOption.proto";
import "wix/catalog/api/v1/ribbon.proto";

option java_package = "com.wix.ecommerce.catalog.api.v1";

service CatalogReadAPINotReviewed {
    option (wix.api.service_exposure) = PRIVATE;

    //Returns up to 100 options
    rpc ListOptions (ListOptionsRequest) returns (ListOptionsResponse) {
        option (google.api.http) = {
            get: "/v1/options"
        };
        option (wix.api.maturity) = ALPHA;

        option (wix.api.permission).name = "WIX_STORES.READ_PRODUCTS";
    }

    rpc ListRibbons (ListRibbonsRequest) returns (ListRibbonsResponse) {
        option (google.api.http) = {
            get: "/v1/ribbons"
        };
        option (wix.api.maturity) = ALPHA;

        option (wix.api.permission).name = "WIX_STORES.READ_PRODUCTS";
    }
}

message ListOptionsRequest {
    Paging paging = 1;
}

message ListOptionsResponse {
    //Options in store that satisfy request
    repeated ProductOptionInBank options = 1;
    PagingMetadata metadata = 2;
    //Number of all options in store that satisfy request
    int32 total_results = 3;
}

message ListRibbonsRequest {
    Paging paging = 2;
}

message ListRibbonsResponse {
    repeated RibbonInBank ribbons = 1;
    PagingMetadata metadata = 2;
    //Number of all ribbons in store that satisfy request
    int32 total_results = 3;
}

service CatalogWriteAPINotReviewed {
    option (wix.api.service_exposure) = PRIVATE;

    //delete all additional info sections from product
    // Need to add full CRUD
    rpc DeleteProductAdditionalInfoSections (DeleteProductAdditionalInfoSectionsRequest) returns (DeleteProductAdditionalInfoSectionsResponse) {
        option (wix.api.required) = "DeleteProductAdditionalInfoSectionsRequest.id";
        option (google.api.http) = {
            delete: "/v1/products/{id}/additionalInfoSections"
        };
        option (wix.api.maturity) = ALPHA;

        option (wix.api.permission).name = "WIX_STORES.MODIFY_PRODUCTS";
    }

    //delete all custom text fields from product
    // Need to add full CRUD
    rpc DeleteProductCustomTextFields (DeleteProductCustomTextFieldsRequest) returns (DeleteProductCustomTextFieldsResponse) {
        option (wix.api.required) = "DeleteProductCustomTextFieldsRequest.id";
        option (google.api.http) = {
            delete: "/v1/products/{id}/customTextFields"
        };
        option (wix.api.maturity) = ALPHA;

        option (wix.api.permission).name = "WIX_STORES.MODIFY_PRODUCTS";
    }

    // update or delete media of collection
    // Change API to be like product media
    rpc UpdateCollectionMedia (UpdateCollectionMediaRequest) returns (UpdateCollectionMediaResponse) {
        option (wix.api.required) = "UpdateCollectionMediaRequest.id";
        option (wix.api.required) = "UpdateCollectionMediaRequest.callback_url";
        option (google.api.http) = {
            patch: "/v1/collections/{id}/media"
        };
        option (wix.api.maturity) = ALPHA;

        option (wix.api.permission).name = "WIX_STORES.MODIFY_PRODUCTS";
    }

    // Change API to be like product media
    rpc DeleteCollectionMedia (DeleteCollectionMediaRequest) returns (DeleteCollectionMediaResponse) {
        option (wix.api.required) = "DeleteCollectionMediaRequest.id";
        option (google.api.http) = {
            delete: "/v1/collections/{id}/media"
        };
        option (wix.api.maturity) = ALPHA;

        option (wix.api.permission).name = "WIX_STORES.MODIFY_PRODUCTS";
    }

    //rename option across all store
    rpc RenameOption (RenameOptionRequest) returns (RenameOptionResponse) {
        option (wix.api.required) = "RenameOptionRequest.id";
        option (google.api.http) = {
            post: "/v1/options/{id}/rename"
        };
        option (wix.api.maturity) = ALPHA;

        option (wix.api.permission).name = "WIX_STORES.MODIFY_PRODUCTS";
    }

    //rename ribbon across all store
    rpc RenameRibbon (RenameRibbonRequest) returns (RenameRibbonResponse) {
        option (wix.api.required) = "RenameRibbonRequest.id";
        option (google.api.http) = {
            post: "/v1/ribbons/{id}/rename"
        };
        option (wix.api.maturity) = ALPHA;

        option (wix.api.permission).name = "WIX_STORES.MODIFY_PRODUCTS";
    }

    //delete ribbon from all products in store
    rpc DeleteRibbon (DeleteRibbonRequest) returns (DeleteRibbonResponse) {
        option (wix.api.required) = "DeleteRibbonRequest.id";
        option (google.api.http) = {
            delete: "/v1/ribbons/{id}"
        };
        option (wix.api.maturity) = ALPHA;

        option (wix.api.permission).name = "WIX_STORES.MODIFY_PRODUCTS";
    }


    rpc SetProductCustomData (SetProductCustomDataRequest) returns (SetProductCustomDataResponse) {
        option (wix.api.required) = "SetProductCustomDataRequest.id";
        option (google.api.http) = {
            patch: "/v1/products/{id}/custom_data"
        };

        option (wix.api.permission).name = "WIX_STORES.MODIFY_PRODUCTS";
    }

    rpc RemoveProductCustomData (RemoveProductCustomDataRequest) returns (RemoveProductCustomDataResponse) {
        option (wix.api.required) = "RemoveProductCustomDataRequest.id";
        option (google.api.http) = {
            delete: "/v1/products/{id}/custom_data/{key}"
        };

        option (wix.api.permission).name = "WIX_STORES.MODIFY_PRODUCTS";
    }

    // Need to add full CRUD for options
}

message UpdateCollectionMediaRequest {
    //id of collection
    string id = 1;
    //new media, don't send it if you want to remove media
    //MediaDataForWrite media = 2;
    //callback URL
    string callback_url = 3;
}

message UpdateCollectionMediaResponse {
}

message DeleteCollectionMediaRequest {
    //id of collection
    string id = 1;
}

message DeleteCollectionMediaResponse {
}

message SetProductCustomDataRequest {
    // id of product
    string id = 1;
    // Data to set
    map<string, string> custom_data = 2;
}

message SetProductCustomDataResponse {

}

message RemoveProductCustomDataRequest {
    // id of product
    string id = 1;
    // Key to remove
    string key = 2;
}

message RemoveProductCustomDataResponse {

}

message DeleteProductAdditionalInfoSectionsRequest {
    //id of product
    string id = 1;
}

message DeleteProductAdditionalInfoSectionsResponse {
}

message DeleteProductRibbonsRequest {
    //id of product
    string id = 1;
}

message DeleteProductRibbonsResponse {
}

message DeleteProductCustomTextFieldsRequest {
    //id of product
    string id = 1;
}

message DeleteProductCustomTextFieldsResponse {
}

message RenameOptionRequest {
    //id of option
    string id = 1;
    //new option name
    string name = 3 [(wix.api.maxLength)=50];
}

message RenameOptionResponse {
}

message RenameRibbonRequest {
    //id of ribbon
    string id = 1;
    // The text that will appear on the ribbon
    string text = 2[(wix.api.maxLength)=30];
}

message RenameRibbonResponse {
}

message DeleteRibbonRequest {
    //id of ribbon
    string id = 1;
}

message DeleteRibbonResponse {
}
