Class: Files::Announcement

Inherits:
Object
  • Object
show all
Defined in:
lib/files.com/models/announcement.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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 = {}, options = {})
  @attributes = attributes || {}
  @options = options || {}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/files.com/models/announcement.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/files.com/models/announcement.rb', line 5

def options
  @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 = {}, options = {})
  list(params, options)
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 = {}, options = {})
  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, options = Api.send_request("/announcements", :get, params, options)
  response.data.map { |object| Announcement.new(object, options) }
end

Instance Method Details

#bodyObject

string - Announcement body



13
14
15
# File 'lib/files.com/models/announcement.rb', line 13

def body
  @attributes[:body]
end

#button_textObject

string - Text to go on the CTA button



18
19
20
# File 'lib/files.com/models/announcement.rb', line 18

def button_text
  @attributes[:button_text]
end

#button_urlObject

string - URL to link to when CTA button is clicked



23
24
25
# File 'lib/files.com/models/announcement.rb', line 23

def button_url
  @attributes[:button_url]
end

#headlineObject

string - Announcement headline



28
29
30
# File 'lib/files.com/models/announcement.rb', line 28

def headline
  @attributes[:headline]
end

#html_bodyObject

string - Body converted to HTML



33
34
35
# File 'lib/files.com/models/announcement.rb', line 33

def html_body
  @attributes[:html_body]
end

#labelObject

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_colorObject

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_atObject

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

#slugObject

string - URL slug for announcement



53
54
55
# File 'lib/files.com/models/announcement.rb', line 53

def slug
  @attributes[:slug]
end