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,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
- @http_methods = {
10
- :retrieve => :get,
11
- }
12
-
13
- # Retrieve analytics for associated API key
14
- # read more: https://www.seven.io/en/docs/gateway/http-api/analytics/
15
- # @param params [Hash]
16
- # @return [Array]
17
- def retrieve(params = {})
18
- request(params)
19
- end
20
- end
21
- 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 /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://www.seven.io/en/docs/gateway/http-api/credit-balance/
15
- # @return [Float]
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
- :delete => :post,
11
- :read => :get,
12
- :write => :post,
13
- }
14
-
15
- # Retrieve contacts associated with the API key
16
- # read more: https://www.seven.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 => SevenApi::Contacts::Action::READ }))
21
- end
22
-
23
- # Delete an account with given ID
24
- # read more: https://www.seven.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 => SevenApi::Contacts::Action::DEL }))
29
- end
30
-
31
- # Create or update a contact
32
- # read more: https://www.seven.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 => SevenApi::Contacts::Action::WRITE }))
37
- end
38
- 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 /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://www.seven.io/en/docs/gateway/http-api/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(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://www.seven.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
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 => :post,
11
- :format => :post,
12
- :hlr => :post,
13
- :mnp => :post,
14
- }
15
-
16
- # Perform a caller name lookup
17
- # read more: https://www.seven.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 => SevenApi::Lookup::Type::CNAM }))
22
- end
23
-
24
- # Retrieve phone number formats
25
- # read more: https://www.seven.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 => SevenApi::Lookup::Type::FORMAT }))
30
- end
31
-
32
- # Perform a home location register lookup
33
- # read more: https://www.seven.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 => SevenApi::Lookup::Type::HLR }))
38
- end
39
-
40
- # Perform a mobile number portability lookup
41
- # read more: https://www.seven.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 => SevenApi::Lookup::Type::MNP }))
46
- end
47
- 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 /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://www.seven.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
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