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



76
77
78
# File 'lib/files.com/models/announcement.rb', line 76

def self.all(params = {}, options = {})
  list(params, options)
end

.create_export(params = {}, options = {}) ⇒ Object

Parameters:

sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction. Valid fields are .


82
83
84
85
86
87
# File 'lib/files.com/models/announcement.rb', line 82

def self.create_export(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: sort_by must be an Hash") if params[:sort_by] and !params[:sort_by].is_a?(Hash)

  response, options = Api.send_request("/announcements/create_export", :post, params, options)
  Export.new(response.data, options)
end

.list(params = {}, options = {}) ⇒ Object

Parameters:

cursor - string - Used for pagination.  When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`.  Send one of those cursor value here to resume an existing list from the next available record.  Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
per_page - int64 - Number of records to show per page.  (Max: 10000, 1,000 or less is recommended).
sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction. Valid fields are .


66
67
68
69
70
71
72
73
74
# File 'lib/files.com/models/announcement.rb', line 66

def self.list(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params[:cursor] and !params[:cursor].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params[:per_page] and !params[:per_page].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: sort_by must be an Hash") if params[:sort_by] and !params[:sort_by].is_a?(Hash)

  List.new(Announcement, params) do
    Api.send_request("/announcements", :get, params, options)
  end
end

Instance Method Details

#bodyObject

string - Announcement body



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

def body
  @attributes[:body]
end

#button_textObject

string - Text to go on the CTA button



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

def button_text
  @attributes[:button_text]
end

#button_urlObject

string - URL to link to when CTA button is clicked



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

def button_url
  @attributes[:button_url]
end

#headlineObject

string - Announcement headline



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

def headline
  @attributes[:headline]
end

#html_bodyObject

string - Body converted to HTML



38
39
40
# File 'lib/files.com/models/announcement.rb', line 38

def html_body
  @attributes[:html_body]
end

#idObject

int64 - Announcement Id



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

def id
  @attributes[:id]
end

#labelObject

string - Text for a label that can be added to the announcement



43
44
45
# File 'lib/files.com/models/announcement.rb', line 43

def label
  @attributes[:label]
end

#label_colorObject

string - Color for label on announcement



48
49
50
# File 'lib/files.com/models/announcement.rb', line 48

def label_color
  @attributes[:label_color]
end

#publish_atObject

date-time - When was this announcement published?



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

def publish_at
  @attributes[:publish_at]
end

#slugObject

string - URL slug for announcement



58
59
60
# File 'lib/files.com/models/announcement.rb', line 58

def slug
  @attributes[:slug]
end