sms77 0.4.0 → 0.5.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.
- checksums.yaml +4 -4
- data/.gitignore +6 -4
- data/.idea/.gitignore +8 -0
- data/.idea/inspectionProfiles/Project_Default.xml +6 -0
- data/.idea/modules.xml +8 -0
- data/.idea/ruby-client.iml +18 -0
- data/.idea/vcs.xml +6 -0
- data/Gemfile +2 -2
- data/LICENSE +20 -20
- data/README.md +41 -35
- data/Rakefile +5 -5
- data/doc/Sms77/Client.html +230 -0
- data/doc/Sms77/Contacts/Action.html +131 -0
- data/doc/Sms77/Contacts.html +126 -0
- data/doc/Sms77/Endpoint.html +187 -0
- data/doc/Sms77/Hooks/Action.html +131 -0
- data/doc/Sms77/Hooks/EventType.html +146 -0
- data/doc/Sms77/Hooks/RequestMethod.html +131 -0
- data/doc/Sms77/Hooks/Validator.html +598 -0
- data/doc/Sms77/Hooks.html +126 -0
- data/doc/Sms77/Journal/Type.html +136 -0
- data/doc/Sms77/Journal/Validator.html +394 -0
- data/doc/Sms77/Journal.html +126 -0
- data/doc/Sms77/Lookup/Type.html +136 -0
- data/doc/Sms77/Lookup.html +126 -0
- data/doc/Sms77/Resource.html +870 -0
- data/doc/Sms77/Resources/Analytics.html +263 -0
- data/doc/Sms77/Resources/Balance.html +246 -0
- data/doc/Sms77/Resources/Contacts.html +449 -0
- data/doc/Sms77/Resources/Hooks.html +457 -0
- data/doc/Sms77/Resources/Journal.html +261 -0
- data/doc/Sms77/Resources/Lookup.html +540 -0
- data/doc/Sms77/Resources/Pricing.html +263 -0
- data/doc/Sms77/Resources/Sms.html +261 -0
- data/doc/Sms77/Resources/Status.html +261 -0
- data/doc/Sms77/Resources/Subaccounts.html +651 -0
- data/doc/Sms77/Resources/ValidateForVoice.html +261 -0
- data/doc/Sms77/Resources/Voice.html +261 -0
- data/doc/Sms77/Resources.html +128 -0
- data/doc/Sms77/Sms/Type.html +126 -0
- data/doc/Sms77/Sms.html +126 -0
- data/doc/Sms77/Subaccounts/Action.html +141 -0
- data/doc/Sms77/Subaccounts/Validator.html +490 -0
- data/doc/Sms77/Subaccounts.html +126 -0
- data/doc/Sms77/Util.html +1033 -0
- data/doc/Sms77.html +146 -0
- data/doc/_index.html +444 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +497 -0
- data/doc/file.README.html +112 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +112 -0
- data/doc/js/app.js +314 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +563 -0
- data/doc/top-level-namespace.html +110 -0
- data/lib/sms77/client.rb +30 -29
- data/lib/sms77/contacts.rb +10 -9
- data/lib/sms77/endpoint.rb +17 -15
- data/lib/sms77/hooks.rb +67 -64
- data/lib/sms77/journal.rb +39 -38
- data/lib/sms77/lookup.rb +11 -10
- data/lib/sms77/resource.rb +94 -93
- data/lib/sms77/resources/analytics.rb +21 -16
- data/lib/sms77/resources/balance.rb +19 -15
- data/lib/sms77/resources/contacts.rb +38 -25
- data/lib/sms77/resources/hooks.rb +40 -29
- data/lib/sms77/resources/journal.rb +20 -15
- data/lib/sms77/resources/lookup.rb +47 -29
- data/lib/sms77/resources/pricing.rb +20 -15
- data/lib/sms77/resources/sms.rb +20 -15
- data/lib/sms77/resources/status.rb +20 -15
- data/lib/sms77/resources/subaccounts.rb +66 -0
- data/lib/sms77/resources/validate_for_voice.rb +20 -15
- data/lib/sms77/resources/voice.rb +20 -15
- data/lib/sms77/sms.rb +9 -8
- data/lib/sms77/subaccounts.rb +55 -0
- data/lib/sms77/util.rb +68 -67
- data/lib/sms77/version.rb +5 -5
- data/lib/sms77.rb +6 -6
- data/release.sh +4 -7
- data/sms77.gemspec +21 -21
- data/spec/EnvKeyStore.rb +14 -14
- data/spec/matchers.rb +22 -22
- data/spec/sms77/balance_spec.rb +12 -12
- data/spec/sms77/client_spec.rb +15 -15
- data/spec/sms77/contacts_spec.rb +129 -116
- data/spec/sms77/hooks_spec.rb +108 -105
- data/spec/sms77/instance_spec.rb +22 -20
- data/spec/sms77/journal_spec.rb +86 -86
- data/spec/sms77/lookup_spec.rb +179 -179
- data/spec/sms77/pricing_spec.rb +76 -76
- data/spec/sms77/sms_spec.rb +103 -103
- data/spec/sms77/subaccounts_spec.rb +121 -0
- data/spec/sms77/validate_for_voice_spec.rb +19 -19
- data/spec/sms77/voice_spec.rb +51 -51
- data/spec/sms77_spec.rb +9 -7
- data/spec/spec_helper.rb +53 -53
- metadata +75 -17
@@ -1,26 +1,39 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'sms77/resource'
|
4
|
-
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
@
|
9
|
-
|
10
|
-
:
|
11
|
-
:
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sms77/resource'
|
4
|
+
|
5
|
+
# This module exposes the methods for communicating with the API endpoint /contacts.
|
6
|
+
module Sms77::Resources
|
7
|
+
class Contacts < Sms77::Resource
|
8
|
+
@endpoint = Sms77::Endpoint::CONTACTS
|
9
|
+
@http_methods = {
|
10
|
+
:delete => :post,
|
11
|
+
:read => :get,
|
12
|
+
:write => :post,
|
13
|
+
}
|
14
|
+
|
15
|
+
# Retrieve contacts associated with the API key
|
16
|
+
# read more: https://www.sms77.io/en/docs/gateway/http-api/contacts/#read-contacts
|
17
|
+
# @param params [Hash]
|
18
|
+
# @return [String, Hash]
|
19
|
+
def read(params = {})
|
20
|
+
request(params.merge({ :action => Sms77::Contacts::Action::READ }))
|
21
|
+
end
|
22
|
+
|
23
|
+
# Delete an account with given ID
|
24
|
+
# read more: https://www.sms77.io/en/docs/gateway/http-api/contacts/#delete-contacts
|
25
|
+
# @param params [Hash]
|
26
|
+
# @return [String, Hash]
|
27
|
+
def delete(params)
|
28
|
+
request({}, params.merge({ :action => Sms77::Contacts::Action::DEL }))
|
29
|
+
end
|
30
|
+
|
31
|
+
# Create or update a contact
|
32
|
+
# read more: https://www.sms77.io/en/docs/gateway/http-api/contacts/#create-and-edit-contacts
|
33
|
+
# @param params [Hash]
|
34
|
+
# @return [String, Hash]
|
35
|
+
def write(params)
|
36
|
+
request({}, params.merge({ :action => Sms77::Contacts::Action::WRITE }))
|
37
|
+
end
|
38
|
+
end
|
26
39
|
end
|
@@ -1,30 +1,41 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'sms77/resource'
|
4
|
-
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
:
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sms77/resource'
|
4
|
+
|
5
|
+
# This module exposes the methods for communicating with the API endpoint /hooks.
|
6
|
+
# read more: https://www.sms77.io/en/docs/gateway/http-api/webhooks/
|
7
|
+
module Sms77::Resources
|
8
|
+
class Hooks < Sms77::Resource
|
9
|
+
@endpoint = Sms77::Endpoint::HOOKS
|
10
|
+
@http_methods = {
|
11
|
+
:read => :get,
|
12
|
+
:subscribe => :post,
|
13
|
+
:unsubscribe => :post,
|
14
|
+
}
|
15
|
+
|
16
|
+
# Retrieve all webhooks
|
17
|
+
# @param params [Hash]
|
18
|
+
# @return [Hash]
|
19
|
+
def read(params = {})
|
20
|
+
request(params.merge({ :action => Sms77::Hooks::Action::READ }))
|
21
|
+
end
|
22
|
+
|
23
|
+
# Register a new webhook
|
24
|
+
# @param params [Hash]
|
25
|
+
# @return [Hash]
|
26
|
+
def subscribe(params)
|
27
|
+
Sms77::Hooks::Validator::subscribe(params)
|
28
|
+
|
29
|
+
request(params.merge({ :action => Sms77::Hooks::Action::SUBSCRIBE }))
|
30
|
+
end
|
31
|
+
|
32
|
+
# Delete a webhook
|
33
|
+
# @param params [Hash]
|
34
|
+
# @return [Hash]
|
35
|
+
def unsubscribe(params)
|
36
|
+
Sms77::Hooks::Validator::unsubscribe(params)
|
37
|
+
|
38
|
+
request(params.merge({ :action => Sms77::Hooks::Action::UNSUBSCRIBE }))
|
39
|
+
end
|
40
|
+
end
|
30
41
|
end
|
@@ -1,16 +1,21 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'sms77/resource'
|
4
|
-
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
@
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sms77/resource'
|
4
|
+
|
5
|
+
# This module exposes the methods for communicating with the API endpoint /journal.
|
6
|
+
module Sms77::Resources
|
7
|
+
class Journal < Sms77::Resource
|
8
|
+
@endpoint = Sms77::Endpoint::JOURNAL
|
9
|
+
@http_methods = {
|
10
|
+
:retrieve => :get,
|
11
|
+
}
|
12
|
+
|
13
|
+
# Retrieve the journal for associated API key
|
14
|
+
# read more: https://www.sms77.io/en/docs/gateway/http-api/journal/
|
15
|
+
# @param params [Hash]
|
16
|
+
# @return [Array]
|
17
|
+
def retrieve(params)
|
18
|
+
request(params)
|
19
|
+
end
|
20
|
+
end
|
16
21
|
end
|
@@ -1,30 +1,48 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'sms77/resource'
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
:
|
11
|
-
:
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sms77/resource'
|
4
|
+
|
5
|
+
# This module exposes the methods for communicating with the API endpoint /lookup.
|
6
|
+
module Sms77::Resources
|
7
|
+
class Lookup < Sms77::Resource
|
8
|
+
@endpoint = Sms77::Endpoint::LOOKUP
|
9
|
+
@http_methods = {
|
10
|
+
:cnam => :post,
|
11
|
+
:format => :post,
|
12
|
+
:hlr => :post,
|
13
|
+
:mnp => :post,
|
14
|
+
}
|
15
|
+
|
16
|
+
# Perform a caller name lookup
|
17
|
+
# read more: https://www.sms77.io/en/docs/gateway/http-api/cnam-lookup/
|
18
|
+
# @param params [Hash]
|
19
|
+
# @return [Hash,Array]
|
20
|
+
def cnam(params)
|
21
|
+
request(params.merge({ :type => Sms77::Lookup::Type::CNAM }))
|
22
|
+
end
|
23
|
+
|
24
|
+
# Retrieve phone number formats
|
25
|
+
# read more: https://www.sms77.io/en/docs/gateway/http-api/nummernformat-lookup/
|
26
|
+
# @param params [Hash]
|
27
|
+
# @return [String,Hash]
|
28
|
+
def format(params)
|
29
|
+
request(params.merge({ :type => Sms77::Lookup::Type::FORMAT }))
|
30
|
+
end
|
31
|
+
|
32
|
+
# Perform a home location register lookup
|
33
|
+
# read more: https://www.sms77.io/en/docs/gateway/http-api/hlr-lookup/
|
34
|
+
# @param params [Hash]
|
35
|
+
# @return [Hash,Array]
|
36
|
+
def hlr(params)
|
37
|
+
request(params.merge({ :type => Sms77::Lookup::Type::HLR }))
|
38
|
+
end
|
39
|
+
|
40
|
+
# Perform a mobile number portability lookup
|
41
|
+
# read more: https://www.sms77.io/en/docs/gateway/http-api/mnp-lookup/
|
42
|
+
# @param params [Hash]
|
43
|
+
# @return [Hash,Array]
|
44
|
+
def mnp(params)
|
45
|
+
request(params.merge({ :type => Sms77::Lookup::Type::MNP }))
|
46
|
+
end
|
47
|
+
end
|
30
48
|
end
|
@@ -1,16 +1,21 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'sms77/resource'
|
4
|
-
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
@
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sms77/resource'
|
4
|
+
|
5
|
+
# This module exposes the methods for communicating with the API endpoint /pricing.
|
6
|
+
module Sms77::Resources
|
7
|
+
class Pricing < Sms77::Resource
|
8
|
+
@endpoint = Sms77::Endpoint::PRICING
|
9
|
+
@http_methods = {
|
10
|
+
:retrieve => :get,
|
11
|
+
}
|
12
|
+
|
13
|
+
# Retrieve pricing
|
14
|
+
# read more: https://www.sms77.io/en/docs/gateway/http-api/pricing/
|
15
|
+
# @param params [Hash]
|
16
|
+
# @return [Hash,String]
|
17
|
+
def retrieve(params = {})
|
18
|
+
request(params)
|
19
|
+
end
|
20
|
+
end
|
16
21
|
end
|
data/lib/sms77/resources/sms.rb
CHANGED
@@ -1,16 +1,21 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'sms77/resource'
|
4
|
-
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
@
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sms77/resource'
|
4
|
+
|
5
|
+
# This module exposes the methods for communicating with the API endpoint /sms.
|
6
|
+
module Sms77::Resources
|
7
|
+
class Sms < Sms77::Resource
|
8
|
+
@endpoint = Sms77::Endpoint::SMS
|
9
|
+
@http_methods = {
|
10
|
+
:retrieve => :post,
|
11
|
+
}
|
12
|
+
|
13
|
+
# Send SMS
|
14
|
+
# read more: https://www.sms77.io/en/docs/gateway/http-api/sms-dispatch/
|
15
|
+
# @param params [Hash]
|
16
|
+
# @return [Integer,String,Hash]
|
17
|
+
def retrieve(params)
|
18
|
+
request(params)
|
19
|
+
end
|
20
|
+
end
|
16
21
|
end
|
@@ -1,16 +1,21 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'sms77/resource'
|
4
|
-
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
@
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sms77/resource'
|
4
|
+
|
5
|
+
# This module exposes the methods for communicating with the API endpoint /status.
|
6
|
+
module Sms77::Resources
|
7
|
+
class Status < Sms77::Resource
|
8
|
+
@endpoint = Sms77::Endpoint::STATUS
|
9
|
+
@http_methods = {
|
10
|
+
:retrieve => :get,
|
11
|
+
}
|
12
|
+
|
13
|
+
# Retrieve delivery report for a SMS
|
14
|
+
# read more: https://www.sms77.io/en/docs/gateway/http-api/status-reports/#query-delivery-reports
|
15
|
+
# @param params [Hash]
|
16
|
+
# @return [String]
|
17
|
+
def retrieve(params)
|
18
|
+
request(params)
|
19
|
+
end
|
20
|
+
end
|
16
21
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sms77/resource'
|
4
|
+
require 'sms77/subaccounts'
|
5
|
+
|
6
|
+
# This module exposes the methods for communicating with the API endpoint /subaccounts.
|
7
|
+
module Sms77::Resources
|
8
|
+
class Subaccounts < Sms77::Resource
|
9
|
+
@endpoint = Sms77::Endpoint::SUBACCOUNTS
|
10
|
+
@http_methods = {
|
11
|
+
:create => :post,
|
12
|
+
:delete => :post,
|
13
|
+
:read => :get,
|
14
|
+
:transfer_credits => :post,
|
15
|
+
:update => :post,
|
16
|
+
}
|
17
|
+
|
18
|
+
# Create a subaccount
|
19
|
+
# read more: https://www.sms77.io/en/docs/gateway/http-api/subaccounts/#create-subaccount
|
20
|
+
# @param params [Hash]
|
21
|
+
# @return [Hash]
|
22
|
+
def create(params)
|
23
|
+
Sms77::Subaccounts::Validator::create(params)
|
24
|
+
|
25
|
+
request(params.merge({ :action => Sms77::Subaccounts::Action::CREATE }))
|
26
|
+
end
|
27
|
+
|
28
|
+
# Delete a subaccount
|
29
|
+
# read more: https://www.sms77.io/en/docs/gateway/http-api/subaccounts/#delete-subaccount
|
30
|
+
# @param params [Hash]
|
31
|
+
# @return [Hash]
|
32
|
+
def delete(params)
|
33
|
+
Sms77::Subaccounts::Validator::delete(params)
|
34
|
+
|
35
|
+
request(params.merge({ :action => Sms77::Subaccounts::Action::DELETE }))
|
36
|
+
end
|
37
|
+
|
38
|
+
# Retrieve all subaccounts
|
39
|
+
# read more: https://www.sms77.io/en/docs/gateway/http-api/subaccounts/#read-subaccounts
|
40
|
+
# @param params [Hash]
|
41
|
+
# @return [Hash]
|
42
|
+
def read(params = {})
|
43
|
+
request({}, params.merge({ :action => Sms77::Subaccounts::Action::READ }))
|
44
|
+
end
|
45
|
+
|
46
|
+
# Transfer credits to a subaccount
|
47
|
+
# read more: https://www.sms77.io/en/docs/gateway/http-api/subaccounts/#transfer-credit
|
48
|
+
# @param params [Hash]
|
49
|
+
# @return [Hash]
|
50
|
+
def transfer_credits(params)
|
51
|
+
Sms77::Subaccounts::Validator::transfer_credits(params)
|
52
|
+
|
53
|
+
request(params.merge({ :action => Sms77::Subaccounts::Action::TRANSFER_CREDITS }))
|
54
|
+
end
|
55
|
+
|
56
|
+
# Update automatic charging of a subaccount
|
57
|
+
# read more: https://www.sms77.io/en/docs/gateway/http-api/subaccounts/#update-automatic-charging-of-the-subaccount
|
58
|
+
# @param params [Hash]
|
59
|
+
# @return [Hash]
|
60
|
+
def update(params)
|
61
|
+
Sms77::Subaccounts::Validator::update(params)
|
62
|
+
|
63
|
+
request(params.merge({ :action => Sms77::Subaccounts::Action::UPDATE }))
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -1,16 +1,21 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'sms77/resource'
|
4
|
-
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
@
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sms77/resource'
|
4
|
+
|
5
|
+
# This module exposes the methods for communicating with the API endpoint /validate_for_voice.
|
6
|
+
module Sms77::Resources
|
7
|
+
class ValidateForVoice < Sms77::Resource
|
8
|
+
@endpoint = Sms77::Endpoint::VALIDATE_FOR_VOICE
|
9
|
+
@http_methods = {
|
10
|
+
:retrieve => :post,
|
11
|
+
}
|
12
|
+
|
13
|
+
# Validate a phone number for using it as caller ID via our voice API
|
14
|
+
# read more: https://www.sms77.io/en/docs/gateway/http-api/caller-ids/
|
15
|
+
# @param params [Hash]
|
16
|
+
# @return [Hash]
|
17
|
+
def retrieve(params)
|
18
|
+
request(params)
|
19
|
+
end
|
20
|
+
end
|
16
21
|
end
|
@@ -1,16 +1,21 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'sms77/resource'
|
4
|
-
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
@
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sms77/resource'
|
4
|
+
|
5
|
+
# This module exposes the methods for communicating with the API endpoint /voice.
|
6
|
+
module Sms77::Resources
|
7
|
+
class Voice < Sms77::Resource
|
8
|
+
@endpoint = Sms77::Endpoint::VOICE
|
9
|
+
@http_methods = {
|
10
|
+
:send => :post,
|
11
|
+
}
|
12
|
+
|
13
|
+
# Convert text to speech, call number and read voice message out loud.
|
14
|
+
# read more: https://www.sms77.io/en/docs/gateway/http-api/voice/
|
15
|
+
# @param params [Hash]
|
16
|
+
# @return [String,Hash]
|
17
|
+
def send(params)
|
18
|
+
request(params)
|
19
|
+
end
|
20
|
+
end
|
16
21
|
end
|
data/lib/sms77/sms.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This module holds all utilities related to the /sms endpoint.
|
4
|
+
module Sms77::Sms
|
5
|
+
module Type
|
6
|
+
DIRECT = 'direct'
|
7
|
+
ECONOMY = 'economy'
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This module holds all utilities related to the /subaccounts endpoint.
|
4
|
+
module Sms77::Subaccounts
|
5
|
+
module Action
|
6
|
+
CREATE = 'create'
|
7
|
+
DELETE = 'delete'
|
8
|
+
READ = 'read'
|
9
|
+
TRANSFER_CREDITS = 'transfer_credits'
|
10
|
+
UPDATE = 'update'
|
11
|
+
end
|
12
|
+
|
13
|
+
module Validator
|
14
|
+
def self.is_action?(str)
|
15
|
+
Sms77::Util::in_module_constants?(str, Sms77::Subaccounts::Action)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.validate(params)
|
19
|
+
action = params[:action]
|
20
|
+
|
21
|
+
case action
|
22
|
+
when Sms77::Subaccounts::Action::CREATE
|
23
|
+
raise 'Parameter validation failed' unless Sms77::Subaccounts::Validator::create(params)
|
24
|
+
when Sms77::Subaccounts::Action::DELETE
|
25
|
+
raise 'Parameter validation failed' unless Sms77::Subaccounts::Validator::delete(params)
|
26
|
+
when Sms77::Subaccounts::Action::TRANSFER_CREDITS
|
27
|
+
raise 'Parameter validation failed' unless Sms77::Subaccounts::Validator::transfer_credits(params)
|
28
|
+
when Sms77::Subaccounts::Action::UPDATE
|
29
|
+
raise 'Parameter validation failed' unless Sms77::Subaccounts::Validator::update(params)
|
30
|
+
else
|
31
|
+
raise "Unknown action #{action}" unless Sms77::Subaccounts::Validator::is_action?(action)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.create(params)
|
36
|
+
Sms77::Util::lengthy_string?(params[:email]) &&
|
37
|
+
Sms77::Util::lengthy_string?(params[:name])
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.delete(params)
|
41
|
+
Sms77::Util::is_positive_integer?(params[:id])
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.transfer_credits(params)
|
45
|
+
Sms77::Util::is_positive_integer?(params[:amount]) &&
|
46
|
+
Sms77::Util::is_positive_integer?(params[:id])
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.update(params)
|
50
|
+
Sms77::Util::is_positive_integer?(params[:amount]) &&
|
51
|
+
Sms77::Util::is_positive_integer?(params[:id]) &&
|
52
|
+
Sms77::Util::is_positive_integer?(params[:threshold])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|