Class: BrightcoveCmsApi::Video

Inherits:
Object
  • Object
show all
Defined in:
lib/brightcove_cms_api/video.rb

Instance Method Summary collapse

Constructor Details

#initialize(account_id:, client_id:, client_secret:) ⇒ Video

Returns a new instance of Video.



10
11
12
13
14
15
# File 'lib/brightcove_cms_api/video.rb', line 10

def initialize(account_id:, client_id:, client_secret:)
  @account_id = 
  @client_id = client_id
  @client_secret = client_secret
  set_authtoken
end

Instance Method Details

#countObject

Get Video count



32
33
34
35
36
# File 'lib/brightcove_cms_api/video.rb', line 32

def count
  check_token_expires
  @response = HTTP.auth("Bearer #{@token}").get("#{API_URL}/#{@account_id}/counts/videos")
  send_response
end

#create(params = {}) ⇒ Object

Create Videos



25
26
27
28
29
# File 'lib/brightcove_cms_api/video.rb', line 25

def create(params = {})
  check_token_expires
  @response = HTTP.auth("Bearer #{@token}").post("#{API_URL}/#{@account_id}/videos", { json: params })
  send_response
end

#custom_fieldsObject

Get custom fields



81
82
83
84
85
# File 'lib/brightcove_cms_api/video.rb', line 81

def custom_fields
  check_token_expires
  @response = HTTP.auth("Bearer #{@token}").get("#{API_URL}/#{@account_id}/video_fields")
  send_response
end

#delete(video_id) ⇒ Object

delete video



46
47
48
49
50
# File 'lib/brightcove_cms_api/video.rb', line 46

def delete(video_id)
  check_token_expires
  @response = HTTP.auth("Bearer #{@token}").delete("#{API_URL}/#{@account_id}/videos/#{video_id}")
  send_response
end

#find_allObject

Get Videos



18
19
20
21
22
# File 'lib/brightcove_cms_api/video.rb', line 18

def find_all
  check_token_expires
  @response = HTTP.auth("Bearer #{@token}").get("#{API_URL}/#{@account_id}/videos")
  send_response
end

#get_by_reference_id(video_id) ⇒ Object

Get Video by id and reference_id



39
40
41
42
43
# File 'lib/brightcove_cms_api/video.rb', line 39

def get_by_reference_id(video_id)
  check_token_expires
  @response = HTTP.auth("Bearer #{@token}").get("#{API_URL}/#{@account_id}/videos/#{video_id}")
  send_response
end

#images(video_id) ⇒ Object

Get video images



60
61
62
63
64
# File 'lib/brightcove_cms_api/video.rb', line 60

def images(video_id)
  check_token_expires
  @response = HTTP.auth("Bearer #{@token}").get("#{API_URL}/#{@account_id}/videos/#{video_id}/images")
  send_response
end

#playlists(video_id) ⇒ Object

get playlists for video



67
68
69
70
71
# File 'lib/brightcove_cms_api/video.rb', line 67

def playlists(video_id)
  check_token_expires
  @response = HTTP.auth("Bearer #{@token}").get("#{API_URL}/#{@account_id}/videos/#{video_id}/references")
  send_response
end

#remove_from_playlists(video_id) ⇒ Object

remove video from all playlists



74
75
76
77
78
# File 'lib/brightcove_cms_api/video.rb', line 74

def remove_from_playlists(video_id)
  check_token_expires
  @response = HTTP.auth("Bearer #{@token}").delete("#{API_URL}/#{@account_id}/videos/#{video_id}/references")
  send_response
end

#update(video_id, params = {}) ⇒ Object

update video



53
54
55
56
57
# File 'lib/brightcove_cms_api/video.rb', line 53

def update(video_id, params = {})
  check_token_expires
  @response = HTTP.auth("Bearer #{@token}").patch("#{API_URL}/#{@account_id}/videos/#{video_id}", { json: params })
  send_response
end