Sha256: 73e8dfb19661ab8146cf92b16da7d155d0c6eb3dfd900eaf9617b304a82916ec

Contents?: true

Size: 752 Bytes

Versions: 11

Compression:

Stored size: 752 Bytes

Contents

# frozen_string_literal: true

module ShopifyCLI
  module Theme
    class ThemeAdminAPIThrottler
      class RequestParser
        def initialize(requests)
          @requests = requests
        end

        def parse
          {
            path: path,
            method: method,
            body: JSON.generate({ assets: assets }),
          }
        end

        private

        def method
          @requests.sample.method
        end

        def path
          @requests.sample.bulk_path
        end

        def assets
          @requests.map do |request|
            body = JSON.parse(request.body)
            body = body.is_a?(Hash) ? body : JSON.parse(body)
            body["asset"]
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
shopify-cli-2.29.0 lib/shopify_cli/theme/theme_admin_api_throttler/request_parser.rb
shopify-cli-2.28.0 lib/shopify_cli/theme/theme_admin_api_throttler/request_parser.rb
shopify-cli-2.27.0 lib/shopify_cli/theme/theme_admin_api_throttler/request_parser.rb
shopify-cli-2.26.0 lib/shopify_cli/theme/theme_admin_api_throttler/request_parser.rb
shopify-cli-2.25.0 lib/shopify_cli/theme/theme_admin_api_throttler/request_parser.rb
shopify-cli-2.24.0 lib/shopify_cli/theme/theme_admin_api_throttler/request_parser.rb
shopify-cli-2.23.0 lib/shopify_cli/theme/theme_admin_api_throttler/request_parser.rb
shopify-cli-2.22.0 lib/shopify_cli/theme/theme_admin_api_throttler/request_parser.rb
shopify-cli-2.21.0 lib/shopify_cli/theme/theme_admin_api_throttler/request_parser.rb
shopify-cli-2.20.1 lib/shopify_cli/theme/theme_admin_api_throttler/request_parser.rb
shopify-cli-2.20.0 lib/shopify_cli/theme/theme_admin_api_throttler/request_parser.rb