seven_api 0.5.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 (112) 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 +51 -4
  5. data/Gemfile +2 -2
  6. data/LICENSE +21 -21
  7. data/README.md +3 -3
  8. data/Rakefile +5 -5
  9. data/doc/{Sms77 → SevenApi}/Client.html +229 -229
  10. data/doc/{Sms77 → SevenApi}/Contacts/Action.html +130 -130
  11. data/doc/{Sms77 → SevenApi}/Contacts.html +125 -125
  12. data/doc/{Sms77 → SevenApi}/Endpoint.html +186 -186
  13. data/doc/{Sms77 → SevenApi}/Hooks/Action.html +130 -130
  14. data/doc/{Sms77 → SevenApi}/Hooks/EventType.html +145 -145
  15. data/doc/{Sms77 → SevenApi}/Hooks/RequestMethod.html +130 -130
  16. data/doc/{Sms77 → SevenApi}/Hooks/Validator.html +597 -597
  17. data/doc/{Sms77 → SevenApi}/Hooks.html +125 -125
  18. data/doc/{Sms77 → SevenApi}/Journal/Type.html +135 -135
  19. data/doc/{Sms77 → SevenApi}/Journal/Validator.html +393 -393
  20. data/doc/{Sms77 → SevenApi}/Journal.html +125 -125
  21. data/doc/{Sms77 → SevenApi}/Lookup/Type.html +135 -135
  22. data/doc/{Sms77 → SevenApi}/Lookup.html +125 -125
  23. data/doc/{Sms77 → SevenApi}/Resource.html +869 -869
  24. data/doc/{Sms77 → SevenApi}/Resources/Analytics.html +262 -262
  25. data/doc/{Sms77 → SevenApi}/Resources/Balance.html +245 -245
  26. data/doc/{Sms77 → SevenApi}/Resources/Contacts.html +448 -448
  27. data/doc/{Sms77 → SevenApi}/Resources/Hooks.html +456 -456
  28. data/doc/{Sms77 → SevenApi}/Resources/Journal.html +260 -260
  29. data/doc/{Sms77 → SevenApi}/Resources/Lookup.html +539 -539
  30. data/doc/{Sms77 → SevenApi}/Resources/Pricing.html +262 -262
  31. data/doc/{Sms77 → SevenApi}/Resources/Sms.html +260 -260
  32. data/doc/{Sms77 → SevenApi}/Resources/Status.html +260 -260
  33. data/doc/{Sms77 → SevenApi}/Resources/Subaccounts.html +650 -650
  34. data/doc/{Sms77 → SevenApi}/Resources/ValidateForVoice.html +260 -260
  35. data/doc/{Sms77 → SevenApi}/Resources/Voice.html +260 -260
  36. data/doc/SevenApi/Resources.html +128 -0
  37. data/doc/{Sms77 → SevenApi}/Sms/Type.html +125 -125
  38. data/doc/{Sms77 → SevenApi}/Sms.html +125 -125
  39. data/doc/{Sms77 → SevenApi}/Subaccounts/Action.html +140 -140
  40. data/doc/SevenApi/Subaccounts/Validator.html +490 -0
  41. data/doc/{Sms77 → SevenApi}/Subaccounts.html +125 -125
  42. data/doc/{Sms77 → SevenApi}/Util.html +1032 -1032
  43. data/doc/{Sms77.html → SevenApi.html} +145 -145
  44. data/doc/_index.html +443 -443
  45. data/doc/class_list.html +51 -51
  46. data/doc/css/full_list.css +58 -58
  47. data/doc/css/style.css +497 -497
  48. data/doc/file.README.html +110 -111
  49. data/doc/file_list.html +56 -56
  50. data/doc/frames.html +17 -17
  51. data/doc/index.html +110 -111
  52. data/doc/js/app.js +314 -314
  53. data/doc/js/full_list.js +216 -216
  54. data/doc/js/jquery.js +3 -3
  55. data/doc/method_list.html +563 -563
  56. data/doc/top-level-namespace.html +109 -109
  57. data/document.sh +3 -0
  58. data/lib/seven_api/client.rb +32 -30
  59. data/lib/seven_api/contacts.rb +5 -10
  60. data/lib/seven_api/endpoint.rb +5 -0
  61. data/lib/seven_api/hooks.rb +69 -67
  62. data/lib/seven_api/journal.rb +39 -39
  63. data/lib/seven_api/lookup.rb +12 -11
  64. data/lib/seven_api/numbers.rb +9 -0
  65. data/lib/seven_api/paginated.rb +10 -0
  66. data/lib/seven_api/rcs.rb +9 -0
  67. data/lib/seven_api/resource.rb +8 -4
  68. data/lib/seven_api/resources/analytics.rb +54 -21
  69. data/lib/seven_api/resources/balance.rb +19 -19
  70. data/lib/seven_api/resources/contacts.rb +56 -38
  71. data/lib/seven_api/resources/groups.rb +57 -0
  72. data/lib/seven_api/resources/hooks.rb +40 -40
  73. data/lib/seven_api/resources/journal.rb +20 -20
  74. data/lib/seven_api/resources/lookup.rb +63 -47
  75. data/lib/seven_api/resources/numbers.rb +71 -0
  76. data/lib/seven_api/resources/pricing.rb +20 -20
  77. data/lib/seven_api/resources/rcs.rb +39 -0
  78. data/lib/seven_api/resources/sms.rb +29 -20
  79. data/lib/seven_api/resources/status.rb +20 -20
  80. data/lib/seven_api/resources/subaccounts.rb +65 -65
  81. data/lib/seven_api/resources/validate_for_voice.rb +20 -20
  82. data/lib/seven_api/resources/voice.rb +29 -20
  83. data/lib/seven_api/sms.rb +9 -9
  84. data/lib/seven_api/subaccounts.rb +55 -55
  85. data/lib/seven_api/util.rb +68 -68
  86. data/lib/seven_api/version.rb +5 -5
  87. data/lib/seven_api.rb +6 -6
  88. data/release.sh +4 -4
  89. data/seven_api.gemspec +5 -5
  90. data/spec/EnvKeyStore.rb +14 -14
  91. data/spec/matchers.rb +22 -22
  92. data/spec/seven_api/analytics_spec.rb +49 -0
  93. data/spec/seven_api/balance_spec.rb +18 -12
  94. data/spec/seven_api/client_spec.rb +15 -15
  95. data/spec/seven_api/contacts_spec.rb +100 -129
  96. data/spec/seven_api/groups_spec.rb +74 -0
  97. data/spec/seven_api/hooks_spec.rb +108 -108
  98. data/spec/seven_api/instance_spec.rb +22 -22
  99. data/spec/seven_api/journal_spec.rb +86 -86
  100. data/spec/seven_api/lookup_spec.rb +197 -179
  101. data/spec/seven_api/numbers_spec.rb +135 -0
  102. data/spec/seven_api/pricing_spec.rb +76 -76
  103. data/spec/seven_api/rcs_spec.rb +99 -0
  104. data/spec/seven_api/sms_spec.rb +103 -103
  105. data/spec/seven_api/subaccounts_spec.rb +121 -121
  106. data/spec/seven_api/validate_for_voice_spec.rb +19 -19
  107. data/spec/seven_api/voice_spec.rb +51 -51
  108. data/spec/seven_api_spec.rb +9 -9
  109. data/spec/spec_helper.rb +8 -17
  110. metadata +62 -50
  111. data/doc/Sms77/Resources.html +0 -128
  112. data/doc/Sms77/Subaccounts/Validator.html +0 -490
@@ -1,110 +1,110 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>
7
- Top Level Namespace
8
-
9
- &mdash; Documentation by YARD 0.9.27
10
-
11
- </title>
12
-
13
- <link rel="stylesheet" href="css/style.css" type="text/css" />
14
-
15
- <link rel="stylesheet" href="css/common.css" type="text/css" />
16
-
17
- <script type="text/javascript">
18
- pathId = "";
19
- relpath = '';
20
- </script>
21
-
22
-
23
- <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
-
25
- <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
-
27
-
28
- </head>
29
- <body>
30
- <div class="nav_wrap">
31
- <iframe id="nav" src="class_list.html?1"></iframe>
32
- <div id="resizer"></div>
33
- </div>
34
-
35
- <div id="main" tabindex="-1">
36
- <div id="header">
37
- <div id="menu">
38
-
39
- <a href="_index.html">Index</a> &raquo;
40
-
41
-
42
- <span class="title">Top Level Namespace</span>
43
-
44
- </div>
45
-
46
- <div id="search">
47
-
48
- <a class="full_list_link" id="class_list_link"
49
- href="class_list.html">
50
-
51
- <svg width="24" height="24">
52
- <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
- <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
- <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
- </svg>
56
- </a>
57
-
58
- </div>
59
- <div class="clear"></div>
60
- </div>
61
-
62
- <div id="content"><h1>Top Level Namespace
63
-
64
-
65
-
66
- </h1>
67
- <div class="box_info">
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
- </div>
80
-
81
- <h2>Defined Under Namespace</h2>
82
- <p class="children">
83
-
84
-
85
- <strong class="modules">Modules:</strong> <span class='object_link'><a href="Sms77.html" title="Sms77 (module)">Sms77</a></span>
86
-
87
-
88
-
89
-
90
- </p>
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
- </div>
101
-
102
- <div id="footer">
103
- Generated on Wed Mar 30 13:55:36 2022 by
104
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
- 0.9.27 (ruby-2.7.4).
106
- </div>
107
-
108
- </div>
109
- </body>
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Top Level Namespace
8
+
9
+ &mdash; Documentation by YARD 0.9.34
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+
41
+
42
+ <span class="title">Top Level Namespace</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Top Level Namespace
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ </div>
80
+
81
+ <h2>Defined Under Namespace</h2>
82
+ <p class="children">
83
+
84
+
85
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="SevenApi.html" title="SevenApi (module)">SevenApi</a></span>
86
+
87
+
88
+
89
+
90
+ </p>
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+ </div>
101
+
102
+ <div id="footer">
103
+ Generated on Fri Aug 25 14:18:45 2023 by
104
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
+ 0.9.34 (ruby-3.2.2).
106
+ </div>
107
+
108
+ </div>
109
+ </body>
110
110
  </html>
data/document.sh ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ yardoc --format=markdown --output-dir=./md
@@ -1,30 +1,32 @@
1
- # frozen_string_literal: true
2
-
3
- require 'seven_api/resources/analytics'
4
- require 'seven_api/resources/balance'
5
- require 'seven_api/resources/contacts'
6
- require 'seven_api/resources/hooks'
7
- require 'seven_api/resources/journal'
8
- require 'seven_api/resources/lookup'
9
- require 'seven_api/resources/pricing'
10
- require 'seven_api/resources/sms'
11
- require 'seven_api/resources/status'
12
- require 'seven_api/resources/subaccounts'
13
- require 'seven_api/resources/validate_for_voice'
14
- require 'seven_api/resources/voice'
15
- require 'seven_api/util'
16
-
17
- module SevenApi
18
- class Client
19
- # @param resource [SevenApi::Resource]
20
- def initialize(resource)
21
- SevenApi::Util::get_namespace_classes(SevenApi::Resources).each do |cls|
22
- name = cls.name.split('::').last
23
-
24
- instance_variable_set("@#{name}", cls.new(resource))
25
-
26
- singleton_class.instance_eval("attr_reader :#{name}")
27
- end
28
- end
29
- end
30
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'seven_api/resources/analytics'
4
+ require 'seven_api/resources/balance'
5
+ require 'seven_api/resources/contacts'
6
+ require 'seven_api/resources/groups'
7
+ require 'seven_api/resources/hooks'
8
+ require 'seven_api/resources/journal'
9
+ require 'seven_api/resources/lookup'
10
+ require 'seven_api/resources/numbers'
11
+ require 'seven_api/resources/pricing'
12
+ require 'seven_api/resources/sms'
13
+ require 'seven_api/resources/status'
14
+ require 'seven_api/resources/subaccounts'
15
+ require 'seven_api/resources/validate_for_voice'
16
+ require 'seven_api/resources/voice'
17
+ require 'seven_api/util'
18
+
19
+ module SevenApi
20
+ class Client
21
+ # @param resource [SevenApi::Resource]
22
+ def initialize(resource)
23
+ SevenApi::Util::get_namespace_classes(SevenApi::Resources).each do |cls|
24
+ name = cls.name.split('::').last
25
+
26
+ instance_variable_set("@#{name}", cls.new(resource))
27
+
28
+ singleton_class.instance_eval("attr_reader :#{name}")
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,10 +1,5 @@
1
- # frozen_string_literal: true
2
-
3
- # This module holds all utilities related to the /contacts endpoint.
4
- module SevenApi::Contacts
5
- module Action
6
- DEL = 'del'
7
- READ = 'read'
8
- WRITE = 'write'
9
- end
10
- end
1
+ # frozen_string_literal: true
2
+
3
+ # This module holds all utilities related to the /contacts endpoint.
4
+ module SevenApi::Contacts
5
+ end
@@ -5,10 +5,15 @@ module SevenApi::Endpoint
5
5
  ANALYTICS = 'analytics'
6
6
  BALANCE = 'balance'
7
7
  CONTACTS = 'contacts'
8
+ GROUPS = 'groups'
8
9
  HOOKS = 'hooks'
9
10
  JOURNAL = 'journal'
10
11
  LOOKUP = 'lookup'
12
+ NUMBERS = 'numbers'
11
13
  PRICING = 'pricing'
14
+ RCS = 'rcs'
15
+ RCS_EVENTS = RCS + '/events'
16
+ RCS_MESSAGES = RCS + '/messages'
12
17
  SMS = 'sms'
13
18
  STATUS = 'status'
14
19
  SUBACCOUNTS = 'subaccounts'
@@ -1,67 +1,69 @@
1
- # frozen_string_literal: true
2
-
3
- # This module holds all utilities related to the /hooks endpoint.
4
- module SevenApi::Hooks
5
- module Action
6
- READ = 'read'
7
- SUBSCRIBE = 'subscribe'
8
- UNSUBSCRIBE = 'unsubscribe'
9
- end
10
-
11
- module EventType
12
- ALL = 'all'
13
- NEW_INBOUND_SMS = 'sms_mo'
14
- SMS_STATUS_UPDATE = 'dlr'
15
- TRACKING = 'tracking'
16
- VOICE_CALL = 'voice_call'
17
- VOICE_STATUS_UPDATE = 'voice_status'
18
- end
19
-
20
- module RequestMethod
21
- GET = 'GET'
22
- JSON = 'JSON'
23
- POST = 'POST'
24
- end
25
-
26
- module Validator
27
- def self.validate(params)
28
- action = params[:action]
29
-
30
- raise "Unknown action #{action}" unless SevenApi::Hooks::Validator::is_action?(action)
31
-
32
- if SevenApi::Hooks::Action::SUBSCRIBE == action
33
- raise 'Parameter validation failed' unless SevenApi::Hooks::Validator::subscribe(params)
34
- elsif SevenApi::Hooks::Action::UNSUBSCRIBE == action
35
- raise 'ID must be a positive integer' unless SevenApi::Hooks::Validator::unsubscribe(params)
36
- end
37
- end
38
-
39
- def self.subscribe(params)
40
- { :request_method => SevenApi::Hooks::RequestMethod::POST }.merge!(params)
41
-
42
- self.event_type?(params[:event_type]) &&
43
- self.request_method?(params[:request_method]) &&
44
- self.target_url?(params[:target_url])
45
- end
46
-
47
- def self.unsubscribe(params)
48
- SevenApi::Util::is_positive_integer?(params[:id])
49
- end
50
-
51
- def self.is_action?(str)
52
- SevenApi::Util::in_module_constants?(str, SevenApi::Hooks::Action)
53
- end
54
-
55
- def self.event_type?(str)
56
- SevenApi::Util::in_module_constants?(str, SevenApi::Hooks::EventType)
57
- end
58
-
59
- def self.request_method?(str)
60
- SevenApi::Util::in_module_constants?(str, SevenApi::Hooks::RequestMethod)
61
- end
62
-
63
- def self.target_url?(str)
64
- SevenApi::Util::is_valid_url?(str)
65
- end
66
- end
67
- end
1
+ # frozen_string_literal: true
2
+
3
+ # This module holds all utilities related to the /hooks endpoint.
4
+ module SevenApi::Hooks
5
+ module Action
6
+ READ = 'read'
7
+ SUBSCRIBE = 'subscribe'
8
+ UNSUBSCRIBE = 'unsubscribe'
9
+ end
10
+
11
+ module EventType
12
+ ALL = 'all'
13
+ NEW_INBOUND_SMS = 'sms_mo'
14
+ RCS = 'rcs'
15
+ SMS_STATUS_UPDATE = 'dlr'
16
+ TRACKING = 'tracking'
17
+ VOICE_CALL = 'voice_call'
18
+ VOICE_DTMF = 'voice_dtmf'
19
+ VOICE_STATUS_UPDATE = 'voice_status'
20
+ end
21
+
22
+ module RequestMethod
23
+ GET = 'GET'
24
+ JSON = 'JSON'
25
+ POST = 'POST'
26
+ end
27
+
28
+ module Validator
29
+ def self.validate(params)
30
+ action = params[:action]
31
+
32
+ raise "Unknown action #{action}" unless SevenApi::Hooks::Validator::is_action?(action)
33
+
34
+ if SevenApi::Hooks::Action::SUBSCRIBE == action
35
+ raise 'Parameter validation failed' unless SevenApi::Hooks::Validator::subscribe(params)
36
+ elsif SevenApi::Hooks::Action::UNSUBSCRIBE == action
37
+ raise 'ID must be a positive integer' unless SevenApi::Hooks::Validator::unsubscribe(params)
38
+ end
39
+ end
40
+
41
+ def self.subscribe(params)
42
+ { :request_method => SevenApi::Hooks::RequestMethod::POST }.merge!(params)
43
+
44
+ self.event_type?(params[:event_type]) &&
45
+ self.request_method?(params[:request_method]) &&
46
+ self.target_url?(params[:target_url])
47
+ end
48
+
49
+ def self.unsubscribe(params)
50
+ SevenApi::Util::is_positive_integer?(params[:id])
51
+ end
52
+
53
+ def self.is_action?(str)
54
+ SevenApi::Util::in_module_constants?(str, SevenApi::Hooks::Action)
55
+ end
56
+
57
+ def self.event_type?(str)
58
+ SevenApi::Util::in_module_constants?(str, SevenApi::Hooks::EventType)
59
+ end
60
+
61
+ def self.request_method?(str)
62
+ SevenApi::Util::in_module_constants?(str, SevenApi::Hooks::RequestMethod)
63
+ end
64
+
65
+ def self.target_url?(str)
66
+ SevenApi::Util::is_valid_url?(str)
67
+ end
68
+ end
69
+ end
@@ -1,39 +1,39 @@
1
- # frozen_string_literal: true
2
-
3
- # This module holds all utilities related to the /journal endpoint.
4
- module SevenApi::Journal
5
- module Type
6
- INBOUND = 'inbound'
7
- OUTBOUND = 'outbound'
8
- REPLIES = 'replies'
9
- VOICE = 'voice'
10
- end
11
-
12
- module Validator
13
- def self.validate(params)
14
- type = params[:type]
15
- date_from = params[:date_from]
16
- date_to = params[:date_to]
17
-
18
- raise "Unknown type #{type}" unless SevenApi::Journal::Validator::is_type?(type)
19
- raise "Wrong date_from #{date_from}" unless SevenApi::Journal::Validator::is_date?(date_from)
20
- raise "Wrong date_to #{date_to}" unless SevenApi::Journal::Validator::is_date?(date_to)
21
- end
22
-
23
- def self.subscribe(params)
24
- { :request_method => SevenApi::Hooks::RequestMethod::POST }.merge!(params)
25
-
26
- self.event_type?(params[:event_type]) &&
27
- self.request_method?(params[:request_method]) &&
28
- self.target_url?(params[:target_url])
29
- end
30
-
31
- def self.is_type?(str)
32
- SevenApi::Util::in_module_constants?(str, SevenApi::Journal::Type)
33
- end
34
-
35
- def self.is_date?(date)
36
- date.is_a?(NilClass) || date.match(/[\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1])/)
37
- end
38
- end
39
- end
1
+ # frozen_string_literal: true
2
+
3
+ # This module holds all utilities related to the /journal endpoint.
4
+ module SevenApi::Journal
5
+ module Type
6
+ INBOUND = 'inbound'
7
+ OUTBOUND = 'outbound'
8
+ REPLIES = 'replies'
9
+ VOICE = 'voice'
10
+ end
11
+
12
+ module Validator
13
+ def self.validate(params)
14
+ type = params[:type]
15
+ date_from = params[:date_from]
16
+ date_to = params[:date_to]
17
+
18
+ raise "Unknown type #{type}" unless SevenApi::Journal::Validator::is_type?(type)
19
+ raise "Wrong date_from #{date_from}" unless SevenApi::Journal::Validator::is_date?(date_from)
20
+ raise "Wrong date_to #{date_to}" unless SevenApi::Journal::Validator::is_date?(date_to)
21
+ end
22
+
23
+ def self.subscribe(params)
24
+ { :request_method => SevenApi::Hooks::RequestMethod::POST }.merge!(params)
25
+
26
+ self.event_type?(params[:event_type]) &&
27
+ self.request_method?(params[:request_method]) &&
28
+ self.target_url?(params[:target_url])
29
+ end
30
+
31
+ def self.is_type?(str)
32
+ SevenApi::Util::in_module_constants?(str, SevenApi::Journal::Type)
33
+ end
34
+
35
+ def self.is_date?(date)
36
+ date.is_a?(NilClass) || date.match(/[\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1])/)
37
+ end
38
+ end
39
+ end
@@ -1,11 +1,12 @@
1
- # frozen_string_literal: true
2
-
3
- # This module holds all utilities related to the /lookup endpoint.
4
- module SevenApi::Lookup
5
- module Type
6
- CNAM = 'cnam'
7
- FORMAT = 'format'
8
- HLR = 'hlr'
9
- MNP = 'mnp'
10
- end
11
- end
1
+ # frozen_string_literal: true
2
+
3
+ # This module holds all utilities related to the /lookup endpoint.
4
+ module SevenApi::Lookup
5
+ module Type
6
+ CNAM = 'cnam'
7
+ FORMAT = 'format'
8
+ HLR = 'hlr'
9
+ MNP = 'mnp'
10
+ RCS = 'rcs'
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This module holds all utilities related to the /numbers endpoint.
4
+ module SevenApi::Numbers
5
+ module PaymentInterval
6
+ ANNUALLY = 'annually'
7
+ MONTHLY = 'monthly'
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SevenApi
4
+ module Paginated
5
+ module OrderDirection
6
+ ASCENDING = 'asc'
7
+ DESCENDING = 'desc'
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This module holds all utilities related to the /rcs endpoint.
4
+ module SevenApi::Rcs
5
+ module Event
6
+ IS_TYPING = 'IS_TYPING'
7
+ READ = 'READ'
8
+ end
9
+ end
@@ -25,9 +25,8 @@ module SevenApi
25
25
 
26
26
  protected
27
27
 
28
- def request(payload = {}, query = {})
29
- path = @endpoint
30
- http_method = @http_methods[caller_locations.first.label.to_sym]
28
+ def request(http_method, payload = {}, query = {}, path = '')
29
+ path = "#{@endpoint}#{path}"
31
30
 
32
31
  if :get == http_method
33
32
  query = payload
@@ -48,9 +47,14 @@ module SevenApi
48
47
  end
49
48
 
50
49
  headers = Hash[
51
- Faraday::Request::Authorization::KEY, "Bearer #{@api_key}",
50
+ 'Accept', 'application/json',
52
51
  'sentWith', @sent_with
53
52
  ]
53
+ if @api_key.start_with?('Bearer ')
54
+ headers.store(Faraday::Request::Authorization::KEY, @api_key)
55
+ else
56
+ headers.store('X-Api-Key', @api_key)
57
+ end
54
58
 
55
59
  res = @conn.run_request(http_method, path, payload, headers)
56
60