monday_ruby 1.1.0 → 1.2.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 (82) hide show
  1. checksums.yaml +4 -4
  2. data/.env +1 -1
  3. data/.rubocop.yml +2 -1
  4. data/CHANGELOG.md +14 -0
  5. data/CONTRIBUTING.md +104 -0
  6. data/README.md +146 -142
  7. data/docs/.vitepress/config.mjs +255 -0
  8. data/docs/.vitepress/theme/index.js +4 -0
  9. data/docs/.vitepress/theme/style.css +43 -0
  10. data/docs/README.md +80 -0
  11. data/docs/explanation/architecture.md +507 -0
  12. data/docs/explanation/best-practices/errors.md +478 -0
  13. data/docs/explanation/best-practices/performance.md +1084 -0
  14. data/docs/explanation/best-practices/rate-limiting.md +630 -0
  15. data/docs/explanation/best-practices/testing.md +820 -0
  16. data/docs/explanation/column-values.md +857 -0
  17. data/docs/explanation/design.md +795 -0
  18. data/docs/explanation/graphql.md +356 -0
  19. data/docs/explanation/migration/v1.md +808 -0
  20. data/docs/explanation/pagination.md +447 -0
  21. data/docs/guides/advanced/batch.md +1274 -0
  22. data/docs/guides/advanced/complex-queries.md +1114 -0
  23. data/docs/guides/advanced/errors.md +818 -0
  24. data/docs/guides/advanced/pagination.md +934 -0
  25. data/docs/guides/advanced/rate-limiting.md +981 -0
  26. data/docs/guides/authentication.md +286 -0
  27. data/docs/guides/boards/create.md +386 -0
  28. data/docs/guides/boards/delete.md +405 -0
  29. data/docs/guides/boards/duplicate.md +511 -0
  30. data/docs/guides/boards/query.md +530 -0
  31. data/docs/guides/boards/update.md +453 -0
  32. data/docs/guides/columns/create.md +452 -0
  33. data/docs/guides/columns/metadata.md +492 -0
  34. data/docs/guides/columns/query.md +455 -0
  35. data/docs/guides/columns/update-multiple.md +459 -0
  36. data/docs/guides/columns/update-values.md +509 -0
  37. data/docs/guides/files/add-to-column.md +40 -0
  38. data/docs/guides/files/add-to-update.md +37 -0
  39. data/docs/guides/files/clear-column.md +33 -0
  40. data/docs/guides/first-request.md +285 -0
  41. data/docs/guides/folders/manage.md +750 -0
  42. data/docs/guides/groups/items.md +626 -0
  43. data/docs/guides/groups/manage.md +501 -0
  44. data/docs/guides/installation.md +169 -0
  45. data/docs/guides/items/create.md +493 -0
  46. data/docs/guides/items/delete.md +514 -0
  47. data/docs/guides/items/query.md +605 -0
  48. data/docs/guides/items/subitems.md +483 -0
  49. data/docs/guides/items/update.md +699 -0
  50. data/docs/guides/updates/manage.md +619 -0
  51. data/docs/guides/use-cases/dashboard.md +1421 -0
  52. data/docs/guides/use-cases/import.md +1962 -0
  53. data/docs/guides/use-cases/task-management.md +1381 -0
  54. data/docs/guides/workspaces/manage.md +502 -0
  55. data/docs/index.md +69 -0
  56. data/docs/package-lock.json +2468 -0
  57. data/docs/package.json +13 -0
  58. data/docs/reference/client.md +540 -0
  59. data/docs/reference/configuration.md +586 -0
  60. data/docs/reference/errors.md +693 -0
  61. data/docs/reference/resources/account.md +208 -0
  62. data/docs/reference/resources/activity-log.md +369 -0
  63. data/docs/reference/resources/board-view.md +359 -0
  64. data/docs/reference/resources/board.md +393 -0
  65. data/docs/reference/resources/column.md +543 -0
  66. data/docs/reference/resources/file.md +236 -0
  67. data/docs/reference/resources/folder.md +386 -0
  68. data/docs/reference/resources/group.md +507 -0
  69. data/docs/reference/resources/item.md +348 -0
  70. data/docs/reference/resources/subitem.md +267 -0
  71. data/docs/reference/resources/update.md +259 -0
  72. data/docs/reference/resources/workspace.md +213 -0
  73. data/docs/reference/response.md +560 -0
  74. data/docs/tutorial/first-integration.md +713 -0
  75. data/lib/monday/client.rb +24 -0
  76. data/lib/monday/configuration.rb +5 -0
  77. data/lib/monday/request.rb +15 -0
  78. data/lib/monday/resources/base.rb +4 -0
  79. data/lib/monday/resources/file.rb +56 -0
  80. data/lib/monday/util.rb +1 -0
  81. data/lib/monday/version.rb +1 -1
  82. metadata +87 -4
@@ -0,0 +1,493 @@
1
+ # Create Items
2
+
3
+ Add items (tasks, rows) to boards programmatically.
4
+
5
+ ## Finding Column IDs
6
+
7
+ ::: warning <span style="display: inline-flex; align-items: center; gap: 6px;"><svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>Column IDs are Board-Specific</span>
8
+ **Before setting column values, you must find your board's actual column IDs.** Column IDs like `status`, `text`, or `date` in these examples are placeholders - replace them with your board's real column IDs.
9
+ :::
10
+
11
+ Query your board to get column IDs:
12
+
13
+ ```ruby
14
+ response = client.board.query(
15
+ args: { ids: [1234567890] }, # Replace with your board ID
16
+ select: [
17
+ "id",
18
+ "name",
19
+ {
20
+ columns: ["id", "title", "type"]
21
+ }
22
+ ]
23
+ )
24
+
25
+ if response.success?
26
+ board = response.body.dig("data", "boards", 0)
27
+
28
+ puts "Columns for board '#{board['name']}':"
29
+ board["columns"].each do |column|
30
+ puts " • #{column['title']}: '#{column['id']}' (#{column['type']})"
31
+ end
32
+ end
33
+ ```
34
+
35
+ **Example output:**
36
+ ```
37
+ Columns for board 'Marketing Campaigns':
38
+ • Name: 'name' (name)
39
+ • Status: 'status' (color)
40
+ • Owner: 'people' (people)
41
+ • Due Date: 'date4' (date)
42
+ • Priority: 'status_1' (color)
43
+ • Text: 'text' (text)
44
+ ```
45
+
46
+ Use these exact column IDs (e.g., `date4`, `status_1`) in your code, not the column titles.
47
+
48
+ ## Basic Item Creation
49
+
50
+ Create an item with just a name:
51
+
52
+ ```ruby
53
+ require "monday_ruby"
54
+
55
+ Monday.configure do |config|
56
+ config.token = ENV["MONDAY_TOKEN"]
57
+ end
58
+
59
+ client = Monday::Client.new
60
+
61
+ response = client.item.create(
62
+ args: {
63
+ board_id: 1234567890,
64
+ item_name: "New Task"
65
+ }
66
+ )
67
+
68
+ if response.success?
69
+ item = response.body.dig("data", "create_item")
70
+ puts "✓ Created item: #{item['name']}"
71
+ puts " ID: #{item['id']}"
72
+ else
73
+ puts "✗ Failed to create item"
74
+ end
75
+ ```
76
+
77
+ **Output:**
78
+ ```
79
+ ✓ Created item: New Task
80
+ ID: 987654321
81
+ ```
82
+
83
+ ## Create with Column Values
84
+
85
+ Set column values when creating an item:
86
+
87
+ ### Status Column
88
+
89
+ ```ruby
90
+ # Replace 'status' with your actual column ID from the query above
91
+ response = client.item.create(
92
+ args: {
93
+ board_id: 1234567890,
94
+ item_name: "Task with Status",
95
+ column_values: {
96
+ status: { # ⚠️ Replace 'status' with your board's status column ID
97
+ label: "Done"
98
+ }
99
+ }
100
+ }
101
+ )
102
+
103
+ if response.success?
104
+ item = response.body.dig("data", "create_item")
105
+ puts "Created: #{item['name']}"
106
+ end
107
+ ```
108
+
109
+ ### Multiple Columns
110
+
111
+ Set multiple column values at once:
112
+
113
+ ```ruby
114
+ # ⚠️ Replace column IDs with your board's actual column IDs
115
+ response = client.item.create(
116
+ args: {
117
+ board_id: 1234567890,
118
+ item_name: "Complete Task Setup",
119
+ column_values: {
120
+ status: { # Your status column ID
121
+ label: "Working on it"
122
+ },
123
+ text: "High priority task", # Your text column ID
124
+ date4: { # Your date column ID (e.g., 'date4', 'date', etc.)
125
+ date: "2024-12-31",
126
+ time: "14:00:00"
127
+ },
128
+ people: { # Your people column ID
129
+ personsAndTeams: [
130
+ { id: 12345678, kind: "person" } # Replace with actual user ID
131
+ ]
132
+ }
133
+ }
134
+ }
135
+ )
136
+ ```
137
+
138
+ ## Create in Specific Group
139
+
140
+ Add item to a particular group (section) on the board:
141
+
142
+ ```ruby
143
+ # First, get the group ID
144
+ board_response = client.board.query(
145
+ args: { ids: [1234567890] },
146
+ select: [
147
+ "id",
148
+ {
149
+ groups: ["id", "title"]
150
+ }
151
+ ]
152
+ )
153
+
154
+ board = board_response.body.dig("data", "boards", 0)
155
+ group_id = board.dig("groups", 0, "id")
156
+
157
+ # Create item in that group
158
+ response = client.item.create(
159
+ args: {
160
+ board_id: 1234567890,
161
+ group_id: group_id,
162
+ item_name: "Task in Specific Group"
163
+ }
164
+ )
165
+
166
+ if response.success?
167
+ item = response.body.dig("data", "create_item")
168
+ puts "✓ Item created in group #{group_id}"
169
+ end
170
+ ```
171
+
172
+ ## Auto-Create Status Labels
173
+
174
+ Automatically create new status labels if they don't exist:
175
+
176
+ ```ruby
177
+ response = client.item.create(
178
+ args: {
179
+ board_id: 1234567890,
180
+ item_name: "Task with New Label",
181
+ column_values: {
182
+ status__1: {
183
+ label: "Custom Status"
184
+ }
185
+ },
186
+ create_labels_if_missing: true
187
+ }
188
+ )
189
+
190
+ if response.success?
191
+ puts "✓ Item created with custom status label"
192
+ end
193
+ ```
194
+
195
+ ::: warning <span style="display: inline-flex; align-items: center; gap: 6px;"><svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>Status Labels</span>
196
+ Without `create_labels_if_missing: true`, attempting to use non-existent status labels will cause an error.
197
+ :::
198
+
199
+ ## Customize Response Fields
200
+
201
+ Choose which fields to return:
202
+
203
+ ```ruby
204
+ response = client.item.create(
205
+ args: {
206
+ board_id: 1234567890,
207
+ item_name: "Detailed Item"
208
+ },
209
+ select: [
210
+ "id",
211
+ "name",
212
+ "created_at",
213
+ "state",
214
+ "board { id name }",
215
+ "group { id title }"
216
+ ]
217
+ )
218
+
219
+ if response.success?
220
+ item = response.body.dig("data", "create_item")
221
+
222
+ puts "Item Details:"
223
+ puts " ID: #{item['id']}"
224
+ puts " Name: #{item['name']}"
225
+ puts " Created: #{item['created_at']}"
226
+ puts " Board: #{item.dig('board', 'name')}"
227
+ puts " Group: #{item.dig('group', 'title')}"
228
+ end
229
+ ```
230
+
231
+ ## Bulk Create Items
232
+
233
+ Create multiple items efficiently:
234
+
235
+ ```ruby
236
+ def create_items_bulk(client, board_id, item_names)
237
+ created_items = []
238
+
239
+ item_names.each do |name|
240
+ response = client.item.create(
241
+ args: {
242
+ board_id: board_id,
243
+ item_name: name
244
+ }
245
+ )
246
+
247
+ if response.success?
248
+ item = response.body.dig("data", "create_item")
249
+ created_items << item
250
+ puts "✓ Created: #{item['name']}"
251
+ else
252
+ puts "✗ Failed to create: #{name}"
253
+ end
254
+
255
+ # Rate limiting: pause between requests
256
+ sleep(0.5)
257
+ end
258
+
259
+ created_items
260
+ end
261
+
262
+ # Usage
263
+ tasks = [
264
+ "Design mockups",
265
+ "Implement feature",
266
+ "Write tests",
267
+ "Deploy to staging",
268
+ "QA review"
269
+ ]
270
+
271
+ items = create_items_bulk(client, 1234567890, tasks)
272
+ puts "\nCreated #{items.length} items"
273
+ ```
274
+
275
+ ## Create with JSON Column Values
276
+
277
+ For complex column types, use JSON strings:
278
+
279
+ ```ruby
280
+ require "json"
281
+
282
+ column_values = {
283
+ status__1: { label: "Done" },
284
+ date: { date: "2024-12-31" }
285
+ }
286
+
287
+ response = client.item.create(
288
+ args: {
289
+ board_id: 1234567890,
290
+ item_name: "Task with JSON Values",
291
+ column_values: JSON.generate(column_values)
292
+ }
293
+ )
294
+ ```
295
+
296
+ ::: tip <span style="display: inline-flex; align-items: center; gap: 6px;"><svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg>Hash vs JSON</span>
297
+ The gem automatically converts Hash column values to JSON. You can pass either format.
298
+ :::
299
+
300
+ ## Error Handling
301
+
302
+ Handle common creation errors:
303
+
304
+ ```ruby
305
+ def create_item_safe(client, board_id, name, columns = {})
306
+ response = client.item.create(
307
+ args: {
308
+ board_id: board_id,
309
+ item_name: name,
310
+ column_values: columns
311
+ }
312
+ )
313
+
314
+ if response.success?
315
+ item = response.body.dig("data", "create_item")
316
+ puts "✓ Created: #{item['name']} (ID: #{item['id']})"
317
+ item['id']
318
+ else
319
+ puts "✗ Failed to create item: #{name}"
320
+ puts " Status: #{response.status}"
321
+
322
+ if response.body["errors"]
323
+ response.body["errors"].each do |error|
324
+ puts " Error: #{error['message']}"
325
+ end
326
+ end
327
+
328
+ nil
329
+ end
330
+ rescue Monday::AuthorizationError
331
+ puts "✗ Invalid API token"
332
+ nil
333
+ rescue Monday::InvalidRequestError => e
334
+ puts "✗ Invalid request: #{e.message}"
335
+ nil
336
+ rescue Monday::Error => e
337
+ puts "✗ API error: #{e.message}"
338
+ nil
339
+ end
340
+
341
+ # Usage
342
+ item_id = create_item_safe(
343
+ client,
344
+ 1234567890,
345
+ "Safe Task",
346
+ { status__1: { label: "Done" } }
347
+ )
348
+ ```
349
+
350
+ ## Validate Item Names
351
+
352
+ Check for valid item names before creating:
353
+
354
+ ```ruby
355
+ def valid_item_name?(name)
356
+ return false if name.nil? || name.empty?
357
+ return false if name.length > 255
358
+
359
+ true
360
+ end
361
+
362
+ item_name = "My New Task"
363
+
364
+ if valid_item_name?(item_name)
365
+ response = client.item.create(
366
+ args: {
367
+ board_id: 1234567890,
368
+ item_name: item_name
369
+ }
370
+ )
371
+ else
372
+ puts "Invalid item name"
373
+ end
374
+ ```
375
+
376
+ ## Complete Example
377
+
378
+ Create a fully configured item:
379
+
380
+ ```ruby
381
+ require "monday_ruby"
382
+ require "dotenv/load"
383
+
384
+ Monday.configure do |config|
385
+ config.token = ENV["MONDAY_TOKEN"]
386
+ end
387
+
388
+ client = Monday::Client.new
389
+
390
+ # IMPORTANT: First, get your board's column IDs:
391
+ # See "Finding Column IDs" section at the top of this guide
392
+
393
+ # Create item with all options
394
+ response = client.item.create(
395
+ args: {
396
+ board_id: 1234567890, # Your board ID
397
+ group_id: "topics", # Your group ID
398
+ item_name: "Q1 2024 Marketing Campaign",
399
+ column_values: {
400
+ status: { # ⚠️ Replace with your status column ID
401
+ label: "Working on it"
402
+ },
403
+ date4: { # ⚠️ Replace with your date column ID
404
+ date: "2024-03-31",
405
+ time: "17:00:00"
406
+ },
407
+ people: { # ⚠️ Replace with your people column ID
408
+ personsAndTeams: [
409
+ { id: 12345678, kind: "person" } # Replace with actual user ID
410
+ ]
411
+ },
412
+ text: "Launch new product marketing campaign" # ⚠️ Replace with your text column ID
413
+ },
414
+ create_labels_if_missing: true
415
+ },
416
+ select: [
417
+ "id",
418
+ "name",
419
+ "created_at",
420
+ "state",
421
+ {
422
+ board: ["id", "name"],
423
+ group: ["id", "title"],
424
+ column_values: ["id", "text", "type"]
425
+ }
426
+ ]
427
+ )
428
+
429
+ if response.success?
430
+ item = response.body.dig("data", "create_item")
431
+
432
+ puts "\n✓ Item Created Successfully\n"
433
+ puts "#{'=' * 50}"
434
+ puts "Name: #{item['name']}"
435
+ puts "ID: #{item['id']}"
436
+ puts "Created: #{item['created_at']}"
437
+ puts "Board: #{item.dig('board', 'name')}"
438
+ puts "Group: #{item.dig('group', 'title')}"
439
+ puts "\nColumn Values:"
440
+
441
+ item["column_values"].each do |col_val|
442
+ next if col_val["text"].nil? || col_val["text"].empty?
443
+ puts " • #{col_val['id']}: #{col_val['text']}"
444
+ end
445
+
446
+ puts "#{'=' * 50}"
447
+ else
448
+ puts "\n✗ Failed to create item"
449
+ puts "Status code: #{response.status}"
450
+
451
+ if response.body["error_message"]
452
+ puts "Error: #{response.body['error_message']}"
453
+ end
454
+ end
455
+ ```
456
+
457
+ ## Create from Template
458
+
459
+ Copy an existing item structure:
460
+
461
+ ```ruby
462
+ # Get the original item's structure
463
+ template_response = client.item.query(
464
+ args: { ids: [987654321] },
465
+ select: [
466
+ "id",
467
+ "name",
468
+ {
469
+ column_values: ["id", "text"]
470
+ }
471
+ ]
472
+ )
473
+
474
+ template_item = template_response.body.dig("data", "items", 0)
475
+
476
+ # Create new item with same column structure
477
+ # (You'll need to parse and reconstruct column values appropriately)
478
+ response = client.item.create(
479
+ args: {
480
+ board_id: 1234567890,
481
+ item_name: "New Item from Template"
482
+ # Add column_values based on template
483
+ }
484
+ )
485
+ ```
486
+
487
+ ## Next Steps
488
+
489
+ - [Query items](/guides/items/query)
490
+ - [Update item values](/guides/items/update)
491
+ - [Work with subitems](/guides/items/subitems)
492
+ - [Update column values](/guides/columns/update-values)
493
+ - [Archive and delete items](/guides/items/delete)