4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/percy/client/snapshots.rb', line 4
def create_snapshot(build_id, resources, options = {})
if !resources.respond_to?(:each)
raise ArgumentError.new(
'resources argument must be an iterable of Percy::Client::Resource objects')
end
name = options[:name]
enable_javascript = options[:enable_javascript]
data = {
'data' => {
'type' => 'snapshots',
'attributes' => {
'name' => name,
'enable-javascript' => enable_javascript,
},
'relationships' => {
'resources' => {
'data' => resources.map { |r| r.serialize },
},
},
},
}
post("#{config.api_url}/builds/#{build_id}/snapshots/", data)
end
|