Class: Bloomy::Headline
- Inherits:
-
Object
- Object
- Bloomy::Headline
- Includes:
- Utilities::UserIdUtility
- Defined in:
- lib/bloomy/operations/headlines.rb
Instance Method Summary collapse
-
#create(meeting_id:, title:, owner_id: user_id, notes: nil) ⇒ Hash
Creates a new headline.
-
#delete(headline_id) ⇒ Boolean
Deletes a headline.
-
#details(headline_id) ⇒ Hash
Get headline details.
-
#initialize(conn) ⇒ Headline
constructor
Initializes a new headline instance.
-
#list(user_id: nil, meeting_id: nil) ⇒ Array<Hash>
Get headlines for a user or a meeting.
-
#update(headline_id:, title:) ⇒ Boolean
Updates a headline.
Methods included from Utilities::UserIdUtility
Constructor Details
#initialize(conn) ⇒ Headline
Initializes a new headline instance
11 12 13 |
# File 'lib/bloomy/operations/headlines.rb', line 11 def initialize(conn) @conn = conn end |
Instance Method Details
#create(meeting_id:, title:, owner_id: user_id, notes: nil) ⇒ Hash
Creates a new headline
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/bloomy/operations/headlines.rb', line 22 def create(meeting_id:, title:, owner_id: user_id, notes: nil) response = @conn.post("/api/v1/L10/#{meeting_id}/headlines", {title: title, ownerId: owner_id, notes: notes}.to_json) raise "Failed to create headline" unless response.status == 200 { id: response.body["Id"], title: response.body["Name"], owner_details: {id: response.body["OwnerId"]}, notes_url: response.body["DetailsUrl"] } end |
#delete(headline_id) ⇒ Boolean
Deletes a headline
134 135 136 137 |
# File 'lib/bloomy/operations/headlines.rb', line 134 def delete(headline_id) response = @conn.delete("/api/v1/headline/#{headline_id}") response.success? end |
#details(headline_id) ⇒ Hash
Get headline details
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/bloomy/operations/headlines.rb', line 51 def details(headline_id) response = @conn.get("/api/v1/headline/#{headline_id}?Include_Origin=true") raise "Failed to get headline details" unless response.status == 200 { id: response.body["Id"], title: response.body["Name"], notes_url: response.body["DetailsUrl"], meeting_details: { id: response.body["OriginId"], title: response.body["Origin"] }, owner_details: { id: response.body["Owner"]["Id"], name: response.body["Owner"]["Name"] }, archived: response.body["Archived"], created_at: response.body["CreateTime"], closed_at: response.body["CloseTime"] } end |
#list(user_id: nil, meeting_id: nil) ⇒ Array<Hash>
Get headlines for a user or a meeting.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/bloomy/operations/headlines.rb', line 99 def list(user_id: nil, meeting_id: nil) raise ArgumentError, "Please provide either `user_id` or `meeting_id`, not both." if user_id && meeting_id if meeting_id response = @conn.get("/api/v1/l10/#{meeting_id}/headlines") else user_id ||= self.user_id response = @conn.get("/api/v1/headline/users/#{user_id}") end raise "Failed to list headlines" unless response.success? response.body.map do |headline| { id: headline["Id"], title: headline["Name"], meeting_details: { id: headline["OriginId"], title: headline["Origin"] }, owner_details: { id: headline["Owner"]["Id"], name: headline["Owner"]["Name"] }, archived: headline["Archived"], created_at: headline["CreateTime"], closed_at: headline["CloseTime"] } end end |
#update(headline_id:, title:) ⇒ Boolean
Updates a headline
40 41 42 43 44 |
# File 'lib/bloomy/operations/headlines.rb', line 40 def update(headline_id:, title:) response = @conn.put("/api/v1/headline/#{headline_id}", {title: title}.to_json) raise "Failed to update headline" unless response.status == 200 true end |