nexmo 5.8.0 → 5.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/nexmo.rb +1 -1
- data/lib/nexmo/account.rb +36 -1
- data/lib/nexmo/alerts.rb +46 -0
- data/lib/nexmo/applications.rb +118 -0
- data/lib/nexmo/applications_v2.rb +71 -0
- data/lib/nexmo/authentication/abstract.rb +3 -1
- data/lib/nexmo/authentication/basic.rb +3 -1
- data/lib/nexmo/authentication/bearer_token.rb +3 -1
- data/lib/nexmo/authentication/key_secret_params.rb +3 -1
- data/lib/nexmo/authentication/key_secret_query.rb +3 -1
- data/lib/nexmo/call_dtmf.rb +12 -0
- data/lib/nexmo/call_stream.rb +26 -0
- data/lib/nexmo/call_talk.rb +30 -0
- data/lib/nexmo/calls.rb +188 -0
- data/lib/nexmo/client.rb +77 -1
- data/lib/nexmo/conversation_events.rb +47 -0
- data/lib/nexmo/conversation_legs.rb +14 -0
- data/lib/nexmo/conversation_members.rb +74 -0
- data/lib/nexmo/conversation_users.rb +63 -0
- data/lib/nexmo/conversations.rb +110 -0
- data/lib/nexmo/errors.rb +41 -0
- data/lib/nexmo/errors/error.rb +0 -27
- data/lib/nexmo/form_data.rb +3 -1
- data/lib/nexmo/http.rb +3 -1
- data/lib/nexmo/json.rb +3 -1
- data/lib/nexmo/jwt.rb +25 -0
- data/lib/nexmo/keys.rb +3 -1
- data/lib/nexmo/logger.rb +3 -1
- data/lib/nexmo/namespace.rb +4 -2
- data/lib/nexmo/number_insight.rb +102 -0
- data/lib/nexmo/numbers.rb +155 -0
- data/lib/nexmo/params.rb +3 -1
- data/lib/nexmo/redact.rb +20 -0
- data/lib/nexmo/secrets.rb +53 -0
- data/lib/nexmo/signature.rb +24 -13
- data/lib/nexmo/sms.rb +88 -0
- data/lib/nexmo/user_agent.rb +3 -1
- data/lib/nexmo/verify.rb +144 -0
- data/lib/nexmo/version.rb +1 -1
- data/nexmo.gemspec +2 -0
- metadata +31 -3
- data/lib/nexmo/problem.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be987b38a38248e453aea6b9ea2497c90f217c28c0390660fbe662dc5d803153
|
4
|
+
data.tar.gz: b497634a50563e3585438756a3b49cedda24292a0c0ffc23eab44f4a88b11f1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 523601a55f30f41b2120447f706c3dbac0f09266af1cab4b4c0649d0007d0e811ada5e47a7e16475e8d33c8e05d5bec94bdbf7269d9fe41acd21181937e474df
|
7
|
+
data.tar.gz: 93d788bbe424ed9076405eec77311e2880281dcd42f68996655f94679bd76c4ce4579f1751adcfa1d31041ec4bd140ac759f9121a6a83a0425c71605132fd2dc
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Nexmo Client Library for Ruby
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/nexmo.svg)](https://badge.fury.io/rb/nexmo) [![Build Status](https://api.travis-ci.org/Nexmo/nexmo-ruby.svg?branch=master)](https://travis-ci.org/Nexmo/nexmo-ruby)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/nexmo.svg)](https://badge.fury.io/rb/nexmo) [![Build Status](https://api.travis-ci.org/Nexmo/nexmo-ruby.svg?branch=master)](https://travis-ci.org/Nexmo/nexmo-ruby) [![Coverage Status](https://coveralls.io/repos/github/Nexmo/nexmo-ruby/badge.svg?branch=coveralls)](https://coveralls.io/github/Nexmo/nexmo-ruby?branch=master)
|
4
4
|
|
5
5
|
This is the Ruby client library for Nexmo's API. To use it you'll
|
6
6
|
need a Nexmo account. Sign up [for free at nexmo.com][signup].
|
data/lib/nexmo.rb
CHANGED
@@ -8,7 +8,7 @@ require 'nexmo/signature'
|
|
8
8
|
require 'nexmo/user_agent'
|
9
9
|
require 'nexmo/keys'
|
10
10
|
require 'nexmo/entity'
|
11
|
-
require 'nexmo/
|
11
|
+
require 'nexmo/errors'
|
12
12
|
require 'nexmo/errors/error'
|
13
13
|
require 'nexmo/errors/client_error'
|
14
14
|
require 'nexmo/errors/server_error'
|
data/lib/nexmo/account.rb
CHANGED
@@ -2,16 +2,51 @@
|
|
2
2
|
|
3
3
|
module Nexmo
|
4
4
|
class Account < Namespace
|
5
|
+
include Keys
|
6
|
+
|
5
7
|
self.host = 'rest.nexmo.com'
|
6
8
|
|
9
|
+
# Retrieve your account balance.
|
10
|
+
#
|
11
|
+
# @return [Entity]
|
12
|
+
#
|
13
|
+
# @see https://developer.nexmo.com/api/developer/account#get-balance
|
14
|
+
#
|
7
15
|
def balance
|
8
16
|
request('/account/get-balance')
|
9
17
|
end
|
10
18
|
|
19
|
+
# Update the default callback URLs (where the webhooks are sent to) associated with your account.
|
20
|
+
#
|
21
|
+
# @note The URLs you provide must be valid and active. Nexmo will check that they return a 200 OK response before the setting is saved.
|
22
|
+
#
|
23
|
+
# @option params [String] :mo_call_back_url
|
24
|
+
# The URL where Nexmo will send a webhook when an SMS is received to a Nexmo number that does not have SMS handling configured.
|
25
|
+
# Send an empty string to unset this value.
|
26
|
+
#
|
27
|
+
# @option params [String] :dr_call_back_url
|
28
|
+
# The URL where Nexmo will send a webhook when an delivery receipt is received without a specific callback URL configured.
|
29
|
+
# Send an empty string to unset this value.
|
30
|
+
#
|
31
|
+
# @param [Hash] params
|
32
|
+
#
|
33
|
+
# @return [Entity]
|
34
|
+
#
|
35
|
+
# @see https://developer.nexmo.com/api/developer/account#settings
|
36
|
+
#
|
11
37
|
def update(params)
|
12
|
-
request('/account/settings', params: params, type: Post)
|
38
|
+
request('/account/settings', params: camelcase(params), type: Post)
|
13
39
|
end
|
14
40
|
|
41
|
+
# Top-up your account balance.
|
42
|
+
#
|
43
|
+
# @option params [required, String] :trx
|
44
|
+
# The ID associated with your original auto-reload transaction.
|
45
|
+
#
|
46
|
+
# @param [Hash] params
|
47
|
+
#
|
48
|
+
# @see https://developer.nexmo.com/api/developer/account#top-up
|
49
|
+
#
|
15
50
|
def topup(params)
|
16
51
|
request('/account/top-up', params: params, type: Post)
|
17
52
|
end
|
data/lib/nexmo/alerts.rb
CHANGED
@@ -4,16 +4,62 @@ module Nexmo
|
|
4
4
|
class Alerts < Namespace
|
5
5
|
self.host = 'rest.nexmo.com'
|
6
6
|
|
7
|
+
# Request the list of phone numbers opted out from your campaign.
|
8
|
+
#
|
9
|
+
# @see https://developer.nexmo.com/api/sms/us-short-codes/alerts/subscription
|
10
|
+
#
|
11
|
+
# @return [Entity]
|
12
|
+
#
|
7
13
|
def list
|
8
14
|
request('/sc/us/alert/opt-in/query/json')
|
9
15
|
end
|
10
16
|
|
17
|
+
# Remove a phone number from the opt-out list.
|
18
|
+
#
|
19
|
+
# @option params [required, String] :msisdn
|
20
|
+
# The phone number to resubscribe to your campaign and remove from the opt-out list.
|
21
|
+
#
|
22
|
+
# @param [Hash] params
|
23
|
+
#
|
24
|
+
# @return [Entity]
|
25
|
+
#
|
26
|
+
# @see https://developer.nexmo.com/api/sms/us-short-codes/alerts/subscription
|
27
|
+
#
|
11
28
|
def remove(params)
|
12
29
|
request('/sc/us/alert/opt-in/manage/json', params: params, type: Post)
|
13
30
|
end
|
14
31
|
|
15
32
|
alias_method :resubscribe, :remove
|
16
33
|
|
34
|
+
# Send an alert to your user.
|
35
|
+
#
|
36
|
+
# @option params [required, String] :to
|
37
|
+
# The single phone number to send pin to.
|
38
|
+
# Mobile number in US format and one recipient per request.
|
39
|
+
#
|
40
|
+
# @option params [Integer] :status_report_req
|
41
|
+
# Set to 1 to receive a delivery receipt.
|
42
|
+
# To receive the delivery receipt, you have to configure a webhook endpoint in Dashboard.
|
43
|
+
#
|
44
|
+
# @option params [String] :client_ref
|
45
|
+
# A 40 character reference string for your internal reporting.
|
46
|
+
#
|
47
|
+
# @option params [Integer] :template
|
48
|
+
# If you have multiple templates, this is the index of the template to call.
|
49
|
+
# The default template starts is 0, each Event Based Alert campaign can have up to 6 templates.
|
50
|
+
# If you have one template only it is the default. That is, template=0.
|
51
|
+
# If you create a request with template=1 the API call will default, template=0 instead.
|
52
|
+
# After you add a valid campaign alert for 2FA, the request will call template 1 instead of template 0.
|
53
|
+
#
|
54
|
+
# @option params [String] :type
|
55
|
+
# Default value is `text`. Possible values are: `text` for plain text SMS or `unicode` only use this when your SMS must contain special characters.
|
56
|
+
#
|
57
|
+
# @param [Hash] params
|
58
|
+
#
|
59
|
+
# @return [Entity]
|
60
|
+
#
|
61
|
+
# @see https://developer.nexmo.com/api/sms/us-short-codes/alerts/sending
|
62
|
+
#
|
17
63
|
def send(params)
|
18
64
|
request('/sc/us/alert/json', params: params, type: Post)
|
19
65
|
end
|
data/lib/nexmo/applications.rb
CHANGED
@@ -4,22 +4,140 @@ module Nexmo
|
|
4
4
|
class Applications < Namespace
|
5
5
|
self.request_body = JSON
|
6
6
|
|
7
|
+
# Create a new application.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# params = {
|
11
|
+
# name: 'Example App',
|
12
|
+
# type: 'voice',
|
13
|
+
# answer_url: answer_url,
|
14
|
+
# event_url: event_url
|
15
|
+
# }
|
16
|
+
#
|
17
|
+
# response = client.applications.create(params)
|
18
|
+
#
|
19
|
+
# @option params [required, String] :name
|
20
|
+
# The name of your application.
|
21
|
+
#
|
22
|
+
# @option params [required, String] :type
|
23
|
+
# The Nexmo product or products that you access with this application.
|
24
|
+
# Currently only `voice` and `messages` are supported.
|
25
|
+
#
|
26
|
+
# @option params [required, String] :answer_url
|
27
|
+
# The URL where your webhook delivers the Nexmo Call Control Object that governs this call.
|
28
|
+
# As soon as your user answers a call Nexmo makes a request to answer_url.
|
29
|
+
#
|
30
|
+
# @option params [String] :answer_method
|
31
|
+
# The HTTP method used to make the request to answer_url.
|
32
|
+
# The default value is GET.
|
33
|
+
#
|
34
|
+
# @option params [required, String] :event_url
|
35
|
+
# Nexmo sends event information asynchronously to this URL when status changes.
|
36
|
+
#
|
37
|
+
# @option params [String] :event_method
|
38
|
+
# The HTTP method used to send event information to event_url.
|
39
|
+
# The default value is POST.
|
40
|
+
#
|
41
|
+
# @param [Hash] params
|
42
|
+
#
|
43
|
+
# @return [Entity]
|
44
|
+
#
|
45
|
+
# @see https://developer.nexmo.com/api/application#create-an-application
|
46
|
+
#
|
7
47
|
def create(params)
|
8
48
|
request('/v1/applications', params: params, type: Post)
|
9
49
|
end
|
10
50
|
|
51
|
+
# Retrieve details of all applications associated with your account.
|
52
|
+
#
|
53
|
+
# @example
|
54
|
+
# response = client.applications.list
|
55
|
+
# response._embedded.applications.each do |item|
|
56
|
+
# puts "#{item.id} #{item.name}"
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
# @option params [Integer] :page_size
|
60
|
+
# Set the number of items returned on each call to this endpoint.
|
61
|
+
# The default is 10 records.
|
62
|
+
#
|
63
|
+
# @option params [Integer] :page_index
|
64
|
+
# Set the offset from the first page.
|
65
|
+
# The default value is 0.
|
66
|
+
#
|
67
|
+
# @param [Hash, nil] params
|
68
|
+
#
|
69
|
+
# @return [Entity]
|
70
|
+
#
|
71
|
+
# @see https://developer.nexmo.com/api/application#retrieve-your-applications
|
72
|
+
#
|
11
73
|
def list(params = nil)
|
12
74
|
request('/v1/applications', params: params)
|
13
75
|
end
|
14
76
|
|
77
|
+
# Retrieve details about a single application.
|
78
|
+
#
|
79
|
+
# @example
|
80
|
+
# response = client.applications.get(id)
|
81
|
+
#
|
82
|
+
# @param [String] id
|
83
|
+
#
|
84
|
+
# @return [Entity]
|
85
|
+
#
|
86
|
+
# @see https://developer.nexmo.com/api/application#retrieve-an-application
|
87
|
+
#
|
15
88
|
def get(id)
|
16
89
|
request('/v1/applications/' + id)
|
17
90
|
end
|
18
91
|
|
92
|
+
# Update an existing application.
|
93
|
+
#
|
94
|
+
# @example
|
95
|
+
# response = client.applications.update(id, answer_method: 'POST')
|
96
|
+
#
|
97
|
+
# @option params [required, String] :name
|
98
|
+
# The name of your application.
|
99
|
+
#
|
100
|
+
# @option params [required, String] :type
|
101
|
+
# The Nexmo product or products that you access with this application.
|
102
|
+
# Currently only `voice` and `messages` are supported.
|
103
|
+
#
|
104
|
+
# @option params [required, String] :answer_url
|
105
|
+
# The URL where your webhook delivers the Nexmo Call Control Object that governs this call.
|
106
|
+
# As soon as your user answers a call Nexmo makes a request to answer_url.
|
107
|
+
#
|
108
|
+
# @option params [String] :answer_method
|
109
|
+
# The HTTP method used to make the request to answer_url.
|
110
|
+
# The default value is GET.
|
111
|
+
#
|
112
|
+
# @option params [required, String] :event_url
|
113
|
+
# Nexmo sends event information asynchronously to this URL when status changes.
|
114
|
+
#
|
115
|
+
# @option params [String] :event_method
|
116
|
+
# The HTTP method used to send event information to event_url.
|
117
|
+
# The default value is POST.
|
118
|
+
#
|
119
|
+
# @param [String] id
|
120
|
+
# @param [Hash] params
|
121
|
+
#
|
122
|
+
# @return [Entity]
|
123
|
+
#
|
124
|
+
# @see https://developer.nexmo.com/api/application#update-an-application
|
125
|
+
#
|
19
126
|
def update(id, params)
|
20
127
|
request('/v1/applications/' + id, params: params, type: Put)
|
21
128
|
end
|
22
129
|
|
130
|
+
# Delete a single application.
|
131
|
+
#
|
132
|
+
# @example
|
133
|
+
# response = client.applications.delete(id)
|
134
|
+
#
|
135
|
+
# @param [String] id
|
136
|
+
#
|
137
|
+
# @return [:no_content]
|
138
|
+
#
|
139
|
+
# @see https://developer.nexmo.com/api/application#destroy-an-application
|
140
|
+
#
|
23
141
|
def delete(id)
|
24
142
|
request('/v1/applications/' + id, type: Delete)
|
25
143
|
end
|
@@ -8,22 +8,93 @@ module Nexmo
|
|
8
8
|
|
9
9
|
self.request_headers['Content-Type'] = 'application/json'
|
10
10
|
|
11
|
+
# Create an application.
|
12
|
+
#
|
13
|
+
# @option params [required, String] :name
|
14
|
+
# Application name.
|
15
|
+
#
|
16
|
+
# @option params [Hash] :keys
|
17
|
+
# - **:public_key** (String) Public key
|
18
|
+
#
|
19
|
+
# @option params [Hash] :capabilities
|
20
|
+
# Your application can use multiple products.
|
21
|
+
# This contains the configuration for each product.
|
22
|
+
# This replaces the application `type` from version 1 of the Application API.
|
23
|
+
#
|
24
|
+
# @param [Hash] params
|
25
|
+
#
|
26
|
+
# @return [Entity]
|
27
|
+
#
|
28
|
+
# @see https://developer.nexmo.com/api/application.v2#createApplication
|
29
|
+
#
|
11
30
|
def create(params)
|
12
31
|
request('/v2/applications', params: params, type: Post)
|
13
32
|
end
|
14
33
|
|
34
|
+
# List available applications.
|
35
|
+
#
|
36
|
+
# @option params [Integer] :page_size
|
37
|
+
# The number of applications per page.
|
38
|
+
#
|
39
|
+
# @option params [Integer] :page
|
40
|
+
# The current page number (starts at 1).
|
41
|
+
#
|
42
|
+
# @param [Hash] params
|
43
|
+
#
|
44
|
+
# @return [Entity]
|
45
|
+
#
|
46
|
+
# @see https://developer.nexmo.com/api/application.v2#listApplication
|
47
|
+
#
|
15
48
|
def list(params = nil)
|
16
49
|
request('/v2/applications', params: params)
|
17
50
|
end
|
18
51
|
|
52
|
+
# Get an application.
|
53
|
+
#
|
54
|
+
# @param [String] id
|
55
|
+
#
|
56
|
+
# @return [Entity]
|
57
|
+
#
|
58
|
+
# @see https://developer.nexmo.com/api/application.v2#getApplication
|
59
|
+
#
|
19
60
|
def get(id)
|
20
61
|
request('/v2/applications/' + id)
|
21
62
|
end
|
22
63
|
|
64
|
+
# Update an application.
|
65
|
+
#
|
66
|
+
# @option params [required, String] :name
|
67
|
+
# Application name.
|
68
|
+
#
|
69
|
+
# @option params [Hash] :keys
|
70
|
+
# - **:public_key** (String) Public key
|
71
|
+
#
|
72
|
+
# @option params [Hash] :capabilities
|
73
|
+
# Your application can use multiple products.
|
74
|
+
# This contains the configuration for each product.
|
75
|
+
# This replaces the application `type` from version 1 of the Application API.
|
76
|
+
#
|
77
|
+
# @param [String] id
|
78
|
+
# @param [Hash] params
|
79
|
+
#
|
80
|
+
# @return [Entity]
|
81
|
+
#
|
82
|
+
# @see https://developer.nexmo.com/api/application.v2#updateApplication
|
83
|
+
#
|
23
84
|
def update(id, params)
|
24
85
|
request('/v2/applications/' + id, params: params, type: Put)
|
25
86
|
end
|
26
87
|
|
88
|
+
# Delete an application.
|
89
|
+
#
|
90
|
+
# @note Deleting an application cannot be undone.
|
91
|
+
#
|
92
|
+
# @param [String] id
|
93
|
+
#
|
94
|
+
# @return [Entity]
|
95
|
+
#
|
96
|
+
# @see https://developer.nexmo.com/api/application.v2#deleteApplication
|
97
|
+
#
|
27
98
|
def delete(id)
|
28
99
|
request('/v2/applications/' + id, type: Delete)
|
29
100
|
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
module Nexmo
|
2
|
-
class Basic < AbstractAuthentication
|
2
|
+
class Basic < AbstractAuthentication
|
3
3
|
def update(object)
|
4
4
|
return unless object.is_a?(Net::HTTPRequest)
|
5
5
|
|
6
6
|
object.basic_auth(@client.api_key, @client.api_secret)
|
7
7
|
end
|
8
8
|
end
|
9
|
+
|
10
|
+
private_constant :Basic
|
9
11
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Nexmo
|
4
|
-
class BearerToken < AbstractAuthentication
|
4
|
+
class BearerToken < AbstractAuthentication
|
5
5
|
def update(object)
|
6
6
|
return unless object.is_a?(Net::HTTPRequest)
|
7
7
|
|
8
8
|
object['Authorization'] = 'Bearer ' + @client.token
|
9
9
|
end
|
10
10
|
end
|
11
|
+
|
12
|
+
private_constant :BearerToken
|
11
13
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Nexmo
|
2
|
-
class KeySecretParams < AbstractAuthentication
|
2
|
+
class KeySecretParams < AbstractAuthentication
|
3
3
|
def update(object)
|
4
4
|
return unless object.is_a?(Hash)
|
5
5
|
|
@@ -7,4 +7,6 @@ module Nexmo
|
|
7
7
|
object[:api_secret] = @client.api_secret
|
8
8
|
end
|
9
9
|
end
|
10
|
+
|
11
|
+
private_constant :KeySecretParams
|
10
12
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Nexmo
|
2
|
-
class KeySecretQuery < AbstractAuthentication
|
2
|
+
class KeySecretQuery < AbstractAuthentication
|
3
3
|
def update(object)
|
4
4
|
return unless object.is_a?(URI)
|
5
5
|
|
@@ -15,4 +15,6 @@ module Nexmo
|
|
15
15
|
}
|
16
16
|
end
|
17
17
|
end
|
18
|
+
|
19
|
+
private_constant :KeySecretQuery
|
18
20
|
end
|