Skip to content

Commit

Permalink
Adds method to move assets
Browse files Browse the repository at this point in the history
  • Loading branch information
afred committed May 4, 2024
1 parent 036bbf8 commit 16babd3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/sony_ci_api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ def asset_download(asset_id)
get "/assets/#{asset_id}/download"
end

def move_assets(asset_ids: [], folder_id:)
post "/assets/move", params: { assetIds: asset_ids, folderId: folder_id }
end

def asset_stream_url(asset_id, type: "hls")
type = type.downcase
raise ArgumentError, "Invalid value for parameter type. Expected one of hls, video-3g, or video-sd, but '#{type}' was given" unless %w[hls video-3g video-sd].include?(type)
Expand Down
39 changes: 38 additions & 1 deletion spec/sony_ci_api/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def camelize_params(**params)

describe '#get' do
# Run shared spec to simply test the
it_behaves_like 'HTTP request method', http_method: :delete
it_behaves_like 'HTTP request method', http_method: :get

let(:response_status) { 200 }
let(:response_body) { { "fooBarResponse" => randstr } }
Expand Down Expand Up @@ -443,6 +443,43 @@ def camelize_params(**params)
end
end

describe '#asset_move' do
let(:asset_ids) { 5.times.map { randhex } }
let(:folder_id) { randhex}
# Pared down response body. In reality it's much bigger.
let(:response_body) {
{
"completeCount" => asset_ids.count,
"errorCount" => 0
}
}

let(:asset_download_info) {
stub_request_and_call_block(
:post,
"#{base_url}/assets/move",
with: {
body: {
"assetIds": asset_ids,
"folderId": folder_id
}
},
stub_response: {
body: response_body.to_json,
status: 200
}
) do
# Call the method under test
client.move_assets(asset_ids: asset_ids, folder_id: folder_id)
end
}

it 'returns download information for an asset' do
expect(asset_download_info).to eq response_body
end
end


describe '#asset_streams' do
let(:asset_id) { randhex }
let(:streaming_url) { "http://io.api.cimediacloud.com/assets/#{asset_id}/streams/smil_md5hash.m3u8" }
Expand Down

0 comments on commit 16babd3

Please sign in to comment.