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
@@ -6,18 +6,65 @@ module Nexmo
|
|
6
6
|
|
7
7
|
self.request_body = JSON
|
8
8
|
|
9
|
+
# Create an event.
|
10
|
+
#
|
11
|
+
# @option params [required, String] :type
|
12
|
+
# Event type.
|
13
|
+
#
|
14
|
+
# @option params [String] :to
|
15
|
+
# Member ID.
|
16
|
+
#
|
17
|
+
# @option params [required, String] :from
|
18
|
+
# Member ID.
|
19
|
+
#
|
20
|
+
# @option params [Hash] :body
|
21
|
+
# Event Body.
|
22
|
+
#
|
23
|
+
# @param [String] conversation_id
|
24
|
+
# @param [Hash] params
|
25
|
+
#
|
26
|
+
# @return [Entity]
|
27
|
+
#
|
28
|
+
# @see https://developer.nexmo.com/api/conversation#createEvent
|
29
|
+
#
|
9
30
|
def create(conversation_id, params)
|
10
31
|
request('/beta/conversations/' + conversation_id + '/events', params: params, type: Post)
|
11
32
|
end
|
12
33
|
|
34
|
+
# List events.
|
35
|
+
#
|
36
|
+
# @param [String] conversation_id
|
37
|
+
#
|
38
|
+
# @return [Entity]
|
39
|
+
#
|
40
|
+
# @see https://developer.nexmo.com/api/conversation#getEvents
|
41
|
+
#
|
13
42
|
def list(conversation_id)
|
14
43
|
request('/beta/conversations/' + conversation_id + '/events')
|
15
44
|
end
|
16
45
|
|
46
|
+
# Retrieve an event.
|
47
|
+
#
|
48
|
+
# @param [String] conversation_id
|
49
|
+
# @param [String] event_id
|
50
|
+
#
|
51
|
+
# @return [Entity]
|
52
|
+
#
|
53
|
+
# @see https://developer.nexmo.com/api/conversation#getEvent
|
54
|
+
#
|
17
55
|
def get(conversation_id, event_id)
|
18
56
|
request('/beta/conversations/' + conversation_id + '/events/' + event_id.to_s)
|
19
57
|
end
|
20
58
|
|
59
|
+
# Delete an event.
|
60
|
+
#
|
61
|
+
# @param [String] conversation_id
|
62
|
+
# @param [String] event_id
|
63
|
+
#
|
64
|
+
# @return [Entity]
|
65
|
+
#
|
66
|
+
# @see https://developer.nexmo.com/api/conversation#deleteEvent
|
67
|
+
#
|
21
68
|
def delete(conversation_id, event_id)
|
22
69
|
request('/beta/conversations/' + conversation_id + '/events/' + event_id.to_s, type: Delete)
|
23
70
|
end
|
@@ -4,10 +4,24 @@ module Nexmo
|
|
4
4
|
class ConversationLegs < Namespace
|
5
5
|
self.authentication = BearerToken
|
6
6
|
|
7
|
+
# List legs.
|
8
|
+
#
|
9
|
+
# @return [Entity]
|
10
|
+
#
|
11
|
+
# @see https://developer.nexmo.com/api/conversation#listLegs
|
12
|
+
#
|
7
13
|
def list
|
8
14
|
request('/beta/legs')
|
9
15
|
end
|
10
16
|
|
17
|
+
# Delete a leg.
|
18
|
+
#
|
19
|
+
# @param [String] leg_id
|
20
|
+
#
|
21
|
+
# @return [Entity]
|
22
|
+
#
|
23
|
+
# @see https://developer.nexmo.com/api/conversation#deleteLeg
|
24
|
+
#
|
11
25
|
def delete(leg_id)
|
12
26
|
request('/beta/legs/' + leg_id, type: Delete)
|
13
27
|
end
|
@@ -6,22 +6,96 @@ module Nexmo
|
|
6
6
|
|
7
7
|
self.request_body = JSON
|
8
8
|
|
9
|
+
# Create a member.
|
10
|
+
#
|
11
|
+
# @option params [String] :action
|
12
|
+
# Invite or join a member to a conversation.
|
13
|
+
# Must be one of: `invite` or `join`.
|
14
|
+
#
|
15
|
+
# @option params [required, String] :user_id
|
16
|
+
# User ID.
|
17
|
+
#
|
18
|
+
# @option params [String] :member_id
|
19
|
+
# Member ID.
|
20
|
+
#
|
21
|
+
# @option params [required, Hash] :channel
|
22
|
+
# A user who joins a conversation as a member can have one channel per membership type.
|
23
|
+
#
|
24
|
+
# @option params [Hash] :media
|
25
|
+
# Media Object.
|
26
|
+
#
|
27
|
+
# @option params [String] :knocking_id
|
28
|
+
# Knocker ID.
|
29
|
+
# A knocker is a pre-member of a conversation who does not exist yet.
|
30
|
+
#
|
31
|
+
# @option params [String] :member_id_inviting
|
32
|
+
# Member ID of the member that sends the invitation.
|
33
|
+
#
|
34
|
+
# @param [String] conversation_id
|
35
|
+
# @param [Hash] params
|
36
|
+
#
|
37
|
+
# @return [Entity]
|
38
|
+
#
|
39
|
+
# @see https://developer.nexmo.com/api/conversation#createMember
|
40
|
+
#
|
9
41
|
def create(conversation_id, params)
|
10
42
|
request('/beta/conversations/' + conversation_id + '/members', params: params, type: Post)
|
11
43
|
end
|
12
44
|
|
45
|
+
# List members.
|
46
|
+
#
|
47
|
+
# @param [String] conversation_id
|
48
|
+
#
|
49
|
+
# @return [Entity]
|
50
|
+
#
|
51
|
+
# @see https://developer.nexmo.com/api/conversation#getMembers
|
52
|
+
#
|
13
53
|
def list(conversation_id)
|
14
54
|
request('/beta/conversations/' + conversation_id + '/members')
|
15
55
|
end
|
16
56
|
|
57
|
+
# Retrieve a member.
|
58
|
+
#
|
59
|
+
# @param [String] conversation_id
|
60
|
+
# @param [String] member_id
|
61
|
+
#
|
62
|
+
# @return [Entity]
|
63
|
+
#
|
64
|
+
# @see https://developer.nexmo.com/api/conversation#getMember
|
65
|
+
#
|
17
66
|
def get(conversation_id, member_id)
|
18
67
|
request('/beta/conversations/' + conversation_id + '/members/' + member_id)
|
19
68
|
end
|
20
69
|
|
70
|
+
# Update a member.
|
71
|
+
#
|
72
|
+
# @option params [String] :action
|
73
|
+
# Invite or join a member to a conversation.
|
74
|
+
#
|
75
|
+
# @option params [Hash] :channel
|
76
|
+
# A user who joins a conversation as a member can have one channel per membership type.
|
77
|
+
#
|
78
|
+
# @param [String] conversation_id
|
79
|
+
# @param [String] member_id
|
80
|
+
# @param [Hash] params
|
81
|
+
#
|
82
|
+
# @return [Entity]
|
83
|
+
#
|
84
|
+
# @see https://developer.nexmo.com/api/conversation#updateMember
|
85
|
+
#
|
21
86
|
def update(conversation_id, member_id, params)
|
22
87
|
request('/beta/conversations/' + conversation_id + '/members/' + member_id, params: params, type: Put)
|
23
88
|
end
|
24
89
|
|
90
|
+
# Delete a member.
|
91
|
+
#
|
92
|
+
# @param [String] conversation_id
|
93
|
+
# @param [String] member_id
|
94
|
+
#
|
95
|
+
# @return [Entity]
|
96
|
+
#
|
97
|
+
# @see https://developer.nexmo.com/api/conversation#deleteMember
|
98
|
+
#
|
25
99
|
def delete(conversation_id, member_id)
|
26
100
|
request('/beta/conversations/' + conversation_id + '/members/' + member_id, type: Delete)
|
27
101
|
end
|
@@ -6,22 +6,85 @@ module Nexmo
|
|
6
6
|
|
7
7
|
self.request_body = JSON
|
8
8
|
|
9
|
+
# Create a user.
|
10
|
+
#
|
11
|
+
# @option params [String] :name
|
12
|
+
# Unique name for a user.
|
13
|
+
#
|
14
|
+
# @option params [String] :display_name
|
15
|
+
# A string to be displayed as user name.
|
16
|
+
# It does not need to be unique.
|
17
|
+
#
|
18
|
+
# @option params [String] :image_url
|
19
|
+
# A link to an image for conversations' and users' avatars.
|
20
|
+
#
|
21
|
+
# @param [Hash] params
|
22
|
+
#
|
23
|
+
# @return [Entity]
|
24
|
+
#
|
25
|
+
# @see https://developer.nexmo.com/api/conversation#createUser
|
26
|
+
#
|
9
27
|
def create(params)
|
10
28
|
request('/beta/users', params: params, type: Post)
|
11
29
|
end
|
12
30
|
|
31
|
+
# List users.
|
32
|
+
#
|
33
|
+
# @return [Entity]
|
34
|
+
#
|
35
|
+
# @see https://developer.nexmo.com/api/conversation#getUsers
|
36
|
+
#
|
13
37
|
def list
|
14
38
|
request('/beta/users')
|
15
39
|
end
|
16
40
|
|
41
|
+
# Retrieve a user.
|
42
|
+
#
|
43
|
+
# @param [String] id
|
44
|
+
#
|
45
|
+
# @return [Entity]
|
46
|
+
#
|
47
|
+
# @see https://developer.nexmo.com/api/conversation#getUser
|
48
|
+
#
|
17
49
|
def get(id)
|
18
50
|
request('/beta/users/' + id)
|
19
51
|
end
|
20
52
|
|
53
|
+
# Update a user.
|
54
|
+
#
|
55
|
+
# @option params [String] :name
|
56
|
+
# Unique name for a user.
|
57
|
+
#
|
58
|
+
# @option params [String] :display_name
|
59
|
+
# A string to be displayed as user name.
|
60
|
+
# It does not need to be unique.
|
61
|
+
#
|
62
|
+
# @option params [String] :image_url
|
63
|
+
# A link to an image for conversations' and users' avatars.
|
64
|
+
#
|
65
|
+
# @option params [Hash] :channels
|
66
|
+
# A user who joins a conversation as a member can have one channel per membership type.
|
67
|
+
# Channels can be `app`, `phone`, `sip`, `websocket`, or `vbc`.
|
68
|
+
#
|
69
|
+
# @param [String] id
|
70
|
+
# @param [Hash] params
|
71
|
+
#
|
72
|
+
# @return [Entity]
|
73
|
+
#
|
74
|
+
# @see https://developer.nexmo.com/api/conversation#updateUser
|
75
|
+
#
|
21
76
|
def update(id, params)
|
22
77
|
request('/beta/users/' + id, params: params, type: Put)
|
23
78
|
end
|
24
79
|
|
80
|
+
# Delete a user.
|
81
|
+
#
|
82
|
+
# @param [String] id
|
83
|
+
#
|
84
|
+
# @return [Entity]
|
85
|
+
#
|
86
|
+
# @see https://developer.nexmo.com/api/conversation#deleteUser
|
87
|
+
#
|
25
88
|
def delete(id)
|
26
89
|
request('/beta/users/' + id, type: Delete)
|
27
90
|
end
|
data/lib/nexmo/conversations.rb
CHANGED
@@ -6,38 +6,148 @@ module Nexmo
|
|
6
6
|
|
7
7
|
self.request_body = JSON
|
8
8
|
|
9
|
+
# Create a conversation.
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# response = client.conversations.create(name: 'Example Conversation', display_name: 'Example Display Name')
|
13
|
+
#
|
14
|
+
# @option params [String] :name
|
15
|
+
# Unique name for a conversation.
|
16
|
+
#
|
17
|
+
# @option params [String] :display_name
|
18
|
+
# The display name for the conversation.
|
19
|
+
# It does not have to be unique.
|
20
|
+
#
|
21
|
+
# @option params [String] :image_url
|
22
|
+
# A link to an image for conversations' and users' avatars.
|
23
|
+
#
|
24
|
+
# @option params [Hash] :numbers
|
25
|
+
# - **:sms** (String) phone number used for sms channel
|
26
|
+
# - **:pstn** (String) phone number used for pstn channel
|
27
|
+
#
|
28
|
+
# @option params [Hash] :properties
|
29
|
+
# - **:ttl** (Integer) After how many seconds an empty conversation is deleted
|
30
|
+
#
|
31
|
+
# @return [Entity]
|
32
|
+
#
|
33
|
+
# @see https://developer.nexmo.com/api/conversation#createConversation
|
34
|
+
#
|
9
35
|
def create(params)
|
10
36
|
request('/beta/conversations', params: params, type: Post)
|
11
37
|
end
|
12
38
|
|
39
|
+
# List all conversations associated with your application.
|
40
|
+
#
|
41
|
+
# @example
|
42
|
+
# response = client.conversations.list
|
43
|
+
#
|
44
|
+
# @option params [String] :date_start
|
45
|
+
# Return the records that occurred after this point in time.
|
46
|
+
#
|
47
|
+
# @option params [String] :date_end
|
48
|
+
# Return the records that occurred before this point in time.
|
49
|
+
#
|
50
|
+
# @option params [Integer] :page_size
|
51
|
+
# Return this amount of records in the response.
|
52
|
+
#
|
53
|
+
# @option params [Integer] :record_index
|
54
|
+
# Return calls from this index in the response.
|
55
|
+
#
|
56
|
+
# @option params ['asc', 'desc'] :order
|
57
|
+
# Return the records in ascending or descending order.
|
58
|
+
#
|
59
|
+
# @param [Hash, nil] params
|
60
|
+
#
|
61
|
+
# @return [Entity]
|
62
|
+
#
|
63
|
+
# @see https://developer.nexmo.com/api/conversation#replaceConversation
|
64
|
+
#
|
13
65
|
def list(params = nil)
|
14
66
|
request('/beta/conversations', params: params)
|
15
67
|
end
|
16
68
|
|
69
|
+
# Retrieve a conversation.
|
70
|
+
#
|
71
|
+
# @example
|
72
|
+
# response = client.conversations.get(id)
|
73
|
+
#
|
74
|
+
# @param [String] id
|
75
|
+
#
|
76
|
+
# @return [Entity]
|
77
|
+
#
|
78
|
+
# @see https://developer.nexmo.com/api/conversation#retrieveConversation
|
79
|
+
#
|
17
80
|
def get(id)
|
18
81
|
request('/beta/conversations/' + id)
|
19
82
|
end
|
20
83
|
|
84
|
+
# Update a conversation.
|
85
|
+
#
|
86
|
+
# @example
|
87
|
+
# response = client.conversations.update(id, display_name: 'Updated conversation')
|
88
|
+
#
|
89
|
+
# @option params [String] :name
|
90
|
+
# Unique name for a conversation
|
91
|
+
#
|
92
|
+
# @option params [String] :display_name
|
93
|
+
# The display name for the conversation.
|
94
|
+
#
|
95
|
+
# @option params [String] :image_url
|
96
|
+
# A link to an image for conversations' and users' avatars.
|
97
|
+
#
|
98
|
+
# @option params [Hash] :numbers
|
99
|
+
# - **:sms** (String) phone number used for sms channel
|
100
|
+
# - **:pstn** (String) phone number used for pstn channel
|
101
|
+
#
|
102
|
+
# @option params [Hash] :properties
|
103
|
+
# - **:ttl** (Integer) After how many seconds an empty conversation is deleted
|
104
|
+
#
|
105
|
+
# @param [String] id
|
106
|
+
# @param [Hash] params
|
107
|
+
#
|
108
|
+
# @return [Entity]
|
109
|
+
#
|
110
|
+
# @see https://developer.nexmo.com/api/conversation#replaceConversation
|
111
|
+
#
|
21
112
|
def update(id, params)
|
22
113
|
request('/beta/conversations/' + id, params: params, type: Put)
|
23
114
|
end
|
24
115
|
|
116
|
+
# Delete a conversation.
|
117
|
+
#
|
118
|
+
# @example
|
119
|
+
# response = client.conversations.delete(id)
|
120
|
+
#
|
121
|
+
# @param [String] id
|
122
|
+
#
|
123
|
+
# @return [Entity]
|
124
|
+
#
|
125
|
+
# @see https://developer.nexmo.com/api/conversation#deleteConversation
|
126
|
+
#
|
25
127
|
def delete(id)
|
26
128
|
request('/beta/conversations/' + id, type: Delete)
|
27
129
|
end
|
28
130
|
|
131
|
+
# @return [ConversationEvents]
|
132
|
+
#
|
29
133
|
def events
|
30
134
|
@events ||= ConversationEvents.new(@client)
|
31
135
|
end
|
32
136
|
|
137
|
+
# @return [ConversationLegs]
|
138
|
+
#
|
33
139
|
def legs
|
34
140
|
@legs ||= ConversationLegs.new(@client)
|
35
141
|
end
|
36
142
|
|
143
|
+
# @return [ConversationMembers]
|
144
|
+
#
|
37
145
|
def members
|
38
146
|
@members ||= ConversationMembers.new(@client)
|
39
147
|
end
|
40
148
|
|
149
|
+
# @return [ConversationUsers]
|
150
|
+
#
|
41
151
|
def users
|
42
152
|
@users ||= ConversationUsers.new(@client)
|
43
153
|
end
|
data/lib/nexmo/errors.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Nexmo
|
5
|
+
module Errors
|
6
|
+
def self.parse(response)
|
7
|
+
exception_class = case response
|
8
|
+
when Net::HTTPUnauthorized
|
9
|
+
AuthenticationError
|
10
|
+
when Net::HTTPClientError
|
11
|
+
ClientError
|
12
|
+
when Net::HTTPServerError
|
13
|
+
ServerError
|
14
|
+
else
|
15
|
+
Error
|
16
|
+
end
|
17
|
+
|
18
|
+
message = if response.content_type == 'application/json'
|
19
|
+
hash = ::JSON.parse(response.body)
|
20
|
+
|
21
|
+
if hash.key?('error_title')
|
22
|
+
hash['error_title']
|
23
|
+
elsif problem_details?(hash)
|
24
|
+
problem_details_message(hash)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
exception_class.new(message)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.problem_details?(hash)
|
32
|
+
hash.key?('title') && hash.key?('detail') && hash.key?('type')
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.problem_details_message(hash)
|
36
|
+
"#{hash['title']}. #{hash['detail']} See #{hash['type']} for more info, or email support@nexmo.com if you have any questions."
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
private_constant :Errors
|
41
|
+
end
|