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,619 @@
1
+ # Manage Updates
2
+
3
+ Work with updates (comments) on monday.com items programmatically.
4
+
5
+ ## What are Updates?
6
+
7
+ Updates are comments or posts on items in monday.com. They appear in the item's updates section and support:
8
+
9
+ - Text content
10
+ - User mentions
11
+ - Rich formatting
12
+ - Replies and threads
13
+
14
+ ## Post an Update
15
+
16
+ Add a comment to an item:
17
+
18
+ ```ruby
19
+ require "monday_ruby"
20
+
21
+ Monday.configure do |config|
22
+ config.token = ENV["MONDAY_TOKEN"]
23
+ end
24
+
25
+ client = Monday::Client.new
26
+
27
+ response = client.update.create(
28
+ args: {
29
+ item_id: 123456,
30
+ body: "This update will be added to the item"
31
+ }
32
+ )
33
+
34
+ if response.success?
35
+ update = response.body.dig("data", "create_update")
36
+ puts "Update posted: #{update['body']}"
37
+ puts "Update ID: #{update['id']}"
38
+ puts "Posted at: #{update['created_at']}"
39
+ else
40
+ puts "Failed to post update"
41
+ end
42
+ ```
43
+
44
+ **Output:**
45
+ ```
46
+ Update posted: This update will be added to the item
47
+ Update ID: 3325555116
48
+ Posted at: 2024-07-25T03:46:49Z
49
+ ```
50
+
51
+ ## Mention Users in Updates
52
+
53
+ Use HTML tags to mention users in your updates:
54
+
55
+ ```ruby
56
+ # Mention a single user
57
+ response = client.update.create(
58
+ args: {
59
+ item_id: 123456,
60
+ body: "Hey <@12345678>, can you review this task?"
61
+ }
62
+ )
63
+ ```
64
+
65
+ ::: 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>User ID Format</span>
66
+ Use `<@user_id>` to mention users. Replace `user_id` with the actual monday.com user ID. Mentioned users will receive a notification.
67
+ :::
68
+
69
+ ### Mention Multiple Users
70
+
71
+ ```ruby
72
+ response = client.update.create(
73
+ args: {
74
+ item_id: 123456,
75
+ body: "Team update: <@12345678> and <@87654321> - please review by EOD"
76
+ }
77
+ )
78
+ ```
79
+
80
+ ### Mention Teams
81
+
82
+ ```ruby
83
+ response = client.update.create(
84
+ args: {
85
+ item_id: 123456,
86
+ body: "Attention <team_id:98765>: New requirements posted"
87
+ }
88
+ )
89
+ ```
90
+
91
+ ## Query Updates
92
+
93
+ Retrieve updates from items or your account:
94
+
95
+ ### Get Recent Updates
96
+
97
+ ```ruby
98
+ response = client.update.query(
99
+ args: { limit: 10 },
100
+ select: [
101
+ "id",
102
+ "body",
103
+ "created_at",
104
+ {
105
+ creator: ["id", "name", "email"]
106
+ }
107
+ ]
108
+ )
109
+
110
+ if response.success?
111
+ updates = response.body.dig("data", "updates")
112
+
113
+ puts "Recent Updates:"
114
+ updates.each do |update|
115
+ creator = update["creator"]
116
+ puts "\n#{creator['name']} (#{update['created_at']}):"
117
+ puts " #{update['body']}"
118
+ end
119
+ end
120
+ ```
121
+
122
+ ### Get Specific Updates
123
+
124
+ ```ruby
125
+ response = client.update.query(
126
+ args: { ids: [3325555116, 3325560030] },
127
+ select: ["id", "body", "created_at", "text_body"]
128
+ )
129
+
130
+ if response.success?
131
+ updates = response.body.dig("data", "updates")
132
+ updates.each do |update|
133
+ puts "Update #{update['id']}: #{update['body']}"
134
+ end
135
+ end
136
+ ```
137
+
138
+ ### Get Item Updates
139
+
140
+ To get updates for a specific item, query the item with updates nested:
141
+
142
+ ```ruby
143
+ response = client.item.query(
144
+ args: { ids: [123456] },
145
+ select: [
146
+ "id",
147
+ "name",
148
+ {
149
+ updates: [
150
+ "id",
151
+ "body",
152
+ "created_at",
153
+ { creator: ["id", "name"] }
154
+ ]
155
+ }
156
+ ]
157
+ )
158
+
159
+ if response.success?
160
+ item = response.body.dig("data", "items", 0)
161
+ puts "Updates on '#{item['name']}':"
162
+
163
+ item["updates"].each do |update|
164
+ puts "\n#{update.dig('creator', 'name')}:"
165
+ puts " #{update['body']}"
166
+ end
167
+ end
168
+ ```
169
+
170
+ ## Like an Update
171
+
172
+ Show appreciation for an update:
173
+
174
+ ```ruby
175
+ response = client.update.like(
176
+ args: { update_id: 3325555116 }
177
+ )
178
+
179
+ if response.success?
180
+ liked_update = response.body.dig("data", "like_update")
181
+ puts "Liked update ID: #{liked_update['id']}"
182
+ end
183
+ ```
184
+
185
+ ## Delete an Update
186
+
187
+ Remove a specific update:
188
+
189
+ ```ruby
190
+ response = client.update.delete(
191
+ args: { id: 3325555116 }
192
+ )
193
+
194
+ if response.success?
195
+ deleted = response.body.dig("data", "delete_update")
196
+ puts "Deleted update ID: #{deleted['id']}"
197
+ else
198
+ puts "Failed to delete update"
199
+ end
200
+ ```
201
+
202
+ ::: 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>
203
+ Deleting an update is permanent and cannot be undone. Only the update creator or board admins can delete updates.
204
+ :::
205
+
206
+ ## Clear All Updates from an Item
207
+
208
+ Remove all updates from an item at once:
209
+
210
+ ```ruby
211
+ response = client.update.clear_item_updates(
212
+ args: { item_id: 123456 }
213
+ )
214
+
215
+ if response.success?
216
+ result = response.body.dig("data", "clear_item_updates")
217
+ puts "Cleared all updates from item #{result['id']}"
218
+ end
219
+ ```
220
+
221
+ ::: 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>Destructive Operation</span>
222
+ This permanently deletes ALL updates from the item. This action cannot be undone. Use with caution.
223
+ :::
224
+
225
+ ## Format Update Text
226
+
227
+ ### Add Line Breaks
228
+
229
+ Use `\n` for line breaks in update text:
230
+
231
+ ```ruby
232
+ update_text = <<~UPDATE
233
+ Task Status Update:
234
+
235
+ ✓ Completed design mockups
236
+ ✓ Implemented core features
237
+ ⚠ Testing in progress
238
+
239
+ Next steps: Deploy to staging
240
+ UPDATE
241
+
242
+ response = client.update.create(
243
+ args: {
244
+ item_id: 123456,
245
+ body: update_text
246
+ }
247
+ )
248
+ ```
249
+
250
+ ### Add Links
251
+
252
+ Include hyperlinks in your updates:
253
+
254
+ ```ruby
255
+ response = client.update.create(
256
+ args: {
257
+ item_id: 123456,
258
+ body: "Check out the docs: https://developer.monday.com/api-reference"
259
+ }
260
+ )
261
+ ```
262
+
263
+ ### Bold and Italic Text
264
+
265
+ Use markdown-style formatting:
266
+
267
+ ```ruby
268
+ response = client.update.create(
269
+ args: {
270
+ item_id: 123456,
271
+ body: "**Important:** This task is *high priority*"
272
+ }
273
+ )
274
+ ```
275
+
276
+ ## Post Status Updates
277
+
278
+ Track progress with regular updates:
279
+
280
+ ```ruby
281
+ def post_status_update(client, item_id, status, details)
282
+ timestamp = Time.now.strftime("%Y-%m-%d %H:%M")
283
+
284
+ body = <<~STATUS
285
+ [#{timestamp}] Status: #{status}
286
+
287
+ #{details}
288
+ STATUS
289
+
290
+ response = client.update.create(
291
+ args: {
292
+ item_id: item_id,
293
+ body: body
294
+ }
295
+ )
296
+
297
+ if response.success?
298
+ update = response.body.dig("data", "create_update")
299
+ puts "Posted status update: #{update['id']}"
300
+ true
301
+ else
302
+ puts "Failed to post status update"
303
+ false
304
+ end
305
+ end
306
+
307
+ # Usage
308
+ post_status_update(
309
+ client,
310
+ 123456,
311
+ "In Progress",
312
+ "Working on feature implementation. ETA: 2 hours."
313
+ )
314
+ ```
315
+
316
+ ## Reply to Updates
317
+
318
+ Create threaded conversations by replying to updates:
319
+
320
+ ```ruby
321
+ # First, get the parent update ID
322
+ parent_update_id = 3325555116
323
+
324
+ # Post a reply (this is done by creating a new update on the same item)
325
+ response = client.update.create(
326
+ args: {
327
+ item_id: 123456,
328
+ body: "Great point! I'll handle that right away."
329
+ }
330
+ )
331
+ ```
332
+
333
+ ::: 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>Replies</span>
334
+ While the API creates flat updates, the monday.com UI organizes them into threads. Updates are displayed chronologically within the item's updates section.
335
+ :::
336
+
337
+ ## Bulk Create Updates
338
+
339
+ Post multiple updates efficiently:
340
+
341
+ ```ruby
342
+ def post_bulk_updates(client, item_id, messages)
343
+ posted = []
344
+
345
+ messages.each do |message|
346
+ response = client.update.create(
347
+ args: {
348
+ item_id: item_id,
349
+ body: message
350
+ }
351
+ )
352
+
353
+ if response.success?
354
+ update = response.body.dig("data", "create_update")
355
+ posted << update
356
+ puts "✓ Posted: #{message[0..50]}..."
357
+ else
358
+ puts "✗ Failed to post: #{message[0..50]}..."
359
+ end
360
+
361
+ # Rate limiting: pause between requests
362
+ sleep(0.3)
363
+ end
364
+
365
+ posted
366
+ end
367
+
368
+ # Usage
369
+ progress_updates = [
370
+ "Started design phase",
371
+ "Mockups completed and approved",
372
+ "Development in progress",
373
+ "First iteration deployed to staging",
374
+ "QA testing completed"
375
+ ]
376
+
377
+ posted = post_bulk_updates(client, 123456, progress_updates)
378
+ puts "\nPosted #{posted.length} updates"
379
+ ```
380
+
381
+ ## Error Handling
382
+
383
+ Handle common update errors gracefully:
384
+
385
+ ```ruby
386
+ def create_update_safe(client, item_id, body)
387
+ response = client.update.create(
388
+ args: {
389
+ item_id: item_id,
390
+ body: body
391
+ }
392
+ )
393
+
394
+ if response.success?
395
+ update = response.body.dig("data", "create_update")
396
+ puts "✓ Posted update: #{update['id']}"
397
+ update['id']
398
+ else
399
+ puts "✗ Failed to post update"
400
+ puts " Status: #{response.status}"
401
+
402
+ if response.body["errors"]
403
+ response.body["errors"].each do |error|
404
+ puts " Error: #{error['message']}"
405
+ end
406
+ end
407
+
408
+ nil
409
+ end
410
+ rescue Monday::AuthorizationError
411
+ puts "✗ Invalid API token"
412
+ nil
413
+ rescue Monday::InvalidRequestError => e
414
+ puts "✗ Invalid request: #{e.message}"
415
+ puts " Check that the item_id is correct"
416
+ nil
417
+ rescue Monday::Error => e
418
+ puts "✗ API error: #{e.message}"
419
+ nil
420
+ end
421
+
422
+ # Usage
423
+ update_id = create_update_safe(
424
+ client,
425
+ 123456,
426
+ "This is a safe update with error handling"
427
+ )
428
+ ```
429
+
430
+ ## Validate Update Content
431
+
432
+ Check update content before posting:
433
+
434
+ ```ruby
435
+ def valid_update_body?(body)
436
+ return false if body.nil? || body.strip.empty?
437
+ return false if body.length > 10000 # monday.com has a character limit
438
+
439
+ true
440
+ end
441
+
442
+ update_body = "This is a valid update"
443
+
444
+ if valid_update_body?(update_body)
445
+ response = client.update.create(
446
+ args: {
447
+ item_id: 123456,
448
+ body: update_body
449
+ }
450
+ )
451
+ else
452
+ puts "Invalid update content"
453
+ end
454
+ ```
455
+
456
+ ## Get Update Creator Information
457
+
458
+ Retrieve who posted an update:
459
+
460
+ ```ruby
461
+ response = client.update.query(
462
+ args: { ids: [3325555116] },
463
+ select: [
464
+ "id",
465
+ "body",
466
+ "created_at",
467
+ {
468
+ creator: [
469
+ "id",
470
+ "name",
471
+ "email",
472
+ "photo_thumb"
473
+ ]
474
+ }
475
+ ]
476
+ )
477
+
478
+ if response.success?
479
+ update = response.body.dig("data", "updates", 0)
480
+ creator = update["creator"]
481
+
482
+ puts "Update by: #{creator['name']}"
483
+ puts "Email: #{creator['email']}"
484
+ puts "Posted: #{update['created_at']}"
485
+ puts "Content: #{update['body']}"
486
+ end
487
+ ```
488
+
489
+ ## Complete Example
490
+
491
+ Post a comprehensive status update with mentions and formatting:
492
+
493
+ ```ruby
494
+ require "monday_ruby"
495
+ require "dotenv/load"
496
+
497
+ Monday.configure do |config|
498
+ config.token = ENV["MONDAY_TOKEN"]
499
+ end
500
+
501
+ client = Monday::Client.new
502
+
503
+ # Define item and user IDs
504
+ item_id = 123456
505
+ project_manager_id = 12345678
506
+ developer_id = 87654321
507
+
508
+ # Create formatted update with mentions
509
+ update_body = <<~UPDATE
510
+ **Weekly Status Update**
511
+
512
+ Progress this week:
513
+ ✓ Completed UI redesign
514
+ ✓ Implemented new authentication flow
515
+ ✓ Updated documentation
516
+
517
+ Next week priorities:
518
+ • Deploy to production
519
+ • User acceptance testing
520
+ • Performance optimization
521
+
522
+ Action items:
523
+ <@#{project_manager_id}> - Schedule production deployment
524
+ <@#{developer_id}> - Review performance metrics
525
+
526
+ Questions or concerns? Let's discuss in tomorrow's standup.
527
+ UPDATE
528
+
529
+ # Post the update
530
+ response = client.update.create(
531
+ args: {
532
+ item_id: item_id,
533
+ body: update_body
534
+ },
535
+ select: [
536
+ "id",
537
+ "body",
538
+ "created_at",
539
+ "text_body",
540
+ {
541
+ creator: ["id", "name"]
542
+ }
543
+ ]
544
+ )
545
+
546
+ if response.success?
547
+ update = response.body.dig("data", "create_update")
548
+
549
+ puts "\n✓ Status Update Posted Successfully\n"
550
+ puts "=" * 50
551
+ puts "Update ID: #{update['id']}"
552
+ puts "Posted by: #{update.dig('creator', 'name')}"
553
+ puts "Posted at: #{update['created_at']}"
554
+ puts "\nContent:"
555
+ puts update['body']
556
+ puts "=" * 50
557
+ else
558
+ puts "\n✗ Failed to post update"
559
+ puts "Status code: #{response.status}"
560
+
561
+ if response.body["error_message"]
562
+ puts "Error: #{response.body['error_message']}"
563
+ end
564
+ end
565
+ ```
566
+
567
+ ## Monitor Item Activity
568
+
569
+ Track all activity on an item:
570
+
571
+ ```ruby
572
+ def monitor_item_activity(client, item_id, interval: 60)
573
+ last_update_id = nil
574
+
575
+ loop do
576
+ response = client.item.query(
577
+ args: { ids: [item_id] },
578
+ select: [
579
+ "id",
580
+ "name",
581
+ {
582
+ updates: [
583
+ "id",
584
+ "body",
585
+ "created_at",
586
+ { creator: ["name"] }
587
+ ]
588
+ }
589
+ ]
590
+ )
591
+
592
+ if response.success?
593
+ item = response.body.dig("data", "items", 0)
594
+ updates = item["updates"] || []
595
+
596
+ # Show new updates
597
+ updates.each do |update|
598
+ if last_update_id.nil? || update["id"].to_i > last_update_id.to_i
599
+ puts "\n[#{update['created_at']}] #{update.dig('creator', 'name')}:"
600
+ puts " #{update['body']}"
601
+ last_update_id = update["id"].to_i
602
+ end
603
+ end
604
+ end
605
+
606
+ sleep(interval)
607
+ end
608
+ end
609
+
610
+ # Monitor item for new updates every 60 seconds
611
+ # monitor_item_activity(client, 123456, interval: 60)
612
+ ```
613
+
614
+ ## Next Steps
615
+
616
+ - [Query items](/guides/items/query)
617
+ - [Create items](/guides/items/create)
618
+ - [Update item values](/guides/items/update)
619
+ - [Work with columns](/guides/columns/update-values)