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,21 +1,54 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'seven_api/resource'
|
4
|
-
|
5
|
-
# This module exposes the methods for communicating with the API endpoint /analytics.
|
6
|
-
module SevenApi::Resources
|
7
|
-
class Analytics < SevenApi::Resource
|
8
|
-
@endpoint = SevenApi::Endpoint::ANALYTICS
|
9
|
-
|
10
|
-
:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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 /analytics.
|
6
|
+
module SevenApi::Resources
|
7
|
+
class Analytics < SevenApi::Resource
|
8
|
+
@endpoint = SevenApi::Endpoint::ANALYTICS
|
9
|
+
PATHS = {
|
10
|
+
:by_country => "/country",
|
11
|
+
:by_date => "/date",
|
12
|
+
:by_label => "/label",
|
13
|
+
:by_subaccount => "/subaccount",
|
14
|
+
}
|
15
|
+
@http_methods = {
|
16
|
+
:by_country => :get,
|
17
|
+
:by_date => :get,
|
18
|
+
:by_label => :get,
|
19
|
+
:by_subaccount => :get,
|
20
|
+
}
|
21
|
+
|
22
|
+
# Retrieve analytics grouped by country
|
23
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/account#statistics
|
24
|
+
# @param params [Hash]
|
25
|
+
# @return [Array]
|
26
|
+
def by_country(params = {})
|
27
|
+
request(:get, {}, params, PATHS[:by_country])
|
28
|
+
end
|
29
|
+
|
30
|
+
# Retrieve analytics grouped by date
|
31
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/account#statistics
|
32
|
+
# @param params [Hash]
|
33
|
+
# @return [Array]
|
34
|
+
def by_date(params = {})
|
35
|
+
request(:get,{}, params, PATHS[:by_date])
|
36
|
+
end
|
37
|
+
|
38
|
+
# Retrieve analytics grouped by label
|
39
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/account#statistics
|
40
|
+
# @param params [Hash]
|
41
|
+
# @return [Array]
|
42
|
+
def by_label(params = {})
|
43
|
+
request(:get,{}, params, PATHS[:by_label])
|
44
|
+
end
|
45
|
+
|
46
|
+
# Retrieve analytics grouped by subaccount
|
47
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/account#statistics
|
48
|
+
# @param params [Hash]
|
49
|
+
# @return [Array]
|
50
|
+
def by_subaccount(params = {})
|
51
|
+
request(:get,{}, params, PATHS[:by_subaccount])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -1,20 +1,20 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'seven_api/resource'
|
4
|
-
|
5
|
-
# This module exposes the methods for communicating with the API endpoint /balance.
|
6
|
-
module SevenApi::Resources
|
7
|
-
class Balance < SevenApi::Resource
|
8
|
-
@endpoint = SevenApi::Endpoint::BALANCE
|
9
|
-
@http_methods = {
|
10
|
-
:retrieve => :get,
|
11
|
-
}
|
12
|
-
|
13
|
-
# Retrieve account balance for associated API key
|
14
|
-
# read more: https://
|
15
|
-
# @return [
|
16
|
-
def retrieve
|
17
|
-
request
|
18
|
-
end
|
19
|
-
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 /balance.
|
6
|
+
module SevenApi::Resources
|
7
|
+
class Balance < SevenApi::Resource
|
8
|
+
@endpoint = SevenApi::Endpoint::BALANCE
|
9
|
+
@http_methods = {
|
10
|
+
:retrieve => :get,
|
11
|
+
}
|
12
|
+
|
13
|
+
# Retrieve account balance for associated API key
|
14
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/account#balance
|
15
|
+
# @return [Hash]
|
16
|
+
def retrieve
|
17
|
+
request(:get)
|
18
|
+
end
|
19
|
+
end
|
20
20
|
end
|
@@ -1,39 +1,57 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'seven_api/resource'
|
4
|
-
|
5
|
-
# This module exposes the methods for communicating with the API endpoint /contacts.
|
6
|
-
module SevenApi::Resources
|
7
|
-
class Contacts < SevenApi::Resource
|
8
|
-
@endpoint = SevenApi::Endpoint::CONTACTS
|
9
|
-
@http_methods = {
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
#
|
18
|
-
#
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
#
|
26
|
-
#
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
#
|
34
|
-
#
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'seven_api/resource'
|
4
|
+
|
5
|
+
# This module exposes the methods for communicating with the API endpoint /contacts.
|
6
|
+
module SevenApi::Resources
|
7
|
+
class Contacts < SevenApi::Resource
|
8
|
+
@endpoint = SevenApi::Endpoint::CONTACTS
|
9
|
+
@http_methods = {
|
10
|
+
:all => :get,
|
11
|
+
:create => :post,
|
12
|
+
:delete => :delete,
|
13
|
+
:one => :get,
|
14
|
+
:update => :patch,
|
15
|
+
}
|
16
|
+
|
17
|
+
# Retrieve contacts associated with the API key
|
18
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/contacts#query-contact-list
|
19
|
+
# @param params [Hash]
|
20
|
+
# @return [Hash]
|
21
|
+
def all(params = {})
|
22
|
+
request(:get, params)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Retrieve a contact associated with the API key
|
26
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/contacts#retrieve-contact
|
27
|
+
# @param id [Int]
|
28
|
+
# @return [Hash]
|
29
|
+
def one(id)
|
30
|
+
request(:get,{}, {}, "/#{id}")
|
31
|
+
end
|
32
|
+
|
33
|
+
# Delete a contact with given ID
|
34
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/contacts#delete-contact
|
35
|
+
# @param id [Integer]
|
36
|
+
# @return [Hash]
|
37
|
+
def delete(id)
|
38
|
+
request({}, {}, "/#{id}")
|
39
|
+
end
|
40
|
+
|
41
|
+
# Create a contact
|
42
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/contacts#create-contact
|
43
|
+
# @param params [Hash]
|
44
|
+
# @return [Hash]
|
45
|
+
def create(params)
|
46
|
+
request( :post, params)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Update a contact
|
50
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/contacts#update-contact
|
51
|
+
# @param contact [Hash]
|
52
|
+
# @return [Hash]
|
53
|
+
def update(contact)
|
54
|
+
request(:patch, contact, {}, "/#{contact['id']}")
|
55
|
+
end
|
56
|
+
end
|
39
57
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'seven_api/resource'
|
4
|
+
|
5
|
+
# This module exposes the methods for communicating with the API endpoint /groups.
|
6
|
+
module SevenApi::Resources
|
7
|
+
class Groups < SevenApi::Resource
|
8
|
+
@endpoint = SevenApi::Endpoint::GROUPS
|
9
|
+
@http_methods = {
|
10
|
+
:all => :get,
|
11
|
+
:create => :post,
|
12
|
+
:delete => :delete,
|
13
|
+
:one => :get,
|
14
|
+
:update => :patch,
|
15
|
+
}
|
16
|
+
|
17
|
+
# Retrieve groups associated with the API key
|
18
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/groups#list-all-groups
|
19
|
+
# @param params [Hash]
|
20
|
+
# @return [Hash]
|
21
|
+
def all(params = {})
|
22
|
+
request(:get, params)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Retrieve a group associated with the API key
|
26
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/groups#retrieve-a-group
|
27
|
+
# @param id [Int]
|
28
|
+
# @return [Hash]
|
29
|
+
def one(id)
|
30
|
+
request(:get,{}, {}, "/#{id}")
|
31
|
+
end
|
32
|
+
|
33
|
+
# Delete a group with given ID
|
34
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/groups#delete-group
|
35
|
+
# @param id [Integer]
|
36
|
+
# @return [Hash]
|
37
|
+
def delete(id)
|
38
|
+
request(:delete,{}, {}, "/#{id}")
|
39
|
+
end
|
40
|
+
|
41
|
+
# Create a group
|
42
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/groups#create-group
|
43
|
+
# @param params [Hash]
|
44
|
+
# @return [Hash]
|
45
|
+
def create(params)
|
46
|
+
request(:post, params)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Update a group
|
50
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/groups#update-a-group
|
51
|
+
# @param contact [Hash]
|
52
|
+
# @return [Hash]
|
53
|
+
def update(contact)
|
54
|
+
request(:patch, contact, {}, "/#{contact['id']}")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -1,41 +1,41 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'seven_api/resource'
|
4
|
-
|
5
|
-
# This module exposes the methods for communicating with the API endpoint /hooks.
|
6
|
-
# read more: https://
|
7
|
-
module SevenApi::Resources
|
8
|
-
class Hooks < SevenApi::Resource
|
9
|
-
@endpoint = SevenApi::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 => SevenApi::Hooks::Action::READ }))
|
21
|
-
end
|
22
|
-
|
23
|
-
# Register a new webhook
|
24
|
-
# @param params [Hash]
|
25
|
-
# @return [Hash]
|
26
|
-
def subscribe(params)
|
27
|
-
SevenApi::Hooks::Validator::subscribe(params)
|
28
|
-
|
29
|
-
request(params.merge({ :action => SevenApi::Hooks::Action::SUBSCRIBE }))
|
30
|
-
end
|
31
|
-
|
32
|
-
# Delete a webhook
|
33
|
-
# @param params [Hash]
|
34
|
-
# @return [Hash]
|
35
|
-
def unsubscribe(params)
|
36
|
-
SevenApi::Hooks::Validator::unsubscribe(params)
|
37
|
-
|
38
|
-
request(params.merge({ :action => SevenApi::Hooks::Action::UNSUBSCRIBE }))
|
39
|
-
end
|
40
|
-
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 /hooks.
|
6
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/webhooks
|
7
|
+
module SevenApi::Resources
|
8
|
+
class Hooks < SevenApi::Resource
|
9
|
+
@endpoint = SevenApi::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(:get, params.merge({ :action => SevenApi::Hooks::Action::READ }))
|
21
|
+
end
|
22
|
+
|
23
|
+
# Register a new webhook
|
24
|
+
# @param params [Hash]
|
25
|
+
# @return [Hash]
|
26
|
+
def subscribe(params)
|
27
|
+
SevenApi::Hooks::Validator::subscribe(params)
|
28
|
+
|
29
|
+
request(:post, params.merge({ :action => SevenApi::Hooks::Action::SUBSCRIBE }))
|
30
|
+
end
|
31
|
+
|
32
|
+
# Delete a webhook
|
33
|
+
# @param params [Hash]
|
34
|
+
# @return [Hash]
|
35
|
+
def unsubscribe(params)
|
36
|
+
SevenApi::Hooks::Validator::unsubscribe(params)
|
37
|
+
|
38
|
+
request(:post, params.merge({ :action => SevenApi::Hooks::Action::UNSUBSCRIBE }))
|
39
|
+
end
|
40
|
+
end
|
41
41
|
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 /journal.
|
6
|
-
module SevenApi::Resources
|
7
|
-
class Journal < SevenApi::Resource
|
8
|
-
@endpoint = SevenApi::Endpoint::JOURNAL
|
9
|
-
@http_methods = {
|
10
|
-
:retrieve => :get,
|
11
|
-
}
|
12
|
-
|
13
|
-
# Retrieve the journal for associated API key
|
14
|
-
# read more: https://
|
15
|
-
# @param params [Hash]
|
16
|
-
# @return [Array]
|
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 /journal.
|
6
|
+
module SevenApi::Resources
|
7
|
+
class Journal < SevenApi::Resource
|
8
|
+
@endpoint = SevenApi::Endpoint::JOURNAL
|
9
|
+
@http_methods = {
|
10
|
+
:retrieve => :get,
|
11
|
+
}
|
12
|
+
|
13
|
+
# Retrieve the journal for associated API key
|
14
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/logbook
|
15
|
+
# @param params [Hash]
|
16
|
+
# @return [Array]
|
17
|
+
def retrieve(params)
|
18
|
+
request(:get, params)
|
19
|
+
end
|
20
|
+
end
|
21
21
|
end
|
@@ -1,48 +1,64 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'seven_api/resource'
|
4
|
-
|
5
|
-
# This module exposes the methods for communicating with the API endpoint /lookup.
|
6
|
-
module SevenApi::Resources
|
7
|
-
class Lookup < SevenApi::Resource
|
8
|
-
@endpoint = SevenApi::Endpoint::LOOKUP
|
9
|
-
@http_methods = {
|
10
|
-
:cnam => :
|
11
|
-
:format => :
|
12
|
-
:hlr => :
|
13
|
-
:mnp => :
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
#
|
25
|
-
# read more: https://
|
26
|
-
# @param
|
27
|
-
# @return [
|
28
|
-
def
|
29
|
-
request(
|
30
|
-
end
|
31
|
-
|
32
|
-
#
|
33
|
-
# read more: https://
|
34
|
-
# @param
|
35
|
-
# @return [Hash
|
36
|
-
def
|
37
|
-
request(
|
38
|
-
end
|
39
|
-
|
40
|
-
# Perform a
|
41
|
-
# read more: https://
|
42
|
-
# @param
|
43
|
-
# @return [Hash,Array]
|
44
|
-
def
|
45
|
-
request(
|
46
|
-
end
|
47
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'seven_api/resource'
|
4
|
+
|
5
|
+
# This module exposes the methods for communicating with the API endpoint /lookup.
|
6
|
+
module SevenApi::Resources
|
7
|
+
class Lookup < SevenApi::Resource
|
8
|
+
@endpoint = SevenApi::Endpoint::LOOKUP
|
9
|
+
@http_methods = {
|
10
|
+
:cnam => :get,
|
11
|
+
:format => :get,
|
12
|
+
:hlr => :get,
|
13
|
+
:mnp => :get,
|
14
|
+
:rcs_capabilities => :get
|
15
|
+
}
|
16
|
+
PATHS = {
|
17
|
+
:cnam => '/cnam',
|
18
|
+
:format => '/format',
|
19
|
+
:hlr => '/hlr',
|
20
|
+
:mnp => '/mnp',
|
21
|
+
:rcs_capabilities => '/rcs'
|
22
|
+
}
|
23
|
+
|
24
|
+
# Perform a caller name lookup
|
25
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/lookup#cnam
|
26
|
+
# @param number [String]
|
27
|
+
# @return [Hash,Array]
|
28
|
+
def cnam(number)
|
29
|
+
request(:get, {}, {number: number}, PATHS[:cnam])
|
30
|
+
end
|
31
|
+
|
32
|
+
# Retrieve phone number formats
|
33
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/lookup#format
|
34
|
+
# @param number [String]
|
35
|
+
# @return [String,Hash]
|
36
|
+
def format(number)
|
37
|
+
request(:get, {}, {number: number}, PATHS[:format])
|
38
|
+
end
|
39
|
+
|
40
|
+
# Perform a home location register lookup
|
41
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/lookup#hlr
|
42
|
+
# @param number [String]
|
43
|
+
# @return [Hash,Array]
|
44
|
+
def hlr(number)
|
45
|
+
request(:get, {}, {number: number}, PATHS[:hlr])
|
46
|
+
end
|
47
|
+
|
48
|
+
# Perform a mobile number portability lookup
|
49
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/lookup#mnp
|
50
|
+
# @param number [String]
|
51
|
+
# @return [Hash,Array]
|
52
|
+
def mnp(number)
|
53
|
+
request(:get, {}, {number: number}, PATHS[:mnp])
|
54
|
+
end
|
55
|
+
|
56
|
+
# Perform a RCS capabilities lookup
|
57
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/lookup#rcs-capabilities
|
58
|
+
# @param number [String]
|
59
|
+
# @return [Hash,Array]
|
60
|
+
def rcs_capabilities(number)
|
61
|
+
request(:get, {}, {number: number}, PATHS[:rcs])
|
62
|
+
end
|
63
|
+
end
|
48
64
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'seven_api/resource'
|
4
|
+
|
5
|
+
# This module exposes the methods for communicating with the API endpoint /numbers.
|
6
|
+
module SevenApi::Resources
|
7
|
+
class Numbers < SevenApi::Resource
|
8
|
+
@endpoint = SevenApi::Endpoint::NUMBERS
|
9
|
+
@http_methods = {
|
10
|
+
:active => :get,
|
11
|
+
:available => :get,
|
12
|
+
:delete => :delete,
|
13
|
+
:order => :post,
|
14
|
+
:one => :get,
|
15
|
+
:update => :patch,
|
16
|
+
}
|
17
|
+
|
18
|
+
# Retrieve active phone numbers
|
19
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/numbers#active-numbers
|
20
|
+
# @return [Array]
|
21
|
+
def active
|
22
|
+
request(:get, {}, {}, '/active')
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
# Retrieve available phone numbers
|
27
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/numbers#available-numbers
|
28
|
+
# @return [Hash]
|
29
|
+
def available
|
30
|
+
request(:get, params, {}, '/available')
|
31
|
+
end
|
32
|
+
|
33
|
+
# Order a phone number
|
34
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/numbers#order-a-number
|
35
|
+
# @param number [String]
|
36
|
+
# @param payment_interval [String]
|
37
|
+
# @return [Hash]
|
38
|
+
def order(number, payment_interval = PaymentInterval.ASCENDING)
|
39
|
+
payload = {
|
40
|
+
number => number,
|
41
|
+
payment_interval => payment_interval,
|
42
|
+
}
|
43
|
+
request(:post, payload, {}, '/order')
|
44
|
+
end
|
45
|
+
|
46
|
+
# Delete a number
|
47
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/numbers#delete-number
|
48
|
+
# @param number [String]
|
49
|
+
# @return [Hash]
|
50
|
+
def delete(number, delete_immediately = false)
|
51
|
+
request(:delete, {}, {delete_immediately => delete_immediately}, "/active/#{number}")
|
52
|
+
end
|
53
|
+
|
54
|
+
# Retrieve a number
|
55
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/numbers#get-number
|
56
|
+
# @param number [String]
|
57
|
+
# @return [Hash]
|
58
|
+
def one(number)
|
59
|
+
request(:get, {}, {}, "/active/#{number}")
|
60
|
+
end
|
61
|
+
|
62
|
+
# Update a number
|
63
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/numbers#update-number
|
64
|
+
# @param number [String]
|
65
|
+
# @param params [Hash]
|
66
|
+
# @return [Hash]
|
67
|
+
def update(number, params)
|
68
|
+
request(:patch, params, {}, "/active/#{number}")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
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 /pricing.
|
6
|
-
module SevenApi::Resources
|
7
|
-
class Pricing < SevenApi::Resource
|
8
|
-
@endpoint = SevenApi::Endpoint::PRICING
|
9
|
-
@http_methods = {
|
10
|
-
:retrieve => :get,
|
11
|
-
}
|
12
|
-
|
13
|
-
# Retrieve pricing
|
14
|
-
# read more: https://
|
15
|
-
# @param params [Hash]
|
16
|
-
# @return [Hash,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 /pricing.
|
6
|
+
module SevenApi::Resources
|
7
|
+
class Pricing < SevenApi::Resource
|
8
|
+
@endpoint = SevenApi::Endpoint::PRICING
|
9
|
+
@http_methods = {
|
10
|
+
:retrieve => :get,
|
11
|
+
}
|
12
|
+
|
13
|
+
# Retrieve pricing
|
14
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/account#prices
|
15
|
+
# @param params [Hash]
|
16
|
+
# @return [Hash,String]
|
17
|
+
def retrieve(params = {})
|
18
|
+
request(:get, params)
|
19
|
+
end
|
20
|
+
end
|
21
21
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'seven_api/resource'
|
4
|
+
|
5
|
+
# This module exposes the methods for communicating with the API endpoint /rcs.
|
6
|
+
module SevenApi::Resources
|
7
|
+
class Rcs < SevenApi::Resource
|
8
|
+
@endpoint = SevenApi::Endpoint::RCS
|
9
|
+
@http_methods = {
|
10
|
+
:delete => :delete,
|
11
|
+
:dispatch => :post,
|
12
|
+
:event => :post
|
13
|
+
}
|
14
|
+
|
15
|
+
# Send RCS
|
16
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/rcs#send-rcs
|
17
|
+
# @param params [Hash]
|
18
|
+
# @return [Hash]
|
19
|
+
def dispatch(params)
|
20
|
+
request(:post, params, {}, '/messages')
|
21
|
+
end
|
22
|
+
|
23
|
+
# Delete scheduled RCS
|
24
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/rcs#delete-rcs
|
25
|
+
# @param params [Hash]
|
26
|
+
# @return [Hash]
|
27
|
+
def delete(params)
|
28
|
+
request(:delete, {}, {}, "/messages/#{params[:id]}")
|
29
|
+
end
|
30
|
+
|
31
|
+
# Send Event
|
32
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/rcs#events
|
33
|
+
# @param params [Hash]
|
34
|
+
# @return [Hash]
|
35
|
+
def event(params)
|
36
|
+
request(:post, params, {}, '/events')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|