onlyoffice_api 0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/lib/onlyoffice_api.rb +65 -0
  3. data/lib/teamlab/config.rb +39 -0
  4. data/lib/teamlab/modules/calendar.rb +111 -0
  5. data/lib/teamlab/modules/community.rb +20 -0
  6. data/lib/teamlab/modules/community/community_blogs.rb +54 -0
  7. data/lib/teamlab/modules/community/community_bookmarks.rb +60 -0
  8. data/lib/teamlab/modules/community/community_events.rb +50 -0
  9. data/lib/teamlab/modules/community/community_forums.rb +70 -0
  10. data/lib/teamlab/modules/community/community_wiki.rb +66 -0
  11. data/lib/teamlab/modules/crm.rb +32 -0
  12. data/lib/teamlab/modules/crm/crm_cases.rb +72 -0
  13. data/lib/teamlab/modules/crm/crm_common.rb +42 -0
  14. data/lib/teamlab/modules/crm/crm_contacts.rb +243 -0
  15. data/lib/teamlab/modules/crm/crm_files.rb +44 -0
  16. data/lib/teamlab/modules/crm/crm_history.rb +42 -0
  17. data/lib/teamlab/modules/crm/crm_invoices.rb +123 -0
  18. data/lib/teamlab/modules/crm/crm_opportunities.rb +93 -0
  19. data/lib/teamlab/modules/crm/crm_organisation.rb +14 -0
  20. data/lib/teamlab/modules/crm/crm_tags.rb +54 -0
  21. data/lib/teamlab/modules/crm/crm_tasks.rb +62 -0
  22. data/lib/teamlab/modules/crm/crm_user_fields.rb +34 -0
  23. data/lib/teamlab/modules/feed.rb +23 -0
  24. data/lib/teamlab/modules/files.rb +256 -0
  25. data/lib/teamlab/modules/group.rb +53 -0
  26. data/lib/teamlab/modules/group/group_helper.rb +15 -0
  27. data/lib/teamlab/modules/mail.rb +32 -0
  28. data/lib/teamlab/modules/mail/mail_accounts.rb +55 -0
  29. data/lib/teamlab/modules/mail/mail_alerts.rb +14 -0
  30. data/lib/teamlab/modules/mail/mail_contacts.rb +14 -0
  31. data/lib/teamlab/modules/mail/mail_conversations.rb +54 -0
  32. data/lib/teamlab/modules/mail/mail_folders.rb +18 -0
  33. data/lib/teamlab/modules/mail/mail_helpcenter.rb +10 -0
  34. data/lib/teamlab/modules/mail/mail_images.rb +18 -0
  35. data/lib/teamlab/modules/mail/mail_messages.rb +74 -0
  36. data/lib/teamlab/modules/mail/mail_settings.rb +17 -0
  37. data/lib/teamlab/modules/mail/mail_signature.rb +14 -0
  38. data/lib/teamlab/modules/mail/mail_tags.rb +30 -0
  39. data/lib/teamlab/modules/people.rb +104 -0
  40. data/lib/teamlab/modules/people/people_reassign.rb +26 -0
  41. data/lib/teamlab/modules/portals.rb +17 -0
  42. data/lib/teamlab/modules/project.rb +37 -0
  43. data/lib/teamlab/modules/projects/projects_comments.rb +34 -0
  44. data/lib/teamlab/modules/projects/projects_contacts.rb +18 -0
  45. data/lib/teamlab/modules/projects/projects_discussions.rb +46 -0
  46. data/lib/teamlab/modules/projects/projects_files.rb +34 -0
  47. data/lib/teamlab/modules/projects/projects_milestones.rb +46 -0
  48. data/lib/teamlab/modules/projects/projects_projects.rb +82 -0
  49. data/lib/teamlab/modules/projects/projects_reports.rb +18 -0
  50. data/lib/teamlab/modules/projects/projects_settings.rb +11 -0
  51. data/lib/teamlab/modules/projects/projects_tags.rb +18 -0
  52. data/lib/teamlab/modules/projects/projects_tasks.rb +94 -0
  53. data/lib/teamlab/modules/projects/projects_team.rb +30 -0
  54. data/lib/teamlab/modules/projects/projects_templates.rb +26 -0
  55. data/lib/teamlab/modules/projects/projects_time.rb +34 -0
  56. data/lib/teamlab/modules/settings.rb +100 -0
  57. data/lib/teamlab/name.rb +5 -0
  58. data/lib/teamlab/request.rb +79 -0
  59. data/lib/teamlab/response.rb +41 -0
  60. data/lib/teamlab/version.rb +5 -0
  61. metadata +140 -0
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teamlab
4
+ # Methods for working with crm files
5
+ module CrmFiles
6
+ def get_root_folder_id
7
+ @request.get(%w[files root])
8
+ end
9
+
10
+ def get_file_list(entity_type, entity_id)
11
+ @request.get([entity_type.to_s,
12
+ entity_id.to_s,
13
+ 'files'])
14
+ end
15
+
16
+ def associate_file_with_entity(entity_type, entity_id, *fileids)
17
+ @request.post([entity_type,
18
+ entity_id,
19
+ 'files'],
20
+ fileids: fileids.flatten)
21
+ end
22
+
23
+ def create_txt(entity_type, entity_id, title, content)
24
+ @request.post([entity_type.to_s,
25
+ entity_id.to_s,
26
+ 'files',
27
+ 'text'],
28
+ title: title,
29
+ content: content)
30
+ end
31
+
32
+ def upload_file(entity_type, entity_id, file)
33
+ @request.post([entity_type.to_s,
34
+ entity_id.to_s,
35
+ 'files',
36
+ 'upload'],
37
+ somefile: File.new(file))
38
+ end
39
+
40
+ def delete_file(id)
41
+ @request.delete(['files', id.to_s])
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teamlab
4
+ # Methods for working with crm history
5
+ module CrmHistory
6
+ def get_event_list_by_filter(options = {})
7
+ @request.get(%w[history filter], options)
8
+ end
9
+
10
+ def get_all_history_categories
11
+ @request.get(%w[history category])
12
+ end
13
+
14
+ def create_event(contact_id, content, category_id, options = {})
15
+ @request.post(%w[history], { contactId: contact_id, content: content, categoryId: category_id }.merge(options))
16
+ end
17
+
18
+ def create_history_category(title, image_name, options = {})
19
+ @request.post(%w[history category], { title: title.to_s, imageName: image_name.to_s }.merge(options))
20
+ end
21
+
22
+ def update_history_category(id, title, options = {})
23
+ @request.put(['history', 'category', id.to_s], { title: title }.merge(options))
24
+ end
25
+
26
+ def update_history_categories_order(*titles)
27
+ @request.put(%w[history category reorder], titles: titles.flatten)
28
+ end
29
+
30
+ def update_history_category_icon(id, icon_name)
31
+ @request.put(['history', 'category', id.to_s, 'icon'], imageName: icon_name.to_s)
32
+ end
33
+
34
+ def delete_event_and_related_files(id)
35
+ @request.delete(['history', id.to_s])
36
+ end
37
+
38
+ def delete_history_category(id)
39
+ @request.delete(['history', 'category', id.to_s])
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,123 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teamlab
4
+ # Methods for working with crm invoices
5
+ module CrmInvoices
6
+ def get_invoice_taxes
7
+ @request.get(%w[invoice tax])
8
+ end
9
+
10
+ def get_invoice_sample
11
+ @request.get(%w[invoice sample])
12
+ end
13
+
14
+ def get_invoices_by_filter(options = {})
15
+ @request.get(%w[invoice filter], options)
16
+ end
17
+
18
+ def get_invoices_settings
19
+ @request.get(%w[invoice settings])
20
+ end
21
+ alias get_settings get_invoices_settings
22
+
23
+ extend Gem::Deprecate
24
+ deprecate :get_settings, 'get_invoices_settings', 2020, 1
25
+
26
+ def get_invoice_items_by_filter(options = {})
27
+ @request.get(%w[invoiceitem filter], options)
28
+ end
29
+
30
+ def get_invoice_by_id(id)
31
+ @request.get(['invoice', id.to_s])
32
+ end
33
+
34
+ def get_entity_invoices(entity_type, entity_id)
35
+ @request.get([entity_type.to_s, 'invoicelist', entity_id.to_s])
36
+ end
37
+
38
+ def create_invoice(number, issue_date, client_id, due_date, language, currency, exchange_rate, terms, invoice_line, options = {})
39
+ @request.post(%w[invoice], { number: number, issueDate: issue_date, contactId: client_id, dueDate: due_date,
40
+ language: language, currency: currency, exchangeRate: exchange_rate, terms: terms,
41
+ invoiceLines: invoice_line }.merge(options))
42
+ end
43
+
44
+ def create_invoice_line(invoice_id, invoice_item_id, options = {})
45
+ @request.post(%w[invoiceline], { invoiceId: invoice_id, invoiceItemId: invoice_item_id }.merge(options))
46
+ end
47
+
48
+ def create_invoice_item(title, description, price, stock_keeping_unit, options = {})
49
+ @request.post(%w[invoiceitem], { title: title, description: description, price: price, sku: stock_keeping_unit.to_s }.merge(options))
50
+ end
51
+
52
+ def create_invoice_tax(name, description, options = {})
53
+ @request.post(%w[invoice tax], { name: name, description: description }.merge(options))
54
+ end
55
+
56
+ def update_invoice_item(id, title, description, price, stock_keeping_unit, options = {})
57
+ @request.put(['invoiceitem', id.to_s], { title: title, description: description, price: price, sku: stock_keeping_unit.to_s }.merge(options))
58
+ end
59
+
60
+ def update_invoice_tax(id, name, options = {})
61
+ @request.put(['invoice', 'tax', id.to_s], { name: name }.merge(options))
62
+ end
63
+
64
+ def update_invoice(id, options = {})
65
+ options[:id] = id
66
+ @request.put(['invoice', id.to_s], options)
67
+ end
68
+
69
+ def save_number_settings(options = {})
70
+ @request.put(%w[invoice settings name], options)
71
+ end
72
+
73
+ def save_terms_settings(options = {})
74
+ @request.put(%w[invoice settings terms], options)
75
+ end
76
+
77
+ # Updates the status of invoices with the IDs specified in the request
78
+ # @param status [String] status to set
79
+ # @param invoice_ids [Array<Integer>] list of status to set
80
+ # @return [Teamlab::Response] result of update
81
+ def update_invoice_group_status(status, invoice_ids)
82
+ @request.put(['invoice', 'status', status.to_s], invoiceids: invoice_ids)
83
+ end
84
+
85
+ def update_invoice_line(invoice_line_id, invoice_id, options = {})
86
+ options[:id] = invoice_line_id
87
+ options[:invoiceId] = invoice_id
88
+ @request.put(['invoiceline', invoice_line_id], options)
89
+ end
90
+
91
+ def delete_batch_invoices(*invoice_ids)
92
+ @request.delete(%w[invoice], invoiceids: invoice_ids.flatten)
93
+ end
94
+ alias delete_invoices_bulk delete_batch_invoices
95
+
96
+ def delete_batch_items(*ids)
97
+ @request.delete(%w[invoiceitem], ids: ids.flatten)
98
+ end
99
+ alias delete_invoice_items_bulk delete_batch_items
100
+
101
+ def delete_invoice_item(id)
102
+ @request.delete(['invoiceitem', id.to_s])
103
+ end
104
+
105
+ def delete_invoice_tax(id)
106
+ @request.delete(['invoice', 'tax', id.to_s])
107
+ end
108
+
109
+ def delete_invoice(id)
110
+ @request.delete(['invoice', id.to_s])
111
+ end
112
+
113
+ def delete_invoice_line(id)
114
+ @request.delete(['invoiceline', id.to_s], id: id)
115
+ end
116
+
117
+ # @param invoice_item_id [Integer] id of invoice
118
+ # @return [Void]
119
+ def get_invoice_item_by_id(invoice_item_id)
120
+ @request.get(['invoiceitem', invoice_item_id])
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teamlab
4
+ # Methods for working with crm opportunities methods
5
+ module CrmOpportunities
6
+ def get_all_opportunity_stages
7
+ @request.get(%w[opportunity stage])
8
+ end
9
+
10
+ def get_opportunity_list(options = {})
11
+ @request.get(%w[opportunity filter], options)
12
+ end
13
+
14
+ def get_opportunity_stage(stage_id)
15
+ @request.get(['opportunity', 'stage', stage_id.to_s])
16
+ end
17
+
18
+ def get_opportunity_by_id(id)
19
+ @request.get(['opportunity', id.to_s])
20
+ end
21
+
22
+ def get_all_opportunity_contacts(opportunity_id)
23
+ @request.get(['opportunity', opportunity_id.to_s, 'contact'])
24
+ end
25
+
26
+ def create_opportunity(stage_id, title, responsible_id, options = {})
27
+ options[:bidCurrencyAbbr] ||= 'USD'
28
+ @request.post(%w[opportunity], { stageId: stage_id, title: title, responsibleid: responsible_id }.merge(options))
29
+ end
30
+
31
+ def create_opportunity_stage(title, color, options = {})
32
+ @request.post(%w[opportunity stage], { title: title, color: color }.merge(options))
33
+ end
34
+
35
+ def add_opportunity_contact(opportunity_id, contact_id)
36
+ @request.post(['opportunity', opportunity_id.to_s, 'contact', contact_id.to_s])
37
+ end
38
+
39
+ def set_opportunity_access_rights(opportunity_ids, is_private, *users)
40
+ @request.put(%w[opportunity access], opportunityid: opportunity_ids.to_a.flatten, isPrivate: is_private, accessList: users.flatten)
41
+ end
42
+
43
+ def update_opportunity_stage(id, title, color, options = {})
44
+ @request.put(['opportunity', 'stage', id.to_s], { title: title, color: color }.merge(options))
45
+ end
46
+
47
+ def update_opportunity_stages_order(options = {})
48
+ @request.put(%w[opportunity stage reorder], options)
49
+ end
50
+
51
+ def set_opportunity_access_rights_for_users(options = {})
52
+ @request.put(%w[opportunity filter access], options)
53
+ end
54
+
55
+ def update_opportunity(opportunity_id, contact_id, title, responsible_id, stage_id, options = {})
56
+ @request.put(['opportunity', opportunity_id.to_s], { contactId: contact_id, title: title, responsibleid: responsible_id,
57
+ stageid: stage_id }.merge(options))
58
+ end
59
+
60
+ def update_opportunity_stage_color(stage_id, color)
61
+ @request.put(['opportunity', 'stage', stage_id.to_s, 'color'], color: color)
62
+ end
63
+
64
+ def set_rights_to_opportunity(opportunity_id, is_private, access_list)
65
+ @request.put(['opportunity', opportunity_id.to_s, 'access'], isPrivate: is_private, accessList: access_list)
66
+ end
67
+
68
+ def update_opportunity_to_stage(opportunity_id, stage_id)
69
+ @request.put(['opportunity', opportunity_id.to_s, 'stage', stage_id.to_s], stageid: stage_id)
70
+ end
71
+
72
+ def delete_opportunity_group(*opportunity_ids)
73
+ @request.put(%w[opportunity], opportunityids: opportunity_ids.flatten)
74
+ end
75
+ alias delete_opportunities_bulk delete_opportunity_group
76
+
77
+ def delete_opportunity_group_by_filter(options = {})
78
+ @request.delete(%w[opportunity filter], options)
79
+ end
80
+
81
+ def delete_opportunity_stage(stage_id)
82
+ @request.delete(['opportunity', 'stage', stage_id.to_s])
83
+ end
84
+
85
+ def delete_opportunity(opportunity_id)
86
+ @request.delete(['opportunity', opportunity_id.to_s])
87
+ end
88
+
89
+ def delete_opportunity_contact(opportunity_id, contact_id)
90
+ @request.delete(['opportunity', opportunity_id.to_s, 'contact', contact_id.to_s])
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teamlab
4
+ # Methods for working with crm cases
5
+ module CrmOrganisation
6
+ def update_organisation_company_name(title)
7
+ @request.put(%w[settings organisation base], companyName: title)
8
+ end
9
+
10
+ def update_organisation_address(options = {})
11
+ @request.put(%w[settings organisation address], options)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teamlab
4
+ # Methods for working with crm cases
5
+ module CrmTags
6
+ def get_tags_for_entity_type(entity_type)
7
+ @request.get([entity_type.to_s, 'tag'])
8
+ end
9
+
10
+ def get_all_contact_tags(contact_id)
11
+ @request.get(['contact', contact_id.to_s, 'tag'])
12
+ end
13
+
14
+ def get_entity_tags(entity_type, entity_id)
15
+ @request.get([entity_type.to_s, 'tag', entity_id.to_s])
16
+ end
17
+
18
+ def create_tag(entity_type, tag_name)
19
+ @request.post([entity_type.to_s, 'tag'], tagName: tag_name)
20
+ end
21
+
22
+ def add_tag_to_case_group_by_filter(tag_name, options = {})
23
+ @request.post(%w[case filter taglist], { tagName: tag_name }.merge(options))
24
+ end
25
+
26
+ def add_tag_group_to_entity(entity_type, entity_id, tag_name)
27
+ @request.post([entity_type.to_s, 'taglist'], entityId: entity_id, tagName: tag_name)
28
+ end
29
+
30
+ def add_tag_to_opportunity_group(tag_name, options = {})
31
+ @request.post(%w[opportunity filter taglist], { tagName: tag_name }.merge(options))
32
+ end
33
+
34
+ def add_tag(entity_type, entity_id, tag_name)
35
+ @request.post([entity_type.to_s, entity_id.to_s, 'tag'], tagName: tag_name)
36
+ end
37
+
38
+ def delete_tag(entity_type, tag_name)
39
+ @request.delete([entity_type.to_s, 'tag'], tagName: tag_name)
40
+ end
41
+
42
+ def delete_unused_tags(entity_type)
43
+ @request.delete([entity_type.to_s, 'tag', 'unused'])
44
+ end
45
+
46
+ def remove_tag(entity_type, entity_id, tag_name)
47
+ @request.delete([entity_type.to_s, entity_id.to_s, 'tag'], tagName: tag_name)
48
+ end
49
+
50
+ def add_contact_tag_to_group(entity_type, entity_id, tag)
51
+ @request.post([entity_type.to_s, entity_id.to_s, 'tag', 'group'], tagName: tag)
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teamlab
4
+ # Methods for working with crm tasks
5
+ module CrmTasks
6
+ def create_task(title, deadline, responsible_id, category_id, options = {})
7
+ @request.post(%w[task], { title: title, deadline: deadline, responsibleId: responsible_id, categoryId: category_id }.merge(options))
8
+ end
9
+
10
+ def update_task(task_id, title, deadline, category_id, options = {})
11
+ @request.put(['task', task_id.to_s], { title: title, deadline: deadline, categoryid: category_id }.merge(options))
12
+ end
13
+
14
+ def get_task_list_by_filter(options = {})
15
+ @request.get(%w[task filter], options)
16
+ end
17
+
18
+ def get_all_task_categories
19
+ @request.get(%w[task category])
20
+ end
21
+
22
+ def get_task_by_id(task_id)
23
+ @request.get(['task', task_id.to_s])
24
+ end
25
+
26
+ def get_task_category(category_id)
27
+ @request.get(['task', 'category', category_id.to_s])
28
+ end
29
+
30
+ def create_task_category(title, image_name, options = {})
31
+ @request.post(%w[task category], { title: title.to_s, imageName: image_name.to_s }.merge(options))
32
+ end
33
+
34
+ def update_task_category(category_id, title, options = {})
35
+ @request.put(['task', 'category', category_id.to_s], { title: title }.merge(options))
36
+ end
37
+
38
+ def close_task(task_id)
39
+ @request.put(['task', task_id.to_s, 'close'])
40
+ end
41
+
42
+ def resume_task(task_id)
43
+ @request.put(['task', task_id.to_s, 'reopen'])
44
+ end
45
+
46
+ def update_task_categories_order(*titles)
47
+ @request.put(%w[task category reorder], titles: titles.flatten)
48
+ end
49
+
50
+ def update_task_category_icon(id, image_name)
51
+ @request.put(['task', 'category', id.to_s, 'icon'], imageName: image_name.to_s)
52
+ end
53
+
54
+ def delete_task(id)
55
+ @request.delete(['task', id.to_s])
56
+ end
57
+
58
+ def delete_task_category(category_id)
59
+ @request.delete(['task', 'category', category_id.to_s])
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teamlab
4
+ # Methods for working with crm tasks
5
+ module CrmUserFields
6
+ def get_user_field_values(entity_type, entity_id)
7
+ @request.get([entity_type.to_s, entity_id.to_s, 'customfield'])
8
+ end
9
+
10
+ def get_user_field_list(entity_type)
11
+ @request.get([entity_type.to_s, 'customfield', 'definitions'])
12
+ end
13
+
14
+ def create_user_field(entity_type, label, field_type, options = {})
15
+ @request.post([entity_type.to_s, 'customfield'], { fieldType: field_type, label: label }.merge(options))
16
+ end
17
+
18
+ def set_user_field_value(entity_type, entity_id, field_id, field_value)
19
+ @request.post([entity_type.to_s, entity_id.to_s, 'customfield', field_id.to_s], fieldValue: field_value)
20
+ end
21
+
22
+ def update_selected_user_field(entity_type, user_field_id, label, field_type, options = {})
23
+ @request.put([entity_type.to_s, 'customfield', user_field_id.to_s], { fieldType: field_type, label: label }.merge(options))
24
+ end
25
+
26
+ def update_user_fields_order(entity_type, *field_ids)
27
+ @request.put([entity_type.to_s, 'customfield', 'reorder'], fieldIds: field_ids.flatten)
28
+ end
29
+
30
+ def delete_user_field(entity_type, field_id)
31
+ @request.delete([entity_type.to_s, 'customfield', field_id.to_s])
32
+ end
33
+ end
34
+ end