syntax = "proto3";

package wix.catalog.api.v1;

import "wix/api/validations.proto";
import "google/protobuf/wrappers.proto";

message Media {
    // Primary media (image, video etc) associated with this product.
    MediaItem main_media = 1;
    // Media (images, videos etc) associated with this product.
    repeated MediaItem items = 2;
}

message MediaItem {
    // Media item thumbnail details.
    MediaItemUrlAndSize thumbnail = 1;
    // Media item type (image, video, etc.).
    MediaItemType media_type = 2;
    // Media item title.
    string title = 3;
    oneof item {
        // Image data (URL, size).
        MediaItemUrlAndSize image = 4;
        // Video data (URL, size).
        MediaItemVideo video = 5;
    }
    // Media ID (for example, `"nsplsh_306d666a123a4a74306459~mv2_d_4517_2992_s_4_2.jpg"`).
    string id = 6;
}

message MediaItemUrlAndSize {
    // Media item URL.
    string url = 1 [(wix.api.format) = WEB_URL];
    // Media item width.
    int32 width = 2 [(wix.api.min) = 0];
    // Media item height.
    int32 height = 3 [(wix.api.min) = 0];
    // Media format (mp4, png, etc.).
    google.protobuf.StringValue format = 4;
    // Alt text. This text will be shown in case the image is not available.
    google.protobuf.StringValue alt_text = 5;
}

message MediaItemVideo {
    // Data (URL, size) about each resolution for which this video is available.
    repeated MediaItemUrlAndSize files = 1;
    // ID of an image taken from the video. Used primarily for Wix Search indexing. For example, `"nsplsh_306d666a123a4a74306459~mv2_d_4517_2992_s_4_2.jpg"`.
    string still_frame_media_id = 2;
}

enum MediaItemType {
    unspecified_media_item_type = 0;
    // Image media type.
    image = 1;
    // Video media type.
    video = 2;
    // Audio media type.
    audio = 3;
    // Document media type.
    document = 4;
    // Zip media type.
    zip = 5;
}

message MediaDataForWrite {
    message OptionAndChoice {
        // Option to add the media to.
        string option = 1 [(wix.api.minLength) = 1, (wix.api.maxLength) = 50];
        // Choice to add the media to.
        string choice = 2 [(wix.api.minLength) = 1, (wix.api.maxLength) = 50];
    }

    oneof media_source {
        // Media ID. For media items previously saved in Wix Media, the media ID is returned in the Query Product response.
        string mediaId = 1;
        // Media external URL (for new media items).
        string url = 2 [(wix.api.format) = WEB_URL];
    }

    // Assign this media item to a specific product choice.
    // Note that you may set media items for choices under only one option (e.g., if Colors blue, green, and red have media items, Sizes S, M, and L can't have media items assigned to them).
    // You may clear existing media from choices with the [Remove Product Media From Choices](/catalog/products/remove-product-media-from-choices).
    OptionAndChoice choice = 3;
}

message MediaAssignmentToChoice {
    // Option name.
    string option = 1 [(wix.api.minLength) = 1, (wix.api.maxLength) = 50];
    // Choice name.
    string choice = 2 [(wix.api.minLength) = 1, (wix.api.maxLength) = 50];
    // Media IDs (available via the Query Product endpoint).
    repeated string media_ids = 3 [(wix.api.maxSize) = 50];
}