commit d713dab392eea105838563deacf6265e3b6d1154 Author: Alexander Garin Date: Tue Apr 4 22:45:55 2023 +0300 - Init project diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8e14d26 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +*.exe +*.exe~ +*.dll +*.so +*.dylib +*.test +*.out +go.work +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf +.idea/**/aws.xml +.idea/**/contentModel.xml +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml +.idea/**/gradle.xml +.idea/**/libraries +cmake-build-*/ +.idea/**/mongoSettings.xml +*.iws +out/ +.idea_modules/ +atlassian-ide-plugin.xml +.idea/replstate.xml +.idea/sonarlint/ +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties +.idea/httpRequests +.idea/caches/build_file_checksums.ser diff --git a/api/swagger.yaml b/api/swagger.yaml new file mode 100644 index 0000000..7824acc --- /dev/null +++ b/api/swagger.yaml @@ -0,0 +1,422 @@ +openapi: 3.0.3 + +info: + title: YouTube Kids Public API + description: For generate API REST clients for Feelter UGC + contact: + email: garin1221@yandex.ru + version: 1.0.0 + +servers: + - url: https://www.youtubekids.com/youtubei/v1 + +tags: + - name: browse + description: Browse resource content + +paths: + + # Получение контента определенного ресурса, {browseId} + /browse: + post: + tags: + - browse + summary: Browse resource content + description: Get content for resource + operationId: browse + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/BrowseRequestPayload' + responses: + '200': + description: OK + content: + 'application/json': + "schema": + $ref: '#/components/schemas/BrowseResponsePayload' + '400': + description: Bad Request + content: + 'application/json': + "schema": + $ref: '#/components/schemas/ErrorResponsePayload' + +# Компоненты +components: + # Схемы данных + schemas: + + # Ошибка + Error: + type: object + properties: + message: + type: string + domain: + type: string + reason: + type: string + + # Доступность данных + AccessibilityData: + type: object + properties: + label: + type: string + + # Доступность + Accessibility: + type: object + properties: + accessibilityData: + $ref: '#/components/schemas/AccessibilityData' + + # WatchEndpoint + WatchEndpoint: + type: object + properties: + videoId: + type: string + + # BrowseEndpoint + BrowseEndpoint: + type: object + properties: + browseId: + type: string + canonicalBaseUrl: + type: string + + # Конечная точка навигации + NavigationEndpoint: + type: object + properties: + clickTrackingParams: + type: string + watchEndpoint: + $ref: '#/components/schemas/WatchEndpoint' + browseEndpoint: + $ref: '#/components/schemas/BrowseEndpoint' + + # Текст -> Runs + TextRun: + type: object + properties: + text: + type: string + navigationEndpoint: + $ref: '#/components/schemas/NavigationEndpoint' + + # Текст + Text: + type: object + properties: + runs: + type: array + items: + $ref: '#/components/schemas/TextRun' + accessibility: + $ref: '#/components/schemas/Accessibility' + + # Строковый параметр ключ-зачение + KeyStringValue: + type: object + properties: + key: + type: string + value: + type: string + + # Ассеты категории + CategoryAssets: + type: object + properties: + assetKey: + type: string + backgroundColor: + type: string + + # Расширение для владельцев детских видео + KidsVideoOwnerExtension: + type: object + properties: + externalChannelId: + type: string + + # Thumbnail + Thumbnail: + type: object + properties: + url: + type: string + width: + type: number + height: + type: number + + # Компактный видеорендерер + CompactVideoRenderer: + type: object + properties: + videoId: + type: string + thumbnail: + type: object + properties: + thumbnails: + type: array + items: + $ref: '#/components/schemas/Thumbnail' + title: + $ref: '#/components/schemas/Text' + longBylineText: + $ref: '#/components/schemas/Text' + publishedTimeText: + $ref: '#/components/schemas/Text' + viewCountText: + $ref: '#/components/schemas/Text' + lengthText: + $ref: '#/components/schemas/Text' + navigationEndpoint: + $ref: '#/components/schemas/NavigationEndpoint' + shortBylineText: + $ref: '#/components/schemas/Text' + channelThumbnail: + type: object + properties: + thumbnails: + type: array + items: + $ref: '#/components/schemas/Thumbnail' + trackingParams: + type: string + shortViewCountText: + $ref: '#/components/schemas/Text' + accessibility: + $ref: '#/components/schemas/Accessibility' + kidsVideoOwnerExtension: + $ref: '#/components/schemas/KidsVideoOwnerExtension' + + # Средство визуализации раздела элемента + ItemSectionRenderer: + type: object + properties: + contents: + type: array + items: + type: object + properties: + compactVideoRenderer: + $ref: '#/components/schemas/CompactVideoRenderer' + trackingParams: + type: string + + # Рендер списка разделов + SectionListRenderer: + type: object + properties: + contents: + type: array + items: + type: object + properties: + itemSectionRenderer: + $ref: '#/components/schemas/ItemSectionRenderer' + trackingParams: + type: string + + # Визуализатор закрепленных сечений + AnchoredSectionRenderer: + type: object + properties: + title: + type: string + content: + type: object + properties: + sectionListRenderer: + $ref: '#/components/schemas/SectionListRenderer' + trackingParams: + type: string + navigationEndpoint: + $ref: '#/components/schemas/NavigationEndpoint' + categoryAssets: + $ref: '#/components/schemas/CategoryAssets' + categoryType: + type: string + + # Якорь экрана + ScreenAnchor: + type: object + properties: + anchoredSectionRenderer: + $ref: '#/components/schemas/AnchoredSectionRenderer' + + # Рендерер экрана + ScreenRenderer: + type: object + properties: + anchors: + type: array + items: + $ref: '#/components/schemas/ScreenAnchor' + + # Средство визуализации заголовка категории + CategoriesHeaderRenderer: + type: object + properties: + trackingParams: + type: string + # TODO + + # Параметры контента + KidsAppContentSettings: + type: object + properties: + corpusPreference: + type: string + example: KIDS_CORPUS_PREFERENCE_TWEEN + kidsNoSearchMode: + type: string + example: YT_KIDS_NO_SEARCH_MODE_OFF + + # Конфигурация категорий + KidsAppCategorySettings: + type: object + properties: + enabledCategories: + type: array + example: ["approved_for_you", "black_joy", "camp", "collections", "earth", "explore", "favorites", "gaming", "halloween", "hero", "learning", "making", "move", "music", "reading", "shared_by_parents", "shows", "soccer", "sports", "spotlight", "winter"] + items: + type: string + + # Параметры приложения + KidsAppInfo: + type: object + description: Kids application configuration + properties: + contentSettings: + $ref: '#/components/schemas/KidsAppContentSettings' + categorySettings: + $ref: '#/components/schemas/KidsAppCategorySettings' + + # Информация о клиенте в запросе + RequestClient: + type: object + description: Client information + properties: + clientName: + type: string + example: WEB_KIDS + clientVersion: + type: string + example: 2.20230202.00.00 + hl: + type: string + example: ru + gl: + type: string + example: RU + experimentsToken: + type: string + browserName: + type: string + example: Safari + deviceMake: + type: string + example: apple + browserVersion: + type: string + example: '16.2' + osName: + type: string + example: Macintosh + osVersion: + type: string + example: 10_15_7 + platform: + type: string + example: DESKTOP + kidsAppInfo: + $ref: '#/components/schemas/KidsAppInfo' + + # Контекст запроса + RequestContext: + type: object + description: Request context + properties: + client: + $ref: '#/components/schemas/RequestClient' + + # Контекст ответа + ResponseContext: + type: object + description: Response context + properties: + visitorData: + type: string + maxAgeSeconds: + type: number + serviceTrackingParams: + type: array + items: + type: object + properties: + service: + type: string + params: + type: array + items: + $ref: '#/components/schemas/KeyStringValue' + + # Данные для запроса на получение контента определенного ресурса + BrowseRequestPayload: + type: object + properties: + context: + $ref: '#/components/schemas/RequestContext' + browseId: + type: string + example: FEkids_home + + # Ответ на запрос получения контента определенного ресурса + BrowseResponsePayload: + type: object + properties: + responseContext: + $ref: '#/components/schemas/ResponseContext' + header: + type: object + properties: + kidsCategoriesHeaderRenderer: + $ref: '#/components/schemas/CategoriesHeaderRenderer' + contents: + type: object + properties: + kidsHomeScreenRenderer: + $ref: '#/components/schemas/ScreenRenderer' + trackingParams: + type: string + + # Ответ с ошибкой + ErrorResponsePayload: + type: object + properties: + error: + type: object + properties: + code: + type: number + example: 400 + message: + type: string + errors: + type: array + items: + $ref: '#/components/schemas/Error' + status: + type: string + example: FAILED_PRECONDITION diff --git a/generate.go b/generate.go new file mode 100644 index 0000000..1f4222e --- /dev/null +++ b/generate.go @@ -0,0 +1,3 @@ +package go_youtubekids_client + +//go:generate go run github.com/ogen-go/ogen/cmd/ogen -target . -clean -generate-tests -no-server -no-webhook-server -no-webhook-client -package go_youtubekids_client ./api/swagger.yaml diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..fa656e7 --- /dev/null +++ b/go.mod @@ -0,0 +1,36 @@ +module githouse.ru/feelter-ugc/go-youtubekids-client + +go 1.20 + +require ( + github.com/go-faster/errors v0.6.1 + github.com/go-faster/jx v1.0.0 + github.com/ogen-go/ogen v0.61.0 + go.opentelemetry.io/otel v1.14.0 + go.opentelemetry.io/otel/metric v0.37.0 + go.opentelemetry.io/otel/trace v1.14.0 +) + +require ( + github.com/dlclark/regexp2 v1.8.1 // indirect + github.com/fatih/color v1.15.0 // indirect + github.com/ghodss/yaml v1.0.0 // indirect + github.com/go-faster/yaml v0.4.3 // indirect + github.com/go-logr/logr v1.2.4 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.18 // indirect + github.com/segmentio/asm v1.2.0 // indirect + go.uber.org/atomic v1.10.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + go.uber.org/zap v1.24.0 // indirect + golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect + golang.org/x/mod v0.9.0 // indirect + golang.org/x/net v0.8.0 // indirect + golang.org/x/sync v0.1.0 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/text v0.8.0 // indirect + golang.org/x/tools v0.7.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..98b387d --- /dev/null +++ b/go.sum @@ -0,0 +1,69 @@ +github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/dlclark/regexp2 v1.8.1 h1:6Lcdwya6GjPUNsBct8Lg/yRPwMhABj269AAzdGSiR+0= +github.com/dlclark/regexp2 v1.8.1/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= +github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= +github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-faster/errors v0.6.1 h1:nNIPOBkprlKzkThvS/0YaX8Zs9KewLCOSFQS5BU06FI= +github.com/go-faster/errors v0.6.1/go.mod h1:5MGV2/2T9yvlrbhe9pD9LO5Z/2zCSq2T8j+Jpi2LAyY= +github.com/go-faster/jx v1.0.0 h1:HE+ms2e6ZGkZ6u13t8u+onBinrPvIPI+0hWXGELm74g= +github.com/go-faster/jx v1.0.0/go.mod h1:zm8SlkwK+H0TYNKYtVJ/7cWFS7soJBQWhcPctKyYL/4= +github.com/go-faster/yaml v0.4.3 h1:j7blP1oLA/2aBQEaWUibtrNNIayr49VGHGpR076NB8k= +github.com/go-faster/yaml v0.4.3/go.mod h1:K2zdBSnXHZ6/rz8iQ1yxgY+R+ytdlZPzdro0NB8EYxw= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= +github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/ogen-go/ogen v0.61.0 h1:U3hkx9ydCL2tb0055ut0o8hWaEOWCs2+rG2rpwCMGPM= +github.com/ogen-go/ogen v0.61.0/go.mod h1:Rn43MIqVcT8utwLi45lv7e/a4kPRk+klLsWsgB1z9GQ= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= +github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM= +go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU= +go.opentelemetry.io/otel/metric v0.37.0 h1:pHDQuLQOZwYD+Km0eb657A25NaRzy0a+eLyKfDXedEs= +go.opentelemetry.io/otel/metric v0.37.0/go.mod h1:DmdaHfGt54iV6UKxsV9slj2bBRJcKC1B1uvDLIioc1s= +go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M= +go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8= +go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= +go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= +go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= +golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= +golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs= +golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= +golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/oas_cfg_gen.go b/oas_cfg_gen.go new file mode 100644 index 0000000..6f53eb4 --- /dev/null +++ b/oas_cfg_gen.go @@ -0,0 +1,136 @@ +// Code generated by ogen, DO NOT EDIT. + +package go_youtubekids_client + +import ( + "net/http" + + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/metric/instrument" + "go.opentelemetry.io/otel/trace" + + ht "github.com/ogen-go/ogen/http" + "github.com/ogen-go/ogen/otelogen" +) + +var ( + // Allocate option closure once. + clientSpanKind = trace.WithSpanKind(trace.SpanKindClient) +) + +type ( + optionFunc[C any] func(*C) + otelOptionFunc func(*otelConfig) +) + +type otelConfig struct { + TracerProvider trace.TracerProvider + Tracer trace.Tracer + MeterProvider metric.MeterProvider + Meter metric.Meter +} + +func (cfg *otelConfig) initOTEL() { + if cfg.TracerProvider == nil { + cfg.TracerProvider = otel.GetTracerProvider() + } + if cfg.MeterProvider == nil { + cfg.MeterProvider = metric.NewNoopMeterProvider() + } + cfg.Tracer = cfg.TracerProvider.Tracer(otelogen.Name, + trace.WithInstrumentationVersion(otelogen.SemVersion()), + ) + cfg.Meter = cfg.MeterProvider.Meter(otelogen.Name) +} + +type clientConfig struct { + otelConfig + Client ht.Client +} + +// ClientOption is client config option. +type ClientOption interface { + applyClient(*clientConfig) +} + +var _ = []ClientOption{ + (optionFunc[clientConfig])(nil), + (otelOptionFunc)(nil), +} + +func (o optionFunc[C]) applyClient(c *C) { + o(c) +} + +func (o otelOptionFunc) applyClient(c *clientConfig) { + o(&c.otelConfig) +} + +func newClientConfig(opts ...ClientOption) clientConfig { + cfg := clientConfig{ + Client: http.DefaultClient, + } + for _, opt := range opts { + opt.applyClient(&cfg) + } + cfg.initOTEL() + return cfg +} + +type baseClient struct { + cfg clientConfig + requests instrument.Int64Counter + errors instrument.Int64Counter + duration instrument.Int64Histogram +} + +func (cfg clientConfig) baseClient() (c baseClient, err error) { + c = baseClient{cfg: cfg} + if c.requests, err = c.cfg.Meter.Int64Counter(otelogen.ClientRequestCount); err != nil { + return c, err + } + if c.errors, err = c.cfg.Meter.Int64Counter(otelogen.ClientErrorsCount); err != nil { + return c, err + } + if c.duration, err = c.cfg.Meter.Int64Histogram(otelogen.ClientDuration); err != nil { + return c, err + } + return c, nil +} + +// Option is config option. +type Option interface { + ClientOption +} + +// WithTracerProvider specifies a tracer provider to use for creating a tracer. +// +// If none is specified, the global provider is used. +func WithTracerProvider(provider trace.TracerProvider) Option { + return otelOptionFunc(func(cfg *otelConfig) { + if provider != nil { + cfg.TracerProvider = provider + } + }) +} + +// WithMeterProvider specifies a meter provider to use for creating a meter. +// +// If none is specified, the metric.NewNoopMeterProvider is used. +func WithMeterProvider(provider metric.MeterProvider) Option { + return otelOptionFunc(func(cfg *otelConfig) { + if provider != nil { + cfg.MeterProvider = provider + } + }) +} + +// WithClient specifies http client to use. +func WithClient(client ht.Client) ClientOption { + return optionFunc[clientConfig](func(cfg *clientConfig) { + if client != nil { + cfg.Client = client + } + }) +} diff --git a/oas_client_gen.go b/oas_client_gen.go new file mode 100644 index 0000000..a2c7e1a --- /dev/null +++ b/oas_client_gen.go @@ -0,0 +1,136 @@ +// Code generated by ogen, DO NOT EDIT. + +package go_youtubekids_client + +import ( + "context" + "net/url" + "strings" + "time" + + "github.com/go-faster/errors" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/trace" + + ht "github.com/ogen-go/ogen/http" + "github.com/ogen-go/ogen/otelogen" + "github.com/ogen-go/ogen/uri" +) + +// Client implements OAS client. +type Client struct { + serverURL *url.URL + baseClient +} + +func trimTrailingSlashes(u *url.URL) { + u.Path = strings.TrimRight(u.Path, "/") + u.RawPath = strings.TrimRight(u.RawPath, "/") +} + +// NewClient initializes new Client defined by OAS. +func NewClient(serverURL string, opts ...ClientOption) (*Client, error) { + u, err := url.Parse(serverURL) + if err != nil { + return nil, err + } + trimTrailingSlashes(u) + + c, err := newClientConfig(opts...).baseClient() + if err != nil { + return nil, err + } + return &Client{ + serverURL: u, + baseClient: c, + }, nil +} + +type serverURLKey struct{} + +// WithServerURL sets context key to override server URL. +func WithServerURL(ctx context.Context, u *url.URL) context.Context { + return context.WithValue(ctx, serverURLKey{}, u) +} + +func (c *Client) requestURL(ctx context.Context) *url.URL { + u, ok := ctx.Value(serverURLKey{}).(*url.URL) + if !ok { + return c.serverURL + } + return u +} + +// Browse invokes browse operation. +// +// Get content for resource. +// +// POST /browse +func (c *Client) Browse(ctx context.Context, request *BrowseRequestPayload) (BrowseRes, error) { + res, err := c.sendBrowse(ctx, request) + _ = res + return res, err +} + +func (c *Client) sendBrowse(ctx context.Context, request *BrowseRequestPayload) (res BrowseRes, err error) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("browse"), + } + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + c.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...) + }() + + // Increment request counter. + c.requests.Add(ctx, 1, otelAttrs...) + + // Start a span for this request. + ctx, span := c.cfg.Tracer.Start(ctx, "Browse", + trace.WithAttributes(otelAttrs...), + clientSpanKind, + ) + // Track stage for error reporting. + var stage string + defer func() { + if err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + c.errors.Add(ctx, 1, otelAttrs...) + } + span.End() + }() + + stage = "BuildURL" + u := uri.Clone(c.requestURL(ctx)) + var pathParts [1]string + pathParts[0] = "/browse" + uri.AddPathParts(u, pathParts[:]...) + + stage = "EncodeRequest" + r, err := ht.NewRequest(ctx, "POST", u, nil) + if err != nil { + return res, errors.Wrap(err, "create request") + } + if err := encodeBrowseRequest(request, r); err != nil { + return res, errors.Wrap(err, "encode request") + } + + stage = "SendRequest" + resp, err := c.cfg.Client.Do(r) + if err != nil { + return res, errors.Wrap(err, "do request") + } + defer resp.Body.Close() + + stage = "DecodeResponse" + result, err := decodeBrowseResponse(resp) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} diff --git a/oas_faker_gen.go b/oas_faker_gen.go new file mode 100644 index 0000000..5495db9 --- /dev/null +++ b/oas_faker_gen.go @@ -0,0 +1,928 @@ +// Code generated by ogen, DO NOT EDIT. + +package go_youtubekids_client + +// SetFake set fake values. +func (s *Accessibility) SetFake() { + { + { + s.AccessibilityData.SetFake() + } + } +} + +// SetFake set fake values. +func (s *AccessibilityData) SetFake() { + { + { + s.Label.SetFake() + } + } +} + +// SetFake set fake values. +func (s *AnchoredSectionRenderer) SetFake() { + { + { + s.Title.SetFake() + } + } + { + { + s.Content.SetFake() + } + } + { + { + s.TrackingParams.SetFake() + } + } + { + { + s.NavigationEndpoint.SetFake() + } + } + { + { + s.CategoryAssets.SetFake() + } + } + { + { + s.CategoryType.SetFake() + } + } +} + +// SetFake set fake values. +func (s *AnchoredSectionRendererContent) SetFake() { + { + { + s.SectionListRenderer.SetFake() + } + } +} + +// SetFake set fake values. +func (s *BrowseEndpoint) SetFake() { + { + { + s.BrowseId.SetFake() + } + } + { + { + s.CanonicalBaseUrl.SetFake() + } + } +} + +// SetFake set fake values. +func (s *BrowseRequestPayload) SetFake() { + { + { + s.Context.SetFake() + } + } + { + { + s.BrowseId.SetFake() + } + } +} + +// SetFake set fake values. +func (s *BrowseResponsePayload) SetFake() { + { + { + s.ResponseContext.SetFake() + } + } + { + { + s.Header.SetFake() + } + } + { + { + s.Contents.SetFake() + } + } + { + { + s.TrackingParams.SetFake() + } + } +} + +// SetFake set fake values. +func (s *BrowseResponsePayloadContents) SetFake() { + { + { + s.KidsHomeScreenRenderer.SetFake() + } + } +} + +// SetFake set fake values. +func (s *BrowseResponsePayloadHeader) SetFake() { + { + { + s.KidsCategoriesHeaderRenderer.SetFake() + } + } +} + +// SetFake set fake values. +func (s *CategoriesHeaderRenderer) SetFake() { + { + { + s.TrackingParams.SetFake() + } + } +} + +// SetFake set fake values. +func (s *CategoryAssets) SetFake() { + { + { + s.AssetKey.SetFake() + } + } + { + { + s.BackgroundColor.SetFake() + } + } +} + +// SetFake set fake values. +func (s *CompactVideoRenderer) SetFake() { + { + { + s.VideoId.SetFake() + } + } + { + { + s.Thumbnail.SetFake() + } + } + { + { + s.Title.SetFake() + } + } + { + { + s.LongBylineText.SetFake() + } + } + { + { + s.PublishedTimeText.SetFake() + } + } + { + { + s.ViewCountText.SetFake() + } + } + { + { + s.LengthText.SetFake() + } + } + { + { + s.NavigationEndpoint.SetFake() + } + } + { + { + s.ShortBylineText.SetFake() + } + } + { + { + s.ChannelThumbnail.SetFake() + } + } + { + { + s.TrackingParams.SetFake() + } + } + { + { + s.ShortViewCountText.SetFake() + } + } + { + { + s.Accessibility.SetFake() + } + } + { + { + s.KidsVideoOwnerExtension.SetFake() + } + } +} + +// SetFake set fake values. +func (s *CompactVideoRendererChannelThumbnail) SetFake() { + { + { + s.Thumbnails = nil + for i := 0; i < 0; i++ { + var elem Thumbnail + { + elem.SetFake() + } + s.Thumbnails = append(s.Thumbnails, elem) + } + } + } +} + +// SetFake set fake values. +func (s *CompactVideoRendererThumbnail) SetFake() { + { + { + s.Thumbnails = nil + for i := 0; i < 0; i++ { + var elem Thumbnail + { + elem.SetFake() + } + s.Thumbnails = append(s.Thumbnails, elem) + } + } + } +} + +// SetFake set fake values. +func (s *Error) SetFake() { + { + { + s.Message.SetFake() + } + } + { + { + s.Domain.SetFake() + } + } + { + { + s.Reason.SetFake() + } + } +} + +// SetFake set fake values. +func (s *ErrorResponsePayload) SetFake() { + { + { + s.Error.SetFake() + } + } +} + +// SetFake set fake values. +func (s *ErrorResponsePayloadError) SetFake() { + { + { + s.Code.SetFake() + } + } + { + { + s.Message.SetFake() + } + } + { + { + s.Errors = nil + for i := 0; i < 0; i++ { + var elem Error + { + elem.SetFake() + } + s.Errors = append(s.Errors, elem) + } + } + } + { + { + s.Status.SetFake() + } + } +} + +// SetFake set fake values. +func (s *ItemSectionRenderer) SetFake() { + { + { + s.Contents = nil + for i := 0; i < 0; i++ { + var elem ItemSectionRendererContentsItem + { + elem.SetFake() + } + s.Contents = append(s.Contents, elem) + } + } + } + { + { + s.TrackingParams.SetFake() + } + } +} + +// SetFake set fake values. +func (s *ItemSectionRendererContentsItem) SetFake() { + { + { + s.CompactVideoRenderer.SetFake() + } + } +} + +// SetFake set fake values. +func (s *KeyStringValue) SetFake() { + { + { + s.Key.SetFake() + } + } + { + { + s.Value.SetFake() + } + } +} + +// SetFake set fake values. +func (s *KidsAppCategorySettings) SetFake() { + { + { + s.EnabledCategories = nil + for i := 0; i < 0; i++ { + var elem string + { + elem = "string" + } + s.EnabledCategories = append(s.EnabledCategories, elem) + } + } + } +} + +// SetFake set fake values. +func (s *KidsAppContentSettings) SetFake() { + { + { + s.CorpusPreference.SetFake() + } + } + { + { + s.KidsNoSearchMode.SetFake() + } + } +} + +// SetFake set fake values. +func (s *KidsAppInfo) SetFake() { + { + { + s.ContentSettings.SetFake() + } + } + { + { + s.CategorySettings.SetFake() + } + } +} + +// SetFake set fake values. +func (s *KidsVideoOwnerExtension) SetFake() { + { + { + s.ExternalChannelId.SetFake() + } + } +} + +// SetFake set fake values. +func (s *NavigationEndpoint) SetFake() { + { + { + s.ClickTrackingParams.SetFake() + } + } + { + { + s.WatchEndpoint.SetFake() + } + } + { + { + s.BrowseEndpoint.SetFake() + } + } +} + +// SetFake set fake values. +func (s *OptAccessibility) SetFake() { + var elem Accessibility + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptAccessibilityData) SetFake() { + var elem AccessibilityData + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptAnchoredSectionRenderer) SetFake() { + var elem AnchoredSectionRenderer + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptAnchoredSectionRendererContent) SetFake() { + var elem AnchoredSectionRendererContent + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptBrowseEndpoint) SetFake() { + var elem BrowseEndpoint + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptBrowseResponsePayloadContents) SetFake() { + var elem BrowseResponsePayloadContents + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptBrowseResponsePayloadHeader) SetFake() { + var elem BrowseResponsePayloadHeader + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptCategoriesHeaderRenderer) SetFake() { + var elem CategoriesHeaderRenderer + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptCategoryAssets) SetFake() { + var elem CategoryAssets + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptCompactVideoRenderer) SetFake() { + var elem CompactVideoRenderer + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptCompactVideoRendererChannelThumbnail) SetFake() { + var elem CompactVideoRendererChannelThumbnail + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptCompactVideoRendererThumbnail) SetFake() { + var elem CompactVideoRendererThumbnail + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptErrorResponsePayloadError) SetFake() { + var elem ErrorResponsePayloadError + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptFloat64) SetFake() { + var elem float64 + { + elem = float64(0) + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptItemSectionRenderer) SetFake() { + var elem ItemSectionRenderer + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptKidsAppCategorySettings) SetFake() { + var elem KidsAppCategorySettings + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptKidsAppContentSettings) SetFake() { + var elem KidsAppContentSettings + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptKidsAppInfo) SetFake() { + var elem KidsAppInfo + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptKidsVideoOwnerExtension) SetFake() { + var elem KidsVideoOwnerExtension + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptNavigationEndpoint) SetFake() { + var elem NavigationEndpoint + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptRequestClient) SetFake() { + var elem RequestClient + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptRequestContext) SetFake() { + var elem RequestContext + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptResponseContext) SetFake() { + var elem ResponseContext + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptScreenRenderer) SetFake() { + var elem ScreenRenderer + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptSectionListRenderer) SetFake() { + var elem SectionListRenderer + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptString) SetFake() { + var elem string + { + elem = "string" + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptText) SetFake() { + var elem Text + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *OptWatchEndpoint) SetFake() { + var elem WatchEndpoint + { + elem.SetFake() + } + s.SetTo(elem) +} + +// SetFake set fake values. +func (s *RequestClient) SetFake() { + { + { + s.ClientName.SetFake() + } + } + { + { + s.ClientVersion.SetFake() + } + } + { + { + s.Hl.SetFake() + } + } + { + { + s.Gl.SetFake() + } + } + { + { + s.ExperimentsToken.SetFake() + } + } + { + { + s.BrowserName.SetFake() + } + } + { + { + s.DeviceMake.SetFake() + } + } + { + { + s.BrowserVersion.SetFake() + } + } + { + { + s.OsName.SetFake() + } + } + { + { + s.OsVersion.SetFake() + } + } + { + { + s.Platform.SetFake() + } + } + { + { + s.KidsAppInfo.SetFake() + } + } +} + +// SetFake set fake values. +func (s *RequestContext) SetFake() { + { + { + s.Client.SetFake() + } + } +} + +// SetFake set fake values. +func (s *ResponseContext) SetFake() { + { + { + s.VisitorData.SetFake() + } + } + { + { + s.MaxAgeSeconds.SetFake() + } + } + { + { + s.ServiceTrackingParams = nil + for i := 0; i < 0; i++ { + var elem ResponseContextServiceTrackingParamsItem + { + elem.SetFake() + } + s.ServiceTrackingParams = append(s.ServiceTrackingParams, elem) + } + } + } +} + +// SetFake set fake values. +func (s *ResponseContextServiceTrackingParamsItem) SetFake() { + { + { + s.Service.SetFake() + } + } + { + { + s.Params = nil + for i := 0; i < 0; i++ { + var elem KeyStringValue + { + elem.SetFake() + } + s.Params = append(s.Params, elem) + } + } + } +} + +// SetFake set fake values. +func (s *ScreenAnchor) SetFake() { + { + { + s.AnchoredSectionRenderer.SetFake() + } + } +} + +// SetFake set fake values. +func (s *ScreenRenderer) SetFake() { + { + { + s.Anchors = nil + for i := 0; i < 0; i++ { + var elem ScreenAnchor + { + elem.SetFake() + } + s.Anchors = append(s.Anchors, elem) + } + } + } +} + +// SetFake set fake values. +func (s *SectionListRenderer) SetFake() { + { + { + s.Contents = nil + for i := 0; i < 0; i++ { + var elem SectionListRendererContentsItem + { + elem.SetFake() + } + s.Contents = append(s.Contents, elem) + } + } + } + { + { + s.TrackingParams.SetFake() + } + } +} + +// SetFake set fake values. +func (s *SectionListRendererContentsItem) SetFake() { + { + { + s.ItemSectionRenderer.SetFake() + } + } +} + +// SetFake set fake values. +func (s *Text) SetFake() { + { + { + s.Runs = nil + for i := 0; i < 0; i++ { + var elem TextRun + { + elem.SetFake() + } + s.Runs = append(s.Runs, elem) + } + } + } + { + { + s.Accessibility.SetFake() + } + } +} + +// SetFake set fake values. +func (s *TextRun) SetFake() { + { + { + s.Text.SetFake() + } + } + { + { + s.NavigationEndpoint.SetFake() + } + } +} + +// SetFake set fake values. +func (s *Thumbnail) SetFake() { + { + { + s.URL.SetFake() + } + } + { + { + s.Width.SetFake() + } + } + { + { + s.Height.SetFake() + } + } +} + +// SetFake set fake values. +func (s *WatchEndpoint) SetFake() { + { + { + s.VideoId.SetFake() + } + } +} diff --git a/oas_interfaces_gen.go b/oas_interfaces_gen.go new file mode 100644 index 0000000..99199df --- /dev/null +++ b/oas_interfaces_gen.go @@ -0,0 +1,6 @@ +// Code generated by ogen, DO NOT EDIT. +package go_youtubekids_client + +type BrowseRes interface { + browseRes() +} diff --git a/oas_json_gen.go b/oas_json_gen.go new file mode 100644 index 0000000..06a5ea1 --- /dev/null +++ b/oas_json_gen.go @@ -0,0 +1,4297 @@ +// Code generated by ogen, DO NOT EDIT. + +package go_youtubekids_client + +import ( + "github.com/go-faster/errors" + "github.com/go-faster/jx" +) + +// Encode implements json.Marshaler. +func (s *Accessibility) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *Accessibility) encodeFields(e *jx.Encoder) { + { + if s.AccessibilityData.Set { + e.FieldStart("accessibilityData") + s.AccessibilityData.Encode(e) + } + } +} + +var jsonFieldsNameOfAccessibility = [1]string{ + 0: "accessibilityData", +} + +// Decode decodes Accessibility from json. +func (s *Accessibility) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Accessibility to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "accessibilityData": + if err := func() error { + s.AccessibilityData.Reset() + if err := s.AccessibilityData.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"accessibilityData\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode Accessibility") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *Accessibility) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *Accessibility) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *AccessibilityData) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *AccessibilityData) encodeFields(e *jx.Encoder) { + { + if s.Label.Set { + e.FieldStart("label") + s.Label.Encode(e) + } + } +} + +var jsonFieldsNameOfAccessibilityData = [1]string{ + 0: "label", +} + +// Decode decodes AccessibilityData from json. +func (s *AccessibilityData) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode AccessibilityData to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "label": + if err := func() error { + s.Label.Reset() + if err := s.Label.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"label\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode AccessibilityData") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *AccessibilityData) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *AccessibilityData) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *AnchoredSectionRenderer) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *AnchoredSectionRenderer) encodeFields(e *jx.Encoder) { + { + if s.Title.Set { + e.FieldStart("title") + s.Title.Encode(e) + } + } + { + if s.Content.Set { + e.FieldStart("content") + s.Content.Encode(e) + } + } + { + if s.TrackingParams.Set { + e.FieldStart("trackingParams") + s.TrackingParams.Encode(e) + } + } + { + if s.NavigationEndpoint.Set { + e.FieldStart("navigationEndpoint") + s.NavigationEndpoint.Encode(e) + } + } + { + if s.CategoryAssets.Set { + e.FieldStart("categoryAssets") + s.CategoryAssets.Encode(e) + } + } + { + if s.CategoryType.Set { + e.FieldStart("categoryType") + s.CategoryType.Encode(e) + } + } +} + +var jsonFieldsNameOfAnchoredSectionRenderer = [6]string{ + 0: "title", + 1: "content", + 2: "trackingParams", + 3: "navigationEndpoint", + 4: "categoryAssets", + 5: "categoryType", +} + +// Decode decodes AnchoredSectionRenderer from json. +func (s *AnchoredSectionRenderer) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode AnchoredSectionRenderer to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "title": + if err := func() error { + s.Title.Reset() + if err := s.Title.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"title\"") + } + case "content": + if err := func() error { + s.Content.Reset() + if err := s.Content.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"content\"") + } + case "trackingParams": + if err := func() error { + s.TrackingParams.Reset() + if err := s.TrackingParams.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"trackingParams\"") + } + case "navigationEndpoint": + if err := func() error { + s.NavigationEndpoint.Reset() + if err := s.NavigationEndpoint.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"navigationEndpoint\"") + } + case "categoryAssets": + if err := func() error { + s.CategoryAssets.Reset() + if err := s.CategoryAssets.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"categoryAssets\"") + } + case "categoryType": + if err := func() error { + s.CategoryType.Reset() + if err := s.CategoryType.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"categoryType\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode AnchoredSectionRenderer") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *AnchoredSectionRenderer) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *AnchoredSectionRenderer) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *AnchoredSectionRendererContent) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *AnchoredSectionRendererContent) encodeFields(e *jx.Encoder) { + { + if s.SectionListRenderer.Set { + e.FieldStart("sectionListRenderer") + s.SectionListRenderer.Encode(e) + } + } +} + +var jsonFieldsNameOfAnchoredSectionRendererContent = [1]string{ + 0: "sectionListRenderer", +} + +// Decode decodes AnchoredSectionRendererContent from json. +func (s *AnchoredSectionRendererContent) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode AnchoredSectionRendererContent to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "sectionListRenderer": + if err := func() error { + s.SectionListRenderer.Reset() + if err := s.SectionListRenderer.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"sectionListRenderer\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode AnchoredSectionRendererContent") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *AnchoredSectionRendererContent) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *AnchoredSectionRendererContent) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *BrowseEndpoint) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *BrowseEndpoint) encodeFields(e *jx.Encoder) { + { + if s.BrowseId.Set { + e.FieldStart("browseId") + s.BrowseId.Encode(e) + } + } + { + if s.CanonicalBaseUrl.Set { + e.FieldStart("canonicalBaseUrl") + s.CanonicalBaseUrl.Encode(e) + } + } +} + +var jsonFieldsNameOfBrowseEndpoint = [2]string{ + 0: "browseId", + 1: "canonicalBaseUrl", +} + +// Decode decodes BrowseEndpoint from json. +func (s *BrowseEndpoint) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode BrowseEndpoint to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "browseId": + if err := func() error { + s.BrowseId.Reset() + if err := s.BrowseId.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"browseId\"") + } + case "canonicalBaseUrl": + if err := func() error { + s.CanonicalBaseUrl.Reset() + if err := s.CanonicalBaseUrl.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"canonicalBaseUrl\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode BrowseEndpoint") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *BrowseEndpoint) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *BrowseEndpoint) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *BrowseRequestPayload) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *BrowseRequestPayload) encodeFields(e *jx.Encoder) { + { + if s.Context.Set { + e.FieldStart("context") + s.Context.Encode(e) + } + } + { + if s.BrowseId.Set { + e.FieldStart("browseId") + s.BrowseId.Encode(e) + } + } +} + +var jsonFieldsNameOfBrowseRequestPayload = [2]string{ + 0: "context", + 1: "browseId", +} + +// Decode decodes BrowseRequestPayload from json. +func (s *BrowseRequestPayload) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode BrowseRequestPayload to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "context": + if err := func() error { + s.Context.Reset() + if err := s.Context.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"context\"") + } + case "browseId": + if err := func() error { + s.BrowseId.Reset() + if err := s.BrowseId.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"browseId\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode BrowseRequestPayload") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *BrowseRequestPayload) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *BrowseRequestPayload) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *BrowseResponsePayload) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *BrowseResponsePayload) encodeFields(e *jx.Encoder) { + { + if s.ResponseContext.Set { + e.FieldStart("responseContext") + s.ResponseContext.Encode(e) + } + } + { + if s.Header.Set { + e.FieldStart("header") + s.Header.Encode(e) + } + } + { + if s.Contents.Set { + e.FieldStart("contents") + s.Contents.Encode(e) + } + } + { + if s.TrackingParams.Set { + e.FieldStart("trackingParams") + s.TrackingParams.Encode(e) + } + } +} + +var jsonFieldsNameOfBrowseResponsePayload = [4]string{ + 0: "responseContext", + 1: "header", + 2: "contents", + 3: "trackingParams", +} + +// Decode decodes BrowseResponsePayload from json. +func (s *BrowseResponsePayload) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode BrowseResponsePayload to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "responseContext": + if err := func() error { + s.ResponseContext.Reset() + if err := s.ResponseContext.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"responseContext\"") + } + case "header": + if err := func() error { + s.Header.Reset() + if err := s.Header.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"header\"") + } + case "contents": + if err := func() error { + s.Contents.Reset() + if err := s.Contents.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"contents\"") + } + case "trackingParams": + if err := func() error { + s.TrackingParams.Reset() + if err := s.TrackingParams.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"trackingParams\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode BrowseResponsePayload") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *BrowseResponsePayload) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *BrowseResponsePayload) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *BrowseResponsePayloadContents) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *BrowseResponsePayloadContents) encodeFields(e *jx.Encoder) { + { + if s.KidsHomeScreenRenderer.Set { + e.FieldStart("kidsHomeScreenRenderer") + s.KidsHomeScreenRenderer.Encode(e) + } + } +} + +var jsonFieldsNameOfBrowseResponsePayloadContents = [1]string{ + 0: "kidsHomeScreenRenderer", +} + +// Decode decodes BrowseResponsePayloadContents from json. +func (s *BrowseResponsePayloadContents) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode BrowseResponsePayloadContents to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "kidsHomeScreenRenderer": + if err := func() error { + s.KidsHomeScreenRenderer.Reset() + if err := s.KidsHomeScreenRenderer.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"kidsHomeScreenRenderer\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode BrowseResponsePayloadContents") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *BrowseResponsePayloadContents) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *BrowseResponsePayloadContents) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *BrowseResponsePayloadHeader) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *BrowseResponsePayloadHeader) encodeFields(e *jx.Encoder) { + { + if s.KidsCategoriesHeaderRenderer.Set { + e.FieldStart("kidsCategoriesHeaderRenderer") + s.KidsCategoriesHeaderRenderer.Encode(e) + } + } +} + +var jsonFieldsNameOfBrowseResponsePayloadHeader = [1]string{ + 0: "kidsCategoriesHeaderRenderer", +} + +// Decode decodes BrowseResponsePayloadHeader from json. +func (s *BrowseResponsePayloadHeader) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode BrowseResponsePayloadHeader to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "kidsCategoriesHeaderRenderer": + if err := func() error { + s.KidsCategoriesHeaderRenderer.Reset() + if err := s.KidsCategoriesHeaderRenderer.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"kidsCategoriesHeaderRenderer\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode BrowseResponsePayloadHeader") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *BrowseResponsePayloadHeader) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *BrowseResponsePayloadHeader) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *CategoriesHeaderRenderer) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *CategoriesHeaderRenderer) encodeFields(e *jx.Encoder) { + { + if s.TrackingParams.Set { + e.FieldStart("trackingParams") + s.TrackingParams.Encode(e) + } + } +} + +var jsonFieldsNameOfCategoriesHeaderRenderer = [1]string{ + 0: "trackingParams", +} + +// Decode decodes CategoriesHeaderRenderer from json. +func (s *CategoriesHeaderRenderer) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CategoriesHeaderRenderer to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "trackingParams": + if err := func() error { + s.TrackingParams.Reset() + if err := s.TrackingParams.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"trackingParams\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode CategoriesHeaderRenderer") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *CategoriesHeaderRenderer) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *CategoriesHeaderRenderer) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *CategoryAssets) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *CategoryAssets) encodeFields(e *jx.Encoder) { + { + if s.AssetKey.Set { + e.FieldStart("assetKey") + s.AssetKey.Encode(e) + } + } + { + if s.BackgroundColor.Set { + e.FieldStart("backgroundColor") + s.BackgroundColor.Encode(e) + } + } +} + +var jsonFieldsNameOfCategoryAssets = [2]string{ + 0: "assetKey", + 1: "backgroundColor", +} + +// Decode decodes CategoryAssets from json. +func (s *CategoryAssets) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CategoryAssets to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "assetKey": + if err := func() error { + s.AssetKey.Reset() + if err := s.AssetKey.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"assetKey\"") + } + case "backgroundColor": + if err := func() error { + s.BackgroundColor.Reset() + if err := s.BackgroundColor.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"backgroundColor\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode CategoryAssets") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *CategoryAssets) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *CategoryAssets) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *CompactVideoRenderer) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *CompactVideoRenderer) encodeFields(e *jx.Encoder) { + { + if s.VideoId.Set { + e.FieldStart("videoId") + s.VideoId.Encode(e) + } + } + { + if s.Thumbnail.Set { + e.FieldStart("thumbnail") + s.Thumbnail.Encode(e) + } + } + { + if s.Title.Set { + e.FieldStart("title") + s.Title.Encode(e) + } + } + { + if s.LongBylineText.Set { + e.FieldStart("longBylineText") + s.LongBylineText.Encode(e) + } + } + { + if s.PublishedTimeText.Set { + e.FieldStart("publishedTimeText") + s.PublishedTimeText.Encode(e) + } + } + { + if s.ViewCountText.Set { + e.FieldStart("viewCountText") + s.ViewCountText.Encode(e) + } + } + { + if s.LengthText.Set { + e.FieldStart("lengthText") + s.LengthText.Encode(e) + } + } + { + if s.NavigationEndpoint.Set { + e.FieldStart("navigationEndpoint") + s.NavigationEndpoint.Encode(e) + } + } + { + if s.ShortBylineText.Set { + e.FieldStart("shortBylineText") + s.ShortBylineText.Encode(e) + } + } + { + if s.ChannelThumbnail.Set { + e.FieldStart("channelThumbnail") + s.ChannelThumbnail.Encode(e) + } + } + { + if s.TrackingParams.Set { + e.FieldStart("trackingParams") + s.TrackingParams.Encode(e) + } + } + { + if s.ShortViewCountText.Set { + e.FieldStart("shortViewCountText") + s.ShortViewCountText.Encode(e) + } + } + { + if s.Accessibility.Set { + e.FieldStart("accessibility") + s.Accessibility.Encode(e) + } + } + { + if s.KidsVideoOwnerExtension.Set { + e.FieldStart("kidsVideoOwnerExtension") + s.KidsVideoOwnerExtension.Encode(e) + } + } +} + +var jsonFieldsNameOfCompactVideoRenderer = [14]string{ + 0: "videoId", + 1: "thumbnail", + 2: "title", + 3: "longBylineText", + 4: "publishedTimeText", + 5: "viewCountText", + 6: "lengthText", + 7: "navigationEndpoint", + 8: "shortBylineText", + 9: "channelThumbnail", + 10: "trackingParams", + 11: "shortViewCountText", + 12: "accessibility", + 13: "kidsVideoOwnerExtension", +} + +// Decode decodes CompactVideoRenderer from json. +func (s *CompactVideoRenderer) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CompactVideoRenderer to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "videoId": + if err := func() error { + s.VideoId.Reset() + if err := s.VideoId.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"videoId\"") + } + case "thumbnail": + if err := func() error { + s.Thumbnail.Reset() + if err := s.Thumbnail.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"thumbnail\"") + } + case "title": + if err := func() error { + s.Title.Reset() + if err := s.Title.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"title\"") + } + case "longBylineText": + if err := func() error { + s.LongBylineText.Reset() + if err := s.LongBylineText.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"longBylineText\"") + } + case "publishedTimeText": + if err := func() error { + s.PublishedTimeText.Reset() + if err := s.PublishedTimeText.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"publishedTimeText\"") + } + case "viewCountText": + if err := func() error { + s.ViewCountText.Reset() + if err := s.ViewCountText.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"viewCountText\"") + } + case "lengthText": + if err := func() error { + s.LengthText.Reset() + if err := s.LengthText.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"lengthText\"") + } + case "navigationEndpoint": + if err := func() error { + s.NavigationEndpoint.Reset() + if err := s.NavigationEndpoint.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"navigationEndpoint\"") + } + case "shortBylineText": + if err := func() error { + s.ShortBylineText.Reset() + if err := s.ShortBylineText.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"shortBylineText\"") + } + case "channelThumbnail": + if err := func() error { + s.ChannelThumbnail.Reset() + if err := s.ChannelThumbnail.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"channelThumbnail\"") + } + case "trackingParams": + if err := func() error { + s.TrackingParams.Reset() + if err := s.TrackingParams.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"trackingParams\"") + } + case "shortViewCountText": + if err := func() error { + s.ShortViewCountText.Reset() + if err := s.ShortViewCountText.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"shortViewCountText\"") + } + case "accessibility": + if err := func() error { + s.Accessibility.Reset() + if err := s.Accessibility.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"accessibility\"") + } + case "kidsVideoOwnerExtension": + if err := func() error { + s.KidsVideoOwnerExtension.Reset() + if err := s.KidsVideoOwnerExtension.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"kidsVideoOwnerExtension\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode CompactVideoRenderer") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *CompactVideoRenderer) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *CompactVideoRenderer) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *CompactVideoRendererChannelThumbnail) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *CompactVideoRendererChannelThumbnail) encodeFields(e *jx.Encoder) { + { + if s.Thumbnails != nil { + e.FieldStart("thumbnails") + e.ArrStart() + for _, elem := range s.Thumbnails { + elem.Encode(e) + } + e.ArrEnd() + } + } +} + +var jsonFieldsNameOfCompactVideoRendererChannelThumbnail = [1]string{ + 0: "thumbnails", +} + +// Decode decodes CompactVideoRendererChannelThumbnail from json. +func (s *CompactVideoRendererChannelThumbnail) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CompactVideoRendererChannelThumbnail to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "thumbnails": + if err := func() error { + s.Thumbnails = make([]Thumbnail, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem Thumbnail + if err := elem.Decode(d); err != nil { + return err + } + s.Thumbnails = append(s.Thumbnails, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"thumbnails\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode CompactVideoRendererChannelThumbnail") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *CompactVideoRendererChannelThumbnail) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *CompactVideoRendererChannelThumbnail) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *CompactVideoRendererThumbnail) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *CompactVideoRendererThumbnail) encodeFields(e *jx.Encoder) { + { + if s.Thumbnails != nil { + e.FieldStart("thumbnails") + e.ArrStart() + for _, elem := range s.Thumbnails { + elem.Encode(e) + } + e.ArrEnd() + } + } +} + +var jsonFieldsNameOfCompactVideoRendererThumbnail = [1]string{ + 0: "thumbnails", +} + +// Decode decodes CompactVideoRendererThumbnail from json. +func (s *CompactVideoRendererThumbnail) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CompactVideoRendererThumbnail to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "thumbnails": + if err := func() error { + s.Thumbnails = make([]Thumbnail, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem Thumbnail + if err := elem.Decode(d); err != nil { + return err + } + s.Thumbnails = append(s.Thumbnails, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"thumbnails\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode CompactVideoRendererThumbnail") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *CompactVideoRendererThumbnail) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *CompactVideoRendererThumbnail) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *Error) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *Error) encodeFields(e *jx.Encoder) { + { + if s.Message.Set { + e.FieldStart("message") + s.Message.Encode(e) + } + } + { + if s.Domain.Set { + e.FieldStart("domain") + s.Domain.Encode(e) + } + } + { + if s.Reason.Set { + e.FieldStart("reason") + s.Reason.Encode(e) + } + } +} + +var jsonFieldsNameOfError = [3]string{ + 0: "message", + 1: "domain", + 2: "reason", +} + +// Decode decodes Error from json. +func (s *Error) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Error to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "message": + if err := func() error { + s.Message.Reset() + if err := s.Message.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"message\"") + } + case "domain": + if err := func() error { + s.Domain.Reset() + if err := s.Domain.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"domain\"") + } + case "reason": + if err := func() error { + s.Reason.Reset() + if err := s.Reason.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"reason\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode Error") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *Error) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *Error) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ErrorResponsePayload) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ErrorResponsePayload) encodeFields(e *jx.Encoder) { + { + if s.Error.Set { + e.FieldStart("error") + s.Error.Encode(e) + } + } +} + +var jsonFieldsNameOfErrorResponsePayload = [1]string{ + 0: "error", +} + +// Decode decodes ErrorResponsePayload from json. +func (s *ErrorResponsePayload) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ErrorResponsePayload to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "error": + if err := func() error { + s.Error.Reset() + if err := s.Error.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"error\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ErrorResponsePayload") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ErrorResponsePayload) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ErrorResponsePayload) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ErrorResponsePayloadError) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ErrorResponsePayloadError) encodeFields(e *jx.Encoder) { + { + if s.Code.Set { + e.FieldStart("code") + s.Code.Encode(e) + } + } + { + if s.Message.Set { + e.FieldStart("message") + s.Message.Encode(e) + } + } + { + if s.Errors != nil { + e.FieldStart("errors") + e.ArrStart() + for _, elem := range s.Errors { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.Status.Set { + e.FieldStart("status") + s.Status.Encode(e) + } + } +} + +var jsonFieldsNameOfErrorResponsePayloadError = [4]string{ + 0: "code", + 1: "message", + 2: "errors", + 3: "status", +} + +// Decode decodes ErrorResponsePayloadError from json. +func (s *ErrorResponsePayloadError) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ErrorResponsePayloadError to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "code": + if err := func() error { + s.Code.Reset() + if err := s.Code.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"code\"") + } + case "message": + if err := func() error { + s.Message.Reset() + if err := s.Message.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"message\"") + } + case "errors": + if err := func() error { + s.Errors = make([]Error, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem Error + if err := elem.Decode(d); err != nil { + return err + } + s.Errors = append(s.Errors, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"errors\"") + } + case "status": + if err := func() error { + s.Status.Reset() + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ErrorResponsePayloadError") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ErrorResponsePayloadError) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ErrorResponsePayloadError) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ItemSectionRenderer) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ItemSectionRenderer) encodeFields(e *jx.Encoder) { + { + if s.Contents != nil { + e.FieldStart("contents") + e.ArrStart() + for _, elem := range s.Contents { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.TrackingParams.Set { + e.FieldStart("trackingParams") + s.TrackingParams.Encode(e) + } + } +} + +var jsonFieldsNameOfItemSectionRenderer = [2]string{ + 0: "contents", + 1: "trackingParams", +} + +// Decode decodes ItemSectionRenderer from json. +func (s *ItemSectionRenderer) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ItemSectionRenderer to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "contents": + if err := func() error { + s.Contents = make([]ItemSectionRendererContentsItem, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem ItemSectionRendererContentsItem + if err := elem.Decode(d); err != nil { + return err + } + s.Contents = append(s.Contents, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"contents\"") + } + case "trackingParams": + if err := func() error { + s.TrackingParams.Reset() + if err := s.TrackingParams.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"trackingParams\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ItemSectionRenderer") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ItemSectionRenderer) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ItemSectionRenderer) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ItemSectionRendererContentsItem) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ItemSectionRendererContentsItem) encodeFields(e *jx.Encoder) { + { + if s.CompactVideoRenderer.Set { + e.FieldStart("compactVideoRenderer") + s.CompactVideoRenderer.Encode(e) + } + } +} + +var jsonFieldsNameOfItemSectionRendererContentsItem = [1]string{ + 0: "compactVideoRenderer", +} + +// Decode decodes ItemSectionRendererContentsItem from json. +func (s *ItemSectionRendererContentsItem) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ItemSectionRendererContentsItem to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "compactVideoRenderer": + if err := func() error { + s.CompactVideoRenderer.Reset() + if err := s.CompactVideoRenderer.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"compactVideoRenderer\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ItemSectionRendererContentsItem") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ItemSectionRendererContentsItem) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ItemSectionRendererContentsItem) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *KeyStringValue) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *KeyStringValue) encodeFields(e *jx.Encoder) { + { + if s.Key.Set { + e.FieldStart("key") + s.Key.Encode(e) + } + } + { + if s.Value.Set { + e.FieldStart("value") + s.Value.Encode(e) + } + } +} + +var jsonFieldsNameOfKeyStringValue = [2]string{ + 0: "key", + 1: "value", +} + +// Decode decodes KeyStringValue from json. +func (s *KeyStringValue) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode KeyStringValue to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "key": + if err := func() error { + s.Key.Reset() + if err := s.Key.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"key\"") + } + case "value": + if err := func() error { + s.Value.Reset() + if err := s.Value.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"value\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode KeyStringValue") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *KeyStringValue) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *KeyStringValue) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *KidsAppCategorySettings) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *KidsAppCategorySettings) encodeFields(e *jx.Encoder) { + { + if s.EnabledCategories != nil { + e.FieldStart("enabledCategories") + e.ArrStart() + for _, elem := range s.EnabledCategories { + e.Str(elem) + } + e.ArrEnd() + } + } +} + +var jsonFieldsNameOfKidsAppCategorySettings = [1]string{ + 0: "enabledCategories", +} + +// Decode decodes KidsAppCategorySettings from json. +func (s *KidsAppCategorySettings) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode KidsAppCategorySettings to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "enabledCategories": + if err := func() error { + s.EnabledCategories = make([]string, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem string + v, err := d.Str() + elem = string(v) + if err != nil { + return err + } + s.EnabledCategories = append(s.EnabledCategories, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"enabledCategories\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode KidsAppCategorySettings") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *KidsAppCategorySettings) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *KidsAppCategorySettings) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *KidsAppContentSettings) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *KidsAppContentSettings) encodeFields(e *jx.Encoder) { + { + if s.CorpusPreference.Set { + e.FieldStart("corpusPreference") + s.CorpusPreference.Encode(e) + } + } + { + if s.KidsNoSearchMode.Set { + e.FieldStart("kidsNoSearchMode") + s.KidsNoSearchMode.Encode(e) + } + } +} + +var jsonFieldsNameOfKidsAppContentSettings = [2]string{ + 0: "corpusPreference", + 1: "kidsNoSearchMode", +} + +// Decode decodes KidsAppContentSettings from json. +func (s *KidsAppContentSettings) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode KidsAppContentSettings to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "corpusPreference": + if err := func() error { + s.CorpusPreference.Reset() + if err := s.CorpusPreference.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"corpusPreference\"") + } + case "kidsNoSearchMode": + if err := func() error { + s.KidsNoSearchMode.Reset() + if err := s.KidsNoSearchMode.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"kidsNoSearchMode\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode KidsAppContentSettings") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *KidsAppContentSettings) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *KidsAppContentSettings) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *KidsAppInfo) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *KidsAppInfo) encodeFields(e *jx.Encoder) { + { + if s.ContentSettings.Set { + e.FieldStart("contentSettings") + s.ContentSettings.Encode(e) + } + } + { + if s.CategorySettings.Set { + e.FieldStart("categorySettings") + s.CategorySettings.Encode(e) + } + } +} + +var jsonFieldsNameOfKidsAppInfo = [2]string{ + 0: "contentSettings", + 1: "categorySettings", +} + +// Decode decodes KidsAppInfo from json. +func (s *KidsAppInfo) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode KidsAppInfo to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "contentSettings": + if err := func() error { + s.ContentSettings.Reset() + if err := s.ContentSettings.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"contentSettings\"") + } + case "categorySettings": + if err := func() error { + s.CategorySettings.Reset() + if err := s.CategorySettings.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"categorySettings\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode KidsAppInfo") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *KidsAppInfo) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *KidsAppInfo) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *KidsVideoOwnerExtension) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *KidsVideoOwnerExtension) encodeFields(e *jx.Encoder) { + { + if s.ExternalChannelId.Set { + e.FieldStart("externalChannelId") + s.ExternalChannelId.Encode(e) + } + } +} + +var jsonFieldsNameOfKidsVideoOwnerExtension = [1]string{ + 0: "externalChannelId", +} + +// Decode decodes KidsVideoOwnerExtension from json. +func (s *KidsVideoOwnerExtension) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode KidsVideoOwnerExtension to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "externalChannelId": + if err := func() error { + s.ExternalChannelId.Reset() + if err := s.ExternalChannelId.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"externalChannelId\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode KidsVideoOwnerExtension") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *KidsVideoOwnerExtension) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *KidsVideoOwnerExtension) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NavigationEndpoint) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NavigationEndpoint) encodeFields(e *jx.Encoder) { + { + if s.ClickTrackingParams.Set { + e.FieldStart("clickTrackingParams") + s.ClickTrackingParams.Encode(e) + } + } + { + if s.WatchEndpoint.Set { + e.FieldStart("watchEndpoint") + s.WatchEndpoint.Encode(e) + } + } + { + if s.BrowseEndpoint.Set { + e.FieldStart("browseEndpoint") + s.BrowseEndpoint.Encode(e) + } + } +} + +var jsonFieldsNameOfNavigationEndpoint = [3]string{ + 0: "clickTrackingParams", + 1: "watchEndpoint", + 2: "browseEndpoint", +} + +// Decode decodes NavigationEndpoint from json. +func (s *NavigationEndpoint) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NavigationEndpoint to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "clickTrackingParams": + if err := func() error { + s.ClickTrackingParams.Reset() + if err := s.ClickTrackingParams.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"clickTrackingParams\"") + } + case "watchEndpoint": + if err := func() error { + s.WatchEndpoint.Reset() + if err := s.WatchEndpoint.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"watchEndpoint\"") + } + case "browseEndpoint": + if err := func() error { + s.BrowseEndpoint.Reset() + if err := s.BrowseEndpoint.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"browseEndpoint\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NavigationEndpoint") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NavigationEndpoint) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NavigationEndpoint) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes Accessibility as json. +func (o OptAccessibility) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes Accessibility from json. +func (o *OptAccessibility) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptAccessibility to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptAccessibility) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptAccessibility) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes AccessibilityData as json. +func (o OptAccessibilityData) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes AccessibilityData from json. +func (o *OptAccessibilityData) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptAccessibilityData to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptAccessibilityData) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptAccessibilityData) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes AnchoredSectionRenderer as json. +func (o OptAnchoredSectionRenderer) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes AnchoredSectionRenderer from json. +func (o *OptAnchoredSectionRenderer) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptAnchoredSectionRenderer to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptAnchoredSectionRenderer) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptAnchoredSectionRenderer) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes AnchoredSectionRendererContent as json. +func (o OptAnchoredSectionRendererContent) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes AnchoredSectionRendererContent from json. +func (o *OptAnchoredSectionRendererContent) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptAnchoredSectionRendererContent to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptAnchoredSectionRendererContent) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptAnchoredSectionRendererContent) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes BrowseEndpoint as json. +func (o OptBrowseEndpoint) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes BrowseEndpoint from json. +func (o *OptBrowseEndpoint) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptBrowseEndpoint to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptBrowseEndpoint) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptBrowseEndpoint) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes BrowseResponsePayloadContents as json. +func (o OptBrowseResponsePayloadContents) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes BrowseResponsePayloadContents from json. +func (o *OptBrowseResponsePayloadContents) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptBrowseResponsePayloadContents to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptBrowseResponsePayloadContents) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptBrowseResponsePayloadContents) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes BrowseResponsePayloadHeader as json. +func (o OptBrowseResponsePayloadHeader) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes BrowseResponsePayloadHeader from json. +func (o *OptBrowseResponsePayloadHeader) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptBrowseResponsePayloadHeader to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptBrowseResponsePayloadHeader) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptBrowseResponsePayloadHeader) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CategoriesHeaderRenderer as json. +func (o OptCategoriesHeaderRenderer) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes CategoriesHeaderRenderer from json. +func (o *OptCategoriesHeaderRenderer) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptCategoriesHeaderRenderer to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptCategoriesHeaderRenderer) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptCategoriesHeaderRenderer) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CategoryAssets as json. +func (o OptCategoryAssets) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes CategoryAssets from json. +func (o *OptCategoryAssets) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptCategoryAssets to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptCategoryAssets) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptCategoryAssets) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CompactVideoRenderer as json. +func (o OptCompactVideoRenderer) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes CompactVideoRenderer from json. +func (o *OptCompactVideoRenderer) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptCompactVideoRenderer to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptCompactVideoRenderer) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptCompactVideoRenderer) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CompactVideoRendererChannelThumbnail as json. +func (o OptCompactVideoRendererChannelThumbnail) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes CompactVideoRendererChannelThumbnail from json. +func (o *OptCompactVideoRendererChannelThumbnail) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptCompactVideoRendererChannelThumbnail to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptCompactVideoRendererChannelThumbnail) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptCompactVideoRendererChannelThumbnail) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CompactVideoRendererThumbnail as json. +func (o OptCompactVideoRendererThumbnail) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes CompactVideoRendererThumbnail from json. +func (o *OptCompactVideoRendererThumbnail) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptCompactVideoRendererThumbnail to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptCompactVideoRendererThumbnail) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptCompactVideoRendererThumbnail) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ErrorResponsePayloadError as json. +func (o OptErrorResponsePayloadError) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes ErrorResponsePayloadError from json. +func (o *OptErrorResponsePayloadError) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptErrorResponsePayloadError to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptErrorResponsePayloadError) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptErrorResponsePayloadError) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes float64 as json. +func (o OptFloat64) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Float64(float64(o.Value)) +} + +// Decode decodes float64 from json. +func (o *OptFloat64) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptFloat64 to nil") + } + o.Set = true + v, err := d.Float64() + if err != nil { + return err + } + o.Value = float64(v) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptFloat64) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptFloat64) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ItemSectionRenderer as json. +func (o OptItemSectionRenderer) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes ItemSectionRenderer from json. +func (o *OptItemSectionRenderer) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptItemSectionRenderer to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptItemSectionRenderer) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptItemSectionRenderer) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes KidsAppCategorySettings as json. +func (o OptKidsAppCategorySettings) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes KidsAppCategorySettings from json. +func (o *OptKidsAppCategorySettings) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptKidsAppCategorySettings to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptKidsAppCategorySettings) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptKidsAppCategorySettings) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes KidsAppContentSettings as json. +func (o OptKidsAppContentSettings) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes KidsAppContentSettings from json. +func (o *OptKidsAppContentSettings) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptKidsAppContentSettings to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptKidsAppContentSettings) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptKidsAppContentSettings) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes KidsAppInfo as json. +func (o OptKidsAppInfo) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes KidsAppInfo from json. +func (o *OptKidsAppInfo) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptKidsAppInfo to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptKidsAppInfo) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptKidsAppInfo) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes KidsVideoOwnerExtension as json. +func (o OptKidsVideoOwnerExtension) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes KidsVideoOwnerExtension from json. +func (o *OptKidsVideoOwnerExtension) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptKidsVideoOwnerExtension to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptKidsVideoOwnerExtension) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptKidsVideoOwnerExtension) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NavigationEndpoint as json. +func (o OptNavigationEndpoint) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes NavigationEndpoint from json. +func (o *OptNavigationEndpoint) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptNavigationEndpoint to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptNavigationEndpoint) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptNavigationEndpoint) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes RequestClient as json. +func (o OptRequestClient) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes RequestClient from json. +func (o *OptRequestClient) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptRequestClient to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptRequestClient) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptRequestClient) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes RequestContext as json. +func (o OptRequestContext) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes RequestContext from json. +func (o *OptRequestContext) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptRequestContext to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptRequestContext) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptRequestContext) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ResponseContext as json. +func (o OptResponseContext) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes ResponseContext from json. +func (o *OptResponseContext) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptResponseContext to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptResponseContext) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptResponseContext) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ScreenRenderer as json. +func (o OptScreenRenderer) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes ScreenRenderer from json. +func (o *OptScreenRenderer) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptScreenRenderer to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptScreenRenderer) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptScreenRenderer) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes SectionListRenderer as json. +func (o OptSectionListRenderer) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes SectionListRenderer from json. +func (o *OptSectionListRenderer) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptSectionListRenderer to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptSectionListRenderer) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptSectionListRenderer) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes string as json. +func (o OptString) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes string from json. +func (o *OptString) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptString to nil") + } + o.Set = true + v, err := d.Str() + if err != nil { + return err + } + o.Value = string(v) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptString) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptString) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes Text as json. +func (o OptText) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes Text from json. +func (o *OptText) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptText to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptText) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptText) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes WatchEndpoint as json. +func (o OptWatchEndpoint) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes WatchEndpoint from json. +func (o *OptWatchEndpoint) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptWatchEndpoint to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptWatchEndpoint) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptWatchEndpoint) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *RequestClient) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *RequestClient) encodeFields(e *jx.Encoder) { + { + if s.ClientName.Set { + e.FieldStart("clientName") + s.ClientName.Encode(e) + } + } + { + if s.ClientVersion.Set { + e.FieldStart("clientVersion") + s.ClientVersion.Encode(e) + } + } + { + if s.Hl.Set { + e.FieldStart("hl") + s.Hl.Encode(e) + } + } + { + if s.Gl.Set { + e.FieldStart("gl") + s.Gl.Encode(e) + } + } + { + if s.ExperimentsToken.Set { + e.FieldStart("experimentsToken") + s.ExperimentsToken.Encode(e) + } + } + { + if s.BrowserName.Set { + e.FieldStart("browserName") + s.BrowserName.Encode(e) + } + } + { + if s.DeviceMake.Set { + e.FieldStart("deviceMake") + s.DeviceMake.Encode(e) + } + } + { + if s.BrowserVersion.Set { + e.FieldStart("browserVersion") + s.BrowserVersion.Encode(e) + } + } + { + if s.OsName.Set { + e.FieldStart("osName") + s.OsName.Encode(e) + } + } + { + if s.OsVersion.Set { + e.FieldStart("osVersion") + s.OsVersion.Encode(e) + } + } + { + if s.Platform.Set { + e.FieldStart("platform") + s.Platform.Encode(e) + } + } + { + if s.KidsAppInfo.Set { + e.FieldStart("kidsAppInfo") + s.KidsAppInfo.Encode(e) + } + } +} + +var jsonFieldsNameOfRequestClient = [12]string{ + 0: "clientName", + 1: "clientVersion", + 2: "hl", + 3: "gl", + 4: "experimentsToken", + 5: "browserName", + 6: "deviceMake", + 7: "browserVersion", + 8: "osName", + 9: "osVersion", + 10: "platform", + 11: "kidsAppInfo", +} + +// Decode decodes RequestClient from json. +func (s *RequestClient) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode RequestClient to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "clientName": + if err := func() error { + s.ClientName.Reset() + if err := s.ClientName.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"clientName\"") + } + case "clientVersion": + if err := func() error { + s.ClientVersion.Reset() + if err := s.ClientVersion.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"clientVersion\"") + } + case "hl": + if err := func() error { + s.Hl.Reset() + if err := s.Hl.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"hl\"") + } + case "gl": + if err := func() error { + s.Gl.Reset() + if err := s.Gl.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"gl\"") + } + case "experimentsToken": + if err := func() error { + s.ExperimentsToken.Reset() + if err := s.ExperimentsToken.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"experimentsToken\"") + } + case "browserName": + if err := func() error { + s.BrowserName.Reset() + if err := s.BrowserName.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"browserName\"") + } + case "deviceMake": + if err := func() error { + s.DeviceMake.Reset() + if err := s.DeviceMake.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"deviceMake\"") + } + case "browserVersion": + if err := func() error { + s.BrowserVersion.Reset() + if err := s.BrowserVersion.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"browserVersion\"") + } + case "osName": + if err := func() error { + s.OsName.Reset() + if err := s.OsName.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"osName\"") + } + case "osVersion": + if err := func() error { + s.OsVersion.Reset() + if err := s.OsVersion.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"osVersion\"") + } + case "platform": + if err := func() error { + s.Platform.Reset() + if err := s.Platform.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"platform\"") + } + case "kidsAppInfo": + if err := func() error { + s.KidsAppInfo.Reset() + if err := s.KidsAppInfo.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"kidsAppInfo\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode RequestClient") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *RequestClient) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *RequestClient) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *RequestContext) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *RequestContext) encodeFields(e *jx.Encoder) { + { + if s.Client.Set { + e.FieldStart("client") + s.Client.Encode(e) + } + } +} + +var jsonFieldsNameOfRequestContext = [1]string{ + 0: "client", +} + +// Decode decodes RequestContext from json. +func (s *RequestContext) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode RequestContext to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "client": + if err := func() error { + s.Client.Reset() + if err := s.Client.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"client\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode RequestContext") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *RequestContext) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *RequestContext) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ResponseContext) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ResponseContext) encodeFields(e *jx.Encoder) { + { + if s.VisitorData.Set { + e.FieldStart("visitorData") + s.VisitorData.Encode(e) + } + } + { + if s.MaxAgeSeconds.Set { + e.FieldStart("maxAgeSeconds") + s.MaxAgeSeconds.Encode(e) + } + } + { + if s.ServiceTrackingParams != nil { + e.FieldStart("serviceTrackingParams") + e.ArrStart() + for _, elem := range s.ServiceTrackingParams { + elem.Encode(e) + } + e.ArrEnd() + } + } +} + +var jsonFieldsNameOfResponseContext = [3]string{ + 0: "visitorData", + 1: "maxAgeSeconds", + 2: "serviceTrackingParams", +} + +// Decode decodes ResponseContext from json. +func (s *ResponseContext) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ResponseContext to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "visitorData": + if err := func() error { + s.VisitorData.Reset() + if err := s.VisitorData.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"visitorData\"") + } + case "maxAgeSeconds": + if err := func() error { + s.MaxAgeSeconds.Reset() + if err := s.MaxAgeSeconds.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"maxAgeSeconds\"") + } + case "serviceTrackingParams": + if err := func() error { + s.ServiceTrackingParams = make([]ResponseContextServiceTrackingParamsItem, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem ResponseContextServiceTrackingParamsItem + if err := elem.Decode(d); err != nil { + return err + } + s.ServiceTrackingParams = append(s.ServiceTrackingParams, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"serviceTrackingParams\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ResponseContext") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ResponseContext) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ResponseContext) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ResponseContextServiceTrackingParamsItem) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ResponseContextServiceTrackingParamsItem) encodeFields(e *jx.Encoder) { + { + if s.Service.Set { + e.FieldStart("service") + s.Service.Encode(e) + } + } + { + if s.Params != nil { + e.FieldStart("params") + e.ArrStart() + for _, elem := range s.Params { + elem.Encode(e) + } + e.ArrEnd() + } + } +} + +var jsonFieldsNameOfResponseContextServiceTrackingParamsItem = [2]string{ + 0: "service", + 1: "params", +} + +// Decode decodes ResponseContextServiceTrackingParamsItem from json. +func (s *ResponseContextServiceTrackingParamsItem) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ResponseContextServiceTrackingParamsItem to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "service": + if err := func() error { + s.Service.Reset() + if err := s.Service.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"service\"") + } + case "params": + if err := func() error { + s.Params = make([]KeyStringValue, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem KeyStringValue + if err := elem.Decode(d); err != nil { + return err + } + s.Params = append(s.Params, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"params\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ResponseContextServiceTrackingParamsItem") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ResponseContextServiceTrackingParamsItem) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ResponseContextServiceTrackingParamsItem) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ScreenAnchor) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ScreenAnchor) encodeFields(e *jx.Encoder) { + { + if s.AnchoredSectionRenderer.Set { + e.FieldStart("anchoredSectionRenderer") + s.AnchoredSectionRenderer.Encode(e) + } + } +} + +var jsonFieldsNameOfScreenAnchor = [1]string{ + 0: "anchoredSectionRenderer", +} + +// Decode decodes ScreenAnchor from json. +func (s *ScreenAnchor) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ScreenAnchor to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "anchoredSectionRenderer": + if err := func() error { + s.AnchoredSectionRenderer.Reset() + if err := s.AnchoredSectionRenderer.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"anchoredSectionRenderer\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ScreenAnchor") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ScreenAnchor) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ScreenAnchor) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ScreenRenderer) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ScreenRenderer) encodeFields(e *jx.Encoder) { + { + if s.Anchors != nil { + e.FieldStart("anchors") + e.ArrStart() + for _, elem := range s.Anchors { + elem.Encode(e) + } + e.ArrEnd() + } + } +} + +var jsonFieldsNameOfScreenRenderer = [1]string{ + 0: "anchors", +} + +// Decode decodes ScreenRenderer from json. +func (s *ScreenRenderer) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ScreenRenderer to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "anchors": + if err := func() error { + s.Anchors = make([]ScreenAnchor, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem ScreenAnchor + if err := elem.Decode(d); err != nil { + return err + } + s.Anchors = append(s.Anchors, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"anchors\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ScreenRenderer") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ScreenRenderer) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ScreenRenderer) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *SectionListRenderer) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *SectionListRenderer) encodeFields(e *jx.Encoder) { + { + if s.Contents != nil { + e.FieldStart("contents") + e.ArrStart() + for _, elem := range s.Contents { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.TrackingParams.Set { + e.FieldStart("trackingParams") + s.TrackingParams.Encode(e) + } + } +} + +var jsonFieldsNameOfSectionListRenderer = [2]string{ + 0: "contents", + 1: "trackingParams", +} + +// Decode decodes SectionListRenderer from json. +func (s *SectionListRenderer) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode SectionListRenderer to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "contents": + if err := func() error { + s.Contents = make([]SectionListRendererContentsItem, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem SectionListRendererContentsItem + if err := elem.Decode(d); err != nil { + return err + } + s.Contents = append(s.Contents, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"contents\"") + } + case "trackingParams": + if err := func() error { + s.TrackingParams.Reset() + if err := s.TrackingParams.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"trackingParams\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode SectionListRenderer") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *SectionListRenderer) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *SectionListRenderer) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *SectionListRendererContentsItem) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *SectionListRendererContentsItem) encodeFields(e *jx.Encoder) { + { + if s.ItemSectionRenderer.Set { + e.FieldStart("itemSectionRenderer") + s.ItemSectionRenderer.Encode(e) + } + } +} + +var jsonFieldsNameOfSectionListRendererContentsItem = [1]string{ + 0: "itemSectionRenderer", +} + +// Decode decodes SectionListRendererContentsItem from json. +func (s *SectionListRendererContentsItem) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode SectionListRendererContentsItem to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "itemSectionRenderer": + if err := func() error { + s.ItemSectionRenderer.Reset() + if err := s.ItemSectionRenderer.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"itemSectionRenderer\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode SectionListRendererContentsItem") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *SectionListRendererContentsItem) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *SectionListRendererContentsItem) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *Text) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *Text) encodeFields(e *jx.Encoder) { + { + if s.Runs != nil { + e.FieldStart("runs") + e.ArrStart() + for _, elem := range s.Runs { + elem.Encode(e) + } + e.ArrEnd() + } + } + { + if s.Accessibility.Set { + e.FieldStart("accessibility") + s.Accessibility.Encode(e) + } + } +} + +var jsonFieldsNameOfText = [2]string{ + 0: "runs", + 1: "accessibility", +} + +// Decode decodes Text from json. +func (s *Text) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Text to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "runs": + if err := func() error { + s.Runs = make([]TextRun, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem TextRun + if err := elem.Decode(d); err != nil { + return err + } + s.Runs = append(s.Runs, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"runs\"") + } + case "accessibility": + if err := func() error { + s.Accessibility.Reset() + if err := s.Accessibility.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"accessibility\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode Text") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *Text) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *Text) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *TextRun) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *TextRun) encodeFields(e *jx.Encoder) { + { + if s.Text.Set { + e.FieldStart("text") + s.Text.Encode(e) + } + } + { + if s.NavigationEndpoint.Set { + e.FieldStart("navigationEndpoint") + s.NavigationEndpoint.Encode(e) + } + } +} + +var jsonFieldsNameOfTextRun = [2]string{ + 0: "text", + 1: "navigationEndpoint", +} + +// Decode decodes TextRun from json. +func (s *TextRun) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode TextRun to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "text": + if err := func() error { + s.Text.Reset() + if err := s.Text.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"text\"") + } + case "navigationEndpoint": + if err := func() error { + s.NavigationEndpoint.Reset() + if err := s.NavigationEndpoint.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"navigationEndpoint\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode TextRun") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *TextRun) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *TextRun) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *Thumbnail) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *Thumbnail) encodeFields(e *jx.Encoder) { + { + if s.URL.Set { + e.FieldStart("url") + s.URL.Encode(e) + } + } + { + if s.Width.Set { + e.FieldStart("width") + s.Width.Encode(e) + } + } + { + if s.Height.Set { + e.FieldStart("height") + s.Height.Encode(e) + } + } +} + +var jsonFieldsNameOfThumbnail = [3]string{ + 0: "url", + 1: "width", + 2: "height", +} + +// Decode decodes Thumbnail from json. +func (s *Thumbnail) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Thumbnail to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "url": + if err := func() error { + s.URL.Reset() + if err := s.URL.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"url\"") + } + case "width": + if err := func() error { + s.Width.Reset() + if err := s.Width.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"width\"") + } + case "height": + if err := func() error { + s.Height.Reset() + if err := s.Height.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"height\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode Thumbnail") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *Thumbnail) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *Thumbnail) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *WatchEndpoint) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *WatchEndpoint) encodeFields(e *jx.Encoder) { + { + if s.VideoId.Set { + e.FieldStart("videoId") + s.VideoId.Encode(e) + } + } +} + +var jsonFieldsNameOfWatchEndpoint = [1]string{ + 0: "videoId", +} + +// Decode decodes WatchEndpoint from json. +func (s *WatchEndpoint) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode WatchEndpoint to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "videoId": + if err := func() error { + s.VideoId.Reset() + if err := s.VideoId.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"videoId\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode WatchEndpoint") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *WatchEndpoint) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *WatchEndpoint) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} diff --git a/oas_request_encoders_gen.go b/oas_request_encoders_gen.go new file mode 100644 index 0000000..18c177d --- /dev/null +++ b/oas_request_encoders_gen.go @@ -0,0 +1,26 @@ +// Code generated by ogen, DO NOT EDIT. + +package go_youtubekids_client + +import ( + "bytes" + "net/http" + + "github.com/go-faster/jx" + + ht "github.com/ogen-go/ogen/http" +) + +func encodeBrowseRequest( + req *BrowseRequestPayload, + r *http.Request, +) error { + const contentType = "application/json" + e := jx.GetEncoder() + { + req.Encode(e) + } + encoded := e.Bytes() + ht.SetBody(r, bytes.NewReader(encoded), contentType) + return nil +} diff --git a/oas_response_decoders_gen.go b/oas_response_decoders_gen.go new file mode 100644 index 0000000..4cf58d3 --- /dev/null +++ b/oas_response_decoders_gen.go @@ -0,0 +1,91 @@ +// Code generated by ogen, DO NOT EDIT. + +package go_youtubekids_client + +import ( + "io" + "mime" + "net/http" + + "github.com/go-faster/errors" + "github.com/go-faster/jx" + + "github.com/ogen-go/ogen/ogenerrors" + "github.com/ogen-go/ogen/validate" +) + +func decodeBrowseResponse(resp *http.Response) (res BrowseRes, err error) { + switch resp.StatusCode { + case 200: + // Code 200. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response BrowseResponsePayload + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 400: + // Code 400. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response ErrorResponsePayload + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + } + return res, validate.UnexpectedStatusCode(resp.StatusCode) +} diff --git a/oas_schemas_gen.go b/oas_schemas_gen.go new file mode 100644 index 0000000..186c3d6 --- /dev/null +++ b/oas_schemas_gen.go @@ -0,0 +1,2439 @@ +// Code generated by ogen, DO NOT EDIT. + +package go_youtubekids_client + +// Ref: #/components/schemas/Accessibility +type Accessibility struct { + AccessibilityData OptAccessibilityData `json:"accessibilityData"` +} + +// GetAccessibilityData returns the value of AccessibilityData. +func (s *Accessibility) GetAccessibilityData() OptAccessibilityData { + return s.AccessibilityData +} + +// SetAccessibilityData sets the value of AccessibilityData. +func (s *Accessibility) SetAccessibilityData(val OptAccessibilityData) { + s.AccessibilityData = val +} + +// Ref: #/components/schemas/AccessibilityData +type AccessibilityData struct { + Label OptString `json:"label"` +} + +// GetLabel returns the value of Label. +func (s *AccessibilityData) GetLabel() OptString { + return s.Label +} + +// SetLabel sets the value of Label. +func (s *AccessibilityData) SetLabel(val OptString) { + s.Label = val +} + +// Ref: #/components/schemas/AnchoredSectionRenderer +type AnchoredSectionRenderer struct { + Title OptString `json:"title"` + Content OptAnchoredSectionRendererContent `json:"content"` + TrackingParams OptString `json:"trackingParams"` + NavigationEndpoint OptNavigationEndpoint `json:"navigationEndpoint"` + CategoryAssets OptCategoryAssets `json:"categoryAssets"` + CategoryType OptString `json:"categoryType"` +} + +// GetTitle returns the value of Title. +func (s *AnchoredSectionRenderer) GetTitle() OptString { + return s.Title +} + +// GetContent returns the value of Content. +func (s *AnchoredSectionRenderer) GetContent() OptAnchoredSectionRendererContent { + return s.Content +} + +// GetTrackingParams returns the value of TrackingParams. +func (s *AnchoredSectionRenderer) GetTrackingParams() OptString { + return s.TrackingParams +} + +// GetNavigationEndpoint returns the value of NavigationEndpoint. +func (s *AnchoredSectionRenderer) GetNavigationEndpoint() OptNavigationEndpoint { + return s.NavigationEndpoint +} + +// GetCategoryAssets returns the value of CategoryAssets. +func (s *AnchoredSectionRenderer) GetCategoryAssets() OptCategoryAssets { + return s.CategoryAssets +} + +// GetCategoryType returns the value of CategoryType. +func (s *AnchoredSectionRenderer) GetCategoryType() OptString { + return s.CategoryType +} + +// SetTitle sets the value of Title. +func (s *AnchoredSectionRenderer) SetTitle(val OptString) { + s.Title = val +} + +// SetContent sets the value of Content. +func (s *AnchoredSectionRenderer) SetContent(val OptAnchoredSectionRendererContent) { + s.Content = val +} + +// SetTrackingParams sets the value of TrackingParams. +func (s *AnchoredSectionRenderer) SetTrackingParams(val OptString) { + s.TrackingParams = val +} + +// SetNavigationEndpoint sets the value of NavigationEndpoint. +func (s *AnchoredSectionRenderer) SetNavigationEndpoint(val OptNavigationEndpoint) { + s.NavigationEndpoint = val +} + +// SetCategoryAssets sets the value of CategoryAssets. +func (s *AnchoredSectionRenderer) SetCategoryAssets(val OptCategoryAssets) { + s.CategoryAssets = val +} + +// SetCategoryType sets the value of CategoryType. +func (s *AnchoredSectionRenderer) SetCategoryType(val OptString) { + s.CategoryType = val +} + +type AnchoredSectionRendererContent struct { + SectionListRenderer OptSectionListRenderer `json:"sectionListRenderer"` +} + +// GetSectionListRenderer returns the value of SectionListRenderer. +func (s *AnchoredSectionRendererContent) GetSectionListRenderer() OptSectionListRenderer { + return s.SectionListRenderer +} + +// SetSectionListRenderer sets the value of SectionListRenderer. +func (s *AnchoredSectionRendererContent) SetSectionListRenderer(val OptSectionListRenderer) { + s.SectionListRenderer = val +} + +// Ref: #/components/schemas/BrowseEndpoint +type BrowseEndpoint struct { + BrowseId OptString `json:"browseId"` + CanonicalBaseUrl OptString `json:"canonicalBaseUrl"` +} + +// GetBrowseId returns the value of BrowseId. +func (s *BrowseEndpoint) GetBrowseId() OptString { + return s.BrowseId +} + +// GetCanonicalBaseUrl returns the value of CanonicalBaseUrl. +func (s *BrowseEndpoint) GetCanonicalBaseUrl() OptString { + return s.CanonicalBaseUrl +} + +// SetBrowseId sets the value of BrowseId. +func (s *BrowseEndpoint) SetBrowseId(val OptString) { + s.BrowseId = val +} + +// SetCanonicalBaseUrl sets the value of CanonicalBaseUrl. +func (s *BrowseEndpoint) SetCanonicalBaseUrl(val OptString) { + s.CanonicalBaseUrl = val +} + +// Ref: #/components/schemas/BrowseRequestPayload +type BrowseRequestPayload struct { + Context OptRequestContext `json:"context"` + BrowseId OptString `json:"browseId"` +} + +// GetContext returns the value of Context. +func (s *BrowseRequestPayload) GetContext() OptRequestContext { + return s.Context +} + +// GetBrowseId returns the value of BrowseId. +func (s *BrowseRequestPayload) GetBrowseId() OptString { + return s.BrowseId +} + +// SetContext sets the value of Context. +func (s *BrowseRequestPayload) SetContext(val OptRequestContext) { + s.Context = val +} + +// SetBrowseId sets the value of BrowseId. +func (s *BrowseRequestPayload) SetBrowseId(val OptString) { + s.BrowseId = val +} + +// Ref: #/components/schemas/BrowseResponsePayload +type BrowseResponsePayload struct { + ResponseContext OptResponseContext `json:"responseContext"` + Header OptBrowseResponsePayloadHeader `json:"header"` + Contents OptBrowseResponsePayloadContents `json:"contents"` + TrackingParams OptString `json:"trackingParams"` +} + +// GetResponseContext returns the value of ResponseContext. +func (s *BrowseResponsePayload) GetResponseContext() OptResponseContext { + return s.ResponseContext +} + +// GetHeader returns the value of Header. +func (s *BrowseResponsePayload) GetHeader() OptBrowseResponsePayloadHeader { + return s.Header +} + +// GetContents returns the value of Contents. +func (s *BrowseResponsePayload) GetContents() OptBrowseResponsePayloadContents { + return s.Contents +} + +// GetTrackingParams returns the value of TrackingParams. +func (s *BrowseResponsePayload) GetTrackingParams() OptString { + return s.TrackingParams +} + +// SetResponseContext sets the value of ResponseContext. +func (s *BrowseResponsePayload) SetResponseContext(val OptResponseContext) { + s.ResponseContext = val +} + +// SetHeader sets the value of Header. +func (s *BrowseResponsePayload) SetHeader(val OptBrowseResponsePayloadHeader) { + s.Header = val +} + +// SetContents sets the value of Contents. +func (s *BrowseResponsePayload) SetContents(val OptBrowseResponsePayloadContents) { + s.Contents = val +} + +// SetTrackingParams sets the value of TrackingParams. +func (s *BrowseResponsePayload) SetTrackingParams(val OptString) { + s.TrackingParams = val +} + +func (*BrowseResponsePayload) browseRes() {} + +type BrowseResponsePayloadContents struct { + KidsHomeScreenRenderer OptScreenRenderer `json:"kidsHomeScreenRenderer"` +} + +// GetKidsHomeScreenRenderer returns the value of KidsHomeScreenRenderer. +func (s *BrowseResponsePayloadContents) GetKidsHomeScreenRenderer() OptScreenRenderer { + return s.KidsHomeScreenRenderer +} + +// SetKidsHomeScreenRenderer sets the value of KidsHomeScreenRenderer. +func (s *BrowseResponsePayloadContents) SetKidsHomeScreenRenderer(val OptScreenRenderer) { + s.KidsHomeScreenRenderer = val +} + +type BrowseResponsePayloadHeader struct { + KidsCategoriesHeaderRenderer OptCategoriesHeaderRenderer `json:"kidsCategoriesHeaderRenderer"` +} + +// GetKidsCategoriesHeaderRenderer returns the value of KidsCategoriesHeaderRenderer. +func (s *BrowseResponsePayloadHeader) GetKidsCategoriesHeaderRenderer() OptCategoriesHeaderRenderer { + return s.KidsCategoriesHeaderRenderer +} + +// SetKidsCategoriesHeaderRenderer sets the value of KidsCategoriesHeaderRenderer. +func (s *BrowseResponsePayloadHeader) SetKidsCategoriesHeaderRenderer(val OptCategoriesHeaderRenderer) { + s.KidsCategoriesHeaderRenderer = val +} + +// Ref: #/components/schemas/CategoriesHeaderRenderer +type CategoriesHeaderRenderer struct { + TrackingParams OptString `json:"trackingParams"` +} + +// GetTrackingParams returns the value of TrackingParams. +func (s *CategoriesHeaderRenderer) GetTrackingParams() OptString { + return s.TrackingParams +} + +// SetTrackingParams sets the value of TrackingParams. +func (s *CategoriesHeaderRenderer) SetTrackingParams(val OptString) { + s.TrackingParams = val +} + +// Ref: #/components/schemas/CategoryAssets +type CategoryAssets struct { + AssetKey OptString `json:"assetKey"` + BackgroundColor OptString `json:"backgroundColor"` +} + +// GetAssetKey returns the value of AssetKey. +func (s *CategoryAssets) GetAssetKey() OptString { + return s.AssetKey +} + +// GetBackgroundColor returns the value of BackgroundColor. +func (s *CategoryAssets) GetBackgroundColor() OptString { + return s.BackgroundColor +} + +// SetAssetKey sets the value of AssetKey. +func (s *CategoryAssets) SetAssetKey(val OptString) { + s.AssetKey = val +} + +// SetBackgroundColor sets the value of BackgroundColor. +func (s *CategoryAssets) SetBackgroundColor(val OptString) { + s.BackgroundColor = val +} + +// Ref: #/components/schemas/CompactVideoRenderer +type CompactVideoRenderer struct { + VideoId OptString `json:"videoId"` + Thumbnail OptCompactVideoRendererThumbnail `json:"thumbnail"` + Title OptText `json:"title"` + LongBylineText OptText `json:"longBylineText"` + PublishedTimeText OptText `json:"publishedTimeText"` + ViewCountText OptText `json:"viewCountText"` + LengthText OptText `json:"lengthText"` + NavigationEndpoint OptNavigationEndpoint `json:"navigationEndpoint"` + ShortBylineText OptText `json:"shortBylineText"` + ChannelThumbnail OptCompactVideoRendererChannelThumbnail `json:"channelThumbnail"` + TrackingParams OptString `json:"trackingParams"` + ShortViewCountText OptText `json:"shortViewCountText"` + Accessibility OptAccessibility `json:"accessibility"` + KidsVideoOwnerExtension OptKidsVideoOwnerExtension `json:"kidsVideoOwnerExtension"` +} + +// GetVideoId returns the value of VideoId. +func (s *CompactVideoRenderer) GetVideoId() OptString { + return s.VideoId +} + +// GetThumbnail returns the value of Thumbnail. +func (s *CompactVideoRenderer) GetThumbnail() OptCompactVideoRendererThumbnail { + return s.Thumbnail +} + +// GetTitle returns the value of Title. +func (s *CompactVideoRenderer) GetTitle() OptText { + return s.Title +} + +// GetLongBylineText returns the value of LongBylineText. +func (s *CompactVideoRenderer) GetLongBylineText() OptText { + return s.LongBylineText +} + +// GetPublishedTimeText returns the value of PublishedTimeText. +func (s *CompactVideoRenderer) GetPublishedTimeText() OptText { + return s.PublishedTimeText +} + +// GetViewCountText returns the value of ViewCountText. +func (s *CompactVideoRenderer) GetViewCountText() OptText { + return s.ViewCountText +} + +// GetLengthText returns the value of LengthText. +func (s *CompactVideoRenderer) GetLengthText() OptText { + return s.LengthText +} + +// GetNavigationEndpoint returns the value of NavigationEndpoint. +func (s *CompactVideoRenderer) GetNavigationEndpoint() OptNavigationEndpoint { + return s.NavigationEndpoint +} + +// GetShortBylineText returns the value of ShortBylineText. +func (s *CompactVideoRenderer) GetShortBylineText() OptText { + return s.ShortBylineText +} + +// GetChannelThumbnail returns the value of ChannelThumbnail. +func (s *CompactVideoRenderer) GetChannelThumbnail() OptCompactVideoRendererChannelThumbnail { + return s.ChannelThumbnail +} + +// GetTrackingParams returns the value of TrackingParams. +func (s *CompactVideoRenderer) GetTrackingParams() OptString { + return s.TrackingParams +} + +// GetShortViewCountText returns the value of ShortViewCountText. +func (s *CompactVideoRenderer) GetShortViewCountText() OptText { + return s.ShortViewCountText +} + +// GetAccessibility returns the value of Accessibility. +func (s *CompactVideoRenderer) GetAccessibility() OptAccessibility { + return s.Accessibility +} + +// GetKidsVideoOwnerExtension returns the value of KidsVideoOwnerExtension. +func (s *CompactVideoRenderer) GetKidsVideoOwnerExtension() OptKidsVideoOwnerExtension { + return s.KidsVideoOwnerExtension +} + +// SetVideoId sets the value of VideoId. +func (s *CompactVideoRenderer) SetVideoId(val OptString) { + s.VideoId = val +} + +// SetThumbnail sets the value of Thumbnail. +func (s *CompactVideoRenderer) SetThumbnail(val OptCompactVideoRendererThumbnail) { + s.Thumbnail = val +} + +// SetTitle sets the value of Title. +func (s *CompactVideoRenderer) SetTitle(val OptText) { + s.Title = val +} + +// SetLongBylineText sets the value of LongBylineText. +func (s *CompactVideoRenderer) SetLongBylineText(val OptText) { + s.LongBylineText = val +} + +// SetPublishedTimeText sets the value of PublishedTimeText. +func (s *CompactVideoRenderer) SetPublishedTimeText(val OptText) { + s.PublishedTimeText = val +} + +// SetViewCountText sets the value of ViewCountText. +func (s *CompactVideoRenderer) SetViewCountText(val OptText) { + s.ViewCountText = val +} + +// SetLengthText sets the value of LengthText. +func (s *CompactVideoRenderer) SetLengthText(val OptText) { + s.LengthText = val +} + +// SetNavigationEndpoint sets the value of NavigationEndpoint. +func (s *CompactVideoRenderer) SetNavigationEndpoint(val OptNavigationEndpoint) { + s.NavigationEndpoint = val +} + +// SetShortBylineText sets the value of ShortBylineText. +func (s *CompactVideoRenderer) SetShortBylineText(val OptText) { + s.ShortBylineText = val +} + +// SetChannelThumbnail sets the value of ChannelThumbnail. +func (s *CompactVideoRenderer) SetChannelThumbnail(val OptCompactVideoRendererChannelThumbnail) { + s.ChannelThumbnail = val +} + +// SetTrackingParams sets the value of TrackingParams. +func (s *CompactVideoRenderer) SetTrackingParams(val OptString) { + s.TrackingParams = val +} + +// SetShortViewCountText sets the value of ShortViewCountText. +func (s *CompactVideoRenderer) SetShortViewCountText(val OptText) { + s.ShortViewCountText = val +} + +// SetAccessibility sets the value of Accessibility. +func (s *CompactVideoRenderer) SetAccessibility(val OptAccessibility) { + s.Accessibility = val +} + +// SetKidsVideoOwnerExtension sets the value of KidsVideoOwnerExtension. +func (s *CompactVideoRenderer) SetKidsVideoOwnerExtension(val OptKidsVideoOwnerExtension) { + s.KidsVideoOwnerExtension = val +} + +type CompactVideoRendererChannelThumbnail struct { + Thumbnails []Thumbnail `json:"thumbnails"` +} + +// GetThumbnails returns the value of Thumbnails. +func (s *CompactVideoRendererChannelThumbnail) GetThumbnails() []Thumbnail { + return s.Thumbnails +} + +// SetThumbnails sets the value of Thumbnails. +func (s *CompactVideoRendererChannelThumbnail) SetThumbnails(val []Thumbnail) { + s.Thumbnails = val +} + +type CompactVideoRendererThumbnail struct { + Thumbnails []Thumbnail `json:"thumbnails"` +} + +// GetThumbnails returns the value of Thumbnails. +func (s *CompactVideoRendererThumbnail) GetThumbnails() []Thumbnail { + return s.Thumbnails +} + +// SetThumbnails sets the value of Thumbnails. +func (s *CompactVideoRendererThumbnail) SetThumbnails(val []Thumbnail) { + s.Thumbnails = val +} + +// Ref: #/components/schemas/Error +type Error struct { + Message OptString `json:"message"` + Domain OptString `json:"domain"` + Reason OptString `json:"reason"` +} + +// GetMessage returns the value of Message. +func (s *Error) GetMessage() OptString { + return s.Message +} + +// GetDomain returns the value of Domain. +func (s *Error) GetDomain() OptString { + return s.Domain +} + +// GetReason returns the value of Reason. +func (s *Error) GetReason() OptString { + return s.Reason +} + +// SetMessage sets the value of Message. +func (s *Error) SetMessage(val OptString) { + s.Message = val +} + +// SetDomain sets the value of Domain. +func (s *Error) SetDomain(val OptString) { + s.Domain = val +} + +// SetReason sets the value of Reason. +func (s *Error) SetReason(val OptString) { + s.Reason = val +} + +// Ref: #/components/schemas/ErrorResponsePayload +type ErrorResponsePayload struct { + Error OptErrorResponsePayloadError `json:"error"` +} + +// GetError returns the value of Error. +func (s *ErrorResponsePayload) GetError() OptErrorResponsePayloadError { + return s.Error +} + +// SetError sets the value of Error. +func (s *ErrorResponsePayload) SetError(val OptErrorResponsePayloadError) { + s.Error = val +} + +func (*ErrorResponsePayload) browseRes() {} + +type ErrorResponsePayloadError struct { + Code OptFloat64 `json:"code"` + Message OptString `json:"message"` + Errors []Error `json:"errors"` + Status OptString `json:"status"` +} + +// GetCode returns the value of Code. +func (s *ErrorResponsePayloadError) GetCode() OptFloat64 { + return s.Code +} + +// GetMessage returns the value of Message. +func (s *ErrorResponsePayloadError) GetMessage() OptString { + return s.Message +} + +// GetErrors returns the value of Errors. +func (s *ErrorResponsePayloadError) GetErrors() []Error { + return s.Errors +} + +// GetStatus returns the value of Status. +func (s *ErrorResponsePayloadError) GetStatus() OptString { + return s.Status +} + +// SetCode sets the value of Code. +func (s *ErrorResponsePayloadError) SetCode(val OptFloat64) { + s.Code = val +} + +// SetMessage sets the value of Message. +func (s *ErrorResponsePayloadError) SetMessage(val OptString) { + s.Message = val +} + +// SetErrors sets the value of Errors. +func (s *ErrorResponsePayloadError) SetErrors(val []Error) { + s.Errors = val +} + +// SetStatus sets the value of Status. +func (s *ErrorResponsePayloadError) SetStatus(val OptString) { + s.Status = val +} + +// Ref: #/components/schemas/ItemSectionRenderer +type ItemSectionRenderer struct { + Contents []ItemSectionRendererContentsItem `json:"contents"` + TrackingParams OptString `json:"trackingParams"` +} + +// GetContents returns the value of Contents. +func (s *ItemSectionRenderer) GetContents() []ItemSectionRendererContentsItem { + return s.Contents +} + +// GetTrackingParams returns the value of TrackingParams. +func (s *ItemSectionRenderer) GetTrackingParams() OptString { + return s.TrackingParams +} + +// SetContents sets the value of Contents. +func (s *ItemSectionRenderer) SetContents(val []ItemSectionRendererContentsItem) { + s.Contents = val +} + +// SetTrackingParams sets the value of TrackingParams. +func (s *ItemSectionRenderer) SetTrackingParams(val OptString) { + s.TrackingParams = val +} + +type ItemSectionRendererContentsItem struct { + CompactVideoRenderer OptCompactVideoRenderer `json:"compactVideoRenderer"` +} + +// GetCompactVideoRenderer returns the value of CompactVideoRenderer. +func (s *ItemSectionRendererContentsItem) GetCompactVideoRenderer() OptCompactVideoRenderer { + return s.CompactVideoRenderer +} + +// SetCompactVideoRenderer sets the value of CompactVideoRenderer. +func (s *ItemSectionRendererContentsItem) SetCompactVideoRenderer(val OptCompactVideoRenderer) { + s.CompactVideoRenderer = val +} + +// Ref: #/components/schemas/KeyStringValue +type KeyStringValue struct { + Key OptString `json:"key"` + Value OptString `json:"value"` +} + +// GetKey returns the value of Key. +func (s *KeyStringValue) GetKey() OptString { + return s.Key +} + +// GetValue returns the value of Value. +func (s *KeyStringValue) GetValue() OptString { + return s.Value +} + +// SetKey sets the value of Key. +func (s *KeyStringValue) SetKey(val OptString) { + s.Key = val +} + +// SetValue sets the value of Value. +func (s *KeyStringValue) SetValue(val OptString) { + s.Value = val +} + +// Ref: #/components/schemas/KidsAppCategorySettings +type KidsAppCategorySettings struct { + EnabledCategories []string `json:"enabledCategories"` +} + +// GetEnabledCategories returns the value of EnabledCategories. +func (s *KidsAppCategorySettings) GetEnabledCategories() []string { + return s.EnabledCategories +} + +// SetEnabledCategories sets the value of EnabledCategories. +func (s *KidsAppCategorySettings) SetEnabledCategories(val []string) { + s.EnabledCategories = val +} + +// Ref: #/components/schemas/KidsAppContentSettings +type KidsAppContentSettings struct { + CorpusPreference OptString `json:"corpusPreference"` + KidsNoSearchMode OptString `json:"kidsNoSearchMode"` +} + +// GetCorpusPreference returns the value of CorpusPreference. +func (s *KidsAppContentSettings) GetCorpusPreference() OptString { + return s.CorpusPreference +} + +// GetKidsNoSearchMode returns the value of KidsNoSearchMode. +func (s *KidsAppContentSettings) GetKidsNoSearchMode() OptString { + return s.KidsNoSearchMode +} + +// SetCorpusPreference sets the value of CorpusPreference. +func (s *KidsAppContentSettings) SetCorpusPreference(val OptString) { + s.CorpusPreference = val +} + +// SetKidsNoSearchMode sets the value of KidsNoSearchMode. +func (s *KidsAppContentSettings) SetKidsNoSearchMode(val OptString) { + s.KidsNoSearchMode = val +} + +// Kids application configuration. +// Ref: #/components/schemas/KidsAppInfo +type KidsAppInfo struct { + ContentSettings OptKidsAppContentSettings `json:"contentSettings"` + CategorySettings OptKidsAppCategorySettings `json:"categorySettings"` +} + +// GetContentSettings returns the value of ContentSettings. +func (s *KidsAppInfo) GetContentSettings() OptKidsAppContentSettings { + return s.ContentSettings +} + +// GetCategorySettings returns the value of CategorySettings. +func (s *KidsAppInfo) GetCategorySettings() OptKidsAppCategorySettings { + return s.CategorySettings +} + +// SetContentSettings sets the value of ContentSettings. +func (s *KidsAppInfo) SetContentSettings(val OptKidsAppContentSettings) { + s.ContentSettings = val +} + +// SetCategorySettings sets the value of CategorySettings. +func (s *KidsAppInfo) SetCategorySettings(val OptKidsAppCategorySettings) { + s.CategorySettings = val +} + +// Ref: #/components/schemas/KidsVideoOwnerExtension +type KidsVideoOwnerExtension struct { + ExternalChannelId OptString `json:"externalChannelId"` +} + +// GetExternalChannelId returns the value of ExternalChannelId. +func (s *KidsVideoOwnerExtension) GetExternalChannelId() OptString { + return s.ExternalChannelId +} + +// SetExternalChannelId sets the value of ExternalChannelId. +func (s *KidsVideoOwnerExtension) SetExternalChannelId(val OptString) { + s.ExternalChannelId = val +} + +// Ref: #/components/schemas/NavigationEndpoint +type NavigationEndpoint struct { + ClickTrackingParams OptString `json:"clickTrackingParams"` + WatchEndpoint OptWatchEndpoint `json:"watchEndpoint"` + BrowseEndpoint OptBrowseEndpoint `json:"browseEndpoint"` +} + +// GetClickTrackingParams returns the value of ClickTrackingParams. +func (s *NavigationEndpoint) GetClickTrackingParams() OptString { + return s.ClickTrackingParams +} + +// GetWatchEndpoint returns the value of WatchEndpoint. +func (s *NavigationEndpoint) GetWatchEndpoint() OptWatchEndpoint { + return s.WatchEndpoint +} + +// GetBrowseEndpoint returns the value of BrowseEndpoint. +func (s *NavigationEndpoint) GetBrowseEndpoint() OptBrowseEndpoint { + return s.BrowseEndpoint +} + +// SetClickTrackingParams sets the value of ClickTrackingParams. +func (s *NavigationEndpoint) SetClickTrackingParams(val OptString) { + s.ClickTrackingParams = val +} + +// SetWatchEndpoint sets the value of WatchEndpoint. +func (s *NavigationEndpoint) SetWatchEndpoint(val OptWatchEndpoint) { + s.WatchEndpoint = val +} + +// SetBrowseEndpoint sets the value of BrowseEndpoint. +func (s *NavigationEndpoint) SetBrowseEndpoint(val OptBrowseEndpoint) { + s.BrowseEndpoint = val +} + +// NewOptAccessibility returns new OptAccessibility with value set to v. +func NewOptAccessibility(v Accessibility) OptAccessibility { + return OptAccessibility{ + Value: v, + Set: true, + } +} + +// OptAccessibility is optional Accessibility. +type OptAccessibility struct { + Value Accessibility + Set bool +} + +// IsSet returns true if OptAccessibility was set. +func (o OptAccessibility) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptAccessibility) Reset() { + var v Accessibility + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptAccessibility) SetTo(v Accessibility) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptAccessibility) Get() (v Accessibility, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptAccessibility) Or(d Accessibility) Accessibility { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptAccessibilityData returns new OptAccessibilityData with value set to v. +func NewOptAccessibilityData(v AccessibilityData) OptAccessibilityData { + return OptAccessibilityData{ + Value: v, + Set: true, + } +} + +// OptAccessibilityData is optional AccessibilityData. +type OptAccessibilityData struct { + Value AccessibilityData + Set bool +} + +// IsSet returns true if OptAccessibilityData was set. +func (o OptAccessibilityData) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptAccessibilityData) Reset() { + var v AccessibilityData + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptAccessibilityData) SetTo(v AccessibilityData) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptAccessibilityData) Get() (v AccessibilityData, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptAccessibilityData) Or(d AccessibilityData) AccessibilityData { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptAnchoredSectionRenderer returns new OptAnchoredSectionRenderer with value set to v. +func NewOptAnchoredSectionRenderer(v AnchoredSectionRenderer) OptAnchoredSectionRenderer { + return OptAnchoredSectionRenderer{ + Value: v, + Set: true, + } +} + +// OptAnchoredSectionRenderer is optional AnchoredSectionRenderer. +type OptAnchoredSectionRenderer struct { + Value AnchoredSectionRenderer + Set bool +} + +// IsSet returns true if OptAnchoredSectionRenderer was set. +func (o OptAnchoredSectionRenderer) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptAnchoredSectionRenderer) Reset() { + var v AnchoredSectionRenderer + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptAnchoredSectionRenderer) SetTo(v AnchoredSectionRenderer) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptAnchoredSectionRenderer) Get() (v AnchoredSectionRenderer, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptAnchoredSectionRenderer) Or(d AnchoredSectionRenderer) AnchoredSectionRenderer { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptAnchoredSectionRendererContent returns new OptAnchoredSectionRendererContent with value set to v. +func NewOptAnchoredSectionRendererContent(v AnchoredSectionRendererContent) OptAnchoredSectionRendererContent { + return OptAnchoredSectionRendererContent{ + Value: v, + Set: true, + } +} + +// OptAnchoredSectionRendererContent is optional AnchoredSectionRendererContent. +type OptAnchoredSectionRendererContent struct { + Value AnchoredSectionRendererContent + Set bool +} + +// IsSet returns true if OptAnchoredSectionRendererContent was set. +func (o OptAnchoredSectionRendererContent) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptAnchoredSectionRendererContent) Reset() { + var v AnchoredSectionRendererContent + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptAnchoredSectionRendererContent) SetTo(v AnchoredSectionRendererContent) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptAnchoredSectionRendererContent) Get() (v AnchoredSectionRendererContent, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptAnchoredSectionRendererContent) Or(d AnchoredSectionRendererContent) AnchoredSectionRendererContent { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptBrowseEndpoint returns new OptBrowseEndpoint with value set to v. +func NewOptBrowseEndpoint(v BrowseEndpoint) OptBrowseEndpoint { + return OptBrowseEndpoint{ + Value: v, + Set: true, + } +} + +// OptBrowseEndpoint is optional BrowseEndpoint. +type OptBrowseEndpoint struct { + Value BrowseEndpoint + Set bool +} + +// IsSet returns true if OptBrowseEndpoint was set. +func (o OptBrowseEndpoint) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptBrowseEndpoint) Reset() { + var v BrowseEndpoint + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptBrowseEndpoint) SetTo(v BrowseEndpoint) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptBrowseEndpoint) Get() (v BrowseEndpoint, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptBrowseEndpoint) Or(d BrowseEndpoint) BrowseEndpoint { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptBrowseResponsePayloadContents returns new OptBrowseResponsePayloadContents with value set to v. +func NewOptBrowseResponsePayloadContents(v BrowseResponsePayloadContents) OptBrowseResponsePayloadContents { + return OptBrowseResponsePayloadContents{ + Value: v, + Set: true, + } +} + +// OptBrowseResponsePayloadContents is optional BrowseResponsePayloadContents. +type OptBrowseResponsePayloadContents struct { + Value BrowseResponsePayloadContents + Set bool +} + +// IsSet returns true if OptBrowseResponsePayloadContents was set. +func (o OptBrowseResponsePayloadContents) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptBrowseResponsePayloadContents) Reset() { + var v BrowseResponsePayloadContents + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptBrowseResponsePayloadContents) SetTo(v BrowseResponsePayloadContents) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptBrowseResponsePayloadContents) Get() (v BrowseResponsePayloadContents, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptBrowseResponsePayloadContents) Or(d BrowseResponsePayloadContents) BrowseResponsePayloadContents { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptBrowseResponsePayloadHeader returns new OptBrowseResponsePayloadHeader with value set to v. +func NewOptBrowseResponsePayloadHeader(v BrowseResponsePayloadHeader) OptBrowseResponsePayloadHeader { + return OptBrowseResponsePayloadHeader{ + Value: v, + Set: true, + } +} + +// OptBrowseResponsePayloadHeader is optional BrowseResponsePayloadHeader. +type OptBrowseResponsePayloadHeader struct { + Value BrowseResponsePayloadHeader + Set bool +} + +// IsSet returns true if OptBrowseResponsePayloadHeader was set. +func (o OptBrowseResponsePayloadHeader) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptBrowseResponsePayloadHeader) Reset() { + var v BrowseResponsePayloadHeader + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptBrowseResponsePayloadHeader) SetTo(v BrowseResponsePayloadHeader) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptBrowseResponsePayloadHeader) Get() (v BrowseResponsePayloadHeader, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptBrowseResponsePayloadHeader) Or(d BrowseResponsePayloadHeader) BrowseResponsePayloadHeader { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptCategoriesHeaderRenderer returns new OptCategoriesHeaderRenderer with value set to v. +func NewOptCategoriesHeaderRenderer(v CategoriesHeaderRenderer) OptCategoriesHeaderRenderer { + return OptCategoriesHeaderRenderer{ + Value: v, + Set: true, + } +} + +// OptCategoriesHeaderRenderer is optional CategoriesHeaderRenderer. +type OptCategoriesHeaderRenderer struct { + Value CategoriesHeaderRenderer + Set bool +} + +// IsSet returns true if OptCategoriesHeaderRenderer was set. +func (o OptCategoriesHeaderRenderer) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptCategoriesHeaderRenderer) Reset() { + var v CategoriesHeaderRenderer + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptCategoriesHeaderRenderer) SetTo(v CategoriesHeaderRenderer) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptCategoriesHeaderRenderer) Get() (v CategoriesHeaderRenderer, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptCategoriesHeaderRenderer) Or(d CategoriesHeaderRenderer) CategoriesHeaderRenderer { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptCategoryAssets returns new OptCategoryAssets with value set to v. +func NewOptCategoryAssets(v CategoryAssets) OptCategoryAssets { + return OptCategoryAssets{ + Value: v, + Set: true, + } +} + +// OptCategoryAssets is optional CategoryAssets. +type OptCategoryAssets struct { + Value CategoryAssets + Set bool +} + +// IsSet returns true if OptCategoryAssets was set. +func (o OptCategoryAssets) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptCategoryAssets) Reset() { + var v CategoryAssets + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptCategoryAssets) SetTo(v CategoryAssets) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptCategoryAssets) Get() (v CategoryAssets, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptCategoryAssets) Or(d CategoryAssets) CategoryAssets { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptCompactVideoRenderer returns new OptCompactVideoRenderer with value set to v. +func NewOptCompactVideoRenderer(v CompactVideoRenderer) OptCompactVideoRenderer { + return OptCompactVideoRenderer{ + Value: v, + Set: true, + } +} + +// OptCompactVideoRenderer is optional CompactVideoRenderer. +type OptCompactVideoRenderer struct { + Value CompactVideoRenderer + Set bool +} + +// IsSet returns true if OptCompactVideoRenderer was set. +func (o OptCompactVideoRenderer) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptCompactVideoRenderer) Reset() { + var v CompactVideoRenderer + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptCompactVideoRenderer) SetTo(v CompactVideoRenderer) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptCompactVideoRenderer) Get() (v CompactVideoRenderer, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptCompactVideoRenderer) Or(d CompactVideoRenderer) CompactVideoRenderer { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptCompactVideoRendererChannelThumbnail returns new OptCompactVideoRendererChannelThumbnail with value set to v. +func NewOptCompactVideoRendererChannelThumbnail(v CompactVideoRendererChannelThumbnail) OptCompactVideoRendererChannelThumbnail { + return OptCompactVideoRendererChannelThumbnail{ + Value: v, + Set: true, + } +} + +// OptCompactVideoRendererChannelThumbnail is optional CompactVideoRendererChannelThumbnail. +type OptCompactVideoRendererChannelThumbnail struct { + Value CompactVideoRendererChannelThumbnail + Set bool +} + +// IsSet returns true if OptCompactVideoRendererChannelThumbnail was set. +func (o OptCompactVideoRendererChannelThumbnail) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptCompactVideoRendererChannelThumbnail) Reset() { + var v CompactVideoRendererChannelThumbnail + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptCompactVideoRendererChannelThumbnail) SetTo(v CompactVideoRendererChannelThumbnail) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptCompactVideoRendererChannelThumbnail) Get() (v CompactVideoRendererChannelThumbnail, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptCompactVideoRendererChannelThumbnail) Or(d CompactVideoRendererChannelThumbnail) CompactVideoRendererChannelThumbnail { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptCompactVideoRendererThumbnail returns new OptCompactVideoRendererThumbnail with value set to v. +func NewOptCompactVideoRendererThumbnail(v CompactVideoRendererThumbnail) OptCompactVideoRendererThumbnail { + return OptCompactVideoRendererThumbnail{ + Value: v, + Set: true, + } +} + +// OptCompactVideoRendererThumbnail is optional CompactVideoRendererThumbnail. +type OptCompactVideoRendererThumbnail struct { + Value CompactVideoRendererThumbnail + Set bool +} + +// IsSet returns true if OptCompactVideoRendererThumbnail was set. +func (o OptCompactVideoRendererThumbnail) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptCompactVideoRendererThumbnail) Reset() { + var v CompactVideoRendererThumbnail + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptCompactVideoRendererThumbnail) SetTo(v CompactVideoRendererThumbnail) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptCompactVideoRendererThumbnail) Get() (v CompactVideoRendererThumbnail, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptCompactVideoRendererThumbnail) Or(d CompactVideoRendererThumbnail) CompactVideoRendererThumbnail { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptErrorResponsePayloadError returns new OptErrorResponsePayloadError with value set to v. +func NewOptErrorResponsePayloadError(v ErrorResponsePayloadError) OptErrorResponsePayloadError { + return OptErrorResponsePayloadError{ + Value: v, + Set: true, + } +} + +// OptErrorResponsePayloadError is optional ErrorResponsePayloadError. +type OptErrorResponsePayloadError struct { + Value ErrorResponsePayloadError + Set bool +} + +// IsSet returns true if OptErrorResponsePayloadError was set. +func (o OptErrorResponsePayloadError) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptErrorResponsePayloadError) Reset() { + var v ErrorResponsePayloadError + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptErrorResponsePayloadError) SetTo(v ErrorResponsePayloadError) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptErrorResponsePayloadError) Get() (v ErrorResponsePayloadError, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptErrorResponsePayloadError) Or(d ErrorResponsePayloadError) ErrorResponsePayloadError { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptFloat64 returns new OptFloat64 with value set to v. +func NewOptFloat64(v float64) OptFloat64 { + return OptFloat64{ + Value: v, + Set: true, + } +} + +// OptFloat64 is optional float64. +type OptFloat64 struct { + Value float64 + Set bool +} + +// IsSet returns true if OptFloat64 was set. +func (o OptFloat64) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptFloat64) Reset() { + var v float64 + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptFloat64) SetTo(v float64) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptFloat64) Get() (v float64, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptFloat64) Or(d float64) float64 { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptItemSectionRenderer returns new OptItemSectionRenderer with value set to v. +func NewOptItemSectionRenderer(v ItemSectionRenderer) OptItemSectionRenderer { + return OptItemSectionRenderer{ + Value: v, + Set: true, + } +} + +// OptItemSectionRenderer is optional ItemSectionRenderer. +type OptItemSectionRenderer struct { + Value ItemSectionRenderer + Set bool +} + +// IsSet returns true if OptItemSectionRenderer was set. +func (o OptItemSectionRenderer) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptItemSectionRenderer) Reset() { + var v ItemSectionRenderer + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptItemSectionRenderer) SetTo(v ItemSectionRenderer) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptItemSectionRenderer) Get() (v ItemSectionRenderer, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptItemSectionRenderer) Or(d ItemSectionRenderer) ItemSectionRenderer { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptKidsAppCategorySettings returns new OptKidsAppCategorySettings with value set to v. +func NewOptKidsAppCategorySettings(v KidsAppCategorySettings) OptKidsAppCategorySettings { + return OptKidsAppCategorySettings{ + Value: v, + Set: true, + } +} + +// OptKidsAppCategorySettings is optional KidsAppCategorySettings. +type OptKidsAppCategorySettings struct { + Value KidsAppCategorySettings + Set bool +} + +// IsSet returns true if OptKidsAppCategorySettings was set. +func (o OptKidsAppCategorySettings) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptKidsAppCategorySettings) Reset() { + var v KidsAppCategorySettings + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptKidsAppCategorySettings) SetTo(v KidsAppCategorySettings) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptKidsAppCategorySettings) Get() (v KidsAppCategorySettings, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptKidsAppCategorySettings) Or(d KidsAppCategorySettings) KidsAppCategorySettings { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptKidsAppContentSettings returns new OptKidsAppContentSettings with value set to v. +func NewOptKidsAppContentSettings(v KidsAppContentSettings) OptKidsAppContentSettings { + return OptKidsAppContentSettings{ + Value: v, + Set: true, + } +} + +// OptKidsAppContentSettings is optional KidsAppContentSettings. +type OptKidsAppContentSettings struct { + Value KidsAppContentSettings + Set bool +} + +// IsSet returns true if OptKidsAppContentSettings was set. +func (o OptKidsAppContentSettings) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptKidsAppContentSettings) Reset() { + var v KidsAppContentSettings + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptKidsAppContentSettings) SetTo(v KidsAppContentSettings) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptKidsAppContentSettings) Get() (v KidsAppContentSettings, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptKidsAppContentSettings) Or(d KidsAppContentSettings) KidsAppContentSettings { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptKidsAppInfo returns new OptKidsAppInfo with value set to v. +func NewOptKidsAppInfo(v KidsAppInfo) OptKidsAppInfo { + return OptKidsAppInfo{ + Value: v, + Set: true, + } +} + +// OptKidsAppInfo is optional KidsAppInfo. +type OptKidsAppInfo struct { + Value KidsAppInfo + Set bool +} + +// IsSet returns true if OptKidsAppInfo was set. +func (o OptKidsAppInfo) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptKidsAppInfo) Reset() { + var v KidsAppInfo + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptKidsAppInfo) SetTo(v KidsAppInfo) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptKidsAppInfo) Get() (v KidsAppInfo, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptKidsAppInfo) Or(d KidsAppInfo) KidsAppInfo { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptKidsVideoOwnerExtension returns new OptKidsVideoOwnerExtension with value set to v. +func NewOptKidsVideoOwnerExtension(v KidsVideoOwnerExtension) OptKidsVideoOwnerExtension { + return OptKidsVideoOwnerExtension{ + Value: v, + Set: true, + } +} + +// OptKidsVideoOwnerExtension is optional KidsVideoOwnerExtension. +type OptKidsVideoOwnerExtension struct { + Value KidsVideoOwnerExtension + Set bool +} + +// IsSet returns true if OptKidsVideoOwnerExtension was set. +func (o OptKidsVideoOwnerExtension) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptKidsVideoOwnerExtension) Reset() { + var v KidsVideoOwnerExtension + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptKidsVideoOwnerExtension) SetTo(v KidsVideoOwnerExtension) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptKidsVideoOwnerExtension) Get() (v KidsVideoOwnerExtension, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptKidsVideoOwnerExtension) Or(d KidsVideoOwnerExtension) KidsVideoOwnerExtension { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptNavigationEndpoint returns new OptNavigationEndpoint with value set to v. +func NewOptNavigationEndpoint(v NavigationEndpoint) OptNavigationEndpoint { + return OptNavigationEndpoint{ + Value: v, + Set: true, + } +} + +// OptNavigationEndpoint is optional NavigationEndpoint. +type OptNavigationEndpoint struct { + Value NavigationEndpoint + Set bool +} + +// IsSet returns true if OptNavigationEndpoint was set. +func (o OptNavigationEndpoint) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptNavigationEndpoint) Reset() { + var v NavigationEndpoint + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptNavigationEndpoint) SetTo(v NavigationEndpoint) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptNavigationEndpoint) Get() (v NavigationEndpoint, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptNavigationEndpoint) Or(d NavigationEndpoint) NavigationEndpoint { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptRequestClient returns new OptRequestClient with value set to v. +func NewOptRequestClient(v RequestClient) OptRequestClient { + return OptRequestClient{ + Value: v, + Set: true, + } +} + +// OptRequestClient is optional RequestClient. +type OptRequestClient struct { + Value RequestClient + Set bool +} + +// IsSet returns true if OptRequestClient was set. +func (o OptRequestClient) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptRequestClient) Reset() { + var v RequestClient + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptRequestClient) SetTo(v RequestClient) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptRequestClient) Get() (v RequestClient, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptRequestClient) Or(d RequestClient) RequestClient { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptRequestContext returns new OptRequestContext with value set to v. +func NewOptRequestContext(v RequestContext) OptRequestContext { + return OptRequestContext{ + Value: v, + Set: true, + } +} + +// OptRequestContext is optional RequestContext. +type OptRequestContext struct { + Value RequestContext + Set bool +} + +// IsSet returns true if OptRequestContext was set. +func (o OptRequestContext) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptRequestContext) Reset() { + var v RequestContext + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptRequestContext) SetTo(v RequestContext) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptRequestContext) Get() (v RequestContext, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptRequestContext) Or(d RequestContext) RequestContext { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptResponseContext returns new OptResponseContext with value set to v. +func NewOptResponseContext(v ResponseContext) OptResponseContext { + return OptResponseContext{ + Value: v, + Set: true, + } +} + +// OptResponseContext is optional ResponseContext. +type OptResponseContext struct { + Value ResponseContext + Set bool +} + +// IsSet returns true if OptResponseContext was set. +func (o OptResponseContext) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptResponseContext) Reset() { + var v ResponseContext + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptResponseContext) SetTo(v ResponseContext) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptResponseContext) Get() (v ResponseContext, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptResponseContext) Or(d ResponseContext) ResponseContext { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptScreenRenderer returns new OptScreenRenderer with value set to v. +func NewOptScreenRenderer(v ScreenRenderer) OptScreenRenderer { + return OptScreenRenderer{ + Value: v, + Set: true, + } +} + +// OptScreenRenderer is optional ScreenRenderer. +type OptScreenRenderer struct { + Value ScreenRenderer + Set bool +} + +// IsSet returns true if OptScreenRenderer was set. +func (o OptScreenRenderer) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptScreenRenderer) Reset() { + var v ScreenRenderer + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptScreenRenderer) SetTo(v ScreenRenderer) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptScreenRenderer) Get() (v ScreenRenderer, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptScreenRenderer) Or(d ScreenRenderer) ScreenRenderer { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptSectionListRenderer returns new OptSectionListRenderer with value set to v. +func NewOptSectionListRenderer(v SectionListRenderer) OptSectionListRenderer { + return OptSectionListRenderer{ + Value: v, + Set: true, + } +} + +// OptSectionListRenderer is optional SectionListRenderer. +type OptSectionListRenderer struct { + Value SectionListRenderer + Set bool +} + +// IsSet returns true if OptSectionListRenderer was set. +func (o OptSectionListRenderer) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptSectionListRenderer) Reset() { + var v SectionListRenderer + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptSectionListRenderer) SetTo(v SectionListRenderer) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptSectionListRenderer) Get() (v SectionListRenderer, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptSectionListRenderer) Or(d SectionListRenderer) SectionListRenderer { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptString returns new OptString with value set to v. +func NewOptString(v string) OptString { + return OptString{ + Value: v, + Set: true, + } +} + +// OptString is optional string. +type OptString struct { + Value string + Set bool +} + +// IsSet returns true if OptString was set. +func (o OptString) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptString) Reset() { + var v string + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptString) SetTo(v string) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptString) Get() (v string, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptString) Or(d string) string { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptText returns new OptText with value set to v. +func NewOptText(v Text) OptText { + return OptText{ + Value: v, + Set: true, + } +} + +// OptText is optional Text. +type OptText struct { + Value Text + Set bool +} + +// IsSet returns true if OptText was set. +func (o OptText) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptText) Reset() { + var v Text + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptText) SetTo(v Text) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptText) Get() (v Text, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptText) Or(d Text) Text { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptWatchEndpoint returns new OptWatchEndpoint with value set to v. +func NewOptWatchEndpoint(v WatchEndpoint) OptWatchEndpoint { + return OptWatchEndpoint{ + Value: v, + Set: true, + } +} + +// OptWatchEndpoint is optional WatchEndpoint. +type OptWatchEndpoint struct { + Value WatchEndpoint + Set bool +} + +// IsSet returns true if OptWatchEndpoint was set. +func (o OptWatchEndpoint) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptWatchEndpoint) Reset() { + var v WatchEndpoint + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptWatchEndpoint) SetTo(v WatchEndpoint) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptWatchEndpoint) Get() (v WatchEndpoint, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptWatchEndpoint) Or(d WatchEndpoint) WatchEndpoint { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// Client information. +// Ref: #/components/schemas/RequestClient +type RequestClient struct { + ClientName OptString `json:"clientName"` + ClientVersion OptString `json:"clientVersion"` + Hl OptString `json:"hl"` + Gl OptString `json:"gl"` + ExperimentsToken OptString `json:"experimentsToken"` + BrowserName OptString `json:"browserName"` + DeviceMake OptString `json:"deviceMake"` + BrowserVersion OptString `json:"browserVersion"` + OsName OptString `json:"osName"` + OsVersion OptString `json:"osVersion"` + Platform OptString `json:"platform"` + KidsAppInfo OptKidsAppInfo `json:"kidsAppInfo"` +} + +// GetClientName returns the value of ClientName. +func (s *RequestClient) GetClientName() OptString { + return s.ClientName +} + +// GetClientVersion returns the value of ClientVersion. +func (s *RequestClient) GetClientVersion() OptString { + return s.ClientVersion +} + +// GetHl returns the value of Hl. +func (s *RequestClient) GetHl() OptString { + return s.Hl +} + +// GetGl returns the value of Gl. +func (s *RequestClient) GetGl() OptString { + return s.Gl +} + +// GetExperimentsToken returns the value of ExperimentsToken. +func (s *RequestClient) GetExperimentsToken() OptString { + return s.ExperimentsToken +} + +// GetBrowserName returns the value of BrowserName. +func (s *RequestClient) GetBrowserName() OptString { + return s.BrowserName +} + +// GetDeviceMake returns the value of DeviceMake. +func (s *RequestClient) GetDeviceMake() OptString { + return s.DeviceMake +} + +// GetBrowserVersion returns the value of BrowserVersion. +func (s *RequestClient) GetBrowserVersion() OptString { + return s.BrowserVersion +} + +// GetOsName returns the value of OsName. +func (s *RequestClient) GetOsName() OptString { + return s.OsName +} + +// GetOsVersion returns the value of OsVersion. +func (s *RequestClient) GetOsVersion() OptString { + return s.OsVersion +} + +// GetPlatform returns the value of Platform. +func (s *RequestClient) GetPlatform() OptString { + return s.Platform +} + +// GetKidsAppInfo returns the value of KidsAppInfo. +func (s *RequestClient) GetKidsAppInfo() OptKidsAppInfo { + return s.KidsAppInfo +} + +// SetClientName sets the value of ClientName. +func (s *RequestClient) SetClientName(val OptString) { + s.ClientName = val +} + +// SetClientVersion sets the value of ClientVersion. +func (s *RequestClient) SetClientVersion(val OptString) { + s.ClientVersion = val +} + +// SetHl sets the value of Hl. +func (s *RequestClient) SetHl(val OptString) { + s.Hl = val +} + +// SetGl sets the value of Gl. +func (s *RequestClient) SetGl(val OptString) { + s.Gl = val +} + +// SetExperimentsToken sets the value of ExperimentsToken. +func (s *RequestClient) SetExperimentsToken(val OptString) { + s.ExperimentsToken = val +} + +// SetBrowserName sets the value of BrowserName. +func (s *RequestClient) SetBrowserName(val OptString) { + s.BrowserName = val +} + +// SetDeviceMake sets the value of DeviceMake. +func (s *RequestClient) SetDeviceMake(val OptString) { + s.DeviceMake = val +} + +// SetBrowserVersion sets the value of BrowserVersion. +func (s *RequestClient) SetBrowserVersion(val OptString) { + s.BrowserVersion = val +} + +// SetOsName sets the value of OsName. +func (s *RequestClient) SetOsName(val OptString) { + s.OsName = val +} + +// SetOsVersion sets the value of OsVersion. +func (s *RequestClient) SetOsVersion(val OptString) { + s.OsVersion = val +} + +// SetPlatform sets the value of Platform. +func (s *RequestClient) SetPlatform(val OptString) { + s.Platform = val +} + +// SetKidsAppInfo sets the value of KidsAppInfo. +func (s *RequestClient) SetKidsAppInfo(val OptKidsAppInfo) { + s.KidsAppInfo = val +} + +// Request context. +// Ref: #/components/schemas/RequestContext +type RequestContext struct { + Client OptRequestClient `json:"client"` +} + +// GetClient returns the value of Client. +func (s *RequestContext) GetClient() OptRequestClient { + return s.Client +} + +// SetClient sets the value of Client. +func (s *RequestContext) SetClient(val OptRequestClient) { + s.Client = val +} + +// Response context. +// Ref: #/components/schemas/ResponseContext +type ResponseContext struct { + VisitorData OptString `json:"visitorData"` + MaxAgeSeconds OptFloat64 `json:"maxAgeSeconds"` + ServiceTrackingParams []ResponseContextServiceTrackingParamsItem `json:"serviceTrackingParams"` +} + +// GetVisitorData returns the value of VisitorData. +func (s *ResponseContext) GetVisitorData() OptString { + return s.VisitorData +} + +// GetMaxAgeSeconds returns the value of MaxAgeSeconds. +func (s *ResponseContext) GetMaxAgeSeconds() OptFloat64 { + return s.MaxAgeSeconds +} + +// GetServiceTrackingParams returns the value of ServiceTrackingParams. +func (s *ResponseContext) GetServiceTrackingParams() []ResponseContextServiceTrackingParamsItem { + return s.ServiceTrackingParams +} + +// SetVisitorData sets the value of VisitorData. +func (s *ResponseContext) SetVisitorData(val OptString) { + s.VisitorData = val +} + +// SetMaxAgeSeconds sets the value of MaxAgeSeconds. +func (s *ResponseContext) SetMaxAgeSeconds(val OptFloat64) { + s.MaxAgeSeconds = val +} + +// SetServiceTrackingParams sets the value of ServiceTrackingParams. +func (s *ResponseContext) SetServiceTrackingParams(val []ResponseContextServiceTrackingParamsItem) { + s.ServiceTrackingParams = val +} + +type ResponseContextServiceTrackingParamsItem struct { + Service OptString `json:"service"` + Params []KeyStringValue `json:"params"` +} + +// GetService returns the value of Service. +func (s *ResponseContextServiceTrackingParamsItem) GetService() OptString { + return s.Service +} + +// GetParams returns the value of Params. +func (s *ResponseContextServiceTrackingParamsItem) GetParams() []KeyStringValue { + return s.Params +} + +// SetService sets the value of Service. +func (s *ResponseContextServiceTrackingParamsItem) SetService(val OptString) { + s.Service = val +} + +// SetParams sets the value of Params. +func (s *ResponseContextServiceTrackingParamsItem) SetParams(val []KeyStringValue) { + s.Params = val +} + +// Ref: #/components/schemas/ScreenAnchor +type ScreenAnchor struct { + AnchoredSectionRenderer OptAnchoredSectionRenderer `json:"anchoredSectionRenderer"` +} + +// GetAnchoredSectionRenderer returns the value of AnchoredSectionRenderer. +func (s *ScreenAnchor) GetAnchoredSectionRenderer() OptAnchoredSectionRenderer { + return s.AnchoredSectionRenderer +} + +// SetAnchoredSectionRenderer sets the value of AnchoredSectionRenderer. +func (s *ScreenAnchor) SetAnchoredSectionRenderer(val OptAnchoredSectionRenderer) { + s.AnchoredSectionRenderer = val +} + +// Ref: #/components/schemas/ScreenRenderer +type ScreenRenderer struct { + Anchors []ScreenAnchor `json:"anchors"` +} + +// GetAnchors returns the value of Anchors. +func (s *ScreenRenderer) GetAnchors() []ScreenAnchor { + return s.Anchors +} + +// SetAnchors sets the value of Anchors. +func (s *ScreenRenderer) SetAnchors(val []ScreenAnchor) { + s.Anchors = val +} + +// Ref: #/components/schemas/SectionListRenderer +type SectionListRenderer struct { + Contents []SectionListRendererContentsItem `json:"contents"` + TrackingParams OptString `json:"trackingParams"` +} + +// GetContents returns the value of Contents. +func (s *SectionListRenderer) GetContents() []SectionListRendererContentsItem { + return s.Contents +} + +// GetTrackingParams returns the value of TrackingParams. +func (s *SectionListRenderer) GetTrackingParams() OptString { + return s.TrackingParams +} + +// SetContents sets the value of Contents. +func (s *SectionListRenderer) SetContents(val []SectionListRendererContentsItem) { + s.Contents = val +} + +// SetTrackingParams sets the value of TrackingParams. +func (s *SectionListRenderer) SetTrackingParams(val OptString) { + s.TrackingParams = val +} + +type SectionListRendererContentsItem struct { + ItemSectionRenderer OptItemSectionRenderer `json:"itemSectionRenderer"` +} + +// GetItemSectionRenderer returns the value of ItemSectionRenderer. +func (s *SectionListRendererContentsItem) GetItemSectionRenderer() OptItemSectionRenderer { + return s.ItemSectionRenderer +} + +// SetItemSectionRenderer sets the value of ItemSectionRenderer. +func (s *SectionListRendererContentsItem) SetItemSectionRenderer(val OptItemSectionRenderer) { + s.ItemSectionRenderer = val +} + +// Ref: #/components/schemas/Text +type Text struct { + Runs []TextRun `json:"runs"` + Accessibility OptAccessibility `json:"accessibility"` +} + +// GetRuns returns the value of Runs. +func (s *Text) GetRuns() []TextRun { + return s.Runs +} + +// GetAccessibility returns the value of Accessibility. +func (s *Text) GetAccessibility() OptAccessibility { + return s.Accessibility +} + +// SetRuns sets the value of Runs. +func (s *Text) SetRuns(val []TextRun) { + s.Runs = val +} + +// SetAccessibility sets the value of Accessibility. +func (s *Text) SetAccessibility(val OptAccessibility) { + s.Accessibility = val +} + +// Ref: #/components/schemas/TextRun +type TextRun struct { + Text OptString `json:"text"` + NavigationEndpoint OptNavigationEndpoint `json:"navigationEndpoint"` +} + +// GetText returns the value of Text. +func (s *TextRun) GetText() OptString { + return s.Text +} + +// GetNavigationEndpoint returns the value of NavigationEndpoint. +func (s *TextRun) GetNavigationEndpoint() OptNavigationEndpoint { + return s.NavigationEndpoint +} + +// SetText sets the value of Text. +func (s *TextRun) SetText(val OptString) { + s.Text = val +} + +// SetNavigationEndpoint sets the value of NavigationEndpoint. +func (s *TextRun) SetNavigationEndpoint(val OptNavigationEndpoint) { + s.NavigationEndpoint = val +} + +// Ref: #/components/schemas/Thumbnail +type Thumbnail struct { + URL OptString `json:"url"` + Width OptFloat64 `json:"width"` + Height OptFloat64 `json:"height"` +} + +// GetURL returns the value of URL. +func (s *Thumbnail) GetURL() OptString { + return s.URL +} + +// GetWidth returns the value of Width. +func (s *Thumbnail) GetWidth() OptFloat64 { + return s.Width +} + +// GetHeight returns the value of Height. +func (s *Thumbnail) GetHeight() OptFloat64 { + return s.Height +} + +// SetURL sets the value of URL. +func (s *Thumbnail) SetURL(val OptString) { + s.URL = val +} + +// SetWidth sets the value of Width. +func (s *Thumbnail) SetWidth(val OptFloat64) { + s.Width = val +} + +// SetHeight sets the value of Height. +func (s *Thumbnail) SetHeight(val OptFloat64) { + s.Height = val +} + +// Ref: #/components/schemas/WatchEndpoint +type WatchEndpoint struct { + VideoId OptString `json:"videoId"` +} + +// GetVideoId returns the value of VideoId. +func (s *WatchEndpoint) GetVideoId() OptString { + return s.VideoId +} + +// SetVideoId sets the value of VideoId. +func (s *WatchEndpoint) SetVideoId(val OptString) { + s.VideoId = val +} diff --git a/oas_test_examples_gen_test.go b/oas_test_examples_gen_test.go new file mode 100644 index 0000000..6a5dd43 --- /dev/null +++ b/oas_test_examples_gen_test.go @@ -0,0 +1,457 @@ +// Code generated by ogen, DO NOT EDIT. + +package go_youtubekids_client + +import ( + "github.com/go-faster/jx" + + std "encoding/json" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestAccessibility_EncodeDecode(t *testing.T) { + var typ Accessibility + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 Accessibility + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestAccessibilityData_EncodeDecode(t *testing.T) { + var typ AccessibilityData + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 AccessibilityData + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestAnchoredSectionRenderer_EncodeDecode(t *testing.T) { + var typ AnchoredSectionRenderer + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 AnchoredSectionRenderer + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestAnchoredSectionRendererContent_EncodeDecode(t *testing.T) { + var typ AnchoredSectionRendererContent + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 AnchoredSectionRendererContent + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestBrowseEndpoint_EncodeDecode(t *testing.T) { + var typ BrowseEndpoint + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 BrowseEndpoint + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestBrowseRequestPayload_EncodeDecode(t *testing.T) { + var typ BrowseRequestPayload + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 BrowseRequestPayload + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestBrowseResponsePayload_EncodeDecode(t *testing.T) { + var typ BrowseResponsePayload + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 BrowseResponsePayload + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestBrowseResponsePayloadContents_EncodeDecode(t *testing.T) { + var typ BrowseResponsePayloadContents + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 BrowseResponsePayloadContents + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestBrowseResponsePayloadHeader_EncodeDecode(t *testing.T) { + var typ BrowseResponsePayloadHeader + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 BrowseResponsePayloadHeader + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestCategoriesHeaderRenderer_EncodeDecode(t *testing.T) { + var typ CategoriesHeaderRenderer + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 CategoriesHeaderRenderer + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestCategoryAssets_EncodeDecode(t *testing.T) { + var typ CategoryAssets + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 CategoryAssets + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestCompactVideoRenderer_EncodeDecode(t *testing.T) { + var typ CompactVideoRenderer + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 CompactVideoRenderer + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestCompactVideoRendererChannelThumbnail_EncodeDecode(t *testing.T) { + var typ CompactVideoRendererChannelThumbnail + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 CompactVideoRendererChannelThumbnail + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestCompactVideoRendererThumbnail_EncodeDecode(t *testing.T) { + var typ CompactVideoRendererThumbnail + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 CompactVideoRendererThumbnail + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestError_EncodeDecode(t *testing.T) { + var typ Error + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 Error + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestErrorResponsePayload_EncodeDecode(t *testing.T) { + var typ ErrorResponsePayload + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 ErrorResponsePayload + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestErrorResponsePayloadError_EncodeDecode(t *testing.T) { + var typ ErrorResponsePayloadError + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 ErrorResponsePayloadError + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestItemSectionRenderer_EncodeDecode(t *testing.T) { + var typ ItemSectionRenderer + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 ItemSectionRenderer + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestItemSectionRendererContentsItem_EncodeDecode(t *testing.T) { + var typ ItemSectionRendererContentsItem + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 ItemSectionRendererContentsItem + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestKeyStringValue_EncodeDecode(t *testing.T) { + var typ KeyStringValue + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 KeyStringValue + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestKidsAppCategorySettings_EncodeDecode(t *testing.T) { + var typ KidsAppCategorySettings + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 KidsAppCategorySettings + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestKidsAppContentSettings_EncodeDecode(t *testing.T) { + var typ KidsAppContentSettings + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 KidsAppContentSettings + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestKidsAppInfo_EncodeDecode(t *testing.T) { + var typ KidsAppInfo + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 KidsAppInfo + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestKidsVideoOwnerExtension_EncodeDecode(t *testing.T) { + var typ KidsVideoOwnerExtension + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 KidsVideoOwnerExtension + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestNavigationEndpoint_EncodeDecode(t *testing.T) { + var typ NavigationEndpoint + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 NavigationEndpoint + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestRequestClient_EncodeDecode(t *testing.T) { + var typ RequestClient + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 RequestClient + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestRequestContext_EncodeDecode(t *testing.T) { + var typ RequestContext + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 RequestContext + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestResponseContext_EncodeDecode(t *testing.T) { + var typ ResponseContext + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 ResponseContext + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestResponseContextServiceTrackingParamsItem_EncodeDecode(t *testing.T) { + var typ ResponseContextServiceTrackingParamsItem + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 ResponseContextServiceTrackingParamsItem + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestScreenAnchor_EncodeDecode(t *testing.T) { + var typ ScreenAnchor + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 ScreenAnchor + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestScreenRenderer_EncodeDecode(t *testing.T) { + var typ ScreenRenderer + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 ScreenRenderer + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestSectionListRenderer_EncodeDecode(t *testing.T) { + var typ SectionListRenderer + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 SectionListRenderer + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestSectionListRendererContentsItem_EncodeDecode(t *testing.T) { + var typ SectionListRendererContentsItem + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 SectionListRendererContentsItem + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestText_EncodeDecode(t *testing.T) { + var typ Text + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 Text + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestTextRun_EncodeDecode(t *testing.T) { + var typ TextRun + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 TextRun + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestThumbnail_EncodeDecode(t *testing.T) { + var typ Thumbnail + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 Thumbnail + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} +func TestWatchEndpoint_EncodeDecode(t *testing.T) { + var typ WatchEndpoint + typ.SetFake() + + e := jx.Encoder{} + typ.Encode(&e) + data := e.Bytes() + require.True(t, std.Valid(data), "Encoded: %s", data) + + var typ2 WatchEndpoint + require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) +} diff --git a/oas_validators_gen.go b/oas_validators_gen.go new file mode 100644 index 0000000..62f9d64 --- /dev/null +++ b/oas_validators_gen.go @@ -0,0 +1,527 @@ +// Code generated by ogen, DO NOT EDIT. + +package go_youtubekids_client + +import ( + "fmt" + + "github.com/go-faster/errors" + + "github.com/ogen-go/ogen/validate" +) + +func (s *AnchoredSectionRenderer) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.Content.Set { + if err := func() error { + if err := s.Content.Value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "content", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} +func (s *AnchoredSectionRendererContent) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.SectionListRenderer.Set { + if err := func() error { + if err := s.SectionListRenderer.Value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "sectionListRenderer", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} +func (s *BrowseResponsePayload) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.ResponseContext.Set { + if err := func() error { + if err := s.ResponseContext.Value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "responseContext", + Error: err, + }) + } + if err := func() error { + if s.Contents.Set { + if err := func() error { + if err := s.Contents.Value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "contents", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} +func (s *BrowseResponsePayloadContents) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.KidsHomeScreenRenderer.Set { + if err := func() error { + if err := s.KidsHomeScreenRenderer.Value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "kidsHomeScreenRenderer", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} +func (s *CompactVideoRenderer) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.Thumbnail.Set { + if err := func() error { + if err := s.Thumbnail.Value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "thumbnail", + Error: err, + }) + } + if err := func() error { + if s.ChannelThumbnail.Set { + if err := func() error { + if err := s.ChannelThumbnail.Value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "channelThumbnail", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} +func (s *CompactVideoRendererChannelThumbnail) Validate() error { + var failures []validate.FieldError + if err := func() error { + var failures []validate.FieldError + for i, elem := range s.Thumbnails { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "thumbnails", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} +func (s *CompactVideoRendererThumbnail) Validate() error { + var failures []validate.FieldError + if err := func() error { + var failures []validate.FieldError + for i, elem := range s.Thumbnails { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "thumbnails", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} +func (s *ErrorResponsePayload) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.Error.Set { + if err := func() error { + if err := s.Error.Value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "error", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} +func (s *ErrorResponsePayloadError) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.Code.Set { + if err := func() error { + if err := (validate.Float{}).Validate(float64(s.Code.Value)); err != nil { + return errors.Wrap(err, "float") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "code", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} +func (s *ItemSectionRenderer) Validate() error { + var failures []validate.FieldError + if err := func() error { + var failures []validate.FieldError + for i, elem := range s.Contents { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "contents", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} +func (s *ItemSectionRendererContentsItem) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.CompactVideoRenderer.Set { + if err := func() error { + if err := s.CompactVideoRenderer.Value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "compactVideoRenderer", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *ResponseContext) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.MaxAgeSeconds.Set { + if err := func() error { + if err := (validate.Float{}).Validate(float64(s.MaxAgeSeconds.Value)); err != nil { + return errors.Wrap(err, "float") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "maxAgeSeconds", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} +func (s *ScreenAnchor) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.AnchoredSectionRenderer.Set { + if err := func() error { + if err := s.AnchoredSectionRenderer.Value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "anchoredSectionRenderer", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} +func (s *ScreenRenderer) Validate() error { + var failures []validate.FieldError + if err := func() error { + var failures []validate.FieldError + for i, elem := range s.Anchors { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "anchors", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} +func (s *SectionListRenderer) Validate() error { + var failures []validate.FieldError + if err := func() error { + var failures []validate.FieldError + for i, elem := range s.Contents { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "contents", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} +func (s *SectionListRendererContentsItem) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.ItemSectionRenderer.Set { + if err := func() error { + if err := s.ItemSectionRenderer.Value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "itemSectionRenderer", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} +func (s *Thumbnail) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.Width.Set { + if err := func() error { + if err := (validate.Float{}).Validate(float64(s.Width.Value)); err != nil { + return errors.Wrap(err, "float") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "width", + Error: err, + }) + } + if err := func() error { + if s.Height.Set { + if err := func() error { + if err := (validate.Float{}).Validate(float64(s.Height.Value)); err != nil { + return errors.Wrap(err, "float") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "height", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +}