Class: Files::Announcement
- Inherits:
-
Object
- Object
- Files::Announcement
- Defined in:
- lib/files.com/models/announcement.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
- .all(params = {}, options = {}) ⇒ Object
-
.list(params = {}, options = {}) ⇒ Object
Parameters: page - integer - Current page number.
Instance Method Summary collapse
-
#body ⇒ Object
string - Announcement body.
-
#button_text ⇒ Object
string - Text to go on the CTA button.
-
#button_url ⇒ Object
string - URL to link to when CTA button is clicked.
-
#headline ⇒ Object
string - Announcement headline.
-
#html_body ⇒ Object
string - Body converted to HTML.
-
#initialize(attributes = {}, options = {}) ⇒ Announcement
constructor
A new instance of Announcement.
-
#label ⇒ Object
string - Text for a label that can be added to the announcement.
-
#label_color ⇒ Object
string - Color for label on announcement.
-
#publish_at ⇒ Object
date-time - When was this announcement published?.
-
#slug ⇒ Object
string - URL slug for announcement.
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ Announcement
Returns a new instance of Announcement.
7 8 9 10 |
# File 'lib/files.com/models/announcement.rb', line 7 def initialize(attributes = {}, = {}) @attributes = attributes || {} @options = || {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/files.com/models/announcement.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/announcement.rb', line 5 def @options end |
Class Method Details
.all(params = {}, options = {}) ⇒ Object
70 71 72 |
# File 'lib/files.com/models/announcement.rb', line 70 def self.all(params = {}, = {}) list(params, ) end |
.list(params = {}, options = {}) ⇒ Object
Parameters:
page - integer - Current page number.
per_page - integer - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves.
61 62 63 64 65 66 67 68 |
# File 'lib/files.com/models/announcement.rb', line 61 def self.list(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String) response, = Api.send_request("/announcements", :get, params, ) response.data.map { |object| Announcement.new(object, ) } end |
Instance Method Details
#body ⇒ Object
string - Announcement body
13 14 15 |
# File 'lib/files.com/models/announcement.rb', line 13 def body @attributes[:body] end |
#button_text ⇒ Object
string - Text to go on the CTA button
18 19 20 |
# File 'lib/files.com/models/announcement.rb', line 18 def @attributes[:button_text] end |
#button_url ⇒ Object
string - URL to link to when CTA button is clicked
23 24 25 |
# File 'lib/files.com/models/announcement.rb', line 23 def @attributes[:button_url] end |
#headline ⇒ Object
string - Announcement headline
28 29 30 |
# File 'lib/files.com/models/announcement.rb', line 28 def headline @attributes[:headline] end |
#html_body ⇒ Object
string - Body converted to HTML
33 34 35 |
# File 'lib/files.com/models/announcement.rb', line 33 def html_body @attributes[:html_body] end |
#label ⇒ Object
string - Text for a label that can be added to the announcement
38 39 40 |
# File 'lib/files.com/models/announcement.rb', line 38 def label @attributes[:label] end |
#label_color ⇒ Object
string - Color for label on announcement
43 44 45 |
# File 'lib/files.com/models/announcement.rb', line 43 def label_color @attributes[:label_color] end |
#publish_at ⇒ Object
date-time - When was this announcement published?
48 49 50 |
# File 'lib/files.com/models/announcement.rb', line 48 def publish_at @attributes[:publish_at] end |
#slug ⇒ Object
string - URL slug for announcement
53 54 55 |
# File 'lib/files.com/models/announcement.rb', line 53 def slug @attributes[:slug] end |