roistat 0.1.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 (43) hide show
  1. checksums.yaml +7 -0
  2. data/.ruby-version +1 -0
  3. data/CHANGELOG.md +18 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +757 -0
  6. data/Rakefile +12 -0
  7. data/docs/ru/README.md +142 -0
  8. data/lefthook.yml +8 -0
  9. data/lib/generators/roistat/install/install_generator.rb +13 -0
  10. data/lib/generators/roistat/install/templates/roistat.rb +13 -0
  11. data/lib/roistat/client.rb +220 -0
  12. data/lib/roistat/configuration.rb +17 -0
  13. data/lib/roistat/errors.rb +18 -0
  14. data/lib/roistat/resources/access.rb +25 -0
  15. data/lib/roistat/resources/analytics.rb +68 -0
  16. data/lib/roistat/resources/base.rb +31 -0
  17. data/lib/roistat/resources/billing.rb +17 -0
  18. data/lib/roistat/resources/calltracking.rb +102 -0
  19. data/lib/roistat/resources/channels.rb +28 -0
  20. data/lib/roistat/resources/clients.rb +38 -0
  21. data/lib/roistat/resources/dashboards.rb +13 -0
  22. data/lib/roistat/resources/emailtracking.rb +16 -0
  23. data/lib/roistat/resources/events.rb +42 -0
  24. data/lib/roistat/resources/indicators.rb +13 -0
  25. data/lib/roistat/resources/lead_hunter.rb +8 -0
  26. data/lib/roistat/resources/leads.rb +33 -0
  27. data/lib/roistat/resources/managers.rb +33 -0
  28. data/lib/roistat/resources/mediaplan.rb +23 -0
  29. data/lib/roistat/resources/orders.rb +76 -0
  30. data/lib/roistat/resources/projects.rb +30 -0
  31. data/lib/roistat/resources/proxy_leads.rb +18 -0
  32. data/lib/roistat/resources/sms.rb +15 -0
  33. data/lib/roistat/resources/speech.rb +68 -0
  34. data/lib/roistat/resources/statistics.rb +8 -0
  35. data/lib/roistat/resources/visits.rb +23 -0
  36. data/lib/roistat/resources/vpbx.rb +100 -0
  37. data/lib/roistat/resources/widgets.rb +17 -0
  38. data/lib/roistat/response.rb +88 -0
  39. data/lib/roistat/version.rb +5 -0
  40. data/lib/roistat.rb +66 -0
  41. data/mise.toml +14 -0
  42. data/sig/roistat.rbs +251 -0
  43. metadata +187 -0
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Roistat::Resources::Channels < Roistat::Resources::Base
4
+ # POST /project/analytics/source/list
5
+ def source_list(**body)
6
+ post_optional_body("project/analytics/source/list", body)
7
+ end
8
+
9
+ # POST /project/analytics/source/cost/list
10
+ def cost_list(**body)
11
+ post_optional_body("project/analytics/source/cost/list", body)
12
+ end
13
+
14
+ # POST /project/analytics/source/cost/add
15
+ def cost_add(**body)
16
+ client.post("project/analytics/source/cost/add", body: body)
17
+ end
18
+
19
+ # POST /project/analytics/source/cost/update
20
+ def cost_update(**body)
21
+ client.post("project/analytics/source/cost/update", body: body)
22
+ end
23
+
24
+ # POST /project/analytics/source/cost/delete
25
+ def cost_delete(id:)
26
+ client.post("project/analytics/source/cost/delete", body: {id: id})
27
+ end
28
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Roistat::Resources::Clients < Roistat::Resources::Base
4
+ # POST /project/clients
5
+ def list(**body)
6
+ post("project/clients", body: body)
7
+ end
8
+
9
+ # POST /project/clients/import — body is a JSON array
10
+ def import(clients)
11
+ client.post("project/clients/import", body: clients)
12
+ end
13
+
14
+ # GET /project/clients/detail/feed?client=
15
+ def detail_feed(client:)
16
+ @client.get("project/clients/detail/feed", params: {client: client})
17
+ end
18
+
19
+ # POST /project/clients/campaign/list
20
+ def campaign_list(**body)
21
+ post("project/clients/campaign/list", body: body)
22
+ end
23
+
24
+ # POST /project/clients/campaign/contact/list
25
+ def campaign_contact_list(**body)
26
+ post("project/clients/campaign/contact/list", body: body)
27
+ end
28
+
29
+ private
30
+
31
+ def post(path, body:)
32
+ if body.nil? || body.empty?
33
+ client.post(path)
34
+ else
35
+ client.post(path, body: body)
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Roistat::Resources::Dashboards < Roistat::Resources::Base
4
+ # GET /project/dashboards
5
+ def list
6
+ client.get("project/dashboards")
7
+ end
8
+
9
+ # GET /project/dashboards/{dashboardId}/widgets
10
+ def widgets(dashboard_id:)
11
+ client.get("project/dashboards/#{dashboard_id}/widgets")
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Roistat::Resources::Emailtracking < Roistat::Resources::Base
4
+ # POST /project/emailtracking/email/list
5
+ def list(**body)
6
+ post_optional_body("project/emailtracking/email/list", body)
7
+ end
8
+
9
+ # GET /project/emailtracking/email/{email_id}/attachment/{attachment_id}
10
+ def attachment(email_id:, attachment_id:)
11
+ client.get(
12
+ "project/emailtracking/email/#{email_id}/attachment/#{attachment_id}",
13
+ parse: :binary
14
+ )
15
+ end
16
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Roistat::Resources::Events < Roistat::Resources::Base
4
+ # POST /project/events/send
5
+ def send_event(**body)
6
+ client.post("project/events/send", body: body)
7
+ end
8
+
9
+ # POST /project/events/bulk/send — body is a JSON array
10
+ def bulk_send(events)
11
+ client.post("project/events/bulk/send", body: events)
12
+ end
13
+
14
+ # POST /project/events/add — body is a JSON array
15
+ def add(events)
16
+ client.post("project/events/add", body: events)
17
+ end
18
+
19
+ # GET /project/events/log — filters as query params (docs heading; curl shows POST JSON)
20
+ def log(**params)
21
+ if params.nil? || params.empty?
22
+ client.get("project/events/log")
23
+ else
24
+ client.get("project/events/log", params: params)
25
+ end
26
+ end
27
+
28
+ # POST /project/events/meta/{eventId}/archive — body is a JSON array
29
+ def archive(event_id:, events:)
30
+ client.post("project/events/meta/#{event_id}/archive", body: events)
31
+ end
32
+
33
+ private
34
+
35
+ def post(path, body:)
36
+ if body.nil? || body.empty?
37
+ client.post(path)
38
+ else
39
+ client.post(path, body: body)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Roistat::Resources::Indicators < Roistat::Resources::Base
4
+ # GET /project/health/indicator/list
5
+ def list
6
+ client.get("project/health/indicator/list")
7
+ end
8
+
9
+ # POST /project/health/indicator/{indicatorId}/run-script
10
+ def run_script(indicator_id:)
11
+ client.post("project/health/indicator/#{indicator_id}/run-script")
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Roistat::Resources::LeadHunter < Roistat::Resources::Base
4
+ # GET /project/lead-hunter/lead/list
5
+ def list(**params)
6
+ client.get("project/lead-hunter/lead/list", params: params)
7
+ end
8
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Roistat::Resources::Leads < Roistat::Resources::Base
4
+ # POST /project/leads/lead/list
5
+ def list(**body)
6
+ post("project/leads/lead/list", body: body)
7
+ end
8
+
9
+ # POST /project/leads/status/list
10
+ def status_list(**body)
11
+ post("project/leads/status/list", body: body)
12
+ end
13
+
14
+ # POST /project/leads/lead/create
15
+ def create(**body)
16
+ client.post("project/leads/lead/create", body: body)
17
+ end
18
+
19
+ # POST /project/leads/lead/update
20
+ def update(**body)
21
+ client.post("project/leads/lead/update", body: body)
22
+ end
23
+
24
+ private
25
+
26
+ def post(path, body:)
27
+ if body.nil? || body.empty?
28
+ client.post(path)
29
+ else
30
+ client.post(path, body: body)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Roistat::Resources::Managers < Roistat::Resources::Base
4
+ # POST /project/integration/manager/list
5
+ def list(**body)
6
+ post("project/integration/manager/list", body: body)
7
+ end
8
+
9
+ # POST /project/integration/manager/add
10
+ def add(**body)
11
+ client.post("project/integration/manager/add", body: body)
12
+ end
13
+
14
+ # POST /project/integration/manager/update
15
+ def update(**body)
16
+ client.post("project/integration/manager/update", body: body)
17
+ end
18
+
19
+ # POST /project/integration/manager/delete
20
+ def delete(id:)
21
+ client.post("project/integration/manager/delete", body: {id: id})
22
+ end
23
+
24
+ private
25
+
26
+ def post(path, body:)
27
+ if body.nil? || body.empty?
28
+ client.post(path)
29
+ else
30
+ client.post(path, body: body)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Roistat::Resources::Mediaplan < Roistat::Resources::Base
4
+ # POST /project/mediaplan/target/list
5
+ def target_list(**body)
6
+ post_optional_body("project/mediaplan/target/list", body)
7
+ end
8
+
9
+ # POST /project/mediaplan/target/create
10
+ def target_create(**body)
11
+ client.post("project/mediaplan/target/create", body: body)
12
+ end
13
+
14
+ # POST /project/mediaplan/target/update
15
+ def target_update(**body)
16
+ client.post("project/mediaplan/target/update", body: body)
17
+ end
18
+
19
+ # POST /project/mediaplan/target/delete
20
+ def target_delete(id:)
21
+ client.post("project/mediaplan/target/delete", body: {id: id})
22
+ end
23
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Roistat::Resources::Orders < Roistat::Resources::Base
4
+ # POST /project/integration/order/list
5
+ def list(**body)
6
+ post("project/integration/order/list", body: body)
7
+ end
8
+
9
+ # POST /project/add-orders — body is a JSON array
10
+ def add(orders)
11
+ client.post("project/add-orders", body: orders)
12
+ end
13
+
14
+ # GET /project/orders/{orderId}/info
15
+ def info(order_id:)
16
+ client.get("project/orders/#{order_id}/info")
17
+ end
18
+
19
+ # GET /project/orders/{orderId}/external-url
20
+ def external_url(order_id:)
21
+ client.get("project/orders/#{order_id}/external-url")
22
+ end
23
+
24
+ # POST /project/integration/status/list
25
+ def status_list(**body)
26
+ post("project/integration/status/list", body: body)
27
+ end
28
+
29
+ # POST /project/set-statuses — body is a JSON array
30
+ def set_statuses(statuses)
31
+ client.post("project/set-statuses", body: statuses)
32
+ end
33
+
34
+ # POST /project/analytics/order-custom-fields
35
+ def custom_fields(**body)
36
+ post("project/analytics/order-custom-fields", body: body)
37
+ end
38
+
39
+ # POST /project/integration/order/{orderId}/status/update
40
+ def status_update(order_id:, status_id:)
41
+ client.post(
42
+ "project/integration/order/#{order_id}/status/update",
43
+ body: {status_id: status_id}
44
+ )
45
+ end
46
+
47
+ # POST /project/integration/order/{orderId}/goal/update
48
+ def goal_update(order_id:, **body)
49
+ client.post("project/integration/order/#{order_id}/goal/update", body: body)
50
+ end
51
+
52
+ # POST /project/integration/order/update
53
+ def update(orders:)
54
+ client.post("project/integration/order/update", body: {orders: orders})
55
+ end
56
+
57
+ # POST /project/integration/order/{orderId}/delete
58
+ def delete(order_id:)
59
+ client.post("project/integration/order/#{order_id}/delete")
60
+ end
61
+
62
+ # POST /project/integration/order/delete
63
+ def delete_many(ids:)
64
+ client.post("project/integration/order/delete", body: {ids: ids})
65
+ end
66
+
67
+ private
68
+
69
+ def post(path, body:)
70
+ if body.nil? || body.empty?
71
+ client.post(path)
72
+ else
73
+ client.post(path, body: body)
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Roistat::Resources::Projects < Roistat::Resources::Base
4
+ # GET /user/projects — API key only.
5
+ def list
6
+ api_key_client.get("user/projects")
7
+ end
8
+
9
+ # POST /account/project/create — API key only.
10
+ def create(name:, currency:)
11
+ api_key_client.post("account/project/create", body: {name: name, currency: currency})
12
+ end
13
+
14
+ # GET|POST /project/settings/module/list — project-scoped (help-ru).
15
+ def modules_list(method: :get)
16
+ case method.to_sym
17
+ when :get
18
+ client.get("project/settings/module/list")
19
+ when :post
20
+ client.post("project/settings/module/list")
21
+ else
22
+ raise ArgumentError, "method must be :get or :post"
23
+ end
24
+ end
25
+
26
+ # POST /project/settings/counter/list — same product idea as modules_list; listed on help-en.
27
+ def counter_list
28
+ client.post("project/settings/counter/list")
29
+ end
30
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Roistat::Resources::ProxyLeads < Roistat::Resources::Base
4
+ # GET /project/proxy-leads?period=YYYY-MM-DD-YYYY-MM-DD
5
+ def list(period:)
6
+ client.get("project/proxy-leads", params: {period: period})
7
+ end
8
+
9
+ # GET /project/proxy-leads/duplicates?period=YYYY-MM-DD-YYYY-MM-DD
10
+ def duplicates(period:)
11
+ client.get("project/proxy-leads/duplicates", params: {period: period})
12
+ end
13
+
14
+ # GET /project/proxy-leads/{proxyLeadId}
15
+ def get(id:)
16
+ client.get("project/proxy-leads/#{id}")
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Roistat::Resources::Sms < Roistat::Resources::Base
4
+ # POST /project/set-sms-report-enabled
5
+ def set_report_enabled(enabled:)
6
+ flag =
7
+ case enabled
8
+ when true, "1", 1 then "1"
9
+ when false, "0", 0 then "0"
10
+ else enabled.to_s
11
+ end
12
+
13
+ client.post("project/set-sms-report-enabled", body: {enabled: flag})
14
+ end
15
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Roistat::Resources::Speech < Roistat::Resources::Base
4
+ # POST /project/speech/call/list
5
+ def call_list(**body)
6
+ post_optional_body("project/speech/call/list", body)
7
+ end
8
+
9
+ # POST /project/speech/call/list/export/excel
10
+ def call_list_export_excel(**body)
11
+ client.post("project/speech/call/list/export/excel", body: body, parse: :binary)
12
+ end
13
+
14
+ # POST /project/speech/call/add
15
+ def call_add(**body)
16
+ client.post("project/speech/call/add", body: body)
17
+ end
18
+
19
+ # POST /project/speech/call/comment/update
20
+ def call_comment_update(**body)
21
+ client.post("project/speech/call/comment/update", body: body)
22
+ end
23
+
24
+ # POST /project/speech/call/operator/update
25
+ def call_operator_update(**body)
26
+ client.post("project/speech/call/operator/update", body: body)
27
+ end
28
+
29
+ # POST /project/speech/call/transcription/list
30
+ def call_transcription_list(**body)
31
+ post_optional_body("project/speech/call/transcription/list", body)
32
+ end
33
+
34
+ # POST /project/speech/dictionary/list
35
+ def dictionary_list(**body)
36
+ post_optional_body("project/speech/dictionary/list", body)
37
+ end
38
+
39
+ # POST /project/speech/dictionary/custom/create
40
+ def dictionary_custom_create(**body)
41
+ client.post("project/speech/dictionary/custom/create", body: body)
42
+ end
43
+
44
+ # POST /project/speech/dictionary/custom/update
45
+ def dictionary_custom_update(**body)
46
+ client.post("project/speech/dictionary/custom/update", body: body)
47
+ end
48
+
49
+ # POST /project/speech/dictionary/custom/delete
50
+ def dictionary_custom_delete(**body)
51
+ client.post("project/speech/dictionary/custom/delete", body: body)
52
+ end
53
+
54
+ # POST /project/speech/dictionary/custom/phrase/list
55
+ def dictionary_custom_phrase_list(**body)
56
+ post_optional_body("project/speech/dictionary/custom/phrase/list", body)
57
+ end
58
+
59
+ # POST /project/speech/settings/list
60
+ def settings_list(**body)
61
+ post_optional_body("project/speech/settings/list", body)
62
+ end
63
+
64
+ # POST /project/speech/settings/update
65
+ def settings_update(**body)
66
+ client.post("project/speech/settings/update", body: body)
67
+ end
68
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Roistat::Resources::Statistics < Roistat::Resources::Base
4
+ # POST /project/statistics/get-daily
5
+ def get_daily(**body)
6
+ client.post("project/statistics/get-daily", body: body)
7
+ end
8
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Roistat::Resources::Visits < Roistat::Resources::Base
4
+ # POST /project/site/visit/list
5
+ def list(**body)
6
+ post("project/site/visit/list", body: body)
7
+ end
8
+
9
+ # POST /project/site/visit/params/update
10
+ def params_update(**body)
11
+ client.post("project/site/visit/params/update", body: body)
12
+ end
13
+
14
+ private
15
+
16
+ def post(path, body:)
17
+ if body.nil? || body.empty?
18
+ client.post(path)
19
+ else
20
+ client.post(path, body: body)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Roistat::Resources::Vpbx < Roistat::Resources::Base
4
+ # POST /project/vpbx/call/list
5
+ def call_list(**body)
6
+ post_optional_body("project/vpbx/call/list", body)
7
+ end
8
+
9
+ # POST /project/vpbx/operator/list
10
+ def operator_list(**body)
11
+ post_optional_body("project/vpbx/operator/list", body)
12
+ end
13
+
14
+ # POST /project/vpbx/operator/create
15
+ def operator_create(**body)
16
+ client.post("project/vpbx/operator/create", body: body)
17
+ end
18
+
19
+ # POST /project/vpbx/operator/update
20
+ def operator_update(**body)
21
+ client.post("project/vpbx/operator/update", body: body)
22
+ end
23
+
24
+ # POST /project/vpbx/operator/deactivate
25
+ def operator_deactivate(**body)
26
+ client.post("project/vpbx/operator/deactivate", body: body)
27
+ end
28
+
29
+ # POST /project/vpbx/operator/group/list
30
+ def operator_group_list(**body)
31
+ post_optional_body("project/vpbx/operator/group/list", body)
32
+ end
33
+
34
+ # POST /project/vpbx/operator/group/create
35
+ def operator_group_create(**body)
36
+ client.post("project/vpbx/operator/group/create", body: body)
37
+ end
38
+
39
+ # POST /project/vpbx/operator/group/update
40
+ def operator_group_update(**body)
41
+ client.post("project/vpbx/operator/group/update", body: body)
42
+ end
43
+
44
+ # GET /project/vpbx/phone/list
45
+ def phone_list(**params)
46
+ client.get("project/vpbx/phone/list", params: params)
47
+ end
48
+
49
+ # POST /project/vpbx/phone/create
50
+ def phone_create(**body)
51
+ client.post("project/vpbx/phone/create", body: body)
52
+ end
53
+
54
+ # POST /project/vpbx/phone/update
55
+ def phone_update(**body)
56
+ client.post("project/vpbx/phone/update", body: body)
57
+ end
58
+
59
+ # POST /project/vpbx/phone/delete
60
+ def phone_delete(**body)
61
+ client.post("project/vpbx/phone/delete", body: body)
62
+ end
63
+
64
+ # GET /project/vpbx/script/list
65
+ def script_list(**params)
66
+ client.get("project/vpbx/script/list", params: params)
67
+ end
68
+
69
+ # POST /project/vpbx/script/create
70
+ def script_create(**body)
71
+ client.post("project/vpbx/script/create", body: body)
72
+ end
73
+
74
+ # POST /project/vpbx/script/update
75
+ def script_update(**body)
76
+ client.post("project/vpbx/script/update", body: body)
77
+ end
78
+
79
+ # POST /project/vpbx/script/delete
80
+ def script_delete(**body)
81
+ client.post("project/vpbx/script/delete", body: body)
82
+ end
83
+
84
+ # POST /project/vpbx/report/data
85
+ def report_data(**body)
86
+ post_optional_body("project/vpbx/report/data", body)
87
+ end
88
+
89
+ # POST /project/vpbx/settings/update
90
+ def settings_update(**body)
91
+ client.post("project/vpbx/settings/update", body: body)
92
+ end
93
+
94
+ # POST /project/vpbx/settings/file/audio/upload (multipart/form-data)
95
+ def settings_file_audio_upload(file:, **fields)
96
+ form = fields.transform_keys(&:to_s)
97
+ form["file"] = file
98
+ client.post_multipart("project/vpbx/settings/file/audio/upload", form: form)
99
+ end
100
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Roistat::Resources::Widgets < Roistat::Resources::Base
4
+ # GET|POST /project/widget/{widgetId}/data — help-en; curl usually POSTs.
5
+ def data(widget_id:, method: :post, **body)
6
+ path = "project/widget/#{widget_id}/data"
7
+
8
+ case method.to_sym
9
+ when :get
10
+ client.get(path)
11
+ when :post
12
+ post_optional_body(path, body)
13
+ else
14
+ raise ArgumentError, "method must be :get or :post"
15
+ end
16
+ end
17
+ end