Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/mural/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def get(path, query = {})
)

req = Net::HTTP::Get.new uri
# retryable_request(req)
retryable_request(req)
end

Expand Down
6 changes: 6 additions & 0 deletions lib/mural/client/mural_content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ class MuralContent
include Areas
include Arrows
include Chats
include Comments
include FacilitationFeatures
include Files
include Images
include Shapes
include StickyNotes
include Tables
include Tags
include TextBoxes
include Titles
include Widgets

def_delegators :@client, :get, :post, :patch, :delete
Expand Down
37 changes: 37 additions & 0 deletions lib/mural/client/mural_content/comments.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: true

module Mural
class Client
class MuralContent
module Comments
# Create a comment widget on a mural.
#
# Authorization scope: murals:write
#
# https://developers.mural.co/public/reference/createcomment
def create_comment(mural_id, create_comment_params)
json = post(
"/api/public/v1/murals/#{mural_id}/widgets/comment",
create_comment_params.encode
)

Mural::Widget::Comment.decode(json['value'])
end

# Update a comment widget on a mural.
#
# Authorization scope: murals:write
#
# https://developers.mural.co/public/reference/updatecomment
def update_comment(mural_id, comment_id, update_comment_params)
json = patch(
"/api/public/v1/murals/#{mural_id}/widgets/comment/#{comment_id}",
update_comment_params.encode
)

Mural::Widget::Comment.decode(json['value'])
end
end
end
end
end
29 changes: 29 additions & 0 deletions lib/mural/client/mural_content/images.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

module Mural
class Client
class MuralContent
module Images
# https://developers.mural.co/public/reference/createimage
def create_image(mural_id, create_image_params)
json = post(
"/api/public/v1/murals/#{mural_id}/widgets/image",
create_image_params.encode
)

Mural::Widget::Image.decode(json['value'])
end

# https://developers.mural.co/public/reference/createimage
def update_image(mural_id, image_id, update_image_params)
json = patch(
"/api/public/v1/murals/#{mural_id}/widgets/image/#{image_id}",
update_image_params.encode
)

Mural::Widget::Image.decode(json['value'])
end
end
end
end
end
38 changes: 38 additions & 0 deletions lib/mural/client/mural_content/shapes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# frozen_string_literal: true

module Mural
class Client
class MuralContent
module Shapes
# Create one or more shape widgets on a mural. Limit 1000.
#
# Authorization scope: murals:write
#
# https://developers.mural.co/public/reference/createshapewidget
def create_shapes(mural_id, create_shape_params)
json = post(
"/api/public/v1/murals/#{mural_id}/widgets/shape",
[*create_shape_params].map(&:encode)
)
json['value'].map do |json_shape|
Mural::Widget::Shape.decode(json_shape)
end
end

# Update a shape widget on a mural.
#
# Authorization scope: murals:write
#
# https://developers.mural.co/public/reference/updateshapewidget
def update_shape(mural_id, shape_id, update_shape_params)
json = patch(
"/api/public/v1/murals/#{mural_id}/widgets/shape/#{shape_id}",
update_shape_params.encode
)

Mural::Widget::Shape.decode(json['value'])
end
end
end
end
end
14 changes: 12 additions & 2 deletions lib/mural/client/mural_content/sticky_notes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module Mural
class Client
class MuralContent
module StickyNotes
# Create one or more sticky note widgets on a mural. Limit 1000.
#
# Authorization scope: murals:write
#
# https://developers.mural.co/public/reference/createstickynote
def create_sticky_notes(mural_id, create_sticky_note_params)
json = post(
Expand All @@ -14,11 +18,17 @@ def create_sticky_notes(mural_id, create_sticky_note_params)
json['value'].map { |s| Mural::Widget::StickyNote.decode(s) }
end

# Update a sticky note widget on a mural.
#
# Authorization scope: murals:write
#
# https://developers.mural.co/public/reference/updatestickynote
def update_sticky_note(mural_id, widget_id, update_sticky_note_params)
def update_sticky_note(
mural_id, sticky_note_id, update_sticky_note_params
)
json = patch(
"/api/public/v1/murals/#{mural_id}/widgets/sticky-note" \
"/#{widget_id}",
"/#{sticky_note_id}",
update_sticky_note_params.encode
)

Expand Down
24 changes: 24 additions & 0 deletions lib/mural/client/mural_content/tables.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

module Mural
class Client
class MuralContent
module Tables
# Create a table widget on a mural.
#
# Authorization scope: murals:write
#
# https://developers.mural.co/public/reference/createtable
def create_table(mural_id, create_table_params)
json = post(
"/api/public/v1/murals/#{mural_id}/widgets/table",
create_table_params.encode
)

# We receive a mix of Table and TableCell widgets
json['value'].map { |widget| Mural::Widget.decode(widget) }
end
end
end
end
end
37 changes: 37 additions & 0 deletions lib/mural/client/mural_content/text_boxes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: true

module Mural
class Client
class MuralContent
module TextBoxes
# Create one or more text box widgets on a mural. Limit 1000.
#
# Authorization scope: murals:write
#
# https://developers.mural.co/public/reference/createtextbox
def create_text_boxes(mural_id, create_text_box_params)
json = post(
"/api/public/v1/murals/#{mural_id}/widgets/textbox",
[*create_text_box_params].map(&:encode)
)

json['value'].map { |text_box| Mural::Widget::Text.decode(text_box) }
end

# Update a textbox on a mural
#
# Authorization scope: murals:write
#
# https://developers.mural.co/public/reference/updatetextbox
def update_text_box(mural_id, text_box_id, update_text_box_params)
json = patch(
"/api/public/v1/murals/#{mural_id}/widgets/textbox/#{text_box_id}",
update_text_box_params.encode
)

Mural::Widget::Text.decode(json['value'])
end
end
end
end
end
37 changes: 37 additions & 0 deletions lib/mural/client/mural_content/titles.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: true

module Mural
class Client
class MuralContent
module Titles
# Create one or more title widgets on a mural. Limit 1000.
#
# Authorization scope: murals:write
#
# https://developers.mural.co/public/reference/createtitle
def create_titles(mural_id, create_title_params)
json = post(
"/api/public/v1/murals/#{mural_id}/widgets/title",
[*create_title_params].map(&:encode)
)

json['value'].map { |title| Mural::Widget::Text.decode(title) }
end

# Update a title on a mural
#
# Authorization scope: murals:write
#
# https://developers.mural.co/public/reference/updatetitle
def update_title(mural_id, title_id, update_title_params)
json = patch(
"/api/public/v1/murals/#{mural_id}/widgets/title/#{title_id}",
update_title_params.encode
)

Mural::Widget::Text.decode(json['value'])
end
end
end
end
end
37 changes: 0 additions & 37 deletions lib/mural/create_sticky_note_params.rb

This file was deleted.

24 changes: 0 additions & 24 deletions lib/mural/update_sticky_note_params.rb

This file was deleted.

23 changes: 23 additions & 0 deletions lib/mural/widget/create_comment_params.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

module Mural
class Widget
class CreateCommentParams
include Mural::Codec

define_attributes(
**Mural::Widget::Comment.attrs.filter do |attr|
%i[
reference_widget_id
message
stacking_order
x
y
].include? attr
end,

resolved: 'resolved'
)
end
end
end
44 changes: 44 additions & 0 deletions lib/mural/widget/create_image_params.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# frozen_string_literal: true

module Mural
class Widget
class CreateImageParams
include Mural::Codec

define_attributes(
**Mural::Widget::Image.attrs.reject do |attr|
%i[
aspect_ratio
content_edited_by
content_edited_on
created_by
created_on
expires_in_minutes
hide_editor
hide_owner
id
invisible
link
locked
locked_by_facilitator
mask
natural_height
natural_width
thumbnail_url
type
updated_by
updated_on
url
].include? attr
end,

# The name of the image.
# The allowed image formats are: bmp, ico, gif, jpeg, jpg, png, webp.
name: 'name',

# The URL used in the widget.
hyperlink: 'hyperlink'
)
end
end
end
Loading