wavix-sdk-ruby 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +124 -0
- data/lib/middleware/follow_redirects_middleware.rb +15 -0
- data/lib/services/fields_validator.rb +26 -0
- data/lib/wavix-sdk-ruby.rb +5 -0
- data/lib/wavix_api/base_methods.rb +180 -0
- data/lib/wavix_api/v1/base_destroy.rb +31 -0
- data/lib/wavix_api/v1/base_find.rb +31 -0
- data/lib/wavix_api/v1/base_search.rb +31 -0
- data/lib/wavix_api/v1/billing/invoices/find.rb +44 -0
- data/lib/wavix_api/v1/billing/invoices/search.rb +21 -0
- data/lib/wavix_api/v1/billing/transactions/search.rb +39 -0
- data/lib/wavix_api/v1/buy/carts/checkout.rb +23 -0
- data/lib/wavix_api/v1/buy/carts/find.rb +23 -0
- data/lib/wavix_api/v1/buy/carts/update.rb +34 -0
- data/lib/wavix_api/v1/buy/cities/search.rb +47 -0
- data/lib/wavix_api/v1/buy/countries/search.rb +31 -0
- data/lib/wavix_api/v1/buy/dids/search.rb +41 -0
- data/lib/wavix_api/v1/buy/regions/search.rb +33 -0
- data/lib/wavix_api/v1/call/recordings/destroy.rb +23 -0
- data/lib/wavix_api/v1/call/recordings/month_statistics/details.rb +35 -0
- data/lib/wavix_api/v1/call/recordings/month_statistics/search.rb +35 -0
- data/lib/wavix_api/v1/call/recordings/recording_settings.rb +40 -0
- data/lib/wavix_api/v1/call/recordings/retention_policy.rb +23 -0
- data/lib/wavix_api/v1/call/recordings/search.rb +55 -0
- data/lib/wavix_api/v1/call/recordings/update_recording_settings.rb +48 -0
- data/lib/wavix_api/v1/call/recordings/update_retention_policy.rb +37 -0
- data/lib/wavix_api/v1/call/transcriptions/find.rb +31 -0
- data/lib/wavix_api/v1/call/transcriptions/retranscribe.rb +35 -0
- data/lib/wavix_api/v1/cdrs/advanced_search.rb +67 -0
- data/lib/wavix_api/v1/cdrs/common_vars.rb +22 -0
- data/lib/wavix_api/v1/cdrs/metrics.rb +29 -0
- data/lib/wavix_api/v1/cdrs/search.rb +35 -0
- data/lib/wavix_api/v1/e911_records/create.rb +47 -0
- data/lib/wavix_api/v1/e911_records/destroy.rb +31 -0
- data/lib/wavix_api/v1/e911_records/search.rb +33 -0
- data/lib/wavix_api/v1/e911_records/validate_address.rb +44 -0
- data/lib/wavix_api/v1/mydids/cities.rb +32 -0
- data/lib/wavix_api/v1/mydids/destroy.rb +55 -0
- data/lib/wavix_api/v1/mydids/find.rb +21 -0
- data/lib/wavix_api/v1/mydids/search.rb +35 -0
- data/lib/wavix_api/v1/mydids/update.rb +40 -0
- data/lib/wavix_api/v1/mydids/update_destinations.rb +73 -0
- data/lib/wavix_api/v1/mydids/update_sms_enabled.rb +32 -0
- data/lib/wavix_api/v1/papers/create.rb +65 -0
- data/lib/wavix_api/v1/papers/find.rb +42 -0
- data/lib/wavix_api/v1/profile/account_config.rb +21 -0
- data/lib/wavix_api/v1/profile/find.rb +21 -0
- data/lib/wavix_api/v1/profile/update.rb +58 -0
- data/lib/wavix_api/v1/sub_organizations/create.rb +36 -0
- data/lib/wavix_api/v1/sub_organizations/find.rb +19 -0
- data/lib/wavix_api/v1/sub_organizations/search.rb +31 -0
- data/lib/wavix_api/v1/sub_organizations/transactions.rb +39 -0
- data/lib/wavix_api/v1/sub_organizations/update.rb +40 -0
- data/lib/wavix_api/v1/trunks/create.rb +76 -0
- data/lib/wavix_api/v1/trunks/destroy.rb +19 -0
- data/lib/wavix_api/v1/trunks/find.rb +19 -0
- data/lib/wavix_api/v1/trunks/search.rb +30 -0
- data/lib/wavix_api/v1/trunks/update.rb +85 -0
- data/lib/wavix_api/v1/voice_campaigns/create.rb +39 -0
- data/lib/wavix_api/v1/voice_campaigns/find.rb +21 -0
- data/lib/wavix_api/v2/base_destroy.rb +10 -0
- data/lib/wavix_api/v2/base_find.rb +10 -0
- data/lib/wavix_api/v2/base_search.rb +10 -0
- data/lib/wavix_api/v2/messages/all.rb +23 -0
- data/lib/wavix_api/v2/messages/async_create.rb +23 -0
- data/lib/wavix_api/v2/messages/attachments/find.rb +59 -0
- data/lib/wavix_api/v2/messages/common_vars.rb +50 -0
- data/lib/wavix_api/v2/messages/create.rb +24 -0
- data/lib/wavix_api/v2/messages/find.rb +19 -0
- data/lib/wavix_api/v2/messages/opt_outs/create.rb +34 -0
- data/lib/wavix_api/v2/messages/search.rb +23 -0
- data/lib/wavix_api/v2/messages/sender_ids/create.rb +40 -0
- data/lib/wavix_api/v2/messages/sender_ids/destroy.rb +21 -0
- data/lib/wavix_api/v2/messages/sender_ids/find.rb +21 -0
- data/lib/wavix_api/v2/messages/sender_ids/restrictions.rb +32 -0
- data/lib/wavix_api/v2/messages/sender_ids/search.rb +21 -0
- data/lib/wavix_api/v3/messages/sender_ids/create.rb +51 -0
- data/lib/wavix_api/v3/messages/sender_ids/find.rb +21 -0
- data/lib/wavix_api/v3/messages/sender_ids/search.rb +21 -0
- data/lib/wavix_api.rb +155 -0
- data/wavix-sdk-ruby.gemspec +40 -0
- metadata +204 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WavixApi
|
4
|
+
module V1
|
5
|
+
module SubOrganizations
|
6
|
+
class Create
|
7
|
+
include WavixApi::BaseMethods
|
8
|
+
|
9
|
+
@params_schema = {
|
10
|
+
type: 'object',
|
11
|
+
properties: {
|
12
|
+
name: { type: 'string' }.freeze,
|
13
|
+
default_destinations: {
|
14
|
+
type: 'object',
|
15
|
+
properties: {
|
16
|
+
sms_endpoint: { type: 'string' }.freeze,
|
17
|
+
dlr_endpoint: { type: 'string' }.freeze
|
18
|
+
}.freeze
|
19
|
+
}.freeze
|
20
|
+
}.freeze,
|
21
|
+
required: %i[name].freeze
|
22
|
+
}.freeze
|
23
|
+
|
24
|
+
class << self
|
25
|
+
def call(params = {})
|
26
|
+
instance = new(params)
|
27
|
+
|
28
|
+
instance.validate!
|
29
|
+
|
30
|
+
instance.post('v1/sub-organizations')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WavixApi
|
4
|
+
module V1
|
5
|
+
module SubOrganizations
|
6
|
+
class Find < ::WavixApi::V1::BaseFind
|
7
|
+
@params_schema = ::WavixApi::BaseMethods::ONLY_ID_SCHEMA
|
8
|
+
|
9
|
+
class << self
|
10
|
+
private
|
11
|
+
|
12
|
+
def path
|
13
|
+
'v1/sub-organizations'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'wavix_api'
|
4
|
+
|
5
|
+
module WavixApi
|
6
|
+
module V1
|
7
|
+
module SubOrganizations
|
8
|
+
class Search
|
9
|
+
include WavixApi::BaseMethods
|
10
|
+
|
11
|
+
@params_schema = {
|
12
|
+
type: 'object',
|
13
|
+
properties: {
|
14
|
+
status: { enum: %w[enabled disabled].freeze }.freeze,
|
15
|
+
**::WavixApi::BaseMethods::PAGINATION_SCHEMA
|
16
|
+
}.freeze
|
17
|
+
}.freeze
|
18
|
+
|
19
|
+
class << self
|
20
|
+
def call(params = {})
|
21
|
+
instance = new(params)
|
22
|
+
|
23
|
+
instance.validate!
|
24
|
+
|
25
|
+
instance.get('v1/sub-organizations')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'wavix_api'
|
4
|
+
|
5
|
+
module WavixApi
|
6
|
+
module V1
|
7
|
+
module SubOrganizations
|
8
|
+
class Transactions
|
9
|
+
include WavixApi::BaseMethods
|
10
|
+
|
11
|
+
@params_schema = {
|
12
|
+
type: 'object',
|
13
|
+
properties: {
|
14
|
+
type: { type: 'string' }.freeze,
|
15
|
+
id: { type: 'integer' }.freeze,
|
16
|
+
**::WavixApi::BaseMethods::PAGINATION_SCHEMA
|
17
|
+
}.freeze,
|
18
|
+
required: %i[id].freeze
|
19
|
+
}.freeze
|
20
|
+
|
21
|
+
class << self
|
22
|
+
def call(params = {})
|
23
|
+
instance = new(params)
|
24
|
+
|
25
|
+
instance.validate!
|
26
|
+
instance.validate_dates!(::WavixApi::V1::Cdrs::CommonVars::DATE_FIELDS)
|
27
|
+
|
28
|
+
instance.stringify_dates!(
|
29
|
+
instance.params, fields: ::WavixApi::V1::Cdrs::CommonVars::DATE_FIELDS
|
30
|
+
)
|
31
|
+
instance.get(
|
32
|
+
['v1/sub-organizations', instance.id, 'billing', 'transactions'].join('/')
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'wavix_api'
|
4
|
+
|
5
|
+
module WavixApi
|
6
|
+
module V1
|
7
|
+
module SubOrganizations
|
8
|
+
class Update
|
9
|
+
include WavixApi::BaseMethods
|
10
|
+
|
11
|
+
@params_schema = {
|
12
|
+
type: 'object',
|
13
|
+
properties: {
|
14
|
+
name: { type: 'string' }.freeze,
|
15
|
+
status: { enum: %w[active disabled].freeze }.freeze,
|
16
|
+
default_destinations: {
|
17
|
+
type: 'object',
|
18
|
+
properties: {
|
19
|
+
sms_endpoint: { type: 'string' }.freeze,
|
20
|
+
dlr_endpoint: { type: 'string' }.freeze
|
21
|
+
}.freeze
|
22
|
+
}.freeze,
|
23
|
+
id: { type: 'integer' }.freeze
|
24
|
+
}.freeze,
|
25
|
+
required: %i[name id].freeze
|
26
|
+
}.freeze
|
27
|
+
|
28
|
+
class << self
|
29
|
+
def call(params = {})
|
30
|
+
instance = new(params)
|
31
|
+
|
32
|
+
instance.validate!
|
33
|
+
|
34
|
+
instance.patch(['v1/sub-organizations', instance.id].join('/'))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WavixApi
|
4
|
+
module V1
|
5
|
+
module Trunks
|
6
|
+
class Create
|
7
|
+
include WavixApi::BaseMethods
|
8
|
+
|
9
|
+
@params_schema = {
|
10
|
+
type: 'object',
|
11
|
+
properties: {
|
12
|
+
label: { type: 'string' }.freeze,
|
13
|
+
password: { type: 'string' }.freeze,
|
14
|
+
callerid: { type: 'string' }.freeze,
|
15
|
+
ip_restrict: { type: 'boolean' }.freeze,
|
16
|
+
didinfo_enabled: { type: 'boolean' }.freeze,
|
17
|
+
call_restrict: { type: 'boolean' }.freeze,
|
18
|
+
call_limit: { type: 'integer' }.freeze,
|
19
|
+
cost_limit: { type: 'boolean' }.freeze,
|
20
|
+
max_call_cost: { type: 'number' }.freeze,
|
21
|
+
channels_restrict: { type: 'boolean' }.freeze,
|
22
|
+
max_channels: { type: 'integer' }.freeze,
|
23
|
+
rewrite_enabled: { type: 'boolean' }.freeze,
|
24
|
+
rewrite_prefix: { type: 'string' }.freeze,
|
25
|
+
rewrite_cond: { type: 'string' }.freeze,
|
26
|
+
multiple_numbers: { type: 'boolean' }.freeze,
|
27
|
+
allowed_ips: {
|
28
|
+
type: 'array',
|
29
|
+
items: {
|
30
|
+
type: 'object',
|
31
|
+
properties: {
|
32
|
+
ip: { type: 'string' }.freeze
|
33
|
+
}.freeze,
|
34
|
+
required: %i[ip].freeze
|
35
|
+
}
|
36
|
+
}.freeze,
|
37
|
+
host_request: {
|
38
|
+
type: 'object',
|
39
|
+
properties: {
|
40
|
+
host: { type: 'string' }.freeze,
|
41
|
+
status: { enum: %w[pending approved].freeze }.freeze
|
42
|
+
}.freeze
|
43
|
+
}.freeze,
|
44
|
+
call_recording_enabled: { type: 'boolean' }.freeze,
|
45
|
+
transcription_enabled: { type: 'boolean' }.freeze,
|
46
|
+
transcription_threshold: { type: 'integer' }.freeze,
|
47
|
+
machine_detection_enabled: { type: 'boolean' }.freeze
|
48
|
+
}.freeze,
|
49
|
+
required: %i[
|
50
|
+
label
|
51
|
+
password
|
52
|
+
callerid
|
53
|
+
ip_restrict
|
54
|
+
didinfo_enabled
|
55
|
+
call_restrict
|
56
|
+
cost_limit
|
57
|
+
channels_restrict
|
58
|
+
rewrite_enabled
|
59
|
+
transcription_enabled
|
60
|
+
transcription_threshold
|
61
|
+
].freeze
|
62
|
+
}.freeze
|
63
|
+
|
64
|
+
class << self
|
65
|
+
def call(params = {})
|
66
|
+
instance = new(params)
|
67
|
+
|
68
|
+
instance.validate!
|
69
|
+
|
70
|
+
instance.post('v1/trunks')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WavixApi
|
4
|
+
module V1
|
5
|
+
module Trunks
|
6
|
+
class Destroy < ::WavixApi::V1::BaseDestroy
|
7
|
+
@params_schema = ::WavixApi::BaseMethods::ONLY_ID_SCHEMA
|
8
|
+
|
9
|
+
class << self
|
10
|
+
private
|
11
|
+
|
12
|
+
def path
|
13
|
+
'v1/trunks'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WavixApi
|
4
|
+
module V1
|
5
|
+
module Trunks
|
6
|
+
class Find < ::WavixApi::V1::BaseFind
|
7
|
+
@params_schema = ::WavixApi::BaseMethods::ONLY_ID_SCHEMA
|
8
|
+
|
9
|
+
class << self
|
10
|
+
private
|
11
|
+
|
12
|
+
def path
|
13
|
+
'v1/trunks'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'wavix_api'
|
4
|
+
|
5
|
+
module WavixApi
|
6
|
+
module V1
|
7
|
+
module Trunks
|
8
|
+
class Search
|
9
|
+
include WavixApi::BaseMethods
|
10
|
+
|
11
|
+
@params_schema = {
|
12
|
+
type: 'object',
|
13
|
+
properties: {
|
14
|
+
**::WavixApi::BaseMethods::PAGINATION_SCHEMA
|
15
|
+
}
|
16
|
+
}.freeze
|
17
|
+
|
18
|
+
class << self
|
19
|
+
def call(params = {})
|
20
|
+
instance = new(params)
|
21
|
+
|
22
|
+
instance.validate!
|
23
|
+
|
24
|
+
instance.get('v1/trunks')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WavixApi
|
4
|
+
module V1
|
5
|
+
module Trunks
|
6
|
+
class Update
|
7
|
+
include WavixApi::BaseMethods
|
8
|
+
|
9
|
+
@params_schema = {
|
10
|
+
type: 'object',
|
11
|
+
properties: {
|
12
|
+
id: { type: 'integer' }.freeze,
|
13
|
+
label: { type: 'string' }.freeze,
|
14
|
+
password: { type: 'string' }.freeze,
|
15
|
+
callerid: { type: 'string' }.freeze,
|
16
|
+
ip_restrict: { type: 'boolean' }.freeze,
|
17
|
+
didinfo_enabled: { type: 'boolean' }.freeze,
|
18
|
+
call_restrict: { type: 'boolean' }.freeze,
|
19
|
+
call_limit: { type: 'integer' }.freeze,
|
20
|
+
cost_limit: { type: 'boolean' }.freeze,
|
21
|
+
max_call_cost: { type: 'number' }.freeze,
|
22
|
+
channels_restrict: { type: 'boolean' }.freeze,
|
23
|
+
max_channels: { type: 'integer' }.freeze,
|
24
|
+
rewrite_enabled: { type: 'boolean' }.freeze,
|
25
|
+
rewrite_prefix: { type: 'string' }.freeze,
|
26
|
+
rewrite_cond: { type: 'string' }.freeze,
|
27
|
+
multiple_numbers: { type: 'boolean' }.freeze,
|
28
|
+
allowed_ips: {
|
29
|
+
type: 'array',
|
30
|
+
items: {
|
31
|
+
type: 'object',
|
32
|
+
properties: {
|
33
|
+
id: { type: 'integer' }.freeze,
|
34
|
+
ip: {
|
35
|
+
type: 'string',
|
36
|
+
pattern: ::WavixApi::BaseMethods::IP_REGEXP
|
37
|
+
}.freeze,
|
38
|
+
_destroy: { type: 'boolean' }.freeze,
|
39
|
+
transcription_enabled: { type: 'boolean' }.freeze,
|
40
|
+
transcription_threshold: { type: 'integer' }.freeze
|
41
|
+
}.freeze,
|
42
|
+
required: %i[ip].freeze
|
43
|
+
}
|
44
|
+
}.freeze,
|
45
|
+
host_request: {
|
46
|
+
type: 'object',
|
47
|
+
properties: {
|
48
|
+
host: { type: 'string' }.freeze,
|
49
|
+
status: { enum: %w[pending approved].freeze }.freeze
|
50
|
+
}.freeze
|
51
|
+
}.freeze,
|
52
|
+
call_recording_enabled: { type: 'boolean' }.freeze,
|
53
|
+
transcription_enabled: { type: 'boolean' }.freeze,
|
54
|
+
transcription_threshold: { type: 'integer' }.freeze,
|
55
|
+
machine_detection_enabled: { type: 'boolean' }.freeze
|
56
|
+
}.freeze,
|
57
|
+
required: %i[
|
58
|
+
id
|
59
|
+
label
|
60
|
+
password
|
61
|
+
callerid
|
62
|
+
ip_restrict
|
63
|
+
didinfo_enabled
|
64
|
+
call_restrict
|
65
|
+
cost_limit
|
66
|
+
channels_restrict
|
67
|
+
rewrite_enabled
|
68
|
+
transcription_enabled
|
69
|
+
transcription_threshold
|
70
|
+
].freeze
|
71
|
+
}.freeze
|
72
|
+
|
73
|
+
class << self
|
74
|
+
def call(params = {})
|
75
|
+
instance = new(params)
|
76
|
+
|
77
|
+
instance.validate!
|
78
|
+
|
79
|
+
instance.put(['v1/trunks', instance.id].join('/'))
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'wavix_api'
|
4
|
+
|
5
|
+
module WavixApi
|
6
|
+
module V1
|
7
|
+
module VoiceCampaigns
|
8
|
+
class Create
|
9
|
+
include WavixApi::BaseMethods
|
10
|
+
|
11
|
+
@params_schema = {
|
12
|
+
type: 'object',
|
13
|
+
properties: {
|
14
|
+
voice_campaign: {
|
15
|
+
type: 'object',
|
16
|
+
properties: {
|
17
|
+
callflow_id: { type: 'integer' }.freeze,
|
18
|
+
contact: { type: 'string' }.freeze,
|
19
|
+
caller_id: { type: 'string' }.freeze
|
20
|
+
}.freeze,
|
21
|
+
required: %i[callflow_id contact caller_id].freeze
|
22
|
+
}.freeze
|
23
|
+
}.freeze,
|
24
|
+
required: %i[voice_campaign].freeze
|
25
|
+
}.freeze
|
26
|
+
|
27
|
+
class << self
|
28
|
+
def call(params = {})
|
29
|
+
instance = new(params)
|
30
|
+
|
31
|
+
instance.validate!
|
32
|
+
|
33
|
+
instance.post('v1/voice-campaigns')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'wavix_api'
|
4
|
+
|
5
|
+
module WavixApi
|
6
|
+
module V1
|
7
|
+
module VoiceCampaigns
|
8
|
+
class Find < ::WavixApi::V1::BaseFind
|
9
|
+
@params_schema = ::WavixApi::BaseMethods::ONLY_ID_SCHEMA
|
10
|
+
|
11
|
+
class << self
|
12
|
+
private
|
13
|
+
|
14
|
+
def path
|
15
|
+
'v1/voice-campaigns'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'common_vars'
|
4
|
+
|
5
|
+
module WavixApi
|
6
|
+
module V2
|
7
|
+
module Messages
|
8
|
+
class All < ::WavixApi::V2::BaseSearch
|
9
|
+
include ::WavixApi::V1::Messages::CommonVars
|
10
|
+
|
11
|
+
@params_schema = ::WavixApi::V1::Messages::CommonVars::SEARCH_PARAMS_SCHEMA
|
12
|
+
|
13
|
+
class << self
|
14
|
+
private
|
15
|
+
|
16
|
+
def path
|
17
|
+
'v2/messages/all'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WavixApi
|
4
|
+
module V2
|
5
|
+
module Messages
|
6
|
+
class AsyncCreate
|
7
|
+
include WavixApi::BaseMethods
|
8
|
+
include ::WavixApi::V1::Messages::CommonVars
|
9
|
+
|
10
|
+
@params_schema = ::WavixApi::V1::Messages::CommonVars::CREATE_PARAMS_SCHEMA
|
11
|
+
class << self
|
12
|
+
def call(params = {})
|
13
|
+
instance = new(params)
|
14
|
+
|
15
|
+
instance.validate!
|
16
|
+
|
17
|
+
instance.post('v2/messages/async')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'wavix_api'
|
4
|
+
|
5
|
+
module WavixApi
|
6
|
+
module V2
|
7
|
+
module Messages
|
8
|
+
module Attachments
|
9
|
+
class Find
|
10
|
+
include WavixApi::BaseMethods
|
11
|
+
|
12
|
+
@params_schema = {
|
13
|
+
type: 'object',
|
14
|
+
properties: {
|
15
|
+
id: { type: 'string' }.freeze,
|
16
|
+
sms_id: { type: 'string' }.freeze,
|
17
|
+
format: { type: 'string' }.freeze
|
18
|
+
}.freeze,
|
19
|
+
required: %i[id sms_id format].freeze
|
20
|
+
}.freeze
|
21
|
+
|
22
|
+
def initialize(params = {})
|
23
|
+
super(params)
|
24
|
+
@id = nil
|
25
|
+
end
|
26
|
+
|
27
|
+
class << self
|
28
|
+
def call(params = {}, save_path: nil)
|
29
|
+
instance = new(params)
|
30
|
+
instance.validate!
|
31
|
+
id = instance.params[:id]
|
32
|
+
format = instance.params[:format]
|
33
|
+
|
34
|
+
instance.download(
|
35
|
+
path(instance.params[:sms_id], id, format),
|
36
|
+
headers:
|
37
|
+
{
|
38
|
+
'Content-Disposition' => "attachment; filename='#{id}.#{format}}'",
|
39
|
+
'Content-Type' => 'application/octet-stream',
|
40
|
+
'Content-Transfer-Encoding' => 'binary'
|
41
|
+
},
|
42
|
+
save_path: save_path
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
def path(sms_id, id, format)
|
47
|
+
['v2/messages/attachments', sms_id, "#{id}.#{format}"]
|
48
|
+
.join('/')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def call(save_path: nil)
|
53
|
+
self.class.call(params, save_path: save_path)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WavixApi
|
4
|
+
module V1
|
5
|
+
module Messages
|
6
|
+
module CommonVars
|
7
|
+
SEARCH_PARAMS_SCHEMA = {
|
8
|
+
type: 'object',
|
9
|
+
properties: {
|
10
|
+
type: { string: 'string' }.freeze,
|
11
|
+
sent_after: { string: 'string' }.freeze,
|
12
|
+
sent_before: { string: 'string' }.freeze,
|
13
|
+
from: { string: 'string' }.freeze,
|
14
|
+
to: { string: 'string' }.freeze,
|
15
|
+
message_type: { string: 'string' }.freeze,
|
16
|
+
status: { string: 'string' }.freeze,
|
17
|
+
tag: { string: 'string' }.freeze,
|
18
|
+
**::WavixApi::BaseMethods::PAGINATION_SCHEMA
|
19
|
+
}.freeze,
|
20
|
+
required: %i[type sent_after sent_before].freeze
|
21
|
+
}.freeze
|
22
|
+
CREATE_PARAMS_SCHEMA = {
|
23
|
+
type: 'object',
|
24
|
+
properties: {
|
25
|
+
from: { string: 'string' }.freeze,
|
26
|
+
to: { string: 'string' }.freeze,
|
27
|
+
message_body: {
|
28
|
+
type: 'object',
|
29
|
+
properties: {
|
30
|
+
text: { type: 'string' }.freeze,
|
31
|
+
media: {
|
32
|
+
anyOf: [
|
33
|
+
{ type: 'array',
|
34
|
+
items: { type: 'string' }.freeze }.freeze,
|
35
|
+
{ type: 'string' }.freeze
|
36
|
+
]
|
37
|
+
}.freeze,
|
38
|
+
required: %i[text].freeze
|
39
|
+
}.freeze
|
40
|
+
},
|
41
|
+
callback_url: { string: 'string' },
|
42
|
+
validity: { integer: 'integer' },
|
43
|
+
tag: { string: 'string' }
|
44
|
+
}.freeze,
|
45
|
+
required: %i[from to message_body].freeze
|
46
|
+
}.freeze
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WavixApi
|
4
|
+
module V2
|
5
|
+
module Messages
|
6
|
+
class Create
|
7
|
+
include WavixApi::BaseMethods
|
8
|
+
include ::WavixApi::V1::Messages::CommonVars
|
9
|
+
|
10
|
+
@params_schema = ::WavixApi::V1::Messages::CommonVars::CREATE_PARAMS_SCHEMA
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def call(params = {})
|
14
|
+
instance = new(params)
|
15
|
+
|
16
|
+
instance.validate!
|
17
|
+
|
18
|
+
instance.post('v2/messages')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|