monday_ruby 1.0.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 (93) hide show
  1. checksums.yaml +4 -4
  2. data/.env +1 -1
  3. data/.rspec +0 -1
  4. data/.rubocop.yml +19 -0
  5. data/.simplecov +1 -0
  6. data/CHANGELOG.md +49 -0
  7. data/CONTRIBUTING.md +165 -0
  8. data/README.md +167 -88
  9. data/docs/.vitepress/config.mjs +255 -0
  10. data/docs/.vitepress/theme/index.js +4 -0
  11. data/docs/.vitepress/theme/style.css +43 -0
  12. data/docs/README.md +80 -0
  13. data/docs/explanation/architecture.md +507 -0
  14. data/docs/explanation/best-practices/errors.md +478 -0
  15. data/docs/explanation/best-practices/performance.md +1084 -0
  16. data/docs/explanation/best-practices/rate-limiting.md +630 -0
  17. data/docs/explanation/best-practices/testing.md +820 -0
  18. data/docs/explanation/column-values.md +857 -0
  19. data/docs/explanation/design.md +795 -0
  20. data/docs/explanation/graphql.md +356 -0
  21. data/docs/explanation/migration/v1.md +808 -0
  22. data/docs/explanation/pagination.md +447 -0
  23. data/docs/guides/advanced/batch.md +1274 -0
  24. data/docs/guides/advanced/complex-queries.md +1114 -0
  25. data/docs/guides/advanced/errors.md +818 -0
  26. data/docs/guides/advanced/pagination.md +934 -0
  27. data/docs/guides/advanced/rate-limiting.md +981 -0
  28. data/docs/guides/authentication.md +286 -0
  29. data/docs/guides/boards/create.md +386 -0
  30. data/docs/guides/boards/delete.md +405 -0
  31. data/docs/guides/boards/duplicate.md +511 -0
  32. data/docs/guides/boards/query.md +530 -0
  33. data/docs/guides/boards/update.md +453 -0
  34. data/docs/guides/columns/create.md +452 -0
  35. data/docs/guides/columns/metadata.md +492 -0
  36. data/docs/guides/columns/query.md +455 -0
  37. data/docs/guides/columns/update-multiple.md +459 -0
  38. data/docs/guides/columns/update-values.md +509 -0
  39. data/docs/guides/files/add-to-column.md +40 -0
  40. data/docs/guides/files/add-to-update.md +37 -0
  41. data/docs/guides/files/clear-column.md +33 -0
  42. data/docs/guides/first-request.md +285 -0
  43. data/docs/guides/folders/manage.md +750 -0
  44. data/docs/guides/groups/items.md +626 -0
  45. data/docs/guides/groups/manage.md +501 -0
  46. data/docs/guides/installation.md +169 -0
  47. data/docs/guides/items/create.md +493 -0
  48. data/docs/guides/items/delete.md +514 -0
  49. data/docs/guides/items/query.md +605 -0
  50. data/docs/guides/items/subitems.md +483 -0
  51. data/docs/guides/items/update.md +699 -0
  52. data/docs/guides/updates/manage.md +619 -0
  53. data/docs/guides/use-cases/dashboard.md +1421 -0
  54. data/docs/guides/use-cases/import.md +1962 -0
  55. data/docs/guides/use-cases/task-management.md +1381 -0
  56. data/docs/guides/workspaces/manage.md +502 -0
  57. data/docs/index.md +69 -0
  58. data/docs/package-lock.json +2468 -0
  59. data/docs/package.json +13 -0
  60. data/docs/reference/client.md +540 -0
  61. data/docs/reference/configuration.md +586 -0
  62. data/docs/reference/errors.md +693 -0
  63. data/docs/reference/resources/account.md +208 -0
  64. data/docs/reference/resources/activity-log.md +369 -0
  65. data/docs/reference/resources/board-view.md +359 -0
  66. data/docs/reference/resources/board.md +393 -0
  67. data/docs/reference/resources/column.md +543 -0
  68. data/docs/reference/resources/file.md +236 -0
  69. data/docs/reference/resources/folder.md +386 -0
  70. data/docs/reference/resources/group.md +507 -0
  71. data/docs/reference/resources/item.md +348 -0
  72. data/docs/reference/resources/subitem.md +267 -0
  73. data/docs/reference/resources/update.md +259 -0
  74. data/docs/reference/resources/workspace.md +213 -0
  75. data/docs/reference/response.md +560 -0
  76. data/docs/tutorial/first-integration.md +713 -0
  77. data/lib/monday/client.rb +41 -2
  78. data/lib/monday/configuration.rb +13 -0
  79. data/lib/monday/deprecation.rb +23 -0
  80. data/lib/monday/error.rb +5 -2
  81. data/lib/monday/request.rb +19 -1
  82. data/lib/monday/resources/base.rb +4 -0
  83. data/lib/monday/resources/board.rb +52 -0
  84. data/lib/monday/resources/column.rb +6 -0
  85. data/lib/monday/resources/file.rb +56 -0
  86. data/lib/monday/resources/folder.rb +55 -0
  87. data/lib/monday/resources/group.rb +66 -0
  88. data/lib/monday/resources/item.rb +62 -0
  89. data/lib/monday/util.rb +33 -1
  90. data/lib/monday/version.rb +1 -1
  91. data/lib/monday_ruby.rb +1 -0
  92. metadata +92 -11
  93. data/monday_ruby.gemspec +0 -39
@@ -0,0 +1,514 @@
1
+ # Archive & Delete Items
2
+
3
+ Remove items from boards using archive (recoverable) or delete (permanent).
4
+
5
+ ## Archive an Item
6
+
7
+ Archive items to hide them while keeping them recoverable:
8
+
9
+ ```ruby
10
+ require "monday_ruby"
11
+
12
+ Monday.configure do |config|
13
+ config.token = ENV["MONDAY_TOKEN"]
14
+ end
15
+
16
+ client = Monday::Client.new
17
+
18
+ response = client.item.archive(987654321)
19
+
20
+ if response.success?
21
+ item = response.body.dig("data", "archive_item")
22
+ puts "✓ Archived item ID: #{item['id']}"
23
+ else
24
+ puts "✗ Failed to archive item"
25
+ end
26
+ ```
27
+
28
+ **Output:**
29
+ ```
30
+ ✓ Archived item ID: 987654321
31
+ ```
32
+
33
+ ::: 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>Archive vs Delete</span>
34
+ Archived items can be restored from the monday.com UI. Deleted items cannot be recovered.
35
+ :::
36
+
37
+ ## Archive with Details
38
+
39
+ Get more information about the archived item:
40
+
41
+ ```ruby
42
+ response = client.item.archive(
43
+ 987654321,
44
+ select: ["id", "name", "state", "created_at"]
45
+ )
46
+
47
+ if response.success?
48
+ item = response.body.dig("data", "archive_item")
49
+
50
+ puts "Archived Item:"
51
+ puts " ID: #{item['id']}"
52
+ puts " Name: #{item['name']}"
53
+ puts " State: #{item['state']}"
54
+ puts " Created: #{item['created_at']}"
55
+ end
56
+ ```
57
+
58
+ ## Delete an Item
59
+
60
+ Permanently delete items:
61
+
62
+ ```ruby
63
+ response = client.item.delete(987654321)
64
+
65
+ if response.success?
66
+ item = response.body.dig("data", "delete_item")
67
+ puts "✓ Deleted item ID: #{item['id']}"
68
+ else
69
+ puts "✗ Failed to delete item"
70
+ end
71
+ ```
72
+
73
+ ::: 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>Permanent Deletion</span>
74
+ Deleted items cannot be recovered. Consider archiving instead if you might need the data later.
75
+ :::
76
+
77
+ ## Bulk Archive Items
78
+
79
+ Archive multiple items:
80
+
81
+ ```ruby
82
+ def archive_items_bulk(client, item_ids)
83
+ archived_items = []
84
+
85
+ item_ids.each do |item_id|
86
+ response = client.item.archive(item_id)
87
+
88
+ if response.success?
89
+ item = response.body.dig("data", "archive_item")
90
+ archived_items << item
91
+ puts "✓ Archived: #{item['id']}"
92
+ else
93
+ puts "✗ Failed to archive: #{item_id}"
94
+ end
95
+
96
+ # Rate limiting: pause between requests
97
+ sleep(0.3)
98
+ end
99
+
100
+ archived_items
101
+ end
102
+
103
+ # Usage
104
+ item_ids = [987654321, 987654322, 987654323]
105
+ archived = archive_items_bulk(client, item_ids)
106
+
107
+ puts "\n✓ Archived #{archived.length} items"
108
+ ```
109
+
110
+ **Output:**
111
+ ```
112
+ ✓ Archived: 987654321
113
+ ✓ Archived: 987654322
114
+ ✓ Archived: 987654323
115
+
116
+ ✓ Archived 3 items
117
+ ```
118
+
119
+ ## Bulk Delete Items
120
+
121
+ Delete multiple items permanently:
122
+
123
+ ```ruby
124
+ def delete_items_bulk(client, item_ids)
125
+ deleted_items = []
126
+
127
+ item_ids.each do |item_id|
128
+ response = client.item.delete(item_id)
129
+
130
+ if response.success?
131
+ item = response.body.dig("data", "delete_item")
132
+ deleted_items << item
133
+ puts "✓ Deleted: #{item['id']}"
134
+ else
135
+ puts "✗ Failed to delete: #{item_id}"
136
+ end
137
+
138
+ # Rate limiting: pause between requests
139
+ sleep(0.3)
140
+ end
141
+
142
+ deleted_items
143
+ end
144
+
145
+ # Usage
146
+ item_ids = [987654321, 987654322, 987654323]
147
+ deleted = delete_items_bulk(client, item_ids)
148
+
149
+ puts "\n✓ Deleted #{deleted.length} items"
150
+ ```
151
+
152
+ ## Archive Items by Status
153
+
154
+ Archive all items with a specific status:
155
+
156
+ ```ruby
157
+ def archive_items_by_status(client, board_id, status_label)
158
+ # Query items with the status
159
+ response = client.item.page_by_column_values(
160
+ board_id: board_id,
161
+ columns: [
162
+ { column_id: "status", column_values: [status_label] }
163
+ ],
164
+ limit: 100,
165
+ select: ["id", "name"]
166
+ )
167
+
168
+ return [] unless response.success?
169
+
170
+ items_page = response.body.dig("data", "items_page_by_column_values")
171
+ items = items_page["items"]
172
+
173
+ puts "Found #{items.length} items with status '#{status_label}'"
174
+
175
+ # Archive each item
176
+ archived = []
177
+ items.each do |item|
178
+ archive_response = client.item.archive(item["id"])
179
+
180
+ if archive_response.success?
181
+ archived << item
182
+ puts " ✓ Archived: #{item['name']}"
183
+ end
184
+
185
+ sleep(0.3)
186
+ end
187
+
188
+ archived
189
+ end
190
+
191
+ # Usage
192
+ archived = archive_items_by_status(client, 1234567890, "Done")
193
+ puts "\n✓ Archived #{archived.length} completed items"
194
+ ```
195
+
196
+ ## Delete Old Items
197
+
198
+ Remove items older than a specific date:
199
+
200
+ ```ruby
201
+ require "date"
202
+
203
+ def delete_items_older_than(client, board_id, days_old)
204
+ cutoff_date = (Date.today - days_old).to_time.utc.iso8601
205
+
206
+ # Query all items
207
+ response = client.board.items_page(
208
+ board_ids: board_id,
209
+ limit: 500,
210
+ select: ["id", "name", "created_at"]
211
+ )
212
+
213
+ return [] unless response.success?
214
+
215
+ items_page = response.body.dig("data", "boards", 0, "items_page")
216
+ items = items_page["items"]
217
+
218
+ # Filter items older than cutoff
219
+ old_items = items.select do |item|
220
+ created_at = DateTime.parse(item["created_at"])
221
+ created_at < DateTime.parse(cutoff_date)
222
+ end
223
+
224
+ puts "Found #{old_items.length} items older than #{days_old} days"
225
+
226
+ # Delete each old item
227
+ deleted = []
228
+ old_items.each do |item|
229
+ delete_response = client.item.delete(item["id"])
230
+
231
+ if delete_response.success?
232
+ deleted << item
233
+ puts " ✓ Deleted: #{item['name']} (#{item['created_at']})"
234
+ end
235
+
236
+ sleep(0.3)
237
+ end
238
+
239
+ deleted
240
+ end
241
+
242
+ # Usage: Delete items older than 90 days
243
+ deleted = delete_items_older_than(client, 1234567890, 90)
244
+ puts "\n✓ Deleted #{deleted.length} old items"
245
+ ```
246
+
247
+ ## Conditional Archive
248
+
249
+ Archive only if certain conditions are met:
250
+
251
+ ```ruby
252
+ def archive_if_complete(client, item_id)
253
+ # Get item details
254
+ response = client.item.query(
255
+ args: { ids: [item_id] },
256
+ select: [
257
+ "id",
258
+ "name",
259
+ {
260
+ column_values: ["id", "text"]
261
+ }
262
+ ]
263
+ )
264
+
265
+ return false unless response.success?
266
+
267
+ item = response.body.dig("data", "items", 0)
268
+ status = item["column_values"].find { |cv| cv["id"] == "status" }
269
+
270
+ # Check if status is "Done"
271
+ return false unless status&.dig("text") == "Done"
272
+
273
+ # Archive the item
274
+ archive_response = client.item.archive(item_id)
275
+
276
+ if archive_response.success?
277
+ puts "✓ Archived completed item: #{item['name']}"
278
+ true
279
+ else
280
+ false
281
+ end
282
+ end
283
+
284
+ # Usage
285
+ archived = archive_if_complete(client, 987654321)
286
+ puts archived ? "Item archived" : "Item not complete or archive failed"
287
+ ```
288
+
289
+ ## Archive with Confirmation
290
+
291
+ Prompt for confirmation before archiving:
292
+
293
+ ```ruby
294
+ def archive_with_confirmation(client, item_id)
295
+ # Get item details first
296
+ response = client.item.query(
297
+ args: { ids: [item_id] },
298
+ select: ["id", "name", "created_at"]
299
+ )
300
+
301
+ return unless response.success?
302
+
303
+ item = response.body.dig("data", "items", 0)
304
+
305
+ puts "\nItem to archive:"
306
+ puts " Name: #{item['name']}"
307
+ puts " ID: #{item['id']}"
308
+ puts " Created: #{item['created_at']}"
309
+
310
+ print "\nArchive this item? (y/n): "
311
+ confirmation = gets.chomp.downcase
312
+
313
+ return unless confirmation == "y"
314
+
315
+ archive_response = client.item.archive(item_id)
316
+
317
+ if archive_response.success?
318
+ puts "✓ Item archived successfully"
319
+ else
320
+ puts "✗ Failed to archive item"
321
+ end
322
+ end
323
+
324
+ # Usage
325
+ archive_with_confirmation(client, 987654321)
326
+ ```
327
+
328
+ ## Error Handling
329
+
330
+ Handle common archive/delete errors:
331
+
332
+ ```ruby
333
+ def archive_item_safe(client, item_id)
334
+ response = client.item.archive(item_id)
335
+
336
+ if response.success?
337
+ item = response.body.dig("data", "archive_item")
338
+ puts "✓ Archived item ID: #{item['id']}"
339
+ true
340
+ else
341
+ puts "✗ Failed to archive item"
342
+ puts " Status: #{response.status}"
343
+
344
+ if response.body["errors"]
345
+ response.body["errors"].each do |error|
346
+ puts " Error: #{error['message']}"
347
+ end
348
+ end
349
+
350
+ false
351
+ end
352
+ rescue Monday::AuthorizationError
353
+ puts "✗ Invalid API token"
354
+ false
355
+ rescue Monday::InvalidRequestError => e
356
+ puts "✗ Invalid item ID: #{e.message}"
357
+ false
358
+ rescue Monday::Error => e
359
+ puts "✗ API error: #{e.message}"
360
+ false
361
+ end
362
+
363
+ # Usage
364
+ success = archive_item_safe(client, 987654321)
365
+ ```
366
+
367
+ ## Duplicate Before Delete
368
+
369
+ Create a backup before permanent deletion:
370
+
371
+ ```ruby
372
+ def duplicate_and_delete(client, board_id, item_id)
373
+ # Duplicate the item first
374
+ duplicate_response = client.item.duplicate(
375
+ board_id,
376
+ item_id,
377
+ true # Include updates
378
+ )
379
+
380
+ unless duplicate_response.success?
381
+ puts "✗ Failed to duplicate item"
382
+ return false
383
+ end
384
+
385
+ duplicated = duplicate_response.body.dig("data", "duplicate_item")
386
+ puts "✓ Created backup copy: #{duplicated['id']}"
387
+
388
+ # Now safe to delete original
389
+ delete_response = client.item.delete(item_id)
390
+
391
+ if delete_response.success?
392
+ puts "✓ Original item deleted"
393
+ true
394
+ else
395
+ puts "✗ Failed to delete original item"
396
+ false
397
+ end
398
+ end
399
+
400
+ # Usage
401
+ success = duplicate_and_delete(client, 1234567890, 987654321)
402
+ ```
403
+
404
+ ## Complete Example
405
+
406
+ Archive or delete with full error handling and logging:
407
+
408
+ ```ruby
409
+ require "monday_ruby"
410
+ require "dotenv/load"
411
+
412
+ Monday.configure do |config|
413
+ config.token = ENV["MONDAY_TOKEN"]
414
+ end
415
+
416
+ client = Monday::Client.new
417
+
418
+ def cleanup_items(client, board_id, status_to_archive, status_to_delete)
419
+ results = {
420
+ archived: [],
421
+ deleted: [],
422
+ errors: []
423
+ }
424
+
425
+ # Get items to clean up
426
+ response = client.item.page_by_column_values(
427
+ board_id: board_id,
428
+ columns: [
429
+ { column_id: "status", column_values: status_to_archive + status_to_delete }
430
+ ],
431
+ limit: 100,
432
+ select: [
433
+ "id",
434
+ "name",
435
+ {
436
+ column_values: ["id", "text"]
437
+ }
438
+ ]
439
+ )
440
+
441
+ unless response.success?
442
+ puts "✗ Failed to query items"
443
+ return results
444
+ end
445
+
446
+ items_page = response.body.dig("data", "items_page_by_column_values")
447
+ items = items_page["items"]
448
+
449
+ puts "Found #{items.length} items to process"
450
+
451
+ items.each do |item|
452
+ status = item["column_values"].find { |cv| cv["id"] == "status" }
453
+ status_label = status&.dig("text")
454
+
455
+ if status_to_archive.include?(status_label)
456
+ # Archive this item
457
+ archive_response = client.item.archive(item["id"])
458
+
459
+ if archive_response.success?
460
+ results[:archived] << item
461
+ puts " ✓ Archived: #{item['name']}"
462
+ else
463
+ results[:errors] << { item: item, action: "archive" }
464
+ puts " ✗ Failed to archive: #{item['name']}"
465
+ end
466
+
467
+ elsif status_to_delete.include?(status_label)
468
+ # Delete this item
469
+ delete_response = client.item.delete(item["id"])
470
+
471
+ if delete_response.success?
472
+ results[:deleted] << item
473
+ puts " ✓ Deleted: #{item['name']}"
474
+ else
475
+ results[:errors] << { item: item, action: "delete" }
476
+ puts " ✗ Failed to delete: #{item['name']}"
477
+ end
478
+ end
479
+
480
+ sleep(0.3)
481
+ end
482
+
483
+ results
484
+ end
485
+
486
+ # Usage: Archive "Done" items, Delete "Cancelled" items
487
+ results = cleanup_items(
488
+ client,
489
+ 1234567890,
490
+ ["Done"],
491
+ ["Cancelled", "Rejected"]
492
+ )
493
+
494
+ puts "\n" + "=" * 50
495
+ puts "Cleanup Summary:"
496
+ puts " Archived: #{results[:archived].length} items"
497
+ puts " Deleted: #{results[:deleted].length} items"
498
+ puts " Errors: #{results[:errors].length}"
499
+ puts "=" * 50
500
+ ```
501
+
502
+ ## Undo Delete (Not Supported)
503
+
504
+ ::: danger <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="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>No Undo for Delete</span>
505
+ monday.com does not provide an API to restore deleted items. Always use archive instead of delete unless you're certain the data won't be needed.
506
+ :::
507
+
508
+ ## Next Steps
509
+
510
+ - [Create items](/guides/items/create)
511
+ - [Query items](/guides/items/query)
512
+ - [Duplicate items for backup](#duplicate-before-delete)
513
+ - [Archive boards](/guides/boards/delete)
514
+ - [Error handling patterns](/guides/advanced/errors)