Sha256: 0fa7e10f10fddc9ae0705e1ac01cf8f45b0a7584c1fc18b1769118f6d71c72db

Contents?: true

Size: 1.03 KB

Versions: 22

Compression:

Stored size: 1.03 KB

Contents

module Percy
  class Client
    module Snapshots
      def create_snapshot(build_id, resources, options = {})
        unless resources.respond_to?(:each)
          raise ArgumentError,
            'resources argument must be an iterable of Percy::Client::Resource objects'
        end

        widths = options[:widths] || config.default_widths
        data = {
          'data' => {
            'type' => 'snapshots',
            'attributes' => {
              'name' => options[:name],
              'enable-javascript' => options[:enable_javascript],
              'minimum-height' => options[:minimum_height],
              'widths' => widths,
            },
            'relationships' => {
              'resources' => {
                'data' => resources.map(&:serialize),
              },
            },
          },
        }
        post("#{config.api_url}/builds/#{build_id}/snapshots/", data)
      end

      def finalize_snapshot(snapshot_id)
        post("#{config.api_url}/snapshots/#{snapshot_id}/finalize", {})
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
percy-client-2.0.6 lib/percy/client/snapshots.rb
percy-client-2.0.5 lib/percy/client/snapshots.rb
percy-client-2.0.4 lib/percy/client/snapshots.rb
percy-client-2.0.3 lib/percy/client/snapshots.rb
percy-client-2.0.2 lib/percy/client/snapshots.rb
percy-client-2.0.1 lib/percy/client/snapshots.rb
percy-client-2.0.0 lib/percy/client/snapshots.rb
percy-client-1.15.0 lib/percy/client/snapshots.rb
percy-client-1.14.1 lib/percy/client/snapshots.rb
percy-client-1.14.0 lib/percy/client/snapshots.rb
percy-client-1.13.10 lib/percy/client/snapshots.rb
percy-client-1.13.9 lib/percy/client/snapshots.rb
percy-client-1.13.8 lib/percy/client/snapshots.rb
percy-client-1.13.7 lib/percy/client/snapshots.rb
percy-client-1.13.6 lib/percy/client/snapshots.rb
percy-client-1.13.5 lib/percy/client/snapshots.rb
percy-client-1.13.4 lib/percy/client/snapshots.rb
percy-client-1.13.3 lib/percy/client/snapshots.rb
percy-client-1.13.2 lib/percy/client/snapshots.rb
percy-client-1.13.1 lib/percy/client/snapshots.rb