monday_ruby 0.6.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.env +1 -1
  3. data/.rspec +0 -1
  4. data/.rubocop.yml +18 -0
  5. data/.simplecov +1 -0
  6. data/CHANGELOG.md +55 -0
  7. data/CONTRIBUTING.md +61 -0
  8. data/README.md +97 -51
  9. data/lib/monday/client.rb +30 -12
  10. data/lib/monday/configuration.rb +8 -0
  11. data/lib/monday/deprecation.rb +23 -0
  12. data/lib/monday/error.rb +5 -2
  13. data/lib/monday/request.rb +4 -1
  14. data/lib/monday/resources/account.rb +6 -4
  15. data/lib/monday/resources/activity_log.rb +7 -5
  16. data/lib/monday/resources/base.rb +20 -0
  17. data/lib/monday/resources/board.rb +71 -17
  18. data/lib/monday/resources/board_view.rb +6 -4
  19. data/lib/monday/resources/column.rb +28 -20
  20. data/lib/monday/resources/folder.rb +55 -0
  21. data/lib/monday/resources/group.rb +84 -16
  22. data/lib/monday/resources/item.rb +77 -13
  23. data/lib/monday/resources/subitem.rb +8 -6
  24. data/lib/monday/resources/update.rb +13 -11
  25. data/lib/monday/resources/workspace.rb +10 -8
  26. data/lib/monday/resources.rb +16 -20
  27. data/lib/monday/util.rb +33 -1
  28. data/lib/monday/version.rb +1 -1
  29. data/lib/monday_ruby.rb +1 -0
  30. metadata +22 -48
  31. data/docs/README.md +0 -13
  32. data/docs/SUMMARY.md +0 -40
  33. data/docs/client.md +0 -15
  34. data/docs/configuration.md +0 -40
  35. data/docs/error-handling.md +0 -71
  36. data/docs/getting-started.md +0 -25
  37. data/docs/quick-start.md +0 -269
  38. data/docs/resources/README.md +0 -27
  39. data/docs/resources/account/README.md +0 -9
  40. data/docs/resources/account/accounts.md +0 -82
  41. data/docs/resources/activity-log/README.md +0 -9
  42. data/docs/resources/activity-log/activity_logs.md +0 -95
  43. data/docs/resources/board/README.md +0 -21
  44. data/docs/resources/board/archive_board.md +0 -79
  45. data/docs/resources/board/boards.md +0 -96
  46. data/docs/resources/board/create_board.md +0 -95
  47. data/docs/resources/board/delete_board.md +0 -79
  48. data/docs/resources/board/delete_board_subscribers.md +0 -87
  49. data/docs/resources/board/duplicate_board.md +0 -94
  50. data/docs/resources/board/update_board.md +0 -91
  51. data/docs/resources/board-view/README.md +0 -9
  52. data/docs/resources/board-view/board_views.md +0 -88
  53. data/docs/resources/column/README.md +0 -25
  54. data/docs/resources/column/change_column_metadata.md +0 -70
  55. data/docs/resources/column/change_column_title.md +0 -68
  56. data/docs/resources/column/change_column_value.md +0 -73
  57. data/docs/resources/column/change_multiple_column_value.md +0 -81
  58. data/docs/resources/column/change_simple_column_value.md +0 -69
  59. data/docs/resources/column/column_values.md +0 -115
  60. data/docs/resources/column/columns.md +0 -117
  61. data/docs/resources/column/create_column.md +0 -70
  62. data/docs/resources/column/delete_column.md +0 -58
  63. data/docs/resources/item/README.md +0 -17
  64. data/docs/resources/item/archive_item.md +0 -80
  65. data/docs/resources/item/create_item.md +0 -105
  66. data/docs/resources/item/delete_item.md +0 -80
  67. data/docs/resources/item/duplicate_item.md +0 -87
  68. data/docs/resources/item/items.md +0 -95
  69. data/docs/response.md +0 -21
  70. data/monday_ruby.gemspec +0 -37
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Monday
4
+ module Resources
5
+ # Base class for all resources.
6
+ class Base
7
+ attr_reader :client
8
+
9
+ def initialize(client)
10
+ @client = client
11
+ end
12
+
13
+ protected
14
+
15
+ def make_request(query)
16
+ client.make_request(query)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,20 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "base"
4
+
3
5
  module Monday
4
6
  module Resources
5
7
  # Represents Monday.com's board resource.
6
- module Board
8
+ class Board < Base
7
9
  DEFAULT_SELECT = %w[id name description].freeze
10
+ DEFAULT_PAGINATED_SELECT = %w[id name].freeze
8
11
 
9
12
  # Retrieves all the boards.
10
13
  #
11
14
  # Allows filtering boards using the args option.
12
15
  # Allows customizing the values to retrieve using the select option.
13
16
  # By default, ID, name and description fields are retrieved.
14
- def boards(args: {}, select: DEFAULT_SELECT)
15
- query = "query { boards#{Util.format_args(args)} {#{Util.format_select(select)}}}"
17
+ def query(args: {}, select: DEFAULT_SELECT)
18
+ request_query = "query{boards#{Util.format_args(args)}{#{Util.format_select(select)}}}"
16
19
 
17
- make_request(query)
20
+ make_request(request_query)
18
21
  end
19
22
 
20
23
  # Creates a new boards.
@@ -22,8 +25,8 @@ module Monday
22
25
  # Allows customizing creating a board using the args option.
23
26
  # Allows customizing the values to retrieve using the select option.
24
27
  # By default, ID, name and description fields are retrieved.
25
- def create_board(args: {}, select: DEFAULT_SELECT)
26
- query = "mutation { create_board#{Util.format_args(args)} {#{Util.format_select(select)}}}"
28
+ def create(args: {}, select: DEFAULT_SELECT)
29
+ query = "mutation{create_board#{Util.format_args(args)}{#{Util.format_select(select)}}}"
27
30
 
28
31
  make_request(query)
29
32
  end
@@ -33,8 +36,8 @@ module Monday
33
36
  # Allows customizing duplicating the board using the args option.
34
37
  # Allows customizing the values to retrieve using the select option.
35
38
  # By default, ID, name and description fields are retrieved.
36
- def duplicate_board(args: {}, select: DEFAULT_SELECT)
37
- query = "mutation { duplicate_board#{Util.format_args(args)} { board {#{Util.format_select(select)}}}}"
39
+ def duplicate(args: {}, select: DEFAULT_SELECT)
40
+ query = "mutation{duplicate_board#{Util.format_args(args)}{board{#{Util.format_select(select)}}}}"
38
41
 
39
42
  make_request(query)
40
43
  end
@@ -43,8 +46,8 @@ module Monday
43
46
  #
44
47
  # Allows customizing updating the board using the args option.
45
48
  # Returns the ID of the updated board.
46
- def update_board(args: {})
47
- query = "mutation { update_board#{Util.format_args(args)}}"
49
+ def update(args: {})
50
+ query = "mutation{update_board#{Util.format_args(args)}}"
48
51
 
49
52
  make_request(query)
50
53
  end
@@ -54,8 +57,8 @@ module Monday
54
57
  # Requires board_id to archive board.
55
58
  # Allows customizing the values to retrieve using the select option.
56
59
  # By default, returns the ID of the board archived.
57
- def archive_board(board_id, select: ["id"])
58
- query = "mutation { archive_board(board_id: #{board_id}) {#{Util.format_select(select)}}}"
60
+ def archive(board_id, select: ["id"])
61
+ query = "mutation{archive_board(board_id: #{board_id}){#{Util.format_select(select)}}}"
59
62
 
60
63
  make_request(query)
61
64
  end
@@ -65,8 +68,8 @@ module Monday
65
68
  # Requires board_id to delete the board.
66
69
  # Allows customizing the values to retrieve using the select option.
67
70
  # By default, returns the ID of the board deleted.
68
- def delete_board(board_id, select: ["id"])
69
- query = "mutation { delete_board(board_id: #{board_id}) {#{Util.format_select(select)}}}"
71
+ def delete(board_id, select: ["id"])
72
+ query = "mutation{delete_board(board_id: #{board_id}){#{Util.format_select(select)}}}"
70
73
 
71
74
  make_request(query)
72
75
  end
@@ -76,12 +79,63 @@ module Monday
76
79
  # Requires board_id and user_ids to delete subscribers.
77
80
  # Allows customizing the values to retrieve using the select option.
78
81
  # By default, returns the deleted subscriber IDs.
79
- def delete_board_subscribers(board_id, user_ids, select: ["id"])
80
- query = "mutation { delete_subscribers_from_board(" \
81
- "board_id: #{board_id}, user_ids: #{user_ids}) {#{Util.format_select(select)}}}"
82
+ def delete_subscribers(board_id, user_ids, select: ["id"])
83
+ Deprecation.warn(
84
+ method_name: "delete_subscribers",
85
+ removal_version: "2.0.0",
86
+ alternative: "user.delete_from_board"
87
+ )
88
+
89
+ query = "mutation{delete_subscribers_from_board(" \
90
+ "board_id: #{board_id}, user_ids: #{user_ids}){#{Util.format_select(select)}}}"
82
91
 
83
92
  make_request(query)
84
93
  end
94
+
95
+ # Retrieves paginated items from a board.
96
+ #
97
+ # Uses cursor-based pagination for efficient data retrieval.
98
+ # The items_page field is the modern replacement for the deprecated items field.
99
+ #
100
+ # @param board_id [Integer] The ID of the board
101
+ # @param limit [Integer] Number of items to retrieve per page (default: 25, max: 500)
102
+ # @param cursor [String, nil] Pagination cursor for fetching next page (expires after 60 minutes)
103
+ # @param query_params [Hash, nil] Query parameters for filtering items with rules and operators
104
+ # @param args [Hash] Additional board query arguments
105
+ # @param select [Array] Fields to retrieve for each item
106
+ # @return [Monday::Response] Response containing items and cursor
107
+ #
108
+ # @example Fetch first page of items
109
+ # response = client.board.items_page(board_id: 123, limit: 50)
110
+ # items = response.dig("data", "boards", 0, "items_page", "items")
111
+ # cursor = response.dig("data", "boards", 0, "items_page", "cursor")
112
+ #
113
+ # @example Fetch next page using cursor
114
+ # response = client.board.items_page(board_id: 123, cursor: cursor)
115
+ #
116
+ # @example Filter items by column value
117
+ # response = client.board.items_page(
118
+ # board_id: 123,
119
+ # limit: 100,
120
+ # query_params: {
121
+ # rules: [{ column_id: "status", compare_value: [1] }],
122
+ # operator: :and
123
+ # }
124
+ # )
125
+ def items_page(board_ids:, limit: 25, cursor: nil, query_params: nil, select: DEFAULT_PAGINATED_SELECT)
126
+ items_args_parts = ["limit: #{limit}"]
127
+ items_args_parts << "cursor: \"#{cursor}\"" if cursor
128
+ items_args_parts << "query_params: #{Util.format_graphql_object(query_params)}" if query_params
129
+
130
+ items_args_string = items_args_parts.empty? ? "" : "(#{items_args_parts.join(", ")})"
131
+
132
+ items_page_select = "items_page#{items_args_string}{cursor items{#{Util.format_select(select)}}}"
133
+
134
+ board_args = { ids: board_ids.is_a?(Array) ? board_ids : [board_ids] }
135
+ request_query = "query{boards#{Util.format_args(board_args)}{#{items_page_select}}}"
136
+
137
+ make_request(request_query)
138
+ end
85
139
  end
86
140
  end
87
141
  end
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "base"
4
+
3
5
  module Monday
4
6
  module Resources
5
7
  # Represents Monday.com's board view resource.
6
- module BoardView
8
+ class BoardView < Base
7
9
  DEFAULT_SELECT = %w[id name type].freeze
8
10
 
9
11
  # Retrieves board views from a specific board.
@@ -11,10 +13,10 @@ module Monday
11
13
  # Allows filtering views using the args option.
12
14
  # Allows customizing the values to retrieve using the select option.
13
15
  # By default, ID, name and type fields are retrieved.
14
- def board_views(args: {}, select: DEFAULT_SELECT)
15
- query = "query { boards#{Util.format_args(args)} { views {#{Util.format_select(select)}}}}"
16
+ def query(args: {}, select: DEFAULT_SELECT)
17
+ request_query = "query{boards#{Util.format_args(args)}{views{#{Util.format_select(select)}}}}"
16
18
 
17
- make_request(query)
19
+ make_request(request_query)
18
20
  end
19
21
  end
20
22
  end
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "base"
4
+
3
5
  module Monday
4
6
  module Resources
5
7
  # Represents Monday.com's column resource.
6
- module Column
8
+ class Column < Base
7
9
  DEFAULT_SELECT = %w[id title description].freeze
8
10
 
9
11
  # Retrieves all the columns for the boards.
@@ -11,10 +13,10 @@ module Monday
11
13
  # Allows filtering columns using the args option.
12
14
  # Allows customizing the values to retrieve using the select option.
13
15
  # By default, ID, title and description fields are retrieved.
14
- def columns(args: {}, select: DEFAULT_SELECT)
15
- query = "query { boards#{Util.format_args(args)} { columns {#{Util.format_select(select)}}}}"
16
+ def query(args: {}, select: DEFAULT_SELECT)
17
+ request_query = "query{boards#{Util.format_args(args)}{columns{#{Util.format_select(select)}}}}"
16
18
 
17
- make_request(query)
19
+ make_request(request_query)
18
20
  end
19
21
 
20
22
  # Retrieves metadata about one or a collection of columns.
@@ -23,10 +25,16 @@ module Monday
23
25
  # Allows customizing the values to retrieve using the select option.
24
26
  # By default, ID, title and description fields are retrieved.
25
27
  def column_values(board_ids = [], item_ids = [], select: DEFAULT_SELECT)
28
+ Deprecation.warn(
29
+ method_name: "column_values",
30
+ removal_version: "2.0.0",
31
+ alternative: "item.column_values"
32
+ )
33
+
26
34
  board_args = board_ids.empty? ? "" : "ids: #{board_ids}"
27
35
  item_args = item_ids.empty? ? "" : "ids: #{item_ids}"
28
- query = "query { boards (#{board_args}) { items (#{item_args}) " \
29
- "{ column_values {#{Util.format_select(select)}}}}}"
36
+ query = "query{boards(#{board_args}){items(#{item_args})" \
37
+ "{column_values{#{Util.format_select(select)}}}}}"
30
38
 
31
39
  make_request(query)
32
40
  end
@@ -36,8 +44,8 @@ module Monday
36
44
  # Allows customizing the column creation using the args option.
37
45
  # Allows customizing the values to retrieve using the select option.
38
46
  # By default, ID, title and description fields are retrieved.
39
- def create_column(args: {}, select: DEFAULT_SELECT)
40
- query = "mutation { create_column#{Util.format_args(args)} {#{Util.format_select(select)}}}"
47
+ def create(args: {}, select: DEFAULT_SELECT)
48
+ query = "mutation{create_column#{Util.format_args(args)}{#{Util.format_select(select)}}}"
41
49
 
42
50
  make_request(query)
43
51
  end
@@ -47,8 +55,8 @@ module Monday
47
55
  # Allows customizing the update using the args option.
48
56
  # Allows customizing the values to retrieve using the select option.
49
57
  # By default, ID, title and description fields are retrieved.
50
- def change_column_title(args: {}, select: DEFAULT_SELECT)
51
- query = "mutation { change_column_title#{Util.format_args(args)} {#{Util.format_select(select)}}}"
58
+ def change_title(args: {}, select: DEFAULT_SELECT)
59
+ query = "mutation{change_column_title#{Util.format_args(args)}{#{Util.format_select(select)}}}"
52
60
 
53
61
  make_request(query)
54
62
  end
@@ -58,8 +66,8 @@ module Monday
58
66
  # Allows customizing the update using the args option.
59
67
  # Allows customizing the values to retrieve using the select option.
60
68
  # By default, ID, title and description fields are retrieved.
61
- def change_column_metadata(args: {}, select: DEFAULT_SELECT)
62
- query = "mutation { change_column_metadata#{Util.format_args(args)} {#{Util.format_select(select)}}}"
69
+ def change_metadata(args: {}, select: DEFAULT_SELECT)
70
+ query = "mutation{change_column_metadata#{Util.format_args(args)}{#{Util.format_select(select)}}}"
63
71
 
64
72
  make_request(query)
65
73
  end
@@ -69,8 +77,8 @@ module Monday
69
77
  # Allows customizing the update using the args option.
70
78
  # Allows customizing the item values to retrieve using the select option.
71
79
  # By default, ID, and name fields are retrieved.
72
- def change_column_value(args: {}, select: %w[id name])
73
- query = "mutation { change_column_value#{Util.format_args(args)} {#{Util.format_select(select)}}}"
80
+ def change_value(args: {}, select: %w[id name])
81
+ query = "mutation{change_column_value#{Util.format_args(args)}{#{Util.format_select(select)}}}"
74
82
 
75
83
  make_request(query)
76
84
  end
@@ -80,8 +88,8 @@ module Monday
80
88
  # Allows customizing the update using the args option.
81
89
  # Allows customizing the item values to retrieve using the select option.
82
90
  # By default, ID, and name fields are retrieved.
83
- def change_simple_column_value(args: {}, select: %w[id name])
84
- query = "mutation { change_simple_column_value#{Util.format_args(args)} {#{Util.format_select(select)}}}"
91
+ def change_simple_value(args: {}, select: %w[id name])
92
+ query = "mutation{change_simple_column_value#{Util.format_args(args)}{#{Util.format_select(select)}}}"
85
93
 
86
94
  make_request(query)
87
95
  end
@@ -91,8 +99,8 @@ module Monday
91
99
  # Allows customizing the update using the args option.
92
100
  # Allows customizing the item values to retrieve using the select option.
93
101
  # By default, ID, and name fields are retrieved.
94
- def change_multiple_column_value(args: {}, select: %w[id name])
95
- query = "mutation { change_multiple_column_values#{Util.format_args(args)} {#{Util.format_select(select)}}}"
102
+ def change_multiple_values(args: {}, select: %w[id name])
103
+ query = "mutation{change_multiple_column_values#{Util.format_args(args)}{#{Util.format_select(select)}}}"
96
104
 
97
105
  make_request(query)
98
106
  end
@@ -102,8 +110,8 @@ module Monday
102
110
  # Requires board_id and column_id to delete.
103
111
  # Allows customizing the values to retrieve using the select option.
104
112
  # By default, ID is retrieved.
105
- def delete_column(board_id, column_id, select: %w[id])
106
- query = "mutation { delete_column(board_id: #{board_id}, column_id: #{column_id}) " \
113
+ def delete(board_id, column_id, select: %w[id])
114
+ query = "mutation{delete_column(board_id: #{board_id}, column_id: \"#{column_id}\")" \
107
115
  "{#{Util.format_select(select)}}}"
108
116
 
109
117
  make_request(query)
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module Monday
6
+ module Resources
7
+ # Represents Monday.com's board resource.
8
+ class Folder < Base
9
+ DEFAULT_SELECT = %w[id name].freeze
10
+
11
+ # Retrieves all the folders.
12
+ #
13
+ # Allows filtering folders using the args option.
14
+ # Allows customizing the values to retrieve using the select option.
15
+ # By default, ID and name fields are retrieved.
16
+ def query(args: {}, select: DEFAULT_SELECT)
17
+ request_query = "query{folders#{Util.format_args(args)}{#{Util.format_select(select)}}}"
18
+
19
+ make_request(request_query)
20
+ end
21
+
22
+ # Create a new folder.
23
+ #
24
+ # Allows customizing creating a folder using the args option.
25
+ # Allows customizing the values to retrieve using the select option.
26
+ # By default, ID and name fields are retrieved.
27
+ def create(args: {}, select: DEFAULT_SELECT)
28
+ query = "mutation{create_folder#{Util.format_args(args)}{#{Util.format_select(select)}}}"
29
+
30
+ make_request(query)
31
+ end
32
+
33
+ # Update a folder.
34
+ #
35
+ # Allows customizing updating the folder using the args option.
36
+ # By default, returns the ID of the updated folder.
37
+ def update(args: {}, select: ["id"])
38
+ query = "mutation{update_folder#{Util.format_args(args)}{#{Util.format_select(select)}}}"
39
+
40
+ make_request(query)
41
+ end
42
+
43
+ # Delete a folder.
44
+ #
45
+ # Requires folder_id in args option to delete the folder.
46
+ # Allows customizing the values to retrieve using the select option.
47
+ # By default, returns the ID of the folder deleted.
48
+ def delete(args: {}, select: ["id"])
49
+ query = "mutation{delete_folder#{Util.format_args(args)}{#{Util.format_select(select)}}}"
50
+
51
+ make_request(query)
52
+ end
53
+ end
54
+ end
55
+ end
@@ -1,20 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "base"
4
+
3
5
  module Monday
4
6
  module Resources
5
7
  # Represents Monday.com's group resource.
6
- module Group
8
+ class Group < Base
7
9
  DEFAULT_SELECT = %w[id title].freeze
10
+ DEFAULT_PAGINATED_SELECT = %w[id name].freeze
8
11
 
9
12
  # Retrieves all the groups.
10
13
  #
11
14
  # Allows filtering groups using the args option.
12
15
  # Allows customizing the values to retrieve using the select option.
13
16
  # By default, ID and title fields are retrieved.
14
- def groups(args: {}, select: DEFAULT_SELECT)
15
- query = "query { boards#{Util.format_args(args)} { groups{#{Util.format_select(select)}}}}"
17
+ def query(args: {}, select: DEFAULT_SELECT)
18
+ request_query = "query{boards#{Util.format_args(args)}{groups{#{Util.format_select(select)}}}}"
16
19
 
17
- make_request(query)
20
+ make_request(request_query)
18
21
  end
19
22
 
20
23
  # Creates a new group.
@@ -22,8 +25,8 @@ module Monday
22
25
  # Allows customizing creating a group using the args option.
23
26
  # Allows customizing the values to retrieve using the select option.
24
27
  # By default, ID and title fields are retrieved.
25
- def create_group(args: {}, select: DEFAULT_SELECT)
26
- query = "mutation { create_group#{Util.format_args(args)} {#{Util.format_select(select)}}}"
28
+ def create(args: {}, select: DEFAULT_SELECT)
29
+ query = "mutation{create_group#{Util.format_args(args)}{#{Util.format_select(select)}}}"
27
30
 
28
31
  make_request(query)
29
32
  end
@@ -32,8 +35,8 @@ module Monday
32
35
  #
33
36
  # Allows customizing updating the group using the args option.
34
37
  # By default, returns the ID of the updated group.
35
- def update_group(args: {}, select: ["id"])
36
- query = "mutation { update_group#{Util.format_args(args)} {#{Util.format_select(select)}}}"
38
+ def update(args: {}, select: ["id"])
39
+ query = "mutation{update_group#{Util.format_args(args)}{#{Util.format_select(select)}}}"
37
40
 
38
41
  make_request(query)
39
42
  end
@@ -43,8 +46,8 @@ module Monday
43
46
  # Requires board_id and group_id in args option to delete the group.
44
47
  # Allows customizing the values to retrieve using the select option.
45
48
  # By default, returns the ID of the group deleted.
46
- def delete_group(args: {}, select: ["id"])
47
- query = "mutation { delete_group#{Util.format_args(args)} {#{Util.format_select(select)}}}"
49
+ def delete(args: {}, select: ["id"])
50
+ query = "mutation{delete_group#{Util.format_args(args)}{#{Util.format_select(select)}}}"
48
51
 
49
52
  make_request(query)
50
53
  end
@@ -54,8 +57,8 @@ module Monday
54
57
  # Requires board_id and group_id in args option to archive the group.
55
58
  # Allows customizing the values to retrieve using the select option.
56
59
  # By default, returns the ID of the group archived.
57
- def archive_group(args: {}, select: ["id"])
58
- query = "mutation { archive_group#{Util.format_args(args)} {#{Util.format_select(select)}}}"
60
+ def archive(args: {}, select: ["id"])
61
+ query = "mutation{archive_group#{Util.format_args(args)}{#{Util.format_select(select)}}}"
59
62
 
60
63
  make_request(query)
61
64
  end
@@ -65,8 +68,8 @@ module Monday
65
68
  # Requires board_id and group_id in args option to duplicate the group.
66
69
  # Allows customizing the values to retrieve using the select option.
67
70
  # By default, ID and title fields are retrieved.
68
- def duplicate_group(args: {}, select: DEFAULT_SELECT)
69
- query = "mutation { duplicate_group#{Util.format_args(args)} {#{Util.format_select(select)}}}"
71
+ def duplicate(args: {}, select: DEFAULT_SELECT)
72
+ query = "mutation{duplicate_group#{Util.format_args(args)}{#{Util.format_select(select)}}}"
70
73
 
71
74
  make_request(query)
72
75
  end
@@ -76,11 +79,76 @@ module Monday
76
79
  # Requires item_id and group_id in args option to move an item to a group.
77
80
  # Allows customizing the values to retrieve using the select option.
78
81
  # By default, ID and title fields are retrieved.
79
- def move_item_to_group(args: {}, select: ["id"])
80
- query = "mutation { move_item_to_group#{Util.format_args(args)} {#{Util.format_select(select)}}}"
82
+ def move_item(args: {}, select: ["id"])
83
+ query = "mutation{move_item_to_group#{Util.format_args(args)}{#{Util.format_select(select)}}}"
81
84
 
82
85
  make_request(query)
83
86
  end
87
+
88
+ # Retrieves paginated items from a group.
89
+ #
90
+ # Uses cursor-based pagination for efficient data retrieval.
91
+ # The items_page field is the modern replacement for the deprecated items field.
92
+ #
93
+ # @param board_ids [Integer, Array<Integer>] The ID(s) of the board(s) containing the group
94
+ # @param group_ids [String, Array<String>] The ID(s) of the group(s)
95
+ # @param limit [Integer] Number of items to retrieve per page (default: 25, max: 500)
96
+ # @param cursor [String, nil] Pagination cursor for fetching next page (expires after 60 minutes)
97
+ # @param query_params [Hash, nil] Query parameters for filtering items with rules and operators
98
+ # @param select [Array] Fields to retrieve for each item
99
+ # @return [Monday::Response] Response containing items and cursor
100
+ #
101
+ # @example Fetch first page of items from a group
102
+ # response = client.group.items_page(board_ids: 123, group_ids: "group_1", limit: 50)
103
+ # items = response.dig("data", "boards", 0, "groups", 0, "items_page", "items")
104
+ # cursor = response.dig("data", "boards", 0, "groups", 0, "items_page", "cursor")
105
+ #
106
+ # @example Fetch next page using cursor
107
+ # response = client.group.items_page(board_ids: 123, group_ids: "group_1", cursor: cursor)
108
+ #
109
+ # @example Filter items by column value
110
+ # response = client.group.items_page(
111
+ # board_ids: 123,
112
+ # group_ids: "group_1",
113
+ # limit: 100,
114
+ # query_params: {
115
+ # rules: [{ column_id: "status", compare_value: [1] }],
116
+ # operator: :and
117
+ # }
118
+ # )
119
+ def items_page(
120
+ board_ids:, group_ids:, limit: 25, cursor: nil, query_params: nil, select: DEFAULT_PAGINATED_SELECT
121
+ )
122
+ items_page_query = build_items_page_query(limit, cursor, query_params, select)
123
+ request_query = build_groups_items_page_request(board_ids, group_ids, items_page_query)
124
+
125
+ make_request(request_query)
126
+ end
127
+
128
+ private
129
+
130
+ def build_items_page_query(limit, cursor, query_params, select)
131
+ args_parts = ["limit: #{limit}"]
132
+ args_parts << "cursor: \"#{cursor}\"" if cursor
133
+ args_parts << "query_params: #{Util.format_graphql_object(query_params)}" if query_params
134
+
135
+ args_string = "(#{args_parts.join(", ")})"
136
+ "items_page#{args_string}{cursor items{#{Util.format_select(select)}}}"
137
+ end
138
+
139
+ def build_groups_items_page_request(board_ids, group_ids, items_page_query)
140
+ board_args = { ids: board_ids.is_a?(Array) ? board_ids : [board_ids] }
141
+ group_ids_formatted = format_group_ids(group_ids)
142
+
143
+ boards_part = "boards#{Util.format_args(board_args)}"
144
+ groups_part = "groups(ids: #{group_ids_formatted})"
145
+ "query{#{boards_part}{#{groups_part}{#{items_page_query}}}}"
146
+ end
147
+
148
+ def format_group_ids(group_ids)
149
+ ids_array = group_ids.is_a?(Array) ? group_ids : [group_ids]
150
+ "[#{ids_array.map { |id| "\"#{id}\"" }.join(", ")}]"
151
+ end
84
152
  end
85
153
  end
86
154
  end
@@ -1,20 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "base"
4
+
3
5
  module Monday
4
6
  module Resources
5
7
  # Represents Monday.com's item resource.
6
- module Item
8
+ class Item < Base
7
9
  DEFAULT_SELECT = %w[id name created_at].freeze
10
+ DEFAULT_PAGINATED_SELECT = %w[id name].freeze
8
11
 
9
12
  # Retrieves all the items for the boards.
10
13
  #
11
14
  # Allows filtering items using the args option.
12
15
  # Allows customizing the values to retrieve using the select option.
13
16
  # By default, ID, name and created_at fields are retrieved.
14
- def items(args: {}, select: DEFAULT_SELECT)
15
- query = "query { items#{Util.format_args(args)} {#{Util.format_select(select)}}}"
17
+ def query(args: {}, select: DEFAULT_SELECT)
18
+ request_query = "query{items#{Util.format_args(args)}{#{Util.format_select(select)}}}"
16
19
 
17
- make_request(query)
20
+ make_request(request_query)
18
21
  end
19
22
 
20
23
  # Creates a new item.
@@ -22,8 +25,8 @@ module Monday
22
25
  # Allows customizing the item creation using the args option.
23
26
  # Allows customizing the values to retrieve using the select option.
24
27
  # By default, ID, name and created_at fields are retrieved.
25
- def create_item(args: {}, select: DEFAULT_SELECT)
26
- query = "mutation { create_item#{Util.format_args(args)} {#{Util.format_select(select)}}}"
28
+ def create(args: {}, select: DEFAULT_SELECT)
29
+ query = "mutation{create_item#{Util.format_args(args)}{#{Util.format_select(select)}}}"
27
30
 
28
31
  make_request(query)
29
32
  end
@@ -33,9 +36,9 @@ module Monday
33
36
  # Allows customizing the item creation using the args option.
34
37
  # Allows customizing the values to retrieve using the select option.
35
38
  # By default, ID, name and created_at fields are retrieved.
36
- def duplicate_item(board_id, item_id, with_updates, select: DEFAULT_SELECT)
37
- query = "mutation { duplicate_item(board_id: #{board_id}, item_id: #{item_id}, " \
38
- "with_updates: #{with_updates}) {#{Util.format_select(select)}}}"
39
+ def duplicate(board_id, item_id, with_updates, select: DEFAULT_SELECT)
40
+ query = "mutation{duplicate_item(board_id: #{board_id}, item_id: #{item_id}, " \
41
+ "with_updates: #{with_updates}){#{Util.format_select(select)}}}"
39
42
 
40
43
  make_request(query)
41
44
  end
@@ -45,8 +48,8 @@ module Monday
45
48
  # Requires item_id to archive item.
46
49
  # Allows customizing the values to retrieve using the select option.
47
50
  # By default, returns the ID of the archived item.
48
- def archive_item(item_id, select: %w[id])
49
- query = "mutation { archive_item(item_id: #{item_id}) {#{Util.format_select(select)}}}"
51
+ def archive(item_id, select: %w[id])
52
+ query = "mutation{archive_item(item_id: #{item_id}){#{Util.format_select(select)}}}"
50
53
 
51
54
  make_request(query)
52
55
  end
@@ -56,11 +59,72 @@ module Monday
56
59
  # Requires item_id to delete item.
57
60
  # Allows customizing the values to retrieve using the select option.
58
61
  # By default, returns the ID of the deleted item.
59
- def delete_item(item_id, select: %w[id])
60
- query = "mutation { delete_item(item_id: #{item_id}) {#{Util.format_select(select)}}}"
62
+ def delete(item_id, select: %w[id])
63
+ query = "mutation{delete_item(item_id: #{item_id}){#{Util.format_select(select)}}}"
61
64
 
62
65
  make_request(query)
63
66
  end
67
+
68
+ # Retrieves paginated items filtered by column values.
69
+ #
70
+ # Enables searching for items based on specific column values.
71
+ # Uses cursor-based pagination for efficient data retrieval.
72
+ #
73
+ # @param board_id [Integer] The ID of the board
74
+ # @param columns [Array<Hash>, nil] Column filtering criteria (mutually exclusive with cursor)
75
+ # Each hash should contain :column_id and :column_values
76
+ # @param limit [Integer] Number of items to retrieve per page (default: 25, max: 500)
77
+ # @param cursor [String, nil] Pagination cursor for fetching next page (mutually exclusive with columns)
78
+ # @param select [Array] Fields to retrieve for each item
79
+ # @return [Monday::Response] Response containing items and cursor
80
+ #
81
+ # @example Search items by column values
82
+ # response = client.item.page_by_column_values(
83
+ # board_id: 123,
84
+ # columns: [
85
+ # { column_id: "status", column_values: ["Done", "Working on it"] },
86
+ # { column_id: "text", column_values: ["High Priority"] }
87
+ # ],
88
+ # limit: 50
89
+ # )
90
+ # items = response.dig("data", "items_page_by_column_values", "items")
91
+ # cursor = response.dig("data", "items_page_by_column_values", "cursor")
92
+ #
93
+ # @example Fetch next page using cursor
94
+ # response = client.item.page_by_column_values(
95
+ # board_id: 123,
96
+ # cursor: cursor
97
+ # )
98
+ #
99
+ # @note Supported column types: Checkbox, Country, Date, Dropdown, Email, Hour, Link,
100
+ # Long Text, Numbers, People, Phone, Status, Text, Timeline, World Clock
101
+ # @note Columns use AND logic; values within a column use ANY_OF logic
102
+ def page_by_column_values(board_id:, columns: nil, limit: 25, cursor: nil, select: DEFAULT_PAGINATED_SELECT)
103
+ query_string = build_items_page_by_column_values_query(board_id, columns, limit, cursor, select)
104
+ make_request(query_string)
105
+ end
106
+
107
+ private
108
+
109
+ def build_items_page_by_column_values_query(board_id, columns, limit, cursor, select)
110
+ args_parts = ["board_id: #{board_id}", "limit: #{limit}"]
111
+ args_parts << "cursor: \"#{cursor}\"" if cursor
112
+ args_parts << "columns: #{format_columns(columns)}" if columns
113
+
114
+ args_string = "(#{args_parts.join(", ")})"
115
+ "query{items_page_by_column_values#{args_string}{cursor items{#{Util.format_select(select)}}}}"
116
+ end
117
+
118
+ def format_columns(columns)
119
+ return nil unless columns
120
+
121
+ column_strings = columns.map do |col|
122
+ values = col[:column_values].map { |v| "\"#{v}\"" }.join(", ")
123
+ "{column_id: \"#{col[:column_id]}\", column_values: [#{values}]}"
124
+ end
125
+
126
+ "[#{column_strings.join(", ")}]"
127
+ end
64
128
  end
65
129
  end
66
130
  end