Sha256: c391b2f5cfee1b88bdca639083fedc800a735dec885fd927dc833570ca2988eb

Contents?: true

Size: 1005 Bytes

Versions: 11

Compression:

Stored size: 1005 Bytes

Contents

# frozen_string_literal: true

require "shopify_cli/thread_pool/job"
require_relative "request_parser"
require_relative "response_parser"

module ShopifyCLI
  module Theme
    class ThemeAdminAPIThrottler
      class PutRequest
        attr_reader :method, :body, :path, :block
        attr_accessor :retries

        def initialize(path, body, &block)
          @method = "PUT"
          @path = path
          @body = body
          @block = block
          @retries = 0
        end

        def to_h
          {
            method: method,
            path: path,
            body: body,
          }
        end

        def to_s
          "#{key}, retries: #{retries}"
        end

        def liquid?
          key.end_with?(".liquid")
        end

        def key
          @key ||= JSON.parse(body)["asset"]["key"]
        end

        def bulk_path
          path.gsub(/.json$/, "/bulk.json")
        end

        def size
          @size ||= body.bytesize
        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/put_request.rb
shopify-cli-2.28.0 lib/shopify_cli/theme/theme_admin_api_throttler/put_request.rb
shopify-cli-2.27.0 lib/shopify_cli/theme/theme_admin_api_throttler/put_request.rb
shopify-cli-2.26.0 lib/shopify_cli/theme/theme_admin_api_throttler/put_request.rb
shopify-cli-2.25.0 lib/shopify_cli/theme/theme_admin_api_throttler/put_request.rb
shopify-cli-2.24.0 lib/shopify_cli/theme/theme_admin_api_throttler/put_request.rb
shopify-cli-2.23.0 lib/shopify_cli/theme/theme_admin_api_throttler/put_request.rb
shopify-cli-2.22.0 lib/shopify_cli/theme/theme_admin_api_throttler/put_request.rb
shopify-cli-2.21.0 lib/shopify_cli/theme/theme_admin_api_throttler/put_request.rb
shopify-cli-2.20.1 lib/shopify_cli/theme/theme_admin_api_throttler/put_request.rb
shopify-cli-2.20.0 lib/shopify_cli/theme/theme_admin_api_throttler/put_request.rb