redbooth-ruby 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +237 -20
  3. data/lib/redbooth-ruby.rb +10 -0
  4. data/lib/redbooth-ruby/base.rb +1 -1
  5. data/lib/redbooth-ruby/client.rb +9 -2
  6. data/lib/redbooth-ruby/client_operations/metadata.rb +32 -0
  7. data/lib/redbooth-ruby/client_operations/search.rb +32 -0
  8. data/lib/redbooth-ruby/comment.rb +34 -0
  9. data/lib/redbooth-ruby/file.rb +68 -0
  10. data/lib/redbooth-ruby/note.rb +25 -0
  11. data/lib/redbooth-ruby/operations/create.rb +1 -1
  12. data/lib/redbooth-ruby/operations/index.rb +0 -12
  13. data/lib/redbooth-ruby/operations/meta.rb +33 -2
  14. data/lib/redbooth-ruby/operations/show.rb +1 -1
  15. data/lib/redbooth-ruby/request/collection.rb +37 -5
  16. data/lib/redbooth-ruby/request/connection.rb +14 -8
  17. data/lib/redbooth-ruby/request/validator.rb +32 -4
  18. data/lib/redbooth-ruby/subtask.rb +18 -0
  19. data/lib/redbooth-ruby/task.rb +1 -1
  20. data/lib/redbooth-ruby/version.rb +1 -1
  21. data/redbooth-ruby.gemspec +1 -0
  22. data/spec/cassettes/RedboothRuby_ClientOperations_Metadata/_metadata/.yml +55 -0
  23. data/spec/cassettes/RedboothRuby_ClientOperations_Metadata/_metadata/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_notes_collection.yml +55 -0
  24. data/spec/cassettes/RedboothRuby_ClientOperations_Search/_index/.yml +271 -0
  25. data/spec/cassettes/RedboothRuby_ClientOperations_Search/_index/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_notes_collection.yml +271 -0
  26. data/spec/cassettes/RedboothRuby_Comment/_create/.yml +47 -0
  27. data/spec/cassettes/RedboothRuby_Comment/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_comment.yml +47 -0
  28. data/spec/cassettes/RedboothRuby_Comment/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_comment.yml +84 -0
  29. data/spec/cassettes/RedboothRuby_Comment/_index/.yml +94 -0
  30. data/spec/cassettes/RedboothRuby_Comment/_index/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_comments_collection.yml +94 -0
  31. data/spec/cassettes/RedboothRuby_Comment/_initialize/.yml +65 -0
  32. data/spec/cassettes/RedboothRuby_Comment/_show/.yml +65 -0
  33. data/spec/cassettes/RedboothRuby_Comment/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_comment.yml +65 -0
  34. data/spec/cassettes/RedboothRuby_Comment/_update/.yml +47 -0
  35. data/spec/cassettes/RedboothRuby_Comment/_update/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_comment.yml +47 -0
  36. data/spec/cassettes/RedboothRuby_File/_create/.yml +65 -0
  37. data/spec/cassettes/RedboothRuby_File/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_file.yml +65 -0
  38. data/spec/cassettes/RedboothRuby_File/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_comment.yml +102 -0
  39. data/spec/cassettes/RedboothRuby_File/_index/.yml +58 -0
  40. data/spec/cassettes/RedboothRuby_File/_index/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_comments_collection.yml +58 -0
  41. data/spec/cassettes/RedboothRuby_File/_initialize/.yml +44 -0
  42. data/spec/cassettes/RedboothRuby_File/_show/.yml +44 -0
  43. data/spec/cassettes/RedboothRuby_File/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_file.yml +44 -0
  44. data/spec/cassettes/RedboothRuby_File/_update/.yml +46 -0
  45. data/spec/cassettes/RedboothRuby_File/_update/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_file.yml +46 -0
  46. data/spec/cassettes/RedboothRuby_Note/_create/.yml +47 -0
  47. data/spec/cassettes/RedboothRuby_Note/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_note.yml +47 -0
  48. data/spec/cassettes/RedboothRuby_Note/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_note.yml +84 -0
  49. data/spec/cassettes/RedboothRuby_Note/_index/.yml +193 -0
  50. data/spec/cassettes/RedboothRuby_Note/_index/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_notes_collection.yml +193 -0
  51. data/spec/cassettes/RedboothRuby_Note/_initialize/.yml +109 -0
  52. data/spec/cassettes/RedboothRuby_Note/_show/.yml +109 -0
  53. data/spec/cassettes/RedboothRuby_Note/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_note.yml +109 -0
  54. data/spec/cassettes/RedboothRuby_Note/_update/.yml +73 -0
  55. data/spec/cassettes/RedboothRuby_Note/_update/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_note.yml +73 -0
  56. data/spec/cassettes/RedboothRuby_Subtask/_create/.yml +47 -0
  57. data/spec/cassettes/RedboothRuby_Subtask/_create/makes_a_new_POST_request_using_the_correct_API_endpoint_to_create_a_specific_subtask.yml +47 -0
  58. data/spec/cassettes/RedboothRuby_Subtask/_delete/makes_a_new_DELETE_request_using_the_correct_API_endpoint_to_delete_a_specific_subtask.yml +84 -0
  59. data/spec/cassettes/RedboothRuby_Subtask/_index/.yml +99 -0
  60. data/spec/cassettes/RedboothRuby_Subtask/_index/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_subtasks_collection.yml +99 -0
  61. data/spec/cassettes/RedboothRuby_Subtask/_initialize/.yml +45 -0
  62. data/spec/cassettes/RedboothRuby_Subtask/_show/.yml +45 -0
  63. data/spec/cassettes/RedboothRuby_Subtask/_show/makes_a_new_GET_request_using_the_correct_API_endpoint_to_receive_a_specific_subtask.yml +45 -0
  64. data/spec/cassettes/RedboothRuby_Subtask/_update/.yml +47 -0
  65. data/spec/cassettes/RedboothRuby_Subtask/_update/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_subtask.yml +47 -0
  66. data/spec/cassettes/RedboothRuby_Task/_medatada/.yml +88 -0
  67. data/spec/cassettes/RedboothRuby_Task/_medatada/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_task.yml +88 -0
  68. data/spec/cassettes/RedboothRuby_Task/_medatada_/.yml +90 -0
  69. data/spec/cassettes/RedboothRuby_Task/_medatada_/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_task.yml +90 -0
  70. data/spec/cassettes/RedboothRuby_Task/_metadata_merge/.yml +133 -0
  71. data/spec/cassettes/RedboothRuby_Task/_metadata_merge/makes_a_new_PUT_request_using_the_correct_API_endpoint_to_receive_a_specific_task.yml +133 -0
  72. data/spec/redbooth-ruby/client_operations/metadata_spec.rb +24 -0
  73. data/spec/redbooth-ruby/client_operations/search_spec.rb +24 -0
  74. data/spec/redbooth-ruby/comment_spec.rb +87 -0
  75. data/spec/redbooth-ruby/file_spec.rb +89 -0
  76. data/spec/redbooth-ruby/note_spec.rb +84 -0
  77. data/spec/redbooth-ruby/subtaks_spec.rb +83 -0
  78. data/spec/redbooth-ruby/task_spec.rb +41 -0
  79. data/spec/spec_helper.rb +2 -0
  80. metadata +134 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c965740525e418665ebed6cdfc26ab17a67fb5e
4
- data.tar.gz: 76bd8e60f6b972b540b23feb613e7e1cb2241544
3
+ metadata.gz: 23c2045bfaa9ab724e5588d13d6c9b835bc75c18
4
+ data.tar.gz: ed38bcf8112e36647ca0dfd09146b1e6f049acf9
5
5
  SHA512:
6
- metadata.gz: 6280ee42271771c0c17d57107084382b841f14e44976426b62eb7da0964214eb4ab8dd42bb3b90d743bd807bfa65218e4b809e217cce5f71acedb4e0303ccfe5
7
- data.tar.gz: 46075bd7b3d79e78762958021e89d38363fb1be2d7a73c94ac7dad71dceaa3e8a1f35f30555aa5ede4bbcb1abd3fce359ce00798df7eca1a29db4b6617c96583
6
+ metadata.gz: e5d57329c98c5827134cca570c2b1dbce3244f5351a0c56e0c678a311def93e91b0bda6119a17b829b9d9524db2119b0d7be4c84a2085673cf3991b1382b8d81
7
+ data.tar.gz: 9f3f2cbff122c1e8d796bbf156520fd6d1591b4c267da527c754e49ed4003f1097c777c1aa9bef5a2d6f1e465946c49a733103b2da3b2d16b06f6cfee194a4e3
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://magnum.travis-ci.com/teambox/redbooth-ruby.svg?token=DytWKainUGNzXxdrekWH&branch=feature/tasks)](https://magnum.travis-ci.com/teambox/redbooth-ruby) [![Code Climate](https://codeclimate.com/repos/5461c4f6e30ba075bc0a0ab0/badges/11031f420440e8a9f525/gpa.svg)](https://codeclimate.com/repos/5461c4f6e30ba075bc0a0ab0/feed) [![Test Coverage](https://codeclimate.com/repos/5461c4f6e30ba075bc0a0ab0/badges/11031f420440e8a9f525/coverage.svg)](https://codeclimate.com/repos/5461c4f6e30ba075bc0a0ab0/feed) [![Inline docs](http://inch-ci.org/github/teambox/redbooth-ruby.svg?branch=master)](http://inch-ci.org/github/teambox/redbooth-ruby)
1
+ [![Build Status](https://travis-ci.org/teambox/redbooth-ruby.svg?branch=master)](https://travis-ci.org/teambox/redbooth-ruby) [![Code Climate](https://codeclimate.com/repos/5461c4f6e30ba075bc0a0ab0/badges/11031f420440e8a9f525/gpa.svg)](https://codeclimate.com/repos/5461c4f6e30ba075bc0a0ab0/feed) [![Test Coverage](https://codeclimate.com/repos/5461c4f6e30ba075bc0a0ab0/badges/11031f420440e8a9f525/coverage.svg)](https://codeclimate.com/repos/5461c4f6e30ba075bc0a0ab0/feed) [![Inline docs](http://inch-ci.org/github/teambox/redbooth-ruby.svg?branch=master)](http://inch-ci.org/github/teambox/redbooth-ruby)
2
2
 
3
3
  Redbooth-Ruby
4
4
  ======
@@ -160,7 +160,7 @@ List users in your network
160
160
  users = users_collection.all
161
161
  ```
162
162
 
163
- Fetch a especific user
163
+ Fetch a specific user
164
164
 
165
165
  ```Ruby
166
166
  user = client.user(:show, id: 123)
@@ -184,19 +184,19 @@ You can also filter by multiple params (see docs [here](https://redbooth.com/api
184
184
  project_id: 123)
185
185
  ```
186
186
 
187
- Fetch a especific task
187
+ Fetch a specific task
188
188
 
189
189
  ```Ruby
190
190
  task = client.task(:show, id: 123)
191
191
  ```
192
192
 
193
- Update a especific task
193
+ Update a specific task
194
194
 
195
195
  ```Ruby
196
196
  task = client.task(:update, id: 123, name: 'new name')
197
197
  ```
198
198
 
199
- Delete a especific task
199
+ Delete a specific task
200
200
 
201
201
  ```Ruby
202
202
  client.task(:delete, id: 123)
@@ -219,7 +219,7 @@ You can also filter by multiple params (see docs [here](https://redbooth.com/api
219
219
  per_page: 50)
220
220
  ```
221
221
 
222
- Fetch a especific organization
222
+ Fetch a specific organization
223
223
 
224
224
  ```Ruby
225
225
  organization = client.organization(:show, id: 123)
@@ -231,13 +231,13 @@ Create a organization
231
231
  organization = client.organization(:create, name: 'New Organization')
232
232
  ```
233
233
 
234
- Update a especific organization
234
+ Update a specific organization
235
235
 
236
236
  ```Ruby
237
237
  organization = client.organization(:update, id: 123, name: 'new name')
238
238
  ```
239
239
 
240
- Delete a especific organization
240
+ Delete a specific organization
241
241
 
242
242
  ```Ruby
243
243
  client.organization(:delete, id: 123)
@@ -260,7 +260,7 @@ You can also filter by multiple params (see docs [here](https://redbooth.com/api
260
260
  per_page: 50)
261
261
  ```
262
262
 
263
- Fetch a especific project
263
+ Fetch a specific project
264
264
 
265
265
  ```Ruby
266
266
  project = client.project(:show, id: 123)
@@ -272,13 +272,13 @@ Create a project
272
272
  project = client.project(:create, name: 'New Project')
273
273
  ```
274
274
 
275
- Update a especific project
275
+ Update a specific project
276
276
 
277
277
  ```Ruby
278
278
  project = client.project(:update, id: 123, name: 'new name')
279
279
  ```
280
280
 
281
- Delete a especific project
281
+ Delete a specific project
282
282
 
283
283
  ```Ruby
284
284
  client.project(:delete, id: 123)
@@ -312,7 +312,7 @@ You can also filter by multiple params (see docs [here](https://redbooth.com/api
312
312
  per_page: 50)
313
313
  ```
314
314
 
315
- Fetch a especific person
315
+ Fetch a specific person
316
316
 
317
317
  ```Ruby
318
318
  people = client.person(:show, id: 123)
@@ -324,13 +324,13 @@ Create a person
324
324
  person = client.person(:create, project_id: 123, user_id: 123, role: 'participant')
325
325
  ```
326
326
 
327
- Update a especific person
327
+ Update a specific person
328
328
 
329
329
  ```Ruby
330
330
  person = client.person(:update, id: 123, role: 'admin')
331
331
  ```
332
332
 
333
- Delete a especific person
333
+ Delete a specific person
334
334
 
335
335
  ```Ruby
336
336
  client.person(:delete, id: 123)
@@ -363,7 +363,7 @@ You can also filter by multiple params (see docs [here](https://redbooth.com/api
363
363
  per_page: 50)
364
364
  ```
365
365
 
366
- Fetch a especific membership
366
+ Fetch a specific membership
367
367
 
368
368
  ```Ruby
369
369
  memberships = client.membership(:show, id: 123)
@@ -375,13 +375,13 @@ Create a membership
375
375
  membership = client.membership(:create, organization_id: 123, user_id: 123, role: 'participant')
376
376
  ```
377
377
 
378
- Update a especific membership
378
+ Update a specific membership
379
379
 
380
380
  ```Ruby
381
381
  membership = client.membership(:update, id: 123, role: 'admin')
382
382
  ```
383
383
 
384
- Delete a especific membership
384
+ Delete a specific membership
385
385
 
386
386
  ```Ruby
387
387
  client.membership(:delete, id: 123)
@@ -405,24 +405,241 @@ You can also filter by multiple params (see docs [here](https://redbooth.com/api
405
405
  project_id: 123)
406
406
  ```
407
407
 
408
- Fetch a especific conversation
408
+ Fetch a specific conversation
409
409
 
410
410
  ```Ruby
411
411
  conversation = client.conversation(:show, id: 123)
412
412
  ```
413
413
 
414
- Update a especific conversation
414
+ Update a specific conversation
415
415
 
416
416
  ```Ruby
417
417
  conversation = client.conversation(:update, id: 123, name: 'new name')
418
418
  ```
419
419
 
420
- Delete a especific conversation
420
+ Delete a specific conversation
421
421
 
422
422
  ```Ruby
423
423
  client.conversation(:delete, id: 123)
424
424
  ```
425
425
 
426
+ Comments
427
+ =====
428
+
429
+ Comments are the redbooth resources containing the `Task` and `Conversation` Content.
430
+ It also contains the information about the task status changes, assigned changes and due_data changes.
431
+
432
+ To consume the comments endpoint you allways need to provide a `target_type` and `target_id`. This is needed for performance reasons.
433
+
434
+ Lists comments in your visibility scope
435
+
436
+ ```Ruby
437
+ comment_collection = client.comment(:index, target_type: 'task', target_id: 123)
438
+ comments = comment_collection.all
439
+ ```
440
+
441
+ You can also filter by multiple params (see docs [here](https://redbooth.com/api/api-docs/#page:comments,header:comments-commnets-list) )
442
+
443
+ ```Ruby
444
+ filtered_comments = client.comment(:index, order: 'id-DESC',
445
+ per_page: 50,
446
+ project_id: 123,
447
+ target_type: 'task',
448
+ target_id: 123)
449
+ ```
450
+
451
+ Fetch a specific comment
452
+
453
+ ```Ruby
454
+ comment = client.comment(:show, id: 123)
455
+ ```
456
+
457
+ Update a specific comment
458
+
459
+ ```Ruby
460
+ comment = client.comment(:update, id: 123, body: 'new body content')
461
+ ```
462
+
463
+ Delete a specific comment
464
+
465
+ ```Ruby
466
+ client.comment(:delete, id: 123)
467
+ ```
468
+
469
+ Notes
470
+ =====
471
+
472
+ Lists notes in your visibility scope
473
+
474
+ ```Ruby
475
+ notes_collection = client.note(:index)
476
+ notes = notes_collection.all
477
+ ```
478
+
479
+ You can also filter by multiple params (see docs [here](https://redbooth.com/api/api-docs/#page:notes,header:notes-notes-list) )
480
+
481
+ ```Ruby
482
+ filtered_notes = client.note(:index, order: 'id-DESC',
483
+ per_page: 50,
484
+ project_id: 123)
485
+ ```
486
+
487
+ Fetch a specific note
488
+
489
+ ```Ruby
490
+ note = client.note(:show, id: 123)
491
+ ```
492
+
493
+ Update a specific note
494
+
495
+ ```Ruby
496
+ note = client.note(:update, id: 123, name: 'new name')
497
+ ```
498
+
499
+ Delete a specific note
500
+
501
+ ```Ruby
502
+ client.note(:delete, id: 123)
503
+ ```
504
+
505
+ Subtasks
506
+ =====
507
+
508
+ Subtasks are little sentences under a task that could de resolved or not.
509
+
510
+ Lists subtasks in your visibility scope. Needs a task_id
511
+
512
+ ```Ruby
513
+ subtask_collection = client.subtask(:index, task_id: 123)
514
+ subtasks = subtask_collection.all
515
+ ```
516
+
517
+ You can also filter by multiple params (see docs [here](https://redbooth.com/api/api-docs/#page:subtasks,header:subtasks-subtasks-list) )
518
+
519
+ ```Ruby
520
+ filtered_subtasks = client.subtask(:index, task_id: 123,
521
+ order: 'id-DESC',
522
+ per_page: 50)
523
+ ```
524
+
525
+ Fetch a specific subtask
526
+
527
+ ```Ruby
528
+ subtask = client.subtask(:show, id: 123)
529
+ ```
530
+
531
+ Create a new subtask
532
+
533
+ ```Ruby
534
+ subtask = client.subtask(:create, task_id: 123, name: 'new name')
535
+ ```
536
+
537
+ Update a specific subtask
538
+
539
+ ```Ruby
540
+ subtask = client.subtask(:update, id: 123, name: 'new name')
541
+ ```
542
+
543
+ Delete a specific subtask
544
+
545
+ ```Ruby
546
+ client.subtask(:delete, id: 123)
547
+ ```
548
+
549
+ Files
550
+ =====
551
+
552
+ Files in redbooth could be uploaded or choosen form other service providers (Copy, Dropbox, Gdrive, Box, Signnow, ...). This client allows you to browse or create files in redbooth api.
553
+
554
+ Lists files in your visibility scope.
555
+
556
+ ```Ruby
557
+ files_colilection = client.file(:index)
558
+ files = files_collection.all
559
+ ```
560
+
561
+ You can also filter by multiple params (see docs [here](https://redbooth.com/api/api-docs/#page:subtasks,header:subtasks-subtasks-list) )
562
+
563
+ ```Ruby
564
+ filtered_files_collection = client.file(:index, backend: 'redbooth',
565
+ project_id: 123,
566
+ order: 'id-DESC',
567
+ per_page: 25)
568
+ ```
569
+
570
+ Update a specific file
571
+
572
+ ```Ruby
573
+ file = client.file(:update, id: 123, name: 'new_name.doc')
574
+ ```
575
+
576
+ Create a new file
577
+
578
+ ```Ruby
579
+ file = File.open('path/to/the/file')
580
+ new_file = client.file(:create, project_id: 123,
581
+ parent_id: nil,
582
+ backend: 'redbooth',
583
+ is_dir: false,
584
+ asset: file )
585
+ ```
586
+
587
+ Delete a specific subtask
588
+
589
+ ```Ruby
590
+ client.file(:delete, id: 123)
591
+ ```
592
+
593
+ Search
594
+ =====
595
+
596
+ You can search throught any redbooth entity by using the search method. There is some filter params available:
597
+
598
+ * `query`: Regex like query to search
599
+
600
+ * `project_id`: Reduce the scope to search for
601
+
602
+ * `target_type`: List of entity types to be returned
603
+
604
+
605
+ Search for redbooth objects in your visibility scope
606
+
607
+ ```Ruby
608
+ entities = client.search(query: 'task+nothing*')
609
+ ```
610
+
611
+ Metadata
612
+ =====
613
+
614
+ ADVISE: Redbooth metadata API is in `Beta` status so use this under your own risk.
615
+
616
+ Metadata API allows you to add custo key value attributes to objects inside redbooth and search by those key value attributes.
617
+ This is really helpful when doing API syncs or tiny implementations in top of the Redbooth API.
618
+
619
+ Fetch object metadata
620
+
621
+ ```Ruby
622
+ task.metadata
623
+ ```
624
+
625
+ Update object metadata by adding new keys or overwriding the exisiting ones but not touching the others if there is any one.
626
+
627
+ ```Ruby
628
+ task.metadata_merge("new_key" => "new value")
629
+ ```
630
+
631
+ Restore user metadata by overwiritng the existing ones.
632
+
633
+ ```Ruby
634
+ task.metadata = {"key" => "value"}
635
+ ```
636
+
637
+ Search for a certain metadata key value
638
+
639
+ ```Ruby
640
+ metadata_collection = client.metadata(key: 'key', value: 'value', target_type: 'Task')
641
+ ```
642
+
426
643
  License
427
644
  =====
428
645
 
data/lib/redbooth-ruby.rb CHANGED
@@ -20,6 +20,11 @@ module RedboothRuby
20
20
  autoload :Project, 'redbooth-ruby/project'
21
21
  autoload :Conversation, 'redbooth-ruby/conversation'
22
22
  autoload :Membership, 'redbooth-ruby/membership'
23
+ autoload :Comment, 'redbooth-ruby/comment'
24
+ autoload :Note, 'redbooth-ruby/note'
25
+ autoload :Subtask, 'redbooth-ruby/subtask'
26
+ autoload :File, 'redbooth-ruby/file'
27
+
23
28
 
24
29
  module Operations
25
30
  autoload :Base, 'redbooth-ruby/operations/base'
@@ -41,6 +46,11 @@ module RedboothRuby
41
46
  autoload :Collection, 'redbooth-ruby/request/collection'
42
47
  end
43
48
 
49
+ module ClientOperations
50
+ autoload :Search, 'redbooth-ruby/client_operations/search'
51
+ autoload :Metadata, 'redbooth-ruby/client_operations/metadata'
52
+ end
53
+
44
54
  class RedboothError < StandardError; end
45
55
  class AuthenticationError < RedboothError; end
46
56
  class OauhtTokenExpired < AuthenticationError; end
@@ -2,7 +2,7 @@ module RedboothRuby
2
2
  class Base
3
3
  include RedboothRuby::Operations::Base
4
4
 
5
- attr_accessor :created_time
5
+ attr_accessor :created_time, :session
6
6
 
7
7
  # Initializes the object using the given attributes
8
8
  #
@@ -1,13 +1,20 @@
1
1
  module RedboothRuby
2
2
  class Client
3
- RESOURCES = [:me, :user, :task, :organization, :person, :project, :conversation, :membership]
3
+ include RedboothRuby::ClientOperations::Search
4
+ include RedboothRuby::ClientOperations::Metadata
5
+
6
+ RESOURCES = [ :me, :user, :task, :organization, :person, :project,
7
+ :conversation, :membership, :comment, :note, :subtask,
8
+ :file ]
4
9
 
5
10
  attr_reader :session, :options
6
11
 
7
12
  # Creates an client object using the given Redbooth session.
8
13
  # existing account.
9
14
  #
10
- # @param [String] client object to use the redbooth api.
15
+ # @param session [Redbooth::Session] redbooth session object with the correct authorization
16
+ # @param options [Hash] client options
17
+ # @option options [Proc] retry (the client will handle) Retry block to be executed when client hits an async endpoint
11
18
  def initialize(session, options={})
12
19
  raise RedboothRuby::AuthenticationError unless session.valid?
13
20
  @session = session
@@ -0,0 +1,32 @@
1
+ module RedboothRuby
2
+ module ClientOperations
3
+ module Metadata
4
+
5
+ # Retrieves all available objects from the Redbooth API by searching by given
6
+ # key and value into the metadata API
7
+ #
8
+ # @param [Hash] options Options to pass to the API
9
+ # @return [Array] The available objects
10
+ def metadata(attributes = {})
11
+ response = RedboothRuby.request(:get, nil, 'metadata/search' , attributes, { session: session })
12
+ collection_from attributes, response, session
13
+ end
14
+
15
+ private
16
+
17
+ # Creates a collection object from the request and response params
18
+ #
19
+ # @param params [Hash] given request params
20
+ # @param response [RedboothRuby::Request::Response] response object
21
+ # @param session [RedboothRuby::Session] session Object
22
+ # @return [RedboothRuby::Request::Collection]
23
+ def collection_from(params, response, session)
24
+ RedboothRuby::Request::Collection.new(response: response,
25
+ resource: self,
26
+ session: session,
27
+ params: params,
28
+ method: :metadata)
29
+ end
30
+ end
31
+ end
32
+ end