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.
- checksums.yaml +4 -4
- data/.gitignore +7 -6
- data/.idea/inspectionProfiles/Project_Default.xml +5 -5
- data/.idea/ruby-client.iml +51 -4
- data/Gemfile +2 -2
- data/LICENSE +21 -21
- data/README.md +3 -3
- data/Rakefile +5 -5
- data/doc/{Sms77 → SevenApi}/Client.html +229 -229
- data/doc/{Sms77 → SevenApi}/Contacts/Action.html +130 -130
- data/doc/{Sms77 → SevenApi}/Contacts.html +125 -125
- data/doc/{Sms77 → SevenApi}/Endpoint.html +186 -186
- data/doc/{Sms77 → SevenApi}/Hooks/Action.html +130 -130
- data/doc/{Sms77 → SevenApi}/Hooks/EventType.html +145 -145
- data/doc/{Sms77 → SevenApi}/Hooks/RequestMethod.html +130 -130
- data/doc/{Sms77 → SevenApi}/Hooks/Validator.html +597 -597
- data/doc/{Sms77 → SevenApi}/Hooks.html +125 -125
- data/doc/{Sms77 → SevenApi}/Journal/Type.html +135 -135
- data/doc/{Sms77 → SevenApi}/Journal/Validator.html +393 -393
- data/doc/{Sms77 → SevenApi}/Journal.html +125 -125
- data/doc/{Sms77 → SevenApi}/Lookup/Type.html +135 -135
- data/doc/{Sms77 → SevenApi}/Lookup.html +125 -125
- data/doc/{Sms77 → SevenApi}/Resource.html +869 -869
- data/doc/{Sms77 → SevenApi}/Resources/Analytics.html +262 -262
- data/doc/{Sms77 → SevenApi}/Resources/Balance.html +245 -245
- data/doc/{Sms77 → SevenApi}/Resources/Contacts.html +448 -448
- data/doc/{Sms77 → SevenApi}/Resources/Hooks.html +456 -456
- data/doc/{Sms77 → SevenApi}/Resources/Journal.html +260 -260
- data/doc/{Sms77 → SevenApi}/Resources/Lookup.html +539 -539
- data/doc/{Sms77 → SevenApi}/Resources/Pricing.html +262 -262
- data/doc/{Sms77 → SevenApi}/Resources/Sms.html +260 -260
- data/doc/{Sms77 → SevenApi}/Resources/Status.html +260 -260
- data/doc/{Sms77 → SevenApi}/Resources/Subaccounts.html +650 -650
- data/doc/{Sms77 → SevenApi}/Resources/ValidateForVoice.html +260 -260
- data/doc/{Sms77 → SevenApi}/Resources/Voice.html +260 -260
- data/doc/SevenApi/Resources.html +128 -0
- data/doc/{Sms77 → SevenApi}/Sms/Type.html +125 -125
- data/doc/{Sms77 → SevenApi}/Sms.html +125 -125
- data/doc/{Sms77 → SevenApi}/Subaccounts/Action.html +140 -140
- data/doc/SevenApi/Subaccounts/Validator.html +490 -0
- data/doc/{Sms77 → SevenApi}/Subaccounts.html +125 -125
- data/doc/{Sms77 → SevenApi}/Util.html +1032 -1032
- data/doc/{Sms77.html → SevenApi.html} +145 -145
- data/doc/_index.html +443 -443
- data/doc/class_list.html +51 -51
- data/doc/css/full_list.css +58 -58
- data/doc/css/style.css +497 -497
- data/doc/file.README.html +110 -111
- data/doc/file_list.html +56 -56
- data/doc/frames.html +17 -17
- data/doc/index.html +110 -111
- data/doc/js/app.js +314 -314
- data/doc/js/full_list.js +216 -216
- data/doc/js/jquery.js +3 -3
- data/doc/method_list.html +563 -563
- data/doc/top-level-namespace.html +109 -109
- data/document.sh +3 -0
- data/lib/seven_api/client.rb +32 -30
- data/lib/seven_api/contacts.rb +5 -10
- data/lib/seven_api/endpoint.rb +5 -0
- data/lib/seven_api/hooks.rb +69 -67
- data/lib/seven_api/journal.rb +39 -39
- data/lib/seven_api/lookup.rb +12 -11
- data/lib/seven_api/numbers.rb +9 -0
- data/lib/seven_api/paginated.rb +10 -0
- data/lib/seven_api/rcs.rb +9 -0
- data/lib/seven_api/resource.rb +8 -4
- data/lib/seven_api/resources/analytics.rb +54 -21
- data/lib/seven_api/resources/balance.rb +19 -19
- data/lib/seven_api/resources/contacts.rb +56 -38
- data/lib/seven_api/resources/groups.rb +57 -0
- data/lib/seven_api/resources/hooks.rb +40 -40
- data/lib/seven_api/resources/journal.rb +20 -20
- data/lib/seven_api/resources/lookup.rb +63 -47
- data/lib/seven_api/resources/numbers.rb +71 -0
- data/lib/seven_api/resources/pricing.rb +20 -20
- data/lib/seven_api/resources/rcs.rb +39 -0
- data/lib/seven_api/resources/sms.rb +29 -20
- data/lib/seven_api/resources/status.rb +20 -20
- data/lib/seven_api/resources/subaccounts.rb +65 -65
- data/lib/seven_api/resources/validate_for_voice.rb +20 -20
- data/lib/seven_api/resources/voice.rb +29 -20
- data/lib/seven_api/sms.rb +9 -9
- data/lib/seven_api/subaccounts.rb +55 -55
- data/lib/seven_api/util.rb +68 -68
- data/lib/seven_api/version.rb +5 -5
- data/lib/seven_api.rb +6 -6
- data/release.sh +4 -4
- data/seven_api.gemspec +5 -5
- data/spec/EnvKeyStore.rb +14 -14
- data/spec/matchers.rb +22 -22
- data/spec/seven_api/analytics_spec.rb +49 -0
- data/spec/seven_api/balance_spec.rb +18 -12
- data/spec/seven_api/client_spec.rb +15 -15
- data/spec/seven_api/contacts_spec.rb +100 -129
- data/spec/seven_api/groups_spec.rb +74 -0
- data/spec/seven_api/hooks_spec.rb +108 -108
- data/spec/seven_api/instance_spec.rb +22 -22
- data/spec/seven_api/journal_spec.rb +86 -86
- data/spec/seven_api/lookup_spec.rb +197 -179
- data/spec/seven_api/numbers_spec.rb +135 -0
- data/spec/seven_api/pricing_spec.rb +76 -76
- data/spec/seven_api/rcs_spec.rb +99 -0
- data/spec/seven_api/sms_spec.rb +103 -103
- data/spec/seven_api/subaccounts_spec.rb +121 -121
- data/spec/seven_api/validate_for_voice_spec.rb +19 -19
- data/spec/seven_api/voice_spec.rb +51 -51
- data/spec/seven_api_spec.rb +9 -9
- data/spec/spec_helper.rb +8 -17
- metadata +62 -50
- data/doc/Sms77/Resources.html +0 -128
- 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
|
-
— Documentation by YARD 0.9.
|
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> »
|
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="
|
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
|
104
|
-
<a href="
|
105
|
-
0.9.
|
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
|
+
— 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> »
|
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
data/lib/seven_api/client.rb
CHANGED
@@ -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/
|
7
|
-
require 'seven_api/resources/
|
8
|
-
require 'seven_api/resources/
|
9
|
-
require 'seven_api/resources/
|
10
|
-
require 'seven_api/resources/
|
11
|
-
require 'seven_api/resources/
|
12
|
-
require 'seven_api/resources/
|
13
|
-
require 'seven_api/resources/
|
14
|
-
require 'seven_api/resources/
|
15
|
-
require 'seven_api/
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
data/lib/seven_api/contacts.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/seven_api/endpoint.rb
CHANGED
@@ -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'
|
data/lib/seven_api/hooks.rb
CHANGED
@@ -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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
raise '
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
data/lib/seven_api/journal.rb
CHANGED
@@ -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
|
data/lib/seven_api/lookup.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/seven_api/resource.rb
CHANGED
@@ -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
|
-
|
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
|
|