Class: BOTR::ChannelThumbnail
- 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
-
.last_status ⇒ Object
readonly
Returns the value of attribute last_status.
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#last_status ⇒ Object
readonly
Returns the value of attribute last_status.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
-
.show(channel_key) ⇒ BOTR::ChannelThumbnail
(also: find)
A new object with the thumbnail properties of the channel referenced by the channel key.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ ChannelThumbnail
constructor
A new instance of ChannelThumbnail.
-
#update ⇒ BOTR::ChannelThumbnail
Update a channel thumbnail by uploading an image.
- #upload(data_path, **options) ⇒ Object
Methods included from Authentication
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.
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_status ⇒ Object (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
#error ⇒ Object (readonly)
Returns the value of attribute error.
44 45 46 |
# File 'lib/botr/channels/channel_thumbnail.rb', line 44 def error @error end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
44 45 46 |
# File 'lib/botr/channels/channel_thumbnail.rb', line 44 def key @key end |
#last_status ⇒ Object (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 |
#status ⇒ Object (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.
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
#update ⇒ BOTR::ChannelThumbnail
Update a channel thumbnail by uploading an image.
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, **) json = post_request(, 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 |