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.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -4
  3. data/.idea/.gitignore +8 -0
  4. data/.idea/inspectionProfiles/Project_Default.xml +6 -0
  5. data/.idea/modules.xml +8 -0
  6. data/.idea/ruby-client.iml +18 -0
  7. data/.idea/vcs.xml +6 -0
  8. data/Gemfile +2 -2
  9. data/LICENSE +20 -20
  10. data/README.md +41 -35
  11. data/Rakefile +5 -5
  12. data/doc/Sms77/Client.html +230 -0
  13. data/doc/Sms77/Contacts/Action.html +131 -0
  14. data/doc/Sms77/Contacts.html +126 -0
  15. data/doc/Sms77/Endpoint.html +187 -0
  16. data/doc/Sms77/Hooks/Action.html +131 -0
  17. data/doc/Sms77/Hooks/EventType.html +146 -0
  18. data/doc/Sms77/Hooks/RequestMethod.html +131 -0
  19. data/doc/Sms77/Hooks/Validator.html +598 -0
  20. data/doc/Sms77/Hooks.html +126 -0
  21. data/doc/Sms77/Journal/Type.html +136 -0
  22. data/doc/Sms77/Journal/Validator.html +394 -0
  23. data/doc/Sms77/Journal.html +126 -0
  24. data/doc/Sms77/Lookup/Type.html +136 -0
  25. data/doc/Sms77/Lookup.html +126 -0
  26. data/doc/Sms77/Resource.html +870 -0
  27. data/doc/Sms77/Resources/Analytics.html +263 -0
  28. data/doc/Sms77/Resources/Balance.html +246 -0
  29. data/doc/Sms77/Resources/Contacts.html +449 -0
  30. data/doc/Sms77/Resources/Hooks.html +457 -0
  31. data/doc/Sms77/Resources/Journal.html +261 -0
  32. data/doc/Sms77/Resources/Lookup.html +540 -0
  33. data/doc/Sms77/Resources/Pricing.html +263 -0
  34. data/doc/Sms77/Resources/Sms.html +261 -0
  35. data/doc/Sms77/Resources/Status.html +261 -0
  36. data/doc/Sms77/Resources/Subaccounts.html +651 -0
  37. data/doc/Sms77/Resources/ValidateForVoice.html +261 -0
  38. data/doc/Sms77/Resources/Voice.html +261 -0
  39. data/doc/Sms77/Resources.html +128 -0
  40. data/doc/Sms77/Sms/Type.html +126 -0
  41. data/doc/Sms77/Sms.html +126 -0
  42. data/doc/Sms77/Subaccounts/Action.html +141 -0
  43. data/doc/Sms77/Subaccounts/Validator.html +490 -0
  44. data/doc/Sms77/Subaccounts.html +126 -0
  45. data/doc/Sms77/Util.html +1033 -0
  46. data/doc/Sms77.html +146 -0
  47. data/doc/_index.html +444 -0
  48. data/doc/class_list.html +51 -0
  49. data/doc/css/common.css +1 -0
  50. data/doc/css/full_list.css +58 -0
  51. data/doc/css/style.css +497 -0
  52. data/doc/file.README.html +112 -0
  53. data/doc/file_list.html +56 -0
  54. data/doc/frames.html +17 -0
  55. data/doc/index.html +112 -0
  56. data/doc/js/app.js +314 -0
  57. data/doc/js/full_list.js +216 -0
  58. data/doc/js/jquery.js +4 -0
  59. data/doc/method_list.html +563 -0
  60. data/doc/top-level-namespace.html +110 -0
  61. data/lib/sms77/client.rb +30 -29
  62. data/lib/sms77/contacts.rb +10 -9
  63. data/lib/sms77/endpoint.rb +17 -15
  64. data/lib/sms77/hooks.rb +67 -64
  65. data/lib/sms77/journal.rb +39 -38
  66. data/lib/sms77/lookup.rb +11 -10
  67. data/lib/sms77/resource.rb +94 -93
  68. data/lib/sms77/resources/analytics.rb +21 -16
  69. data/lib/sms77/resources/balance.rb +19 -15
  70. data/lib/sms77/resources/contacts.rb +38 -25
  71. data/lib/sms77/resources/hooks.rb +40 -29
  72. data/lib/sms77/resources/journal.rb +20 -15
  73. data/lib/sms77/resources/lookup.rb +47 -29
  74. data/lib/sms77/resources/pricing.rb +20 -15
  75. data/lib/sms77/resources/sms.rb +20 -15
  76. data/lib/sms77/resources/status.rb +20 -15
  77. data/lib/sms77/resources/subaccounts.rb +66 -0
  78. data/lib/sms77/resources/validate_for_voice.rb +20 -15
  79. data/lib/sms77/resources/voice.rb +20 -15
  80. data/lib/sms77/sms.rb +9 -8
  81. data/lib/sms77/subaccounts.rb +55 -0
  82. data/lib/sms77/util.rb +68 -67
  83. data/lib/sms77/version.rb +5 -5
  84. data/lib/sms77.rb +6 -6
  85. data/release.sh +4 -7
  86. data/sms77.gemspec +21 -21
  87. data/spec/EnvKeyStore.rb +14 -14
  88. data/spec/matchers.rb +22 -22
  89. data/spec/sms77/balance_spec.rb +12 -12
  90. data/spec/sms77/client_spec.rb +15 -15
  91. data/spec/sms77/contacts_spec.rb +129 -116
  92. data/spec/sms77/hooks_spec.rb +108 -105
  93. data/spec/sms77/instance_spec.rb +22 -20
  94. data/spec/sms77/journal_spec.rb +86 -86
  95. data/spec/sms77/lookup_spec.rb +179 -179
  96. data/spec/sms77/pricing_spec.rb +76 -76
  97. data/spec/sms77/sms_spec.rb +103 -103
  98. data/spec/sms77/subaccounts_spec.rb +121 -0
  99. data/spec/sms77/validate_for_voice_spec.rb +19 -19
  100. data/spec/sms77/voice_spec.rb +51 -51
  101. data/spec/sms77_spec.rb +9 -7
  102. data/spec/spec_helper.rb +53 -53
  103. metadata +75 -17
@@ -1,26 +1,39 @@
1
- # frozen_string_literal: true
2
-
3
- require 'sms77/resource'
4
-
5
- module Sms77::Resources
6
- class Contacts < Sms77::Resource
7
- @endpoint = Sms77::Endpoint::CONTACTS
8
- @http_methods = {
9
- :delete => :post,
10
- :read => :get,
11
- :write => :post,
12
- }
13
-
14
- def read(params = {})
15
- request(params.merge({ :action => Sms77::Contacts::Action::READ }))
16
- end
17
-
18
- def delete(params)
19
- request({}, params.merge({ :action => Sms77::Contacts::Action::DEL }))
20
- end
21
-
22
- def write(params)
23
- request({}, params.merge({ :action => Sms77::Contacts::Action::WRITE }))
24
- end
25
- end
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 Sms77::Resources
6
- class Hooks < Sms77::Resource
7
- @endpoint = Sms77::Endpoint::HOOKS
8
- @http_methods = {
9
- :read => :get,
10
- :subscribe => :post,
11
- :unsubscribe => :post,
12
- }
13
-
14
- def read(params = {})
15
- request(params.merge({ :action => Sms77::Hooks::Action::READ }))
16
- end
17
-
18
- def subscribe(params)
19
- Sms77::Hooks::Validator::subscribe(params)
20
-
21
- request(params.merge({ :action => Sms77::Hooks::Action::SUBSCRIBE }))
22
- end
23
-
24
- def unsubscribe(params)
25
- Sms77::Hooks::Validator::unsubscribe(params)
26
-
27
- request(params.merge({ :action => Sms77::Hooks::Action::UNSUBSCRIBE }))
28
- end
29
- end
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 Sms77::Resources
6
- class Journal < Sms77::Resource
7
- @endpoint = Sms77::Endpoint::JOURNAL
8
- @http_methods = {
9
- :retrieve => :get,
10
- }
11
-
12
- def retrieve(params)
13
- request(params)
14
- end
15
- end
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
- module Sms77::Resources
5
- class Lookup < Sms77::Resource
6
- @endpoint = Sms77::Endpoint::LOOKUP
7
- @http_methods = {
8
- :cnam => :post,
9
- :format => :post,
10
- :hlr => :post,
11
- :mnp => :post,
12
- }
13
-
14
- def cnam(params)
15
- request(params.merge({ :type => Sms77::Lookup::Type::CNAM }))
16
- end
17
-
18
- def format(params)
19
- request(params.merge({ :type => Sms77::Lookup::Type::FORMAT }))
20
- end
21
-
22
- def hlr(params)
23
- request(params.merge({ :type => Sms77::Lookup::Type::HLR }))
24
- end
25
-
26
- def mnp(params)
27
- request(params.merge({ :type => Sms77::Lookup::Type::MNP }))
28
- end
29
- end
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 Sms77::Resources
6
- class Pricing < Sms77::Resource
7
- @endpoint = Sms77::Endpoint::PRICING
8
- @http_methods = {
9
- :retrieve => :get,
10
- }
11
-
12
- def retrieve(params = {})
13
- request(params)
14
- end
15
- end
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
@@ -1,16 +1,21 @@
1
- # frozen_string_literal: true
2
-
3
- require 'sms77/resource'
4
-
5
- module Sms77::Resources
6
- class Sms < Sms77::Resource
7
- @endpoint = Sms77::Endpoint::SMS
8
- @http_methods = {
9
- :retrieve => :post,
10
- }
11
-
12
- def retrieve(params)
13
- request(params)
14
- end
15
- end
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 Sms77::Resources
6
- class Status < Sms77::Resource
7
- @endpoint = Sms77::Endpoint::STATUS
8
- @http_methods = {
9
- :retrieve => :get,
10
- }
11
-
12
- def retrieve(params)
13
- request(params)
14
- end
15
- end
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 Sms77::Resources
6
- class ValidateForVoice < Sms77::Resource
7
- @endpoint = Sms77::Endpoint::VALIDATE_FOR_VOICE
8
- @http_methods = {
9
- :retrieve => :post,
10
- }
11
-
12
- def retrieve(params)
13
- request(params)
14
- end
15
- end
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 Sms77::Resources
6
- class Voice < Sms77::Resource
7
- @endpoint = Sms77::Endpoint::VOICE
8
- @http_methods = {
9
- :send => :post,
10
- }
11
-
12
- def send(params)
13
- request(params)
14
- end
15
- end
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 Sms77::Sms
4
- module Type
5
- DIRECT = 'direct'
6
- ECONOMY = 'economy'
7
- end
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