seven_api 0.6.0 → 0.6.1

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 (96) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +7 -6
  3. data/.idea/inspectionProfiles/Project_Default.xml +5 -5
  4. data/.idea/ruby-client.iml +48 -13
  5. data/Gemfile +2 -2
  6. data/LICENSE +21 -21
  7. data/README.md +1 -1
  8. data/Rakefile +5 -5
  9. data/doc/SevenApi/Client.html +8 -8
  10. data/doc/SevenApi/Contacts/Action.html +0 -0
  11. data/doc/SevenApi/Contacts.html +0 -0
  12. data/doc/SevenApi/Endpoint.html +0 -0
  13. data/doc/SevenApi/Hooks/Action.html +0 -0
  14. data/doc/SevenApi/Hooks/EventType.html +0 -0
  15. data/doc/SevenApi/Hooks/RequestMethod.html +0 -0
  16. data/doc/SevenApi/Hooks/Validator.html +26 -26
  17. data/doc/SevenApi/Hooks.html +0 -0
  18. data/doc/SevenApi/Journal/Type.html +0 -0
  19. data/doc/SevenApi/Journal/Validator.html +18 -18
  20. data/doc/SevenApi/Journal.html +0 -0
  21. data/doc/SevenApi/Lookup/Type.html +0 -0
  22. data/doc/SevenApi/Lookup.html +0 -0
  23. data/doc/SevenApi/Resource.html +13 -13
  24. data/doc/SevenApi/Resources/Analytics.html +2 -2
  25. data/doc/SevenApi/Resources/Balance.html +2 -2
  26. data/doc/SevenApi/Resources/Contacts.html +6 -6
  27. data/doc/SevenApi/Resources/Hooks.html +10 -10
  28. data/doc/SevenApi/Resources/Journal.html +2 -2
  29. data/doc/SevenApi/Resources/Lookup.html +8 -8
  30. data/doc/SevenApi/Resources/Pricing.html +2 -2
  31. data/doc/SevenApi/Resources/Sms.html +2 -2
  32. data/doc/SevenApi/Resources/Status.html +2 -2
  33. data/doc/SevenApi/Resources/Subaccounts.html +18 -18
  34. data/doc/SevenApi/Resources/ValidateForVoice.html +2 -2
  35. data/doc/SevenApi/Resources/Voice.html +2 -2
  36. data/doc/SevenApi/Resources.html +0 -0
  37. data/doc/SevenApi/Sms/Type.html +0 -0
  38. data/doc/SevenApi/Sms.html +0 -0
  39. data/doc/SevenApi/Subaccounts/Action.html +0 -0
  40. data/doc/SevenApi/Subaccounts/Validator.html +29 -29
  41. data/doc/SevenApi/Subaccounts.html +0 -0
  42. data/doc/SevenApi/Util.html +39 -39
  43. data/doc/SevenApi.html +0 -0
  44. data/document.sh +3 -0
  45. data/lib/seven_api/client.rb +32 -32
  46. data/lib/seven_api/contacts.rb +5 -5
  47. data/lib/seven_api/endpoint.rb +0 -0
  48. data/lib/seven_api/hooks.rb +69 -68
  49. data/lib/seven_api/journal.rb +39 -39
  50. data/lib/seven_api/lookup.rb +12 -12
  51. data/lib/seven_api/numbers.rb +9 -9
  52. data/lib/seven_api/paginated.rb +10 -10
  53. data/lib/seven_api/rcs.rb +0 -0
  54. data/lib/seven_api/resource.rb +1 -2
  55. data/lib/seven_api/resources/analytics.rb +54 -54
  56. data/lib/seven_api/resources/balance.rb +19 -19
  57. data/lib/seven_api/resources/contacts.rb +56 -56
  58. data/lib/seven_api/resources/groups.rb +56 -56
  59. data/lib/seven_api/resources/hooks.rb +40 -40
  60. data/lib/seven_api/resources/journal.rb +20 -20
  61. data/lib/seven_api/resources/lookup.rb +63 -63
  62. data/lib/seven_api/resources/numbers.rb +70 -69
  63. data/lib/seven_api/resources/pricing.rb +20 -20
  64. data/lib/seven_api/resources/rcs.rb +3 -3
  65. data/lib/seven_api/resources/sms.rb +29 -20
  66. data/lib/seven_api/resources/status.rb +20 -20
  67. data/lib/seven_api/resources/subaccounts.rb +65 -65
  68. data/lib/seven_api/resources/validate_for_voice.rb +20 -20
  69. data/lib/seven_api/resources/voice.rb +29 -20
  70. data/lib/seven_api/sms.rb +9 -9
  71. data/lib/seven_api/subaccounts.rb +55 -55
  72. data/lib/seven_api/util.rb +68 -68
  73. data/lib/seven_api/version.rb +5 -5
  74. data/lib/seven_api.rb +6 -6
  75. data/release.sh +4 -4
  76. data/seven_api.gemspec +0 -0
  77. data/spec/EnvKeyStore.rb +14 -14
  78. data/spec/matchers.rb +22 -22
  79. data/spec/seven_api/analytics_spec.rb +49 -49
  80. data/spec/seven_api/balance_spec.rb +18 -18
  81. data/spec/seven_api/client_spec.rb +15 -15
  82. data/spec/seven_api/contacts_spec.rb +100 -100
  83. data/spec/seven_api/groups_spec.rb +74 -74
  84. data/spec/seven_api/hooks_spec.rb +108 -108
  85. data/spec/seven_api/instance_spec.rb +22 -22
  86. data/spec/seven_api/journal_spec.rb +86 -86
  87. data/spec/seven_api/lookup_spec.rb +197 -197
  88. data/spec/seven_api/numbers_spec.rb +135 -135
  89. data/spec/seven_api/pricing_spec.rb +76 -76
  90. data/spec/seven_api/rcs_spec.rb +0 -0
  91. data/spec/seven_api/sms_spec.rb +103 -103
  92. data/spec/seven_api/subaccounts_spec.rb +121 -121
  93. data/spec/seven_api/validate_for_voice_spec.rb +19 -19
  94. data/spec/seven_api/voice_spec.rb +51 -51
  95. data/spec/seven_api_spec.rb +9 -9
  96. metadata +4 -6
@@ -1,21 +1,21 @@
1
- # frozen_string_literal: true
2
-
3
- require 'seven_api/resource'
4
-
5
- # This module exposes the methods for communicating with the API endpoint /status.
6
- module SevenApi::Resources
7
- class Status < SevenApi::Resource
8
- @endpoint = SevenApi::Endpoint::STATUS
9
- @http_methods = {
10
- :retrieve => :get,
11
- }
12
-
13
- # Retrieve delivery report for a SMS
14
- # read more: https://docs.seven.io/en/rest-api/endpoints/status-reports#query-status-reports
15
- # @param params [Hash]
16
- # @return [String]
17
- def retrieve(params)
18
- request(params)
19
- end
20
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'seven_api/resource'
4
+
5
+ # This module exposes the methods for communicating with the API endpoint /status.
6
+ module SevenApi::Resources
7
+ class Status < SevenApi::Resource
8
+ @endpoint = SevenApi::Endpoint::STATUS
9
+ @http_methods = {
10
+ :retrieve => :get,
11
+ }
12
+
13
+ # Retrieve delivery report for a SMS
14
+ # read more: https://docs.seven.io/en/rest-api/endpoints/status-reports#query-status-reports
15
+ # @param params [Hash]
16
+ # @return [String]
17
+ def retrieve(params)
18
+ request(:get, params)
19
+ end
20
+ end
21
21
  end
@@ -1,66 +1,66 @@
1
- # frozen_string_literal: true
2
-
3
- require 'seven_api/resource'
4
- require 'seven_api/subaccounts'
5
-
6
- # This module exposes the methods for communicating with the API endpoint /subaccounts.
7
- module SevenApi::Resources
8
- class Subaccounts < SevenApi::Resource
9
- @endpoint = SevenApi::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://docs.seven.io/en/rest-api/endpoints/subaccounts#create-subaccount
20
- # @param params [Hash]
21
- # @return [Hash]
22
- def create(params)
23
- SevenApi::Subaccounts::Validator::create(params)
24
-
25
- request(params.merge({ :action => SevenApi::Subaccounts::Action::CREATE }))
26
- end
27
-
28
- # Delete a subaccount
29
- # read more: https://docs.seven.io/en/rest-api/endpoints/subaccounts#delete-a-subaccount
30
- # @param params [Hash]
31
- # @return [Hash]
32
- def delete(params)
33
- SevenApi::Subaccounts::Validator::delete(params)
34
-
35
- request(params.merge({ :action => SevenApi::Subaccounts::Action::DELETE }))
36
- end
37
-
38
- # Retrieve all subaccounts
39
- # read more: https://docs.seven.io/en/rest-api/endpoints/subaccounts#list-subaccounts
40
- # @param params [Hash]
41
- # @return [Hash]
42
- def read(params = {})
43
- request({}, params.merge({ :action => SevenApi::Subaccounts::Action::READ }))
44
- end
45
-
46
- # Transfer credits to a subaccount
47
- # read more: https://docs.seven.io/en/rest-api/endpoints/subaccounts#manual-credit-transfer
48
- # @param params [Hash]
49
- # @return [Hash]
50
- def transfer_credits(params)
51
- SevenApi::Subaccounts::Validator::transfer_credits(params)
52
-
53
- request(params.merge({ :action => SevenApi::Subaccounts::Action::TRANSFER_CREDITS }))
54
- end
55
-
56
- # Update automatic charging of a subaccount
57
- # read more: https://docs.seven.io/en/rest-api/endpoints/subaccounts#automatic-credit-transfer
58
- # @param params [Hash]
59
- # @return [Hash]
60
- def update(params)
61
- SevenApi::Subaccounts::Validator::update(params)
62
-
63
- request(params.merge({ :action => SevenApi::Subaccounts::Action::UPDATE }))
64
- end
65
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'seven_api/resource'
4
+ require 'seven_api/subaccounts'
5
+
6
+ # This module exposes the methods for communicating with the API endpoint /subaccounts.
7
+ module SevenApi::Resources
8
+ class Subaccounts < SevenApi::Resource
9
+ @endpoint = SevenApi::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://docs.seven.io/en/rest-api/endpoints/subaccounts#create-subaccount
20
+ # @param params [Hash]
21
+ # @return [Hash]
22
+ def create(params)
23
+ SevenApi::Subaccounts::Validator::create(params)
24
+
25
+ request(:post, params.merge({ :action => SevenApi::Subaccounts::Action::CREATE }))
26
+ end
27
+
28
+ # Delete a subaccount
29
+ # read more: https://docs.seven.io/en/rest-api/endpoints/subaccounts#delete-a-subaccount
30
+ # @param params [Hash]
31
+ # @return [Hash]
32
+ def delete(params)
33
+ SevenApi::Subaccounts::Validator::delete(params)
34
+
35
+ request(:post, params.merge({ :action => SevenApi::Subaccounts::Action::DELETE }))
36
+ end
37
+
38
+ # Retrieve all subaccounts
39
+ # read more: https://docs.seven.io/en/rest-api/endpoints/subaccounts#list-subaccounts
40
+ # @param params [Hash]
41
+ # @return [Hash]
42
+ def read(params = {})
43
+ request(:get, {}, params.merge({ :action => SevenApi::Subaccounts::Action::READ }))
44
+ end
45
+
46
+ # Transfer credits to a subaccount
47
+ # read more: https://docs.seven.io/en/rest-api/endpoints/subaccounts#manual-credit-transfer
48
+ # @param params [Hash]
49
+ # @return [Hash]
50
+ def transfer_credits(params)
51
+ SevenApi::Subaccounts::Validator::transfer_credits(params)
52
+
53
+ request(:post, params.merge({ :action => SevenApi::Subaccounts::Action::TRANSFER_CREDITS }))
54
+ end
55
+
56
+ # Update automatic charging of a subaccount
57
+ # read more: https://docs.seven.io/en/rest-api/endpoints/subaccounts#automatic-credit-transfer
58
+ # @param params [Hash]
59
+ # @return [Hash]
60
+ def update(params)
61
+ SevenApi::Subaccounts::Validator::update(params)
62
+
63
+ request(:post, params.merge({ :action => SevenApi::Subaccounts::Action::UPDATE }))
64
+ end
65
+ end
66
66
  end
@@ -1,21 +1,21 @@
1
- # frozen_string_literal: true
2
-
3
- require 'seven_api/resource'
4
-
5
- # This module exposes the methods for communicating with the API endpoint /validate_for_voice.
6
- module SevenApi::Resources
7
- class ValidateForVoice < SevenApi::Resource
8
- @endpoint = SevenApi::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://docs.seven.io/en/rest-api/endpoints/sender-identifiers#validate-sender-for-voice
15
- # @param params [Hash]
16
- # @return [Hash]
17
- def retrieve(params)
18
- request(params)
19
- end
20
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'seven_api/resource'
4
+
5
+ # This module exposes the methods for communicating with the API endpoint /validate_for_voice.
6
+ module SevenApi::Resources
7
+ class ValidateForVoice < SevenApi::Resource
8
+ @endpoint = SevenApi::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://docs.seven.io/en/rest-api/endpoints/sender-identifiers#validate-sender-for-voice
15
+ # @param params [Hash]
16
+ # @return [Hash]
17
+ def retrieve(params)
18
+ request(:post, params)
19
+ end
20
+ end
21
21
  end
@@ -1,21 +1,30 @@
1
- # frozen_string_literal: true
2
-
3
- require 'seven_api/resource'
4
-
5
- # This module exposes the methods for communicating with the API endpoint /voice.
6
- module SevenApi::Resources
7
- class Voice < SevenApi::Resource
8
- @endpoint = SevenApi::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://docs.seven.io/en/rest-api/endpoints/voice#send-voice-call
15
- # @param params [Hash]
16
- # @return [String,Hash]
17
- def send(params)
18
- request(params)
19
- end
20
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'seven_api/resource'
4
+
5
+ # This module exposes the methods for communicating with the API endpoint /voice.
6
+ module SevenApi::Resources
7
+ class Voice < SevenApi::Resource
8
+ @endpoint = SevenApi::Endpoint::VOICE
9
+ @http_methods = {
10
+ :hangup => :post,
11
+ :send => :post,
12
+ }
13
+
14
+ # This endpoint ends an active call. Only calls with the status in-progress can be ended.
15
+ # read more: https://docs.seven.io/en/rest-api/endpoints/voice#hangup-a-call
16
+ # @param call_id [String]
17
+ # @return Hash
18
+ def hangup(call_id)
19
+ request(:post, {}, {}, "/#{call_id}/hangup")
20
+ end
21
+
22
+ # Convert text to speech, call number and read voice message out loud.
23
+ # read more: https://docs.seven.io/en/rest-api/endpoints/voice#send-voice-call
24
+ # @param params [Hash]
25
+ # @return [String,Hash]
26
+ def send(params)
27
+ request(:post, params)
28
+ end
29
+ end
21
30
  end
data/lib/seven_api/sms.rb CHANGED
@@ -1,9 +1,9 @@
1
- # frozen_string_literal: true
2
-
3
- # This module holds all utilities related to the /sms endpoint.
4
- module SevenApi::Sms
5
- module Type
6
- DIRECT = 'direct'
7
- ECONOMY = 'economy'
8
- end
9
- end
1
+ # frozen_string_literal: true
2
+
3
+ # This module holds all utilities related to the /sms endpoint.
4
+ module SevenApi::Sms
5
+ module Type
6
+ DIRECT = 'direct'
7
+ ECONOMY = 'economy'
8
+ end
9
+ end
@@ -1,55 +1,55 @@
1
- # frozen_string_literal: true
2
-
3
- # This module holds all utilities related to the /subaccounts endpoint.
4
- module SevenApi::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
- SevenApi::Util::in_module_constants?(str, SevenApi::Subaccounts::Action)
16
- end
17
-
18
- def self.validate(params)
19
- action = params[:action]
20
-
21
- case action
22
- when SevenApi::Subaccounts::Action::CREATE
23
- raise 'Parameter validation failed' unless SevenApi::Subaccounts::Validator::create(params)
24
- when SevenApi::Subaccounts::Action::DELETE
25
- raise 'Parameter validation failed' unless SevenApi::Subaccounts::Validator::delete(params)
26
- when SevenApi::Subaccounts::Action::TRANSFER_CREDITS
27
- raise 'Parameter validation failed' unless SevenApi::Subaccounts::Validator::transfer_credits(params)
28
- when SevenApi::Subaccounts::Action::UPDATE
29
- raise 'Parameter validation failed' unless SevenApi::Subaccounts::Validator::update(params)
30
- else
31
- raise "Unknown action #{action}" unless SevenApi::Subaccounts::Validator::is_action?(action)
32
- end
33
- end
34
-
35
- def self.create(params)
36
- SevenApi::Util::lengthy_string?(params[:email]) &&
37
- SevenApi::Util::lengthy_string?(params[:name])
38
- end
39
-
40
- def self.delete(params)
41
- SevenApi::Util::is_positive_integer?(params[:id])
42
- end
43
-
44
- def self.transfer_credits(params)
45
- SevenApi::Util::is_positive_integer?(params[:amount]) &&
46
- SevenApi::Util::is_positive_integer?(params[:id])
47
- end
48
-
49
- def self.update(params)
50
- SevenApi::Util::is_positive_integer?(params[:amount]) &&
51
- SevenApi::Util::is_positive_integer?(params[:id]) &&
52
- SevenApi::Util::is_positive_integer?(params[:threshold])
53
- end
54
- end
55
- end
1
+ # frozen_string_literal: true
2
+
3
+ # This module holds all utilities related to the /subaccounts endpoint.
4
+ module SevenApi::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
+ SevenApi::Util::in_module_constants?(str, SevenApi::Subaccounts::Action)
16
+ end
17
+
18
+ def self.validate(params)
19
+ action = params[:action]
20
+
21
+ case action
22
+ when SevenApi::Subaccounts::Action::CREATE
23
+ raise 'Parameter validation failed' unless SevenApi::Subaccounts::Validator::create(params)
24
+ when SevenApi::Subaccounts::Action::DELETE
25
+ raise 'Parameter validation failed' unless SevenApi::Subaccounts::Validator::delete(params)
26
+ when SevenApi::Subaccounts::Action::TRANSFER_CREDITS
27
+ raise 'Parameter validation failed' unless SevenApi::Subaccounts::Validator::transfer_credits(params)
28
+ when SevenApi::Subaccounts::Action::UPDATE
29
+ raise 'Parameter validation failed' unless SevenApi::Subaccounts::Validator::update(params)
30
+ else
31
+ raise "Unknown action #{action}" unless SevenApi::Subaccounts::Validator::is_action?(action)
32
+ end
33
+ end
34
+
35
+ def self.create(params)
36
+ SevenApi::Util::lengthy_string?(params[:email]) &&
37
+ SevenApi::Util::lengthy_string?(params[:name])
38
+ end
39
+
40
+ def self.delete(params)
41
+ SevenApi::Util::is_positive_integer?(params[:id])
42
+ end
43
+
44
+ def self.transfer_credits(params)
45
+ SevenApi::Util::is_positive_integer?(params[:amount]) &&
46
+ SevenApi::Util::is_positive_integer?(params[:id])
47
+ end
48
+
49
+ def self.update(params)
50
+ SevenApi::Util::is_positive_integer?(params[:amount]) &&
51
+ SevenApi::Util::is_positive_integer?(params[:id]) &&
52
+ SevenApi::Util::is_positive_integer?(params[:threshold])
53
+ end
54
+ end
55
+ end
@@ -1,69 +1,69 @@
1
- require 'date'
2
-
3
- # This module exposes general utilities used throughout the library.
4
- module SevenApi::Util
5
- def self.to_numbered_bool(val)
6
- if true == val
7
- return 1
8
- elsif false == val
9
- return 0
10
- end
11
-
12
- return val
13
- end
14
-
15
- def self.get_namespace_members_by_type(ns, type)
16
- ns.constants.map(&ns.method(:const_get)).grep(type)
17
- end
18
-
19
- def self.get_namespace_classes(ns)
20
- return self.get_namespace_members_by_type(ns, Class)
21
- end
22
-
23
- def self.get_module_constant_values(mod)
24
- mod.constants(false).map &mod.method(:const_get)
25
- end
26
-
27
- def self.is_valid_url?(str)
28
- str =~ URI::regexp
29
- end
30
-
31
- def self.is_valid_datetime?(str)
32
- begin
33
- DateTime.parse(str)
34
- true
35
- rescue ArgumentError
36
- false
37
- end
38
- end
39
-
40
- def self.is_positive_integer?(val)
41
- /\A\d+\z/.match?(val.to_s)
42
- end
43
-
44
- def self.in_module_constants?(needle, mod)
45
- get_module_constant_values(mod).include?(needle)
46
- end
47
-
48
- def self.valid_float?(str)
49
- !!Float(str) rescue false
50
- end
51
-
52
- def self.numeric?(val)
53
- return true if val.is_a?(Integer)
54
-
55
- val.scan(/\D/).empty?
56
- end
57
-
58
- def self.boolean?(val)
59
- [true, false].include? val
60
- end
61
-
62
- def self.nil_or_lengthy_string?(val)
63
- val.nil? || (val.is_a?(String) && val.length)
64
- end
65
-
66
- def self.lengthy_string?(val)
67
- return val.is_a?(String) && !val.empty?
68
- end
1
+ require 'date'
2
+
3
+ # This module exposes general utilities used throughout the library.
4
+ module SevenApi::Util
5
+ def self.to_numbered_bool(val)
6
+ if true == val
7
+ return 1
8
+ elsif false == val
9
+ return 0
10
+ end
11
+
12
+ return val
13
+ end
14
+
15
+ def self.get_namespace_members_by_type(ns, type)
16
+ ns.constants.map(&ns.method(:const_get)).grep(type)
17
+ end
18
+
19
+ def self.get_namespace_classes(ns)
20
+ return self.get_namespace_members_by_type(ns, Class)
21
+ end
22
+
23
+ def self.get_module_constant_values(mod)
24
+ mod.constants(false).map &mod.method(:const_get)
25
+ end
26
+
27
+ def self.is_valid_url?(str)
28
+ str =~ URI::regexp
29
+ end
30
+
31
+ def self.is_valid_datetime?(str)
32
+ begin
33
+ DateTime.parse(str)
34
+ true
35
+ rescue ArgumentError
36
+ false
37
+ end
38
+ end
39
+
40
+ def self.is_positive_integer?(val)
41
+ /\A\d+\z/.match?(val.to_s)
42
+ end
43
+
44
+ def self.in_module_constants?(needle, mod)
45
+ get_module_constant_values(mod).include?(needle)
46
+ end
47
+
48
+ def self.valid_float?(str)
49
+ !!Float(str) rescue false
50
+ end
51
+
52
+ def self.numeric?(val)
53
+ return true if val.is_a?(Integer)
54
+
55
+ val.scan(/\D/).empty?
56
+ end
57
+
58
+ def self.boolean?(val)
59
+ [true, false].include? val
60
+ end
61
+
62
+ def self.nil_or_lengthy_string?(val)
63
+ val.nil? || (val.is_a?(String) && val.length)
64
+ end
65
+
66
+ def self.lengthy_string?(val)
67
+ return val.is_a?(String) && !val.empty?
68
+ end
69
69
  end
@@ -1,5 +1,5 @@
1
- # frozen_string_literal: true
2
-
3
- module SevenApi
4
- VERSION = '0.6.0'
5
- end
1
+ # frozen_string_literal: true
2
+
3
+ module SevenApi
4
+ VERSION = '0.6.1'
5
+ end
data/lib/seven_api.rb CHANGED
@@ -1,6 +1,6 @@
1
- # frozen_string_literal: true
2
-
3
- require 'seven_api/version'
4
-
5
- module SevenApi
6
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'seven_api/version'
4
+
5
+ module SevenApi
6
+ end
data/release.sh CHANGED
@@ -1,5 +1,5 @@
1
- #!/bin/sh
2
-
3
- gem build --strict
4
-
1
+ #!/bin/sh
2
+
3
+ gem build --strict
4
+
5
5
  gem push "$(find . -name "*.gem" -print0 | xargs -r -0 ls -1 -t | head -1)"
data/seven_api.gemspec CHANGED
File without changes
data/spec/EnvKeyStore.rb CHANGED
@@ -1,15 +1,15 @@
1
- class EnvKeyStore
2
- def initialize(key)
3
- @key = "SEVEN_TEST_#{key}"
4
-
5
- @store = ENV[@key]
6
- end
7
-
8
- def get(fallback = nil)
9
- @store.nil? ? fallback : @store
10
- end
11
-
12
- def set(val, only_on_nil = false)
13
- @store = val unless only_on_nil
14
- end
1
+ class EnvKeyStore
2
+ def initialize(key)
3
+ @key = "SEVEN_TEST_#{key}"
4
+
5
+ @store = ENV[@key]
6
+ end
7
+
8
+ def get(fallback = nil)
9
+ @store.nil? ? fallback : @store
10
+ end
11
+
12
+ def set(val, only_on_nil = false)
13
+ @store = val unless only_on_nil
14
+ end
15
15
  end
data/spec/matchers.rb CHANGED
@@ -1,23 +1,23 @@
1
- RSpec::Matchers.define :be_nil_or_lengthy_string do
2
- match do |val|
3
- SevenApi::Util::nil_or_lengthy_string?(val)
4
- end
5
- end
6
-
7
- RSpec::Matchers.define :be_boolean do
8
- match do |val|
9
- SevenApi::Util::boolean?(val)
10
- end
11
- end
12
-
13
- RSpec::Matchers.define :be_numeric do
14
- match do |val|
15
- SevenApi::Util::numeric?(val)
16
- end
17
- end
18
-
19
- RSpec::Matchers.define :be_lengthy_string do
20
- match do |val|
21
- SevenApi::Util::lengthy_string?(val)
22
- end
1
+ RSpec::Matchers.define :be_nil_or_lengthy_string do
2
+ match do |val|
3
+ SevenApi::Util::nil_or_lengthy_string?(val)
4
+ end
5
+ end
6
+
7
+ RSpec::Matchers.define :be_boolean do
8
+ match do |val|
9
+ SevenApi::Util::boolean?(val)
10
+ end
11
+ end
12
+
13
+ RSpec::Matchers.define :be_numeric do
14
+ match do |val|
15
+ SevenApi::Util::numeric?(val)
16
+ end
17
+ end
18
+
19
+ RSpec::Matchers.define :be_lengthy_string do
20
+ match do |val|
21
+ SevenApi::Util::lengthy_string?(val)
22
+ end
23
23
  end