teamlab 0.2.2 → 0.3.1

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.
@@ -51,8 +51,8 @@ module Teamlab
51
51
  @request.post([calendar_id.to_s, 'event'], {name: name}.merge(options))
52
52
  end
53
53
 
54
- def import_ical(calendar_id, *files)
55
- @request.post([calendar_id.to_s, 'import'], files: files.flatten)
54
+ def import_ical(calendar_id, file)
55
+ @request.post([calendar_id.to_s, 'import'], somefile: File.new(file))
56
56
  end
57
57
 
58
58
  #============== TODO: OPTIONAL VARIABLES
@@ -214,10 +214,8 @@ module Teamlab
214
214
  @request.post(%w(wiki), {name: name.to_s, body: body.to_s})
215
215
  end
216
216
 
217
- #================================== TODO: UPLOAD FILES ================================
218
-
219
- def upload_files(*files)
220
- @request.post(%w(wiki file), files)
217
+ def upload_files(file)
218
+ @request.post(%w(wiki file), somefile: File.new(file))
221
219
  end
222
220
 
223
221
  def create_wiki_page_comment(page_name, content, options = {})
@@ -577,10 +577,8 @@ module Teamlab
577
577
  @request.post([entity_type.to_s, entity_id.to_s, 'files', 'text'], title: title, content: content)
578
578
  end
579
579
 
580
- #================================== TODO: UPLOAD FILES ================================
581
-
582
- def upload_file(entity_type, entity_id, *files)
583
- @request.post([entity_type.to_s, entity_id.to_s, 'files', 'upload'], files)
580
+ def upload_file(entity_type, entity_id, file)
581
+ @request.post([entity_type.to_s, entity_id.to_s, 'files', 'upload'], somefile: File.new(file))
584
582
  end
585
583
 
586
584
  def delete_file(id)
@@ -45,44 +45,36 @@ module Teamlab
45
45
  @request.put([file_id.to_s, 'sharedlink'], share: share)
46
46
  end
47
47
 
48
- #================================== TODO: UPLOAD FILES ================================
49
-
50
- def upload_to_my_docs(*files)
51
- @request.post(['@my', 'upload'], files, headers: { 'Content-Type' => 'multipart/form-data' } ) #НЕ МАТАТ
48
+ def upload_to_my_docs(file)
49
+ @request.post(%w(@my upload), somefile: File.new(file))
52
50
  end
53
51
 
54
- #================================== TODO: UPLOAD FILES ================================
55
-
56
- def upload_to_common_docs(*files)
57
- @request.post(['@common', 'upload'], files, headers: { 'Content-Type' => 'multipart/form-data' } ) #НЕ МАТАТ
52
+ def upload_to_common_docs(file)
53
+ @request.post(%w(@common upload), somefile: File.new(file))
58
54
  end
59
55
 
60
- #================================== TODO: UPLOAD FILES ================================
61
-
62
- def upload_to_folder(folder_id, *files)
63
- @request.post([folder_id.to_s, 'upload'], files, headers: { 'Content-Type' => 'multipart/form-data' } ) #НЕ МАТАТ
56
+ def upload_to_folder(folder_id, file)
57
+ @request.post([folder_id.to_s, 'upload'], somefile: File.new(file))
64
58
  end
65
59
 
66
- #================================== TODO: UPLOAD FILES ================================
67
-
68
60
  def chunked_upload(folder_id, filename, file_size)
69
- @request.post([folder_id.to_s, 'upload', 'create_session'], fileName: filename, fileSize: file_size) #НЕ МАТАТ
61
+ @request.post([folder_id.to_s, 'upload', 'create_session'], fileName: filename, fileSize: file_size)
70
62
  end
71
63
 
72
64
  def create_txt_in_my_docs(title, content)
73
- @request.post(['@my', 'text'], title: title.to_s, content: content.to_s)
65
+ @request.post(%w(@my text), title: title.to_s, content: content.to_s)
74
66
  end
75
67
 
76
68
  def create_html_in_my_docs(title, content)
77
- @request.post(['@my', 'html'], title: title.to_s, content: content.to_s)
69
+ @request.post(%w(@my html), title: title.to_s, content: content.to_s)
78
70
  end
79
71
 
80
72
  def create_txt_in_common_docs(title, content)
81
- @request.post(['@common', 'text'], title: title.to_s, content: content.to_s)
73
+ @request.post(%w(@common text), title: title.to_s, content: content.to_s)
82
74
  end
83
75
 
84
76
  def create_html_in_common_docs(title, content)
85
- @request.post(['@common', 'html'], title: title.to_s, content: content.to_s)
77
+ @request.post(%w(common html), title: title.to_s, content: content.to_s)
86
78
  end
87
79
 
88
80
  def create_txt(folder_id, title, content)
@@ -36,7 +36,7 @@ module Teamlab
36
36
  url = generate_request_url(command)
37
37
  attempts = 0
38
38
  begin
39
- response = Teamlab::Response.new(HTTParty.send(type, url, opts))
39
+ response = Teamlab::Response.new(HTTMultiParty.send(type, url, opts))
40
40
  rescue TimeoutError
41
41
  attempts += 1
42
42
  retry if attempts < 3
@@ -56,10 +56,12 @@ module Teamlab
56
56
  command = args.first.instance_of?(Array) ? '/' + args.shift.join('/') : args.shift.to_s
57
57
  opts = {}
58
58
  opts[:body] = args.last.instance_of?(Hash) ? args.pop : {}
59
- opts[:headers] = opts[:body][:headers] ? Teamlab.config.headers.merge(opts[:body].delete(:headers)) : Teamlab.config.headers
60
- opts[:query] = opts.delete(:body) if opts[:body].key?(:somefile)
59
+ opts[:headers] = Teamlab.config.headers
60
+ if opts[:body].key?(:somefile)
61
+ opts[:query] = opts.delete(:body)
62
+ opts[:detect_mime_type] = true
63
+ end
61
64
  [command, opts]
62
65
  end
63
-
64
66
  end
65
67
  end
@@ -1,3 +1,3 @@
1
1
  module Teamlab
2
- VERSION = '0.2.2'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -41,6 +41,72 @@ describe Teamlab do
41
41
  end
42
42
  end
43
43
 
44
+ describe 'Preparing enviroment' do
45
+ describe '#add_user' do
46
+ it_should_behave_like 'an api request' do
47
+ let(:teamlab_module) { :people }
48
+ let(:command) { :add_user }
49
+ let(:args) { [false, random_email, random_word.capitalize, random_word.capitalize] }
50
+ let(:add_data_to_collector) { true }
51
+ let(:data_param) { :user_ids }
52
+ let(:param_names) { %w(id) }
53
+ end
54
+ end
55
+
56
+ describe '#get_self' do
57
+ it_should_behave_like 'an api request' do
58
+ let(:teamlab_module) { :people }
59
+ let(:command) { :get_self }
60
+ let(:add_data_to_collector) { true }
61
+ let(:data_param) { :self_username }
62
+ let(:param_names) { %w(userName) }
63
+ end
64
+ end
65
+
66
+ describe '#get_my_files' do
67
+ it_should_behave_like 'an api request' do
68
+ let(:teamlab_module) { :files }
69
+ let(:command) { :get_my_files }
70
+ let(:add_data_to_collector) { true }
71
+ let(:data_param) { :my_documents_ids }
72
+ let(:param_names) { %w(current id) }
73
+ end
74
+ end
75
+
76
+ describe '#create_file' do
77
+ it_should_behave_like 'an api request' do
78
+ let(:teamlab_module) { :files }
79
+ let(:command) { :create_file }
80
+ let(:args) { [random_id(:my_documents), random_word] }
81
+ let(:add_data_to_collector) { true }
82
+ let(:data_param) { :file_ids }
83
+ let(:param_names) { %w(id) }
84
+ end
85
+ end
86
+
87
+ describe '#create_person' do
88
+ it_should_behave_like 'an api request' do
89
+ let(:teamlab_module) { :crm }
90
+ let(:command) { :create_person }
91
+ let(:args) { [random_word.capitalize, random_word.capitalize] }
92
+ let(:add_data_to_collector) { true }
93
+ let(:data_param) { :contact_ids }
94
+ let(:param_names) { %w(id) }
95
+ end
96
+ end
97
+
98
+ describe '#create_project' do
99
+ it_should_behave_like 'an api request' do
100
+ let(:teamlab_module) { :project }
101
+ let(:command) { :create_project }
102
+ let(:args) { [random_word, random_word, random_id(:user), random_word(3), random_bool] }
103
+ let(:add_data_to_collector) { true }
104
+ let(:data_param) { :project_ids }
105
+ let(:param_names) { %w(id) }
106
+ end
107
+ end
108
+ end
109
+
44
110
  describe '[People]' do
45
111
  let(:teamlab_module) { :people }
46
112
 
@@ -450,41 +516,38 @@ describe Teamlab do
450
516
  end
451
517
  end
452
518
 
453
- #describe '#upload_to_my_docs' do
454
- # it_should_behave_like 'an api request' do
455
- # let(:command) { :upload_to_my_docs }
456
- # let(:args) { FILE_TO_UPLOAD }
457
- # end
458
- #end
459
- #
460
- #describe '#upload_to_common_docs' do
461
- # it_should_behave_like 'an api request' do
462
- # let(:command) { :upload_to_common_docs }
463
- # let(:args) { FILE_TO_UPLOAD }
464
- # end
465
- #end
466
- #
467
- #describe '#upload_to_folder' do
468
- # it_should_behave_like 'an api request' do
469
- # let(:command) { :upload_to_folder }
470
- # let(:args) { [random_id(:new_folder), FILE_TO_UPLOAD] }
471
- # end
472
- #end
473
- #
474
- #describe '#chunked_upload' do
475
- # it_should_behave_like 'an api request' do
476
- # let(:command) { :chunked_upload }
477
- # let(:args) { [random_id(:new_folder), FILE_TO_UPLOAD] }
478
- # end
479
- #end
519
+ describe '#upload_to_my_docs' do
520
+ it_should_behave_like 'an api request' do
521
+ let(:command) { :upload_to_my_docs }
522
+ let(:args) { FILES_FOR_UPLOAD.sample }
523
+ end
524
+ end
525
+
526
+ describe '#upload_to_common_docs' do
527
+ it_should_behave_like 'an api request' do
528
+ let(:command) { :upload_to_common_docs }
529
+ let(:args) { FILES_FOR_UPLOAD.sample }
530
+ end
531
+ end
532
+
533
+ describe '#upload_to_folder' do
534
+ it_should_behave_like 'an api request' do
535
+ let(:command) { :upload_to_folder }
536
+ let(:args) { [random_id(:new_folder), FILES_FOR_UPLOAD.sample] }
537
+ end
538
+ end
539
+
540
+ describe '#chunked_upload' do
541
+ it_should_behave_like 'an api request' do
542
+ let(:command) { :chunked_upload }
543
+ let(:args) { [random_id(:new_folder), File.basename(FILES_FOR_UPLOAD.sample), rand(1..50)] }
544
+ end
545
+ end
480
546
 
481
547
  describe '#create_txt_in_my_docs' do
482
548
  it_should_behave_like 'an api request' do
483
549
  let(:command) { :create_txt_in_my_docs }
484
550
  let(:args) { [random_word, random_word(rand(100))] }
485
- #let(:add_data_to_collector) { true }
486
- #let(:data_param) {:some_file_ids}
487
- #let(:param_names) {%w(current id)}
488
551
  end
489
552
  end
490
553
 
@@ -492,9 +555,6 @@ describe Teamlab do
492
555
  it_should_behave_like 'an api request' do
493
556
  let(:command) { :create_html_in_my_docs }
494
557
  let(:args) { [random_word, random_word(rand(100))] }
495
- #let(:add_data_to_collector) { true }
496
- #let(:data_param) {:some_file_ids}
497
- #let(:param_names) {%w(current id)}
498
558
  end
499
559
  end
500
560
 
@@ -502,9 +562,6 @@ describe Teamlab do
502
562
  it_should_behave_like 'an api request' do
503
563
  let(:command) { :create_txt_in_common_docs }
504
564
  let(:args) { [random_word, random_word(rand(100))] }
505
- #let(:add_data_to_collector) { true }
506
- #let(:data_param) {:some_file_ids}
507
- #let(:param_names) {%w(current id)}
508
565
  end
509
566
  end
510
567
 
@@ -512,9 +569,6 @@ describe Teamlab do
512
569
  it_should_behave_like 'an api request' do
513
570
  let(:command) { :create_html_in_common_docs }
514
571
  let(:args) { [random_word, random_word(rand(100))] }
515
- #let(:add_data_to_collector) { true }
516
- #let(:data_param) {:some_file_ids}
517
- #let(:param_names) {%w(current id)}
518
572
  end
519
573
  end
520
574
 
@@ -522,9 +576,6 @@ describe Teamlab do
522
576
  it_should_behave_like 'an api request' do
523
577
  let(:command) { :create_txt }
524
578
  let(:args) { [random_id(:new_folder), random_word, random_word(rand(100))] }
525
- #let(:add_data_to_collector) { true }
526
- #let(:data_param) {:some_file_ids}
527
- #let(:param_names) {%w(current id)}
528
579
  end
529
580
  end
530
581
 
@@ -532,9 +583,6 @@ describe Teamlab do
532
583
  it_should_behave_like 'an api request' do
533
584
  let(:command) { :create_html }
534
585
  let(:args) { [random_id(:new_folder), random_word, random_word(rand(100))] }
535
- #let(:add_data_to_collector) { true }
536
- #let(:data_param) {:some_file_ids}
537
- #let(:param_names) {%w(current id)}
538
586
  end
539
587
  end
540
588
 
@@ -2382,12 +2430,12 @@ describe Teamlab do
2382
2430
  end
2383
2431
  end
2384
2432
 
2385
- #describe '#upload_file' do
2386
- # it_should_behave_like 'an api request' do
2387
- # let(:command) { :upload_file }
2388
- # let(:args) { [entity = ENTITY_TYPES.sample, random_id(entity.to_sym), 'files'] }
2389
- # end
2390
- #end
2433
+ describe '#upload_file' do
2434
+ it_should_behave_like 'an api request' do
2435
+ let(:command) { :upload_file }
2436
+ let(:args) { [entity = ENTITY_TYPES.sample, random_id(entity.to_sym), FILES_FOR_UPLOAD.sample] }
2437
+ end
2438
+ end
2391
2439
 
2392
2440
  describe '#create_tag' do
2393
2441
  it_should_behave_like 'an api request' do
@@ -3442,7 +3490,6 @@ describe Teamlab do
3442
3490
 
3443
3491
  describe '#import_ical' do
3444
3492
  it_should_behave_like 'an api request' do
3445
- pending 'Upload File'
3446
3493
  let(:command) { :import_ical }
3447
3494
  let(:args) { [random_id(:calendar), CALENDAR_TO_UPLOAD] }
3448
3495
  end
@@ -3510,72 +3557,6 @@ describe Teamlab do
3510
3557
 
3511
3558
  describe '[Mail]' do
3512
3559
 
3513
- describe 'Preparing enviroment' do
3514
- describe '#add_user' do
3515
- it_should_behave_like 'an api request' do
3516
- let(:teamlab_module) { :people }
3517
- let(:command) { :add_user }
3518
- let(:args) { [false, random_email, random_word.capitalize, random_word.capitalize] }
3519
- let(:add_data_to_collector) { true }
3520
- let(:data_param) { :user_ids }
3521
- let(:param_names) { %w(id) }
3522
- end
3523
- end
3524
-
3525
- describe '#get_self' do
3526
- it_should_behave_like 'an api request' do
3527
- let(:teamlab_module) { :people }
3528
- let(:command) { :get_self }
3529
- let(:add_data_to_collector) { true }
3530
- let(:data_param) { :self_username }
3531
- let(:param_names) { %w(userName) }
3532
- end
3533
- end
3534
-
3535
- describe '#get_my_files' do
3536
- it_should_behave_like 'an api request' do
3537
- let(:teamlab_module) { :files }
3538
- let(:command) { :get_my_files }
3539
- let(:add_data_to_collector) { true }
3540
- let(:data_param) { :my_documents_ids }
3541
- let(:param_names) { %w(current id) }
3542
- end
3543
- end
3544
-
3545
- describe '#create_file' do
3546
- it_should_behave_like 'an api request' do
3547
- let(:teamlab_module) { :files }
3548
- let(:command) { :create_file }
3549
- let(:args) { [random_id(:my_documents), random_word] }
3550
- let(:add_data_to_collector) { true }
3551
- let(:data_param) { :file_ids }
3552
- let(:param_names) { %w(id) }
3553
- end
3554
- end
3555
-
3556
- describe '#create_person' do
3557
- it_should_behave_like 'an api request' do
3558
- let(:teamlab_module) { :crm }
3559
- let(:command) { :create_person }
3560
- let(:args) { [random_word.capitalize, random_word.capitalize] }
3561
- let(:add_data_to_collector) { true }
3562
- let(:data_param) { :contact_ids }
3563
- let(:param_names) { %w(id) }
3564
- end
3565
- end
3566
-
3567
- describe '#create_project' do
3568
- it_should_behave_like 'an api request' do
3569
- let(:teamlab_module) { :project }
3570
- let(:command) { :create_project }
3571
- let(:args) { [random_word, random_word, random_id(:user), random_word(3), random_bool] }
3572
- let(:add_data_to_collector) { true }
3573
- let(:data_param) { :project_ids }
3574
- let(:param_names) { %w(id) }
3575
- end
3576
- end
3577
- end
3578
-
3579
3560
  let(:teamlab_module) { :mail }
3580
3561
 
3581
3562
  describe '#create_tag' do
@@ -3637,39 +3618,39 @@ describe Teamlab do
3637
3618
  ########################################################################################################################
3638
3619
  ############################################### DELETING ###############################################################
3639
3620
  ########################################################################################################################
3621
+ end
3640
3622
 
3641
- describe 'Cleaning enviroment' do
3623
+ describe 'Cleaning enviroment' do
3642
3624
 
3643
- describe '#delete_file' do
3644
- it_should_behave_like 'an api request' do
3645
- let(:teamlab_module) { :files }
3646
- let(:command) { :delete_file }
3647
- let(:args) { [DATA_COLLECTOR[:file_ids].pop] }
3648
- end
3625
+ describe '#delete_file' do
3626
+ it_should_behave_like 'an api request' do
3627
+ let(:teamlab_module) { :files }
3628
+ let(:command) { :delete_file }
3629
+ let(:args) { [DATA_COLLECTOR[:file_ids].pop] }
3649
3630
  end
3631
+ end
3650
3632
 
3651
- describe '#delete_user' do
3652
- it_should_behave_like 'an api request' do
3653
- let(:teamlab_module) { :people }
3654
- let(:command) { :delete_user }
3655
- let(:args) { [DATA_COLLECTOR[:user_ids].pop] }
3656
- end
3633
+ describe '#delete_user' do
3634
+ it_should_behave_like 'an api request' do
3635
+ let(:teamlab_module) { :people }
3636
+ let(:command) { :delete_user }
3637
+ let(:args) { [DATA_COLLECTOR[:user_ids].pop] }
3657
3638
  end
3639
+ end
3658
3640
 
3659
- describe '#delete_contact' do
3660
- it_should_behave_like 'an api request' do
3661
- let(:teamlab_module) { :crm }
3662
- let(:command) { :delete_contact }
3663
- let(:args) { [DATA_COLLECTOR[:contact_ids].pop] }
3664
- end
3641
+ describe '#delete_contact' do
3642
+ it_should_behave_like 'an api request' do
3643
+ let(:teamlab_module) { :crm }
3644
+ let(:command) { :delete_contact }
3645
+ let(:args) { [DATA_COLLECTOR[:contact_ids].pop] }
3665
3646
  end
3647
+ end
3666
3648
 
3667
- describe '#delete_project' do
3668
- it_should_behave_like 'an api request' do
3669
- let(:teamlab_module) { :project }
3670
- let(:command) { :delete_project }
3671
- let(:args) { [DATA_COLLECTOR[:project_ids].pop] }
3672
- end
3649
+ describe '#delete_project' do
3650
+ it_should_behave_like 'an api request' do
3651
+ let(:teamlab_module) { :project }
3652
+ let(:command) { :delete_project }
3653
+ let(:args) { [DATA_COLLECTOR[:project_ids].pop] }
3673
3654
  end
3674
3655
  end
3675
3656
  end
@@ -59,6 +59,30 @@ SETTINGS_FOR_TALK = { enabled: true }
59
59
  #region Files
60
60
  FILE_FOR_OPERATIONS_VERSION = 1
61
61
  FILES_SHARE_TYPES = %w(None ReadWrite Read Restrict)
62
+ FILES_FOR_UPLOAD = %w(
63
+ /mnt/data_share/Files/DOCX/AllDOCX/InternationalFoodCrisisAutosaved.docx
64
+ /mnt/data_share/Files/DOCX/AllDOCX/dogs dont tell jokes bm.docx
65
+ /mnt/data_share/Files/DOCX/AllDOCX/Demo-Hayden-Management.docx
66
+ /mnt/data_share/Files/DOCX/AllDOCX/6 sınıf AAAAd.docx
67
+ /mnt/data_share/Files/DOCX/AllDOCX/2010-2011 alparlan i.ö.o. 4.sınıf ingilizce 1.dönem.1yazılı sınzva.docx
68
+ /mnt/data_share/Files/DOCX/AllDOCX/2.15.10TheEngagedUniversity.docx
69
+ /mnt/data_share/Files/XLSX/ICO_IMAGES.xlsx
70
+ /mnt/data_share/Files/XLSX/SmokeTopToolbar.xlsx
71
+ /mnt/data_share/Files/XLSX/Hasil TO GANAPATYA.xlsx
72
+ /mnt/data_share/Files/XLSX/FormulaDoc.xlsx
73
+ /mnt/data_share/Files/XLSX/EML_IMAGES.xlsx
74
+ /mnt/data_share/Files/PPTX/AllPPTX/Abiturientu_tolimesnis_mokymasis_2010.pptx
75
+ /mnt/data_share/Files/PPTX/AllPPTX/Disney Magic 5-D.pptx
76
+ /mnt/data_share/Files/PPTX/AllPPTX/Kutatasok_a_kozteruleten.pptx
77
+ /mnt/data_share/Files/PPTX/AllPPTX/oouchida_booster.pptx
78
+ /mnt/data_share/Files/PPTX/AllPPTX/RR_Customer_Deck_FINAL_11.23.09.pptx
79
+ /mnt/data_share/Files/PPTX/AllPPTX/SMB_Forms_ThruPartner.pptx
80
+ /mnt/data_share/Files/JPG/2flash5.jpg
81
+ /mnt/data_share/Files/JPG/3flash6-a.jpg
82
+ /mnt/data_share/Files/JPG/141_014.jpg
83
+ /mnt/data_share/Files/JPG/5350678_085.jpg
84
+ /mnt/data_share/Files/JPG/animal39_animated_70x80_020.jpg
85
+ )
62
86
  #endregion
63
87
 
64
88
  #region Projects
@@ -91,6 +115,6 @@ EVENT_TYPES = %w(None News Order Advert AllNews Poll All)
91
115
 
92
116
  #region Calendar
93
117
  TIME_ZONES = %w(UTC)
94
- CALENDAR_TO_UPLOAD = 'path_to_file.ics'
118
+ CALENDAR_TO_UPLOAD = '/mnt/data_share/Files/basic.ics'
95
119
  #endregion
96
120
  #endregion
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teamlab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-13 00:00:00.000000000 Z
12
+ date: 2014-05-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty