Class: BOTR::ChannelThumbnail

Inherits:
Object
  • Object
show all
Defined in:
lib/botr/channels/channel_thumbnail.rb

Overview

The BOTR::ChannelThumbnail class contains calls that can be used to upload a preview image for a channel. Channels don’t have a thumb by default.

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Authentication

#signature

Methods included from API

#api_call_class, #api_format, #api_key, #api_nonce, #api_protocol, #api_secret_key, #api_server, #api_timestamp, #api_url, #api_version, #progress_url, #upload_address, #upload_key, #upload_protocol, #upload_token, #upload_url

Methods included from HTTP

#client, #delete_request, #get_request, #post_request, #put_request

Constructor Details

#initialize(params = {}) ⇒ ChannelThumbnail

Returns a new instance of ChannelThumbnail.

Raises:

  • (ArgumentError)


46
47
48
49
50
51
52
53
54
# File 'lib/botr/channels/channel_thumbnail.rb', line 46

def initialize(params = {})
	params.each do |key, val|
		param = "@#{key.to_s}"
		next unless methods.include? key.to_sym
		instance_variable_set(param, val)
	end
	
	raise ArgumentError, "You must specify a channel key." if @key.nil?
end

Class Attribute Details

.last_statusObject (readonly)

Returns the value of attribute last_status.



9
10
11
# File 'lib/botr/channels/channel_thumbnail.rb', line 9

def last_status
  @last_status
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



44
45
46
# File 'lib/botr/channels/channel_thumbnail.rb', line 44

def error
  @error
end

#keyObject (readonly)

Returns the value of attribute key.



44
45
46
# File 'lib/botr/channels/channel_thumbnail.rb', line 44

def key
  @key
end

#last_statusObject (readonly)

Returns the value of attribute last_status.



44
45
46
# File 'lib/botr/channels/channel_thumbnail.rb', line 44

def last_status
  @last_status
end

#statusObject (readonly)

Returns the value of attribute status.



44
45
46
# File 'lib/botr/channels/channel_thumbnail.rb', line 44

def status
  @status
end

Class Method Details

.show(channel_key) ⇒ BOTR::ChannelThumbnail Also known as: find

Returns a new object with the thumbnail properties of the channel referenced by the channel key.

Parameters:

  • channel_key (String)

    key of the channel for which to show thumbnails creation status

Returns:

  • (BOTR::ChannelThumbnail)

    a new object with the thumbnail properties of the channel referenced by the channel key



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/botr/channels/channel_thumbnail.rb', line 18

def show(channel_key)
	json = get_request({:method => 'show',
					    :channel_key => channel_key})
	res = JSON.parse(json.body)

	if json.status == 200
		params = process_show_response(res)
	else
		raise "HTTP Error #{json.status}: #{json.body}"
	end

	return new(params)
end

Instance Method Details

#updateBOTR::ChannelThumbnail

Update a channel thumbnail by uploading an image.

Returns:



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/botr/channels/channel_thumbnail.rb', line 59

def update
	json = put_request({:channel_key => @key})
	res = JSON.parse(json.body)

	if json.status == 200
		process_update_response(res)
	else
		raise "HTTP Error #{json.status}: #{json.body}"
	end
	
	return self
end

#upload(data_path, **options) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/botr/channels/channel_thumbnail.rb', line 72

def upload(data_path, **options)
	json = post_request(options, data_path)
	res = JSON.parse(json.body)

	if json.status == 200
		process_upload_response(res)
	else
		raise "HTTP Error #{json.status}: #{json.body}"
	end

	return self
end