diff --git a/lib/sony_ci_api/client.rb b/lib/sony_ci_api/client.rb index c6aedcc..39b31ed 100644 --- a/lib/sony_ci_api/client.rb +++ b/lib/sony_ci_api/client.rb @@ -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) diff --git a/spec/sony_ci_api/client_spec.rb b/spec/sony_ci_api/client_spec.rb index 610cbdb..488cdb6 100644 --- a/spec/sony_ci_api/client_spec.rb +++ b/spec/sony_ci_api/client_spec.rb @@ -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 } } @@ -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" }