From fdf7686c204456d2404256a3fc03313778df1780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Pham?= Date: Sat, 20 Sep 2025 17:40:53 +0200 Subject: [PATCH 01/19] chore: harmonize create/update area params --- lib/mural/widget/create_area_params.rb | 30 +++++++++++++------------- lib/mural/widget/update_area_params.rb | 1 + 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/mural/widget/create_area_params.rb b/lib/mural/widget/create_area_params.rb index 0c8d260..7c58ac9 100644 --- a/lib/mural/widget/create_area_params.rb +++ b/lib/mural/widget/create_area_params.rb @@ -5,23 +5,23 @@ class Widget class CreateAreaParams include Mural::Codec + # https://developers.mural.co/public/reference/createarea define_attributes( - **Mural::Widget::Area.attrs.reject do |attr| + **Mural::Widget::Area.attrs.filter do |attr| %i[ - content_edited_by - content_edited_on - created_by - created_on - hide_editor - hide_owner - id - invisible - locked - locked_by_facilitator - rotation - type - updated_by - updated_on + height + hidden + instruction + layout + parent_id + presentation_index + show_title + stacking_order + style + title + width + x + y ].include? attr end ) diff --git a/lib/mural/widget/update_area_params.rb b/lib/mural/widget/update_area_params.rb index f2db340..892b622 100644 --- a/lib/mural/widget/update_area_params.rb +++ b/lib/mural/widget/update_area_params.rb @@ -5,6 +5,7 @@ class Widget class UpdateAreaParams include Mural::Codec + # https://developers.mural.co/public/reference/updatearea define_attributes( **Mural::Widget::CreateAreaParams.attrs ) From 92e36b14e4acfaa20508845509e802a12eee488e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Pham?= Date: Sat, 20 Sep 2025 17:41:03 +0200 Subject: [PATCH 02/19] chore: harmonize create/update arrow params --- lib/mural/widget/create_arrow_params.rb | 42 ++++++++++++++----------- lib/mural/widget/update_arrow_params.rb | 9 +++--- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/lib/mural/widget/create_arrow_params.rb b/lib/mural/widget/create_arrow_params.rb index 6c32f96..ae2bbcc 100644 --- a/lib/mural/widget/create_arrow_params.rb +++ b/lib/mural/widget/create_arrow_params.rb @@ -7,26 +7,34 @@ class CreateArrowParams # https://developers.mural.co/public/reference/createarrow define_attributes( - **Mural::Widget::Arrow.attrs.reject do |attr| + **Mural::Widget::Arrow.attrs.filter do |attr| %i[ - content_edited_by - content_edited_on - created_by - created_on - hidden - hide_editor - hide_owner - id - invisible - locked - locked_by_facilitator - type - updated_by - updated_on + arrow_type + end_ref_id + height + instruction + label + parent_id + points + presentation_index + rotation + stackable + stacking_order + start_ref_id + style + tip + title + width + x + y ].include? attr end ) + Style = Mural::Widget::Arrow::Style + Label = Mural::Widget::Arrow::Label + Point = Mural::Widget::Arrow::Point + def encode super.tap do |json| json['points']&.map!(&:encode) @@ -34,10 +42,6 @@ def encode json['style'] = json['style']&.encode end end - - Style = Mural::Widget::Arrow::Style - Label = Mural::Widget::Arrow::Label - Point = Mural::Widget::Arrow::Point end end end diff --git a/lib/mural/widget/update_arrow_params.rb b/lib/mural/widget/update_arrow_params.rb index 8abd0ee..bdb2e6b 100644 --- a/lib/mural/widget/update_arrow_params.rb +++ b/lib/mural/widget/update_arrow_params.rb @@ -5,12 +5,17 @@ class Widget class UpdateArrowParams include Mural::Codec + # https://developers.mural.co/public/reference/updatearrow define_attributes( **Mural::Widget::CreateArrowParams.attrs.reject do |attr| %i[stacking_order].include? attr end ) + Style = Mural::Widget::Arrow::Style + Label = Mural::Widget::Arrow::Label + Point = Mural::Widget::Arrow::Point + def encode super.tap do |json| json['points']&.map!(&:encode) @@ -18,10 +23,6 @@ def encode json['style'] = json['style']&.encode end end - - Style = Mural::Widget::Arrow::Style - Label = Mural::Widget::Arrow::Label - Point = Mural::Widget::Arrow::Point end end end From 8f6615d7f04c8fc39bfd65d87fd15e18ee59db8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Pham?= Date: Sat, 20 Sep 2025 17:43:49 +0200 Subject: [PATCH 03/19] chore: harmonize create/update comment params --- lib/mural/widget/create_comment_params.rb | 4 +++- lib/mural/widget/update_comment_params.rb | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/mural/widget/create_comment_params.rb b/lib/mural/widget/create_comment_params.rb index 3cbddc7..12beb9c 100644 --- a/lib/mural/widget/create_comment_params.rb +++ b/lib/mural/widget/create_comment_params.rb @@ -5,17 +5,19 @@ class Widget class CreateCommentParams include Mural::Codec + # https://developers.mural.co/public/reference/createcomment define_attributes( **Mural::Widget::Comment.attrs.filter do |attr| %i[ - reference_widget_id message + reference_widget_id stacking_order x y ].include? attr end, + # If true, the comment is marked as resolved. resolved: 'resolved' ) end diff --git a/lib/mural/widget/update_comment_params.rb b/lib/mural/widget/update_comment_params.rb index a2d6c9d..23a86bf 100644 --- a/lib/mural/widget/update_comment_params.rb +++ b/lib/mural/widget/update_comment_params.rb @@ -5,6 +5,7 @@ class Widget class UpdateCommentParams include Mural::Codec + # https://developers.mural.co/public/reference/updatecomment define_attributes( **Mural::Widget::CreateCommentParams.attrs.reject do |attr| %i[stacking_order].include? attr From a3064b1fff316707a03240091af48c7591d0d8c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Pham?= Date: Sat, 20 Sep 2025 18:00:22 +0200 Subject: [PATCH 04/19] chore: harmonize create/update file params + add tests --- lib/mural/widget/create_file_params.rb | 57 ++++++------------- lib/mural/widget/update_area_params.rb | 4 +- lib/mural/widget/update_file_params.rb | 40 +------------ test/mural/client/mural_content/test_areas.rb | 39 +++++++++++++ .../mural/client/mural_content/test_arrows.rb | 49 ++++++++++++++++ .../client/mural_content/test_comments.rb | 26 +++++++++ test/mural/client/mural_content/test_files.rb | 36 ++++++++++++ 7 files changed, 172 insertions(+), 79 deletions(-) diff --git a/lib/mural/widget/create_file_params.rb b/lib/mural/widget/create_file_params.rb index 5c33c0c..c462fda 100644 --- a/lib/mural/widget/create_file_params.rb +++ b/lib/mural/widget/create_file_params.rb @@ -7,49 +7,24 @@ class CreateFileParams # https://developers.mural.co/public/reference/createfile define_attributes( - # The height of the widget in px. This value will be overwritten if the - # file has a preview from which the final value will be extracted. - height: 'height', - - # If true, the widget is hidden from non-facilitators. Applies only when - # the widget is in the outline. - hidden: 'hidden', - - # The instructions for a section of the outline. This text can only be - # added and modified by a facilitator. - instruction: 'instruction', + **Mural::Widget::File.attrs.filter do |attr| + %i[ + height + hidden + instruction + parent_id + presentation_index + rotation + stacking_order + title + width + x + y + ].include? attr + end, # The name of the file. - name: 'name', - - # The ID of the area widget that contains the widget. - parent_id: 'parentId', - - # The list order of the widget in the outline. - presentation_index: 'presentationIndex', - - # The angle of widget rotation in degrees. - rotation: 'rotation', - - # The z-index stacking order of the widget. - stacking_order: 'stackingOrder', - - # The title in the file widget and in the outline. - title: 'title', - - # The width of the widget in px. This value will be overwritten if the - # file has a preview from which the final value will be extracted. - width: 'width', - - # The horizontal position of the widget in px. This is the distance from - # the left of the parent widget, such as an area. If the widget has no - # parent widget, this is the distance from the left of the mural. - x: 'x', - - # The vertical position of the widget in px. This is the distance from - # the top of the parent widget, such as an area. If the widget has no - # parent widget, this is the distance from the top of the mural. - y: 'y' + name: 'name' ) end end diff --git a/lib/mural/widget/update_area_params.rb b/lib/mural/widget/update_area_params.rb index 892b622..d3153a0 100644 --- a/lib/mural/widget/update_area_params.rb +++ b/lib/mural/widget/update_area_params.rb @@ -7,7 +7,9 @@ class UpdateAreaParams # https://developers.mural.co/public/reference/updatearea define_attributes( - **Mural::Widget::CreateAreaParams.attrs + **Mural::Widget::CreateAreaParams.attrs.reject do |attr| + %i[stacking_order].include? attr + end ) Style = Mural::Widget::Area::Style diff --git a/lib/mural/widget/update_file_params.rb b/lib/mural/widget/update_file_params.rb index 4f5c0fa..ea759e0 100644 --- a/lib/mural/widget/update_file_params.rb +++ b/lib/mural/widget/update_file_params.rb @@ -7,43 +7,9 @@ class UpdateFileParams # https://developers.mural.co/public/reference/updatefile define_attributes( - # The height of the widget in px. This value will be overwritten if the - # file has a preview from which the final value will be extracted. - height: 'height', - - # If true, the widget is hidden from non-facilitators. Applies only when - # the widget is in the outline. - hidden: 'hidden', - - # The instructions for a section of the outline. This text can only be - # added and modified by a facilitator. - instruction: 'instruction', - - # The ID of the area widget that contains the widget. - parent_id: 'parentId', - - # The list order of the widget in the outline. - presentation_index: 'presentationIndex', - - # The angle of widget rotation in degrees. - rotation: 'rotation', - - # The title in the file widget and in the outline. - title: 'title', - - # The width of the widget in px. This value will be overwritten if the - # file has a preview from which the final value will be extracted. - width: 'width', - - # The horizontal position of the widget in px. This is the distance from - # the left of the parent widget, such as an area. If the widget has no - # parent widget, this is the distance from the left of the mural. - x: 'x', - - # The vertical position of the widget in px. This is the distance from - # the top of the parent widget, such as an area. If the widget has no - # parent widget, this is the distance from the top of the mural. - y: 'y' + **Mural::Widget::CreateFileParams.attrs.reject do |attr| + %i[name stacking_order].include? attr + end ) end end diff --git a/test/mural/client/mural_content/test_areas.rb b/test/mural/client/mural_content/test_areas.rb index 1835c6d..a6c1b7c 100644 --- a/test/mural/client/mural_content/test_areas.rb +++ b/test/mural/client/mural_content/test_areas.rb @@ -5,6 +5,45 @@ def setup @client = Mural::Client.new end + def test_create_area_params + want = %i[ + height + hidden + instruction + layout + parent_id + presentation_index + show_title + stacking_order + style + title + width + x + y + ] + + assert_equal want, Mural::Widget::CreateAreaParams.attrs.keys.sort + end + + def test_update_area_params + want = %i[ + height + hidden + instruction + layout + parent_id + presentation_index + show_title + style + title + width + x + y + ] + + assert_equal want, Mural::Widget::UpdateAreaParams.attrs.keys.sort + end + def test_create_area mural_id = 'mural-1' diff --git a/test/mural/client/mural_content/test_arrows.rb b/test/mural/client/mural_content/test_arrows.rb index e823f70..bc533ba 100644 --- a/test/mural/client/mural_content/test_arrows.rb +++ b/test/mural/client/mural_content/test_arrows.rb @@ -5,6 +5,55 @@ def setup @client = Mural::Client.new end + def test_create_arrow_params + want = %i[ + arrow_type + end_ref_id + height + instruction + label + parent_id + points + presentation_index + rotation + stackable + stacking_order + start_ref_id + style + tip + title + width + x + y + ] + + assert_equal want, Mural::Widget::CreateArrowParams.attrs.keys.sort + end + + def test_update_arrow_params + want = %i[ + arrow_type + end_ref_id + height + instruction + label + parent_id + points + presentation_index + rotation + stackable + start_ref_id + style + tip + title + width + x + y + ] + + assert_equal want, Mural::Widget::UpdateArrowParams.attrs.keys.sort + end + def test_create_minimal_arrow mural_id = 'mural-1' diff --git a/test/mural/client/mural_content/test_comments.rb b/test/mural/client/mural_content/test_comments.rb index f973717..bc8ef10 100644 --- a/test/mural/client/mural_content/test_comments.rb +++ b/test/mural/client/mural_content/test_comments.rb @@ -5,6 +5,32 @@ def setup @client = Mural::Client.new end + def test_create_comment_params + want = %i[ + message + reference_widget_id + resolved + stacking_order + x + y + ] + + assert_equal want, Mural::Widget::CreateCommentParams.attrs.keys.sort + end + + def test_update_comment_params + want = %i[ + message + reference_widget_id + replies + resolved + x + y + ] + + assert_equal want, Mural::Widget::UpdateCommentParams.attrs.keys.sort + end + def test_create_comment mural_id = 'mural-1' diff --git a/test/mural/client/mural_content/test_files.rb b/test/mural/client/mural_content/test_files.rb index 995ca7f..faea2a2 100644 --- a/test/mural/client/mural_content/test_files.rb +++ b/test/mural/client/mural_content/test_files.rb @@ -7,6 +7,42 @@ def setup @client = Mural::Client.new end + def test_create_file_params + want = %i[ + height + hidden + instruction + name + parent_id + presentation_index + rotation + stacking_order + title + width + x + y + ] + + assert_equal want, Mural::Widget::CreateFileParams.attrs.keys.sort + end + + def test_update_file_params + want = %i[ + height + hidden + instruction + parent_id + presentation_index + rotation + title + width + x + y + ] + + assert_equal want, Mural::Widget::UpdateFileParams.attrs.keys.sort + end + def test_create_file mural_id = 'mural-1' From a16da24a35cd74502664fbe763783f747be17ea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Pham?= Date: Sat, 20 Sep 2025 18:08:10 +0200 Subject: [PATCH 05/19] chore: harmonize create/update image params --- lib/mural/widget/create_image_params.rb | 38 +++++++--------- lib/mural/widget/update_image_params.rb | 2 +- .../mural/client/mural_content/test_images.rb | 44 +++++++++++++++++++ 3 files changed, 61 insertions(+), 23 deletions(-) diff --git a/lib/mural/widget/create_image_params.rb b/lib/mural/widget/create_image_params.rb index c0a73cc..4b31136 100644 --- a/lib/mural/widget/create_image_params.rb +++ b/lib/mural/widget/create_image_params.rb @@ -5,30 +5,24 @@ class Widget class CreateImageParams include Mural::Codec + # https://developers.mural.co/public/reference/createimage define_attributes( - **Mural::Widget::Image.attrs.reject do |attr| + **Mural::Widget::Image.attrs.filter 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 + border + caption + description + height + hidden + instruction + parent_id + presentation_index + rotation + show_caption + stacking_order + width + x + y ].include? attr end, diff --git a/lib/mural/widget/update_image_params.rb b/lib/mural/widget/update_image_params.rb index bb510ac..57394d6 100644 --- a/lib/mural/widget/update_image_params.rb +++ b/lib/mural/widget/update_image_params.rb @@ -7,7 +7,7 @@ class UpdateImageParams define_attributes( **Mural::Widget::CreateImageParams.attrs.reject do |attr| - %i[name].include? attr + %i[name stacking_order].include? attr end ) end diff --git a/test/mural/client/mural_content/test_images.rb b/test/mural/client/mural_content/test_images.rb index e9f52c1..f567d3c 100644 --- a/test/mural/client/mural_content/test_images.rb +++ b/test/mural/client/mural_content/test_images.rb @@ -7,6 +7,50 @@ def setup @client = Mural::Client.new end + def test_create_image_params + want = %i[ + border + caption + description + height + hidden + hyperlink + instruction + name + parent_id + presentation_index + rotation + show_caption + stacking_order + width + x + y + ] + + assert_equal want, Mural::Widget::CreateImageParams.attrs.keys.sort + end + + def test_update_image_params + want = %i[ + border + caption + description + height + hidden + hyperlink + instruction + parent_id + presentation_index + rotation + show_caption + width + x + y + ] + + assert_equal want, Mural::Widget::UpdateImageParams.attrs.keys.sort + end + def test_create_image mural_id = 'mural-1' From ce6a5f1ead285e9e8c13e52d161fb3d0cc1d0511 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Pham?= Date: Sat, 20 Sep 2025 18:10:30 +0200 Subject: [PATCH 06/19] chore: harmonize create/update shape params --- lib/mural/widget/create_shape_params.rb | 1 + lib/mural/widget/update_shape_params.rb | 1 + .../mural/client/mural_content/test_shapes.rb | 42 +++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/lib/mural/widget/create_shape_params.rb b/lib/mural/widget/create_shape_params.rb index f8b672e..859f34a 100644 --- a/lib/mural/widget/create_shape_params.rb +++ b/lib/mural/widget/create_shape_params.rb @@ -5,6 +5,7 @@ class Widget class CreateShapeParams include Mural::Codec + # https://developers.mural.co/public/reference/createshapewidget define_attributes( **Mural::Widget::Shape.attrs.filter do |attr| %i[ diff --git a/lib/mural/widget/update_shape_params.rb b/lib/mural/widget/update_shape_params.rb index 2262804..3e6dcc4 100644 --- a/lib/mural/widget/update_shape_params.rb +++ b/lib/mural/widget/update_shape_params.rb @@ -5,6 +5,7 @@ class Widget class UpdateShapeParams include Mural::Codec + # https://developers.mural.co/public/reference/updateshapewidget define_attributes( **Mural::Widget::CreateShapeParams.attrs.reject do |attr| %i[shape stacking_order].include? attr diff --git a/test/mural/client/mural_content/test_shapes.rb b/test/mural/client/mural_content/test_shapes.rb index 0458e11..4bfd55b 100644 --- a/test/mural/client/mural_content/test_shapes.rb +++ b/test/mural/client/mural_content/test_shapes.rb @@ -5,6 +5,48 @@ def setup @client = Mural::Client.new end + def test_create_shape_params + want = %i[ + height + hidden + html_text + instruction + parent_id + presentation_index + rotation + shape + stacking_order + style + text + title + width + x + y + ] + + assert_equal want, Mural::Widget::CreateShapeParams.attrs.keys.sort + end + + def test_update_shape_params + want = %i[ + height + hidden + html_text + instruction + parent_id + presentation_index + rotation + style + text + title + width + x + y + ] + + assert_equal want, Mural::Widget::UpdateShapeParams.attrs.keys.sort + end + def test_create_shapes mural_id = 'mural-1' From 606fd0a6654b803843c5bfba142163605b7a0c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Pham?= Date: Sat, 20 Sep 2025 18:14:01 +0200 Subject: [PATCH 07/19] chore: harmonize create/update sticky note params --- lib/mural/widget/create_sticky_note_params.rb | 6 +-- lib/mural/widget/update_sticky_note_params.rb | 10 ++-- .../client/mural_content/test_sticky_notes.rb | 48 +++++++++++++++++++ 3 files changed, 55 insertions(+), 9 deletions(-) diff --git a/lib/mural/widget/create_sticky_note_params.rb b/lib/mural/widget/create_sticky_note_params.rb index 5a5d189..4e3e281 100644 --- a/lib/mural/widget/create_sticky_note_params.rb +++ b/lib/mural/widget/create_sticky_note_params.rb @@ -5,6 +5,7 @@ class Widget class CreateStickyNoteParams include Mural::Codec + # https://developers.mural.co/public/reference/createstickynote define_attributes( **Mural::Widget::StickyNote.attrs.filter do |attr| %i[ @@ -30,14 +31,13 @@ class CreateStickyNoteParams end ) + Style = Mural::Widget::StickyNote::Style + def encode super.tap do |json| json['style'] = json['style']&.encode end.compact end - - # Exact same values, no restrictions - Style = Mural::Widget::StickyNote::Style end end end diff --git a/lib/mural/widget/update_sticky_note_params.rb b/lib/mural/widget/update_sticky_note_params.rb index 2cdb5fe..b58e783 100644 --- a/lib/mural/widget/update_sticky_note_params.rb +++ b/lib/mural/widget/update_sticky_note_params.rb @@ -5,22 +5,20 @@ class Widget class UpdateStickyNoteParams include Mural::Codec + # https://developers.mural.co/public/reference/updatestickynote define_attributes( **Mural::Widget::CreateStickyNoteParams.attrs.reject do |attr| - %i[ - stacking_order - shape - ].include? attr + %i[stacking_order shape].include? attr end ) + Style = Mural::Widget::StickyNote::Style + def encode super.tap do |json| json['style'] = json['style']&.encode end end - - Style = Mural::Widget::StickyNote::Style end end end diff --git a/test/mural/client/mural_content/test_sticky_notes.rb b/test/mural/client/mural_content/test_sticky_notes.rb index f60c974..d62ee0f 100644 --- a/test/mural/client/mural_content/test_sticky_notes.rb +++ b/test/mural/client/mural_content/test_sticky_notes.rb @@ -7,6 +7,54 @@ def setup @client = Mural::Client.new end + def test_create_sticky_note_params + want = %i[ + height + hidden + html_text + hyperlink + hyperlink_title + instruction + parent_id + presentation_index + rotation + shape + stacking_order + style + tags + text + title + width + x + y + ] + + assert_equal want, Mural::Widget::CreateStickyNoteParams.attrs.keys.sort + end + + def test_update_sticky_note_params + want = %i[ + height + hidden + html_text + hyperlink + hyperlink_title + instruction + parent_id + presentation_index + rotation + style + tags + text + title + width + x + y + ] + + assert_equal want, Mural::Widget::UpdateStickyNoteParams.attrs.keys.sort + end + def test_create_sticky_notes mural_id = 'some-mural-1' From 543d5154d6b0f1c6dbb1d253f3433eef3f34d1f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Pham?= Date: Sat, 20 Sep 2025 18:17:50 +0200 Subject: [PATCH 08/19] chore: harmonize create table/table cell params --- lib/mural/widget/create_table_cell_params.rb | 7 ++-- lib/mural/widget/create_table_params.rb | 1 + .../mural/client/mural_content/test_tables.rb | 41 +++++++++++++++++++ 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/lib/mural/widget/create_table_cell_params.rb b/lib/mural/widget/create_table_cell_params.rb index 02a80bb..9581147 100644 --- a/lib/mural/widget/create_table_cell_params.rb +++ b/lib/mural/widget/create_table_cell_params.rb @@ -5,6 +5,7 @@ class Widget class CreateTableCellParams include Mural::Codec + # https://developers.mural.co/public/reference/createtable define_attributes( **Mural::Widget::TableCell.attrs.filter do |attr| %i[ @@ -23,15 +24,15 @@ class CreateTableCellParams end ) + Style = Mural::Widget::TableCell::Style + TextContent = Mural::Widget::TableCell::TextContent + def encode super.tap do |json| json['style'] = json['style']&.encode json['textContent'] = json['textContent']&.encode end.compact end - - Style = Mural::Widget::TableCell::Style - TextContent = Mural::Widget::TableCell::TextContent end end end diff --git a/lib/mural/widget/create_table_params.rb b/lib/mural/widget/create_table_params.rb index 37af35b..3a81c33 100644 --- a/lib/mural/widget/create_table_params.rb +++ b/lib/mural/widget/create_table_params.rb @@ -5,6 +5,7 @@ class Widget class CreateTableParams include Mural::Codec + # https://developers.mural.co/public/reference/createtable define_attributes( **Mural::Widget::Table.attrs.filter do |attr| %i[ diff --git a/test/mural/client/mural_content/test_tables.rb b/test/mural/client/mural_content/test_tables.rb index 76d35ea..7a1c391 100644 --- a/test/mural/client/mural_content/test_tables.rb +++ b/test/mural/client/mural_content/test_tables.rb @@ -5,6 +5,47 @@ def setup @client = Mural::Client.new end + def test_create_table_cell_params + want = %i[ + col_span + column_id + height + rotation + row_id + row_span + style + text_content + width + x + y + ] + + assert_equal want, Mural::Widget::CreateTableCellParams.attrs.keys.sort + end + + def test_create_table_params + want = %i[ + auto_resize + cells + columns + height + hidden + instruction + parent_id + presentation_index + rotation + rows + stacking_order + style + title + width + x + y + ] + + assert_equal want, Mural::Widget::CreateTableParams.attrs.keys.sort + end + def test_create_table mural_id = 'mural-1' From 26956b59f6334edbe8303e199e4a2e07f7c95237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Pham?= Date: Sat, 20 Sep 2025 18:20:15 +0200 Subject: [PATCH 09/19] chore: harmonize create/update text box params --- lib/mural/widget/create_text_box_params.rb | 1 + lib/mural/widget/update_text_box_params.rb | 1 + .../client/mural_content/test_text_boxes.rb | 43 +++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/lib/mural/widget/create_text_box_params.rb b/lib/mural/widget/create_text_box_params.rb index c11c82c..a4e4617 100644 --- a/lib/mural/widget/create_text_box_params.rb +++ b/lib/mural/widget/create_text_box_params.rb @@ -5,6 +5,7 @@ class Widget class CreateTextBoxParams include Mural::Codec + # https://developers.mural.co/public/reference/createtextbox define_attributes( **Mural::Widget::Text.attrs.filter do |attr| %i[ diff --git a/lib/mural/widget/update_text_box_params.rb b/lib/mural/widget/update_text_box_params.rb index 0010c00..33d5602 100644 --- a/lib/mural/widget/update_text_box_params.rb +++ b/lib/mural/widget/update_text_box_params.rb @@ -5,6 +5,7 @@ class Widget class UpdateTextBoxParams include Mural::Codec + # https://developers.mural.co/public/reference/updatetextbox define_attributes( **Mural::Widget::CreateTextBoxParams.attrs.reject do |attr| %i[stacking_order].include? attr diff --git a/test/mural/client/mural_content/test_text_boxes.rb b/test/mural/client/mural_content/test_text_boxes.rb index 88ea977..eee25be 100644 --- a/test/mural/client/mural_content/test_text_boxes.rb +++ b/test/mural/client/mural_content/test_text_boxes.rb @@ -5,6 +5,49 @@ def setup @client = Mural::Client.new end + def test_create_text_box_params + want = %i[ + height + hidden + hyperlink + hyperlink_title + instruction + parent_id + presentation_index + rotation + stacking_order + style + text + title + width + x + y + ] + + assert_equal want, Mural::Widget::CreateTextBoxParams.attrs.keys.sort + end + + def test_update_text_box_params + want = %i[ + height + hidden + hyperlink + hyperlink_title + instruction + parent_id + presentation_index + rotation + style + text + title + width + x + y + ] + + assert_equal want, Mural::Widget::UpdateTextBoxParams.attrs.keys.sort + end + def test_create_text_boxes mural_id = 'mural-1' From e851ab5ba507671a5dfdacdcae01a523e3f47391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Pham?= Date: Sat, 20 Sep 2025 18:21:54 +0200 Subject: [PATCH 10/19] chore: harmonize create/update title params --- lib/mural/widget/create_title_params.rb | 1 + lib/mural/widget/update_title_params.rb | 1 + .../mural/client/mural_content/test_titles.rb | 43 +++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/lib/mural/widget/create_title_params.rb b/lib/mural/widget/create_title_params.rb index 413b565..0d24050 100644 --- a/lib/mural/widget/create_title_params.rb +++ b/lib/mural/widget/create_title_params.rb @@ -5,6 +5,7 @@ class Widget class CreateTitleParams include Mural::Codec + # https://developers.mural.co/public/reference/createtitle define_attributes( **Mural::Widget::Text.attrs.filter do |attr| %i[ diff --git a/lib/mural/widget/update_title_params.rb b/lib/mural/widget/update_title_params.rb index f2eb3b7..8de4f98 100644 --- a/lib/mural/widget/update_title_params.rb +++ b/lib/mural/widget/update_title_params.rb @@ -5,6 +5,7 @@ class Widget class UpdateTitleParams include Mural::Codec + # https://developers.mural.co/public/reference/updatetitle define_attributes( **Mural::Widget::CreateTitleParams.attrs.reject do |attr| %i[stacking_order].include? attr diff --git a/test/mural/client/mural_content/test_titles.rb b/test/mural/client/mural_content/test_titles.rb index 23266e5..7b22853 100644 --- a/test/mural/client/mural_content/test_titles.rb +++ b/test/mural/client/mural_content/test_titles.rb @@ -5,6 +5,49 @@ def setup @client = Mural::Client.new end + def test_create_title_params + want = %i[ + height + hidden + hyperlink + hyperlink_title + instruction + parent_id + presentation_index + rotation + stacking_order + style + text + title + width + x + y + ] + + assert_equal want, Mural::Widget::CreateTitleParams.attrs.keys.sort + end + + def test_update_title_params + want = %i[ + height + hidden + hyperlink + hyperlink_title + instruction + parent_id + presentation_index + rotation + style + text + title + width + x + y + ] + + assert_equal want, Mural::Widget::UpdateTitleParams.attrs.keys.sort + end + def test_create_titles mural_id = 'mural-1' From 6c61c377209132820bca97aca047e9b696c5aa65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Pham?= Date: Sat, 20 Sep 2025 18:32:10 +0200 Subject: [PATCH 11/19] fix: (area) widget common attributes should be parsed --- lib/mural/client/mural_content/areas.rb | 4 +- test/mural/client/mural_content/test_areas.rb | 40 +++++++++++++++++-- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/lib/mural/client/mural_content/areas.rb b/lib/mural/client/mural_content/areas.rb index 27e93f5..84d5de1 100644 --- a/lib/mural/client/mural_content/areas.rb +++ b/lib/mural/client/mural_content/areas.rb @@ -11,7 +11,7 @@ def create_area(mural_id, create_area_params) create_area_params.encode ) - Mural::Widget::Area.decode(json['value']) + Mural::Widget.decode(json['value']) end # https://developers.mural.co/public/reference/updatearea @@ -21,7 +21,7 @@ def update_area(mural_id, area_id, update_area_params) update_area_params.encode ) - Mural::Widget::Area.decode(json['value']) + Mural::Widget.decode(json['value']) end end end diff --git a/test/mural/client/mural_content/test_areas.rb b/test/mural/client/mural_content/test_areas.rb index a6c1b7c..2938440 100644 --- a/test/mural/client/mural_content/test_areas.rb +++ b/test/mural/client/mural_content/test_areas.rb @@ -52,7 +52,7 @@ def test_create_area "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets/area" ).with(body: { title: 'Nothing to see here' }) .to_return_json( - body: { value: { id: 'area-51' } }, + body: { value: { id: 'area-51', type: 'area' } }, status: 201 ) @@ -65,6 +65,38 @@ def test_create_area assert_instance_of Mural::Widget::Area, area end + def test_should_parse_content_edited_by + mural_id = 'mural-1' + + stub_request( + :post, + "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets/area" + ).with(body: { title: 'Nothing to see here' }) + .to_return_json( + body: { + value: { + id: 'area-51', + contentEditedBy: { + id: 'user-1', + firstName: 'John', + lastName: 'Doe' + }, + type: 'area' + } + }, + status: 201 + ) + + create_area_params = Mural::Widget::CreateAreaParams.new.tap do |params| + params.title = 'Nothing to see here' + end + + area = @client.mural_content.create_area(mural_id, create_area_params) + + assert_instance_of Mural::Widget::Area, area + assert_equal 'John', area.content_edited_by.first_name + end + def test_create_area_with_style mural_id = 'mural-1' @@ -75,7 +107,7 @@ def test_create_area_with_style body: { title: 'Todo', style: { backgroundColor: '#FFFFFF33' } } ) .to_return_json( - body: { value: { id: 'area-1' } }, + body: { value: { id: 'area-1', type: 'area' } }, status: 201 ) @@ -100,7 +132,7 @@ def test_update_area "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets" \ "/area/#{area_id}" ).with(body: { title: 'updated title' }) - .to_return_json(body: { value: { id: 'area-1' } }) + .to_return_json(body: { value: { id: 'area-1', type: 'area' } }) update_area_params = Mural::Widget::UpdateAreaParams.new.tap do |params| params.title = 'updated title' @@ -122,7 +154,7 @@ def test_update_area_with_style "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets" \ "/area/#{area_id}" ).with(body: { style: { backgroundColor: '#FAFAFAFF' } }) - .to_return_json(body: { value: { id: 'area-1' } }) + .to_return_json(body: { value: { id: 'area-1', type: 'area' } }) update_area_params = Mural::Widget::UpdateAreaParams.new.tap do |params| params.style = Mural::Widget::UpdateAreaParams::Style.new.tap do |style| From a42183b85123fc5b942e6e3ce0d825a4a369f4a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Pham?= Date: Sat, 20 Sep 2025 18:36:24 +0200 Subject: [PATCH 12/19] fix: (arrow) widget common attributes should be decoded --- lib/mural/client/mural_content/arrows.rb | 4 +- .../mural/client/mural_content/test_arrows.rb | 63 +++++++++++++++++-- 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/lib/mural/client/mural_content/arrows.rb b/lib/mural/client/mural_content/arrows.rb index afe17f0..a4fe41b 100644 --- a/lib/mural/client/mural_content/arrows.rb +++ b/lib/mural/client/mural_content/arrows.rb @@ -11,7 +11,7 @@ def create_arrow(mural_id, create_arrow_params) create_arrow_params.encode ) - Mural::Widget::Arrow.decode(json['value']) + Mural::Widget.decode(json['value']) end # https://developers.mural.co/public/reference/updatearrow @@ -21,7 +21,7 @@ def update_arrow(mural_id, arrow_id, update_arrow_params) update_arrow_params.encode ) - Mural::Widget::Arrow.decode(json['value']) + Mural::Widget.decode(json['value']) end end end diff --git a/test/mural/client/mural_content/test_arrows.rb b/test/mural/client/mural_content/test_arrows.rb index bc533ba..99101bf 100644 --- a/test/mural/client/mural_content/test_arrows.rb +++ b/test/mural/client/mural_content/test_arrows.rb @@ -72,7 +72,7 @@ def test_create_minimal_arrow ] } ).to_return_json( - body: { value: { id: 'arrow-1' } }, + body: { value: { id: 'arrow-1', type: 'arrow' } }, status: 201 ) @@ -100,6 +100,59 @@ def test_create_minimal_arrow assert_equal 'arrow-1', arrow.id end + def test_should_parse_content_edited_by + mural_id = 'mural-1' + + stub_request( + :post, + "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets/arrow" + ).with( + body: { + height: 1, + width: 216, + x: 0, + y: 0, + points: [ + { x: 216, y: 0 }, + { x: 0, y: 0 } + ] + } + ).to_return_json( + body: { + value: { + id: 'arrow-1', + contentEditedBy: { id: 'user-1', firstName: 'John' }, + type: 'arrow' + } + }, + status: 201 + ) + + create_arrow_params = Mural::Widget::CreateArrowParams.new.tap do |params| + params.height = 1 + params.width = 216 + params.x = 0 + params.y = 0 + + params.points = [ + Mural::Widget::Arrow::Point.new.tap do |p| + p.x = 216 + p.y = 0 + end, + Mural::Widget::Arrow::Point.new.tap do |p| + p.x = 0 + p.y = 0 + end + ] + end + + arrow = @client.mural_content.create_arrow(mural_id, create_arrow_params) + + assert_instance_of Mural::Widget::Arrow, arrow + assert_equal 'arrow-1', arrow.id + assert_equal 'John', arrow.content_edited_by.first_name + end + def test_create_arrow_without_points mural_id = 'mural-1' @@ -160,7 +213,7 @@ def test_create_arrow_with_style_and_formatted_label label: { format: { fontFamily: 'proxima-nova' } } } ).to_return_json( - body: { value: { id: 'arrow-1' } }, + body: { value: { id: 'arrow-1', type: 'arrow' } }, status: 201 ) @@ -222,7 +275,7 @@ def test_create_arrow_with_unformatted_labels } } ).to_return_json( - body: { value: { id: 'arrow-1' } }, + body: { value: { id: 'arrow-1', type: 'arrow' } }, status: 201 ) @@ -277,7 +330,7 @@ def test_update_arrow { x: 0, y: 0 } ] } - ).to_return_json(body: { value: { id: 'arrow-1' } }) + ).to_return_json(body: { value: { id: 'arrow-1', type: 'arrow' } }) update_arrow_params = Mural::Widget::UpdateArrowParams.new.tap do |params| params.points = [ @@ -315,7 +368,7 @@ def test_update_arrow_with_style_and_formatted_label style: { strokeColor: '#FAFAFAFF' }, label: { format: { fontFamily: 'proxima-nova' } } } - ).to_return_json(body: { value: { id: 'arrow-1' } }) + ).to_return_json(body: { value: { id: 'arrow-1', type: 'arrow' } }) update_arrow_params = Mural::Widget::UpdateArrowParams.new.tap do |params| params.style = Mural::Widget::UpdateArrowParams::Style.new.tap do |style| From 0dc656eacf9e691fc604636eb3e065e083aee768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Pham?= Date: Sat, 20 Sep 2025 18:40:37 +0200 Subject: [PATCH 13/19] fix: (comment) widget common attributes should be decoded --- lib/mural/client/mural_content/comments.rb | 4 +- .../client/mural_content/test_comments.rb | 45 ++++++++++++++++++- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/lib/mural/client/mural_content/comments.rb b/lib/mural/client/mural_content/comments.rb index ed5328f..84b4cb7 100644 --- a/lib/mural/client/mural_content/comments.rb +++ b/lib/mural/client/mural_content/comments.rb @@ -15,7 +15,7 @@ def create_comment(mural_id, create_comment_params) create_comment_params.encode ) - Mural::Widget::Comment.decode(json['value']) + Mural::Widget.decode(json['value']) end # Update a comment widget on a mural. @@ -29,7 +29,7 @@ def update_comment(mural_id, comment_id, update_comment_params) update_comment_params.encode ) - Mural::Widget::Comment.decode(json['value']) + Mural::Widget.decode(json['value']) end end end diff --git a/test/mural/client/mural_content/test_comments.rb b/test/mural/client/mural_content/test_comments.rb index bc8ef10..7cc9e86 100644 --- a/test/mural/client/mural_content/test_comments.rb +++ b/test/mural/client/mural_content/test_comments.rb @@ -40,7 +40,13 @@ def test_create_comment ) .with(body: { message: 'This is a test', x: 0, y: 0 }) .to_return_json( - body: { value: { id: 'comment-1', message: 'This is a test' } }, + body: { + value: { + id: 'comment-1', + message: 'This is a test', + type: 'comment' + } + }, status: 201 ) @@ -59,6 +65,40 @@ def test_create_comment assert_equal 'This is a test', comment.message end + def test_should_parse_content_edited_by + mural_id = 'mural-1' + + stub_request( + :post, + "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets/comment" + ) + .with(body: { message: 'This is a test', x: 0, y: 0 }) + .to_return_json( + body: { + value: { + id: 'comment-1', + message: 'This is a test', + contentEditedBy: { id: 'user-1', firstName: 'John' }, + type: 'comment' + } + }, + status: 201 + ) + + create_comment_params = Mural::Widget::CreateCommentParams.new.tap do |c| + c.message = 'This is a test' + c.x = 0 + c.y = 0 + end + + comment = @client + .mural_content + .create_comment(mural_id, create_comment_params) + + assert_instance_of Mural::Widget::Comment, comment + assert_equal 'John', comment.content_edited_by.first_name + end + def test_update_comment mural_id = 'mural-1' comment_id = 'comment-1' @@ -76,7 +116,8 @@ def test_update_comment message: 'This is a test', replies: [ { created: 1, message: 'And it succeeded', user: 'user-1' } - ] + ], + type: 'comment' } }, status: 201 From 89fc1488749c26697d0411284588f0ea9f1949c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Pham?= Date: Sat, 20 Sep 2025 18:43:50 +0200 Subject: [PATCH 14/19] fix: (file) widget common attributes should be decoded --- lib/mural/client/mural_content/files.rb | 6 ++-- test/mural/client/mural_content/test_areas.rb | 2 +- .../mural/client/mural_content/test_arrows.rb | 2 +- .../client/mural_content/test_comments.rb | 2 +- test/mural/client/mural_content/test_files.rb | 33 ++++++++++++++++++- 5 files changed, 38 insertions(+), 7 deletions(-) diff --git a/lib/mural/client/mural_content/files.rb b/lib/mural/client/mural_content/files.rb index 6363b2e..68b20ea 100644 --- a/lib/mural/client/mural_content/files.rb +++ b/lib/mural/client/mural_content/files.rb @@ -11,7 +11,7 @@ def create_file(mural_id, params) params.encode ) - Mural::Widget::File.decode(json['value']) + Mural::Widget.decode(json['value']) end # https://developers.mural.co/public/reference/getmuralfilewidgets @@ -21,7 +21,7 @@ def list_files(mural_id, next_page: nil) { next: next_page } ) - files = json['value'].map { |f| Mural::Widget::File.decode(f) } + files = json['value'].map { |f| Mural::Widget.decode(f) } [files, json['next']] end @@ -32,7 +32,7 @@ def update_file(mural_id, widget_id:, update_file_params:) update_file_params.encode ) - Mural::Widget::File.decode(json['value']) + Mural::Widget.decode(json['value']) end end end diff --git a/test/mural/client/mural_content/test_areas.rb b/test/mural/client/mural_content/test_areas.rb index 2938440..77f6f46 100644 --- a/test/mural/client/mural_content/test_areas.rb +++ b/test/mural/client/mural_content/test_areas.rb @@ -65,7 +65,7 @@ def test_create_area assert_instance_of Mural::Widget::Area, area end - def test_should_parse_content_edited_by + def test_should_decode_content_edited_by mural_id = 'mural-1' stub_request( diff --git a/test/mural/client/mural_content/test_arrows.rb b/test/mural/client/mural_content/test_arrows.rb index 99101bf..e0c2a7e 100644 --- a/test/mural/client/mural_content/test_arrows.rb +++ b/test/mural/client/mural_content/test_arrows.rb @@ -100,7 +100,7 @@ def test_create_minimal_arrow assert_equal 'arrow-1', arrow.id end - def test_should_parse_content_edited_by + def test_should_decode_content_edited_by mural_id = 'mural-1' stub_request( diff --git a/test/mural/client/mural_content/test_comments.rb b/test/mural/client/mural_content/test_comments.rb index 7cc9e86..674d326 100644 --- a/test/mural/client/mural_content/test_comments.rb +++ b/test/mural/client/mural_content/test_comments.rb @@ -65,7 +65,7 @@ def test_create_comment assert_equal 'This is a test', comment.message end - def test_should_parse_content_edited_by + def test_should_decode_content_edited_by mural_id = 'mural-1' stub_request( diff --git a/test/mural/client/mural_content/test_files.rb b/test/mural/client/mural_content/test_files.rb index faea2a2..ee5a4b4 100644 --- a/test/mural/client/mural_content/test_files.rb +++ b/test/mural/client/mural_content/test_files.rb @@ -52,7 +52,7 @@ def test_create_file ) .with(body: { name: 'my file', x: 5, y: 10 }) .to_return_json( - body: { value: { id: 'widget-1' } }, + body: { value: { id: 'widget-1', type: 'file' } }, status: 201 ) @@ -68,6 +68,37 @@ def test_create_file assert_equal 'widget-1', file.id end + def test_should_decode_content_edited_by + mural_id = 'mural-1' + + stub_request( + :post, + "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets/file" + ) + .with(body: { name: 'my file', x: 5, y: 10 }) + .to_return_json( + body: { + value: { + id: 'widget-1', + contentEditedBy: { id: 'user-1', firstName: 'John' }, + type: 'file' + } + }, + status: 201 + ) + + params = Mural::Widget::CreateFileParams.new.tap do |params| + params.name = 'my file' + params.x = 5 + params.y = 10 + end + + file = @client.mural_content.create_file(mural_id, params) + + assert_instance_of Mural::Widget::File, file + assert_equal 'John', file.content_edited_by.first_name + end + def test_list_files mural_id = 'mural-2' From cd47e8d5d2c484c2a46cf8a6c637b6f9ccb04fed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Pham?= Date: Sat, 20 Sep 2025 18:48:25 +0200 Subject: [PATCH 15/19] fix: (image) widget common attributes should be decoded --- lib/mural/client/mural_content/images.rb | 4 +- .../mural/client/mural_content/test_images.rb | 38 ++++++++++++++++++- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/lib/mural/client/mural_content/images.rb b/lib/mural/client/mural_content/images.rb index 54368ca..cc10fa7 100644 --- a/lib/mural/client/mural_content/images.rb +++ b/lib/mural/client/mural_content/images.rb @@ -11,7 +11,7 @@ def create_image(mural_id, create_image_params) create_image_params.encode ) - Mural::Widget::Image.decode(json['value']) + Mural::Widget.decode(json['value']) end # https://developers.mural.co/public/reference/createimage @@ -21,7 +21,7 @@ def update_image(mural_id, image_id, update_image_params) update_image_params.encode ) - Mural::Widget::Image.decode(json['value']) + Mural::Widget.decode(json['value']) end end end diff --git a/test/mural/client/mural_content/test_images.rb b/test/mural/client/mural_content/test_images.rb index f567d3c..d4aad68 100644 --- a/test/mural/client/mural_content/test_images.rb +++ b/test/mural/client/mural_content/test_images.rb @@ -63,7 +63,8 @@ def test_create_image body: { value: { id: 'image-1', - thumbnailUrl: 'https://example.com/thumbnail.jpg' + thumbnailUrl: 'https://example.com/thumbnail.jpg', + type: 'image' } }, status: 201 @@ -80,6 +81,39 @@ def test_create_image assert_equal 'https://example.com/thumbnail.jpg', image.thumbnail_url end + def test_should_decode_content_edited_by + mural_id = 'mural-1' + + stub_request( + :post, + "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets/image" + ) + .with(body: { name: 'my image' }) + .to_return_json( + body: { + value: { + id: 'image-1', + thumbnailUrl: 'https://example.com/thumbnail.jpg', + contentEditedBy: { + id: 'user-1', + firstName: 'John' + }, + type: 'image' + } + }, + status: 201 + ) + + params = Mural::Widget::CreateImageParams.new.tap do |params| + params.name = 'my image' + end + + image = @client.mural_content.create_image(mural_id, params) + + assert_instance_of Mural::Widget::Image, image + assert_equal 'John', image.content_edited_by.first_name + end + def test_update_image mural_id = 'mural-1' image_id = 'image-1' @@ -91,7 +125,7 @@ def test_update_image ) .with(body: { showCaption: false }) .to_return_json( - body: { value: { id: 'image-1' } }, + body: { value: { id: 'image-1', type: 'image' } }, status: 201 ) From a9f276a7e135c037ab8a4d11b87a629df858fb4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Pham?= Date: Sat, 20 Sep 2025 18:51:45 +0200 Subject: [PATCH 16/19] fix: (shape) widget common attributes should be decoded --- lib/mural/client/mural_content/shapes.rb | 4 +- .../mural/client/mural_content/test_shapes.rb | 54 +++++++++++++++++-- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/lib/mural/client/mural_content/shapes.rb b/lib/mural/client/mural_content/shapes.rb index 5c21d79..a69ac62 100644 --- a/lib/mural/client/mural_content/shapes.rb +++ b/lib/mural/client/mural_content/shapes.rb @@ -15,7 +15,7 @@ def create_shapes(mural_id, create_shape_params) [*create_shape_params].map(&:encode) ) json['value'].map do |json_shape| - Mural::Widget::Shape.decode(json_shape) + Mural::Widget.decode(json_shape) end end @@ -30,7 +30,7 @@ def update_shape(mural_id, shape_id, update_shape_params) update_shape_params.encode ) - Mural::Widget::Shape.decode(json['value']) + Mural::Widget.decode(json['value']) end end end diff --git a/test/mural/client/mural_content/test_shapes.rb b/test/mural/client/mural_content/test_shapes.rb index 4bfd55b..a8573f9 100644 --- a/test/mural/client/mural_content/test_shapes.rb +++ b/test/mural/client/mural_content/test_shapes.rb @@ -68,11 +68,12 @@ def test_create_shapes .to_return_json( body: { value: [ - { id: 'shape-1', shape: 'rectangle' }, + { id: 'shape-1', shape: 'rectangle', type: 'shape' }, { id: 'shape-2', shape: 'ellipse', - style: { backgroundColor: '#FAFAFAFF' } + style: { backgroundColor: '#FAFAFAFF' }, + type: 'shape' } ] }, @@ -115,6 +116,51 @@ def test_create_shapes assert_equal '#FAFAFAFF', ellipse.style.background_color end + def test_should_decode_content_edited_by + mural_id = 'mural-1' + + stub_request( + :post, + "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets/shape" + ) + .with(body: [{ shape: 'rectangle', x: 0, y: 0 }]) + .to_return_json( + body: { + value: [ + { + id: 'shape-1', + shape: 'rectangle', + contentEditedBy: { + id: 'user-1', + firstName: 'John' + }, + type: 'shape' + } + ] + }, + status: 201 + ) + + create_shape_params = + Mural::Widget::CreateShapeParams.new.tap do |params| + params.shape = 'rectangle' + params.x = 0 + params.y = 0 + end + + shapes = @client.mural_content.create_shapes( + mural_id, + create_shape_params + ) + + assert_equal 1, shapes.size + + rectangle = shapes.find { |s| s.shape == 'rectangle' } + + assert_instance_of Mural::Widget::Shape, rectangle + assert_equal 'John', rectangle.content_edited_by.first_name + end + def test_update_shape mural_id = 'mural-1' shape_id = 'shape-1' @@ -126,7 +172,7 @@ def test_update_shape ) .with(body: { title: 'dat shape' }) .to_return_json( - body: { value: { id: 'shape-1', title: 'dat shape' } }, + body: { value: { id: 'shape-1', title: 'dat shape', type: 'shape' } }, status: 201 ) @@ -157,7 +203,7 @@ def test_update_shape_with_style ) .with(body: { style: { backgroundColor: '#FAFAFAFF' } }) .to_return_json( - body: { value: { id: 'shape-1' } }, + body: { value: { id: 'shape-1', type: 'shape' } }, status: 201 ) From 98fb1733f5b4c1e09bc7ab2850dc0678ca5e4a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Pham?= Date: Sat, 20 Sep 2025 18:58:44 +0200 Subject: [PATCH 17/19] fix: (sticky note) widget common attributes should be decoded --- .../client/mural_content/sticky_notes.rb | 4 +- .../client/mural_content/test_sticky_notes.rb | 55 +++++++++++++++++-- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/lib/mural/client/mural_content/sticky_notes.rb b/lib/mural/client/mural_content/sticky_notes.rb index 0e4de39..c737d20 100644 --- a/lib/mural/client/mural_content/sticky_notes.rb +++ b/lib/mural/client/mural_content/sticky_notes.rb @@ -15,7 +15,7 @@ def create_sticky_notes(mural_id, create_sticky_note_params) [*create_sticky_note_params].map(&:encode) ) - json['value'].map { |s| Mural::Widget::StickyNote.decode(s) } + json['value'].map { |s| Mural::Widget.decode(s) } end # Update a sticky note widget on a mural. @@ -32,7 +32,7 @@ def update_sticky_note( update_sticky_note_params.encode ) - Mural::Widget::StickyNote.decode(json['value']) + Mural::Widget.decode(json['value']) end end end diff --git a/test/mural/client/mural_content/test_sticky_notes.rb b/test/mural/client/mural_content/test_sticky_notes.rb index d62ee0f..0b3a878 100644 --- a/test/mural/client/mural_content/test_sticky_notes.rb +++ b/test/mural/client/mural_content/test_sticky_notes.rb @@ -64,7 +64,10 @@ def test_create_sticky_notes '/sticky-note' ) .with(body: [{ text: 'My sticky' }]) - .to_return_json(body: { value: [{ id: 'sticky-1' }] }, status: 201) + .to_return_json( + body: { value: [{ id: 'sticky-1', type: 'sticky note' }] }, + status: 201 + ) create_sticky_note_params = Mural::Widget::CreateStickyNoteParams.new.tap do |sticky_note| @@ -77,9 +80,50 @@ def test_create_sticky_notes .create_sticky_notes(mural_id, create_sticky_note_params) assert_equal 1, created_sticky_notes.size + assert_instance_of Mural::Widget::StickyNote, created_sticky_notes.first assert_equal 'sticky-1', created_sticky_notes.first.id end + def test_should_decode_content_edited_by + mural_id = 'some-mural-1' + + stub_request( + :post, + "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets" \ + '/sticky-note' + ) + .with(body: [{ text: 'My sticky' }]) + .to_return_json( + body: { + value: [ + { + id: 'sticky-1', + contentEditedBy: { id: 'user-1', firstName: 'John' }, + type: 'sticky note' + } + ] + }, + status: 201 + ) + + create_sticky_note_params = + Mural::Widget::CreateStickyNoteParams.new.tap do |sticky_note| + sticky_note.text = 'My sticky' + end + + created_sticky_notes = + @client + .mural_content + .create_sticky_notes(mural_id, create_sticky_note_params) + + assert_equal 1, created_sticky_notes.size + + sticky_note = created_sticky_notes.first + + assert_equal 'sticky-1', sticky_note.id + assert_instance_of Mural::Widget::StickyNote, sticky_note + end + def test_create_sticky_notes_with_style mural_id = 'some-mural-1' @@ -92,7 +136,7 @@ def test_create_sticky_notes_with_style body: [{ text: 'My sticky', style: { backgroundColor: '#FAFAFAFF' } }] ) .to_return_json( - body: { value: [{ id: 'sticky-1' }] }, + body: { value: [{ id: 'sticky-1', type: 'sticky note' }] }, status: 201 ) @@ -111,6 +155,7 @@ def test_create_sticky_notes_with_style .create_sticky_notes(mural_id, create_sticky_note_params) assert_equal 1, created_sticky_notes.size + assert_instance_of Mural::Widget::StickyNote, created_sticky_notes.first assert_equal 'sticky-1', created_sticky_notes.first.id end @@ -124,7 +169,7 @@ def test_update_sticky_note "/sticky-note/#{widget_id}" ) .with(body: { text: 'updated text' }) - .to_return_json(body: { value: { id: widget_id } }) + .to_return_json(body: { value: { id: widget_id, type: 'sticky note' } }) update_params = Mural::Widget::UpdateStickyNoteParams.new.tap do |params| @@ -135,6 +180,7 @@ def test_update_sticky_note .update_sticky_note(mural_id, widget_id, update_params) assert_equal widget_id, updated.id + assert_instance_of Mural::Widget::StickyNote, updated end def test_update_sticky_note_with_style @@ -147,7 +193,7 @@ def test_update_sticky_note_with_style "/sticky-note/#{widget_id}" ) .with(body: { style: { bold: true } }) - .to_return_json(body: { value: { id: widget_id } }) + .to_return_json(body: { value: { id: widget_id, type: 'sticky note' } }) update_params = Mural::Widget::UpdateStickyNoteParams.new.tap do |params| @@ -161,5 +207,6 @@ def test_update_sticky_note_with_style .update_sticky_note(mural_id, widget_id, update_params) assert_equal widget_id, updated.id + assert_instance_of Mural::Widget::StickyNote, updated end end From c1bfa265b1b20cb766b2d00271f23ddb2cb20389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Pham?= Date: Sat, 20 Sep 2025 19:06:41 +0200 Subject: [PATCH 18/19] fix: (text box) widget common attributes should be decoded --- lib/mural/client/mural_content/text_boxes.rb | 4 +- .../client/mural_content/test_text_boxes.rb | 53 +++++++++++++++++-- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/lib/mural/client/mural_content/text_boxes.rb b/lib/mural/client/mural_content/text_boxes.rb index c6c12e5..04cec57 100644 --- a/lib/mural/client/mural_content/text_boxes.rb +++ b/lib/mural/client/mural_content/text_boxes.rb @@ -15,7 +15,7 @@ def create_text_boxes(mural_id, create_text_box_params) [*create_text_box_params].map(&:encode) ) - json['value'].map { |text_box| Mural::Widget::Text.decode(text_box) } + json['value'].map { |text_box| Mural::Widget.decode(text_box) } end # Update a textbox on a mural @@ -29,7 +29,7 @@ def update_text_box(mural_id, text_box_id, update_text_box_params) update_text_box_params.encode ) - Mural::Widget::Text.decode(json['value']) + Mural::Widget.decode(json['value']) end end end diff --git a/test/mural/client/mural_content/test_text_boxes.rb b/test/mural/client/mural_content/test_text_boxes.rb index eee25be..3b1fe05 100644 --- a/test/mural/client/mural_content/test_text_boxes.rb +++ b/test/mural/client/mural_content/test_text_boxes.rb @@ -48,6 +48,46 @@ def test_update_text_box_params assert_equal want, Mural::Widget::UpdateTextBoxParams.attrs.keys.sort end + def test_should_decode_content_edited_by + mural_id = 'mural-1' + + stub_request( + :post, + "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets/textbox" + ) + .with(body: [{ text: 'Hello world' }]) + .to_return_json( + body: { value: [ + { + id: 'text-box-1', + text: 'Hello world', + contentEditedBy: { id: 'user-1', firstName: 'John' }, + type: 'text' + } + ] }, + status: 201 + ) + + create_text_box_params = [ + Mural::Widget::CreateTextBoxParams.new.tap do |t| + t.text = 'Hello world' + end + ] + + text_boxes = @client.mural_content.create_text_boxes( + mural_id, + create_text_box_params + ) + + assert_equal 1, text_boxes.size + + text_box = text_boxes.first + + assert_instance_of Mural::Widget::Text, text_box + assert_equal 'Hello world', text_box.text + assert_equal 'John', text_box.content_edited_by.first_name + end + def test_create_text_boxes mural_id = 'mural-1' @@ -63,11 +103,12 @@ def test_create_text_boxes ) .to_return_json( body: { value: [ - { id: 'text-box-1', text: 'Hello world' }, + { id: 'text-box-1', text: 'Hello world', type: 'text' }, { id: 'text-box-2', text: 'Bonjour monde', - style: { backgroundColor: '#FAFAFAFF' } + style: { backgroundColor: '#FAFAFAFF' }, + type: 'text' } ] }, status: 201 @@ -116,7 +157,7 @@ def test_update_text_box ) .with(body: { text: 'Hola mundo' }) .to_return_json( - body: { value: { id: text_box_id, text: 'Hola mundo' } } + body: { value: { id: text_box_id, text: 'Hola mundo', type: 'text' } } ) update_text_box_params = Mural::Widget::UpdateTextBoxParams.new.tap do |t| @@ -144,7 +185,11 @@ def test_update_text_box_with_style .with(body: { style: { backgroundColor: '#FAFAFAFF' } }) .to_return_json( body: { - value: { id: text_box_id, style: { backgroundColor: '#FAFAFAFF' } } + value: { + id: text_box_id, + style: { backgroundColor: '#FAFAFAFF' }, + type: 'text' + } } ) From c22186db3dfb653a3bfffad36b5c7dc113b75832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Pham?= Date: Sat, 20 Sep 2025 19:12:21 +0200 Subject: [PATCH 19/19] fix: (title) widget common attributes should be decoded --- lib/mural/client/mural_content/titles.rb | 4 +- .../mural/client/mural_content/test_titles.rb | 50 +++++++++++++++++-- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/lib/mural/client/mural_content/titles.rb b/lib/mural/client/mural_content/titles.rb index 3af8ca1..19ec479 100644 --- a/lib/mural/client/mural_content/titles.rb +++ b/lib/mural/client/mural_content/titles.rb @@ -15,7 +15,7 @@ def create_titles(mural_id, create_title_params) [*create_title_params].map(&:encode) ) - json['value'].map { |title| Mural::Widget::Text.decode(title) } + json['value'].map { |title| Mural::Widget.decode(title) } end # Update a title on a mural @@ -29,7 +29,7 @@ def update_title(mural_id, title_id, update_title_params) update_title_params.encode ) - Mural::Widget::Text.decode(json['value']) + Mural::Widget.decode(json['value']) end end end diff --git a/test/mural/client/mural_content/test_titles.rb b/test/mural/client/mural_content/test_titles.rb index 7b22853..3a7f3f5 100644 --- a/test/mural/client/mural_content/test_titles.rb +++ b/test/mural/client/mural_content/test_titles.rb @@ -63,11 +63,12 @@ def test_create_titles ) .to_return_json( body: { value: [ - { id: 'title-1', text: 'Hello world' }, + { id: 'title-1', text: 'Hello world', type: 'text' }, { id: 'title-2', text: 'Bonjour monde', - style: { backgroundColor: '#FAFAFAFF' } + style: { backgroundColor: '#FAFAFAFF' }, + type: 'text' } ] }, status: 201 @@ -102,6 +103,43 @@ def test_create_titles assert_equal '#FAFAFAFF', title_with_style.style.background_color end + def test_should_decode_content_edited_by + mural_id = 'mural-1' + + stub_request( + :post, + "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets/title" + ) + .with(body: [{ text: 'Hello world' }]) + .to_return_json( + body: { + value: [ + { + id: 'title-1', + text: 'Hello world', + contentEditedBy: { id: 'user-1', firstName: 'John' }, + type: 'text' + } + ] + }, + status: 201 + ) + + create_title_params = + Mural::Widget::CreateTitleParams.new.tap do |t| + t.text = 'Hello world' + end + + titles = @client.mural_content.create_titles(mural_id, create_title_params) + + assert_equal 1, titles.size + + title = titles.first + + assert_instance_of Mural::Widget::Text, title + assert_equal 'John', title.content_edited_by.first_name + end + def test_update_title mural_id = 'mural-1' title_id = 'title-1' @@ -113,7 +151,7 @@ def test_update_title ) .with(body: { text: 'Hola mundo' }) .to_return_json( - body: { value: { id: title_id, text: 'Hola mundo' } } + body: { value: { id: title_id, text: 'Hola mundo', type: 'text' } } ) update_title_params = Mural::Widget::UpdateTitleParams.new.tap do |t| @@ -141,7 +179,11 @@ def test_update_title_with_style .with(body: { style: { backgroundColor: '#FAFAFAFF' } }) .to_return_json( body: { - value: { id: title_id, style: { backgroundColor: '#FAFAFAFF' } } + value: { + id: title_id, + style: { backgroundColor: '#FAFAFAFF' }, + type: 'text' + } } )