vonage 7.23.0 → 8.0.0.beta
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/README.md +87 -387
- data/lib/vonage/applications.rb +4 -12
- data/lib/vonage/client.rb +0 -51
- data/lib/vonage/client_error.rb +1 -1
- data/lib/vonage/config.rb +1 -9
- data/lib/vonage/conversations/events.rb +0 -12
- data/lib/vonage/conversations/legs.rb +0 -6
- data/lib/vonage/conversations/members.rb +0 -15
- data/lib/vonage/conversations/users.rb +0 -15
- data/lib/vonage/conversations.rb +0 -30
- data/lib/vonage/errors.rb +20 -37
- data/lib/vonage/gsm7.rb +1 -1
- data/lib/vonage/jwt.rb +0 -17
- data/lib/vonage/keys.rb +0 -2
- data/lib/vonage/logger.rb +3 -5
- data/lib/vonage/messaging/channels/viber.rb +1 -8
- data/lib/vonage/messaging/channels/whats_app.rb +1 -3
- data/lib/vonage/messaging.rb +0 -11
- data/lib/vonage/namespace.rb +60 -132
- data/lib/vonage/numbers.rb +6 -29
- data/lib/vonage/server_error.rb +1 -1
- data/lib/vonage/signature.rb +5 -5
- data/lib/vonage/sms.rb +20 -20
- data/lib/vonage/version.rb +1 -1
- data/lib/vonage/video/archives.rb +53 -18
- data/lib/vonage/video/list_response.rb +11 -0
- data/lib/vonage/video/moderation.rb +22 -7
- data/lib/vonage/video/signals.rb +9 -4
- data/lib/vonage/video/streams.rb +12 -6
- data/lib/vonage/video.rb +13 -31
- data/lib/vonage/voice/actions/connect.rb +3 -27
- data/lib/vonage/voice/actions/conversation.rb +2 -2
- data/lib/vonage/voice/actions/pay.rb +107 -0
- data/lib/vonage/voice/actions/talk.rb +2 -11
- data/lib/vonage/voice/talk.rb +1 -11
- data/lib/vonage/voice.rb +0 -22
- data/lib/vonage.rb +0 -2
- data/vonage.gemspec +1 -3
- metadata +9 -94
- data/lib/vonage/api_error.rb +0 -33
- data/lib/vonage/conversation/event/list_response.rb +0 -11
- data/lib/vonage/conversation/event.rb +0 -108
- data/lib/vonage/conversation/list_response.rb +0 -11
- data/lib/vonage/conversation/member/list_response.rb +0 -11
- data/lib/vonage/conversation/member.rb +0 -134
- data/lib/vonage/conversation/user/conversations_list_response.rb +0 -11
- data/lib/vonage/conversation/user/sessions_list_response.rb +0 -11
- data/lib/vonage/conversation/user.rb +0 -67
- data/lib/vonage/conversation.rb +0 -164
- data/lib/vonage/meetings/applications.rb +0 -25
- data/lib/vonage/meetings/dial_in_numbers/list_response.rb +0 -11
- data/lib/vonage/meetings/dial_in_numbers.rb +0 -23
- data/lib/vonage/meetings/recordings.rb +0 -36
- data/lib/vonage/meetings/rooms/list_response.rb +0 -11
- data/lib/vonage/meetings/rooms.rb +0 -155
- data/lib/vonage/meetings/sessions/list_response.rb +0 -11
- data/lib/vonage/meetings/sessions.rb +0 -28
- data/lib/vonage/meetings/themes/list_response.rb +0 -11
- data/lib/vonage/meetings/themes.rb +0 -218
- data/lib/vonage/meetings.rb +0 -38
- data/lib/vonage/number_insight_2.rb +0 -36
- data/lib/vonage/proactive_connect/events/list_response.rb +0 -11
- data/lib/vonage/proactive_connect/events.rb +0 -68
- data/lib/vonage/proactive_connect/item.rb +0 -104
- data/lib/vonage/proactive_connect/items/file_response.rb +0 -32
- data/lib/vonage/proactive_connect/items/list_response.rb +0 -11
- data/lib/vonage/proactive_connect/items.rb +0 -107
- data/lib/vonage/proactive_connect/list.rb +0 -168
- data/lib/vonage/proactive_connect/lists/list_response.rb +0 -11
- data/lib/vonage/proactive_connect/lists.rb +0 -35
- data/lib/vonage/proactive_connect.rb +0 -33
- data/lib/vonage/subaccounts/balance_transfers/list_response.rb +0 -11
- data/lib/vonage/subaccounts/credit_transfers/list_response.rb +0 -11
- data/lib/vonage/subaccounts/list_response.rb +0 -15
- data/lib/vonage/subaccounts.rb +0 -203
- data/lib/vonage/users/list_response.rb +0 -11
- data/lib/vonage/users.rb +0 -156
- data/lib/vonage/verify2/channels/email.rb +0 -36
- data/lib/vonage/verify2/channels/silent_auth.rb +0 -45
- data/lib/vonage/verify2/channels/sms.rb +0 -53
- data/lib/vonage/verify2/channels/voice.rb +0 -32
- data/lib/vonage/verify2/channels/whats_app.rb +0 -38
- data/lib/vonage/verify2/channels/whats_app_interactive.rb +0 -32
- data/lib/vonage/verify2/start_verification_options.rb +0 -62
- data/lib/vonage/verify2/workflow.rb +0 -39
- data/lib/vonage/verify2/workflow_builder.rb +0 -25
- data/lib/vonage/verify2.rb +0 -97
- data/lib/vonage/video/archives/list_response.rb +0 -11
- data/lib/vonage/video/broadcasts/list_response.rb +0 -11
- data/lib/vonage/video/broadcasts.rb +0 -75
- data/lib/vonage/video/sip.rb +0 -48
- data/lib/vonage/video/streams/list_response.rb +0 -11
@@ -1,218 +0,0 @@
|
|
1
|
-
# typed: true
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Vonage
|
5
|
-
class Meetings::Themes < Namespace
|
6
|
-
extend T::Sig
|
7
|
-
|
8
|
-
self.authentication = BearerToken
|
9
|
-
|
10
|
-
self.request_body = JSON
|
11
|
-
|
12
|
-
self.host = :vonage_host
|
13
|
-
|
14
|
-
# Get a list of themes associated with the Vonage application.
|
15
|
-
#
|
16
|
-
# @return [ListResponse]
|
17
|
-
#
|
18
|
-
# @see https://developer.vonage.com/en/api/meetings#getThemes
|
19
|
-
def list
|
20
|
-
request("/v1/meetings/themes", response_class: ListResponse)
|
21
|
-
end
|
22
|
-
|
23
|
-
# Return information for specified theme.
|
24
|
-
#
|
25
|
-
# @param [required, String] theme_id The id of the theme for which the info should be returned
|
26
|
-
#
|
27
|
-
# @return [Response]
|
28
|
-
#
|
29
|
-
# @see https://developer.vonage.com/en/api/meetings#getThemeById
|
30
|
-
def info(theme_id:)
|
31
|
-
request("/v1/meetings/themes/" + theme_id)
|
32
|
-
end
|
33
|
-
|
34
|
-
# Create a new theme.
|
35
|
-
#
|
36
|
-
# @param [required, String] :main_color
|
37
|
-
# The main color that will be used for the meeting room.
|
38
|
-
#
|
39
|
-
# @param [required, String] :brand_text
|
40
|
-
# The text that will appear on the meeting homepage, in the case that there is no brand image
|
41
|
-
#
|
42
|
-
# @param [optional, String] :theme_name
|
43
|
-
# The name of the theme (must be unique). If null, a UUID will automatically be generated
|
44
|
-
#
|
45
|
-
# @param [optional, String] :short_company_url
|
46
|
-
# The URL that will represent every meeting room with this theme. The value must be unique across Vonage
|
47
|
-
#
|
48
|
-
# @return [Response]
|
49
|
-
#
|
50
|
-
# @see https://developer.vonage.com/en/api/meetings#createTheme
|
51
|
-
def create(main_color:, brand_text:, **params)
|
52
|
-
request(
|
53
|
-
"/v1/meetings/themes",
|
54
|
-
params: params.merge(main_color: main_color, brand_text: brand_text),
|
55
|
-
type: Post
|
56
|
-
)
|
57
|
-
end
|
58
|
-
|
59
|
-
# Update an existing theme.
|
60
|
-
#
|
61
|
-
# @param [required, String] theme_id The id of the theme to be updated
|
62
|
-
#
|
63
|
-
# @param [required, String] :main_color
|
64
|
-
# The main color that will be used for the meeting room.
|
65
|
-
#
|
66
|
-
# @param [required, String] :brand_text
|
67
|
-
# The text that will appear on the meeting homepage, in the case that there is no brand image
|
68
|
-
#
|
69
|
-
# @param [optional, String] :theme_name
|
70
|
-
# The name of the theme (must be unique). If null, a UUID will automatically be generated
|
71
|
-
#
|
72
|
-
# @param [optional, String] :short_company_url
|
73
|
-
# The URL that will represent every meeting room with this theme. The value must be unique across Vonage
|
74
|
-
#
|
75
|
-
# @return [Response]
|
76
|
-
#
|
77
|
-
# @see https://developer.vonage.com/en/api/meetings#updateTheme
|
78
|
-
def update(theme_id:, **params)
|
79
|
-
request(
|
80
|
-
"/v1/meetings/themes/" + theme_id,
|
81
|
-
params: {
|
82
|
-
update_details: params
|
83
|
-
},
|
84
|
-
type: Patch
|
85
|
-
)
|
86
|
-
end
|
87
|
-
|
88
|
-
# Delete an existing theme.
|
89
|
-
#
|
90
|
-
# @param [required, String] :theme_id The id of the theme to be deleted
|
91
|
-
#
|
92
|
-
# @param [optional, Boolean] :force. Set to `true` to force delete a theme currently being used for a room, or as
|
93
|
-
# a default theme. (Defaults to `false`)
|
94
|
-
#
|
95
|
-
# @return [Response]
|
96
|
-
#
|
97
|
-
# @see https://developer.vonage.com/en/api/meetings#deleteTheme
|
98
|
-
def delete(theme_id:, force: false)
|
99
|
-
request(
|
100
|
-
"/v1/meetings/themes/" + theme_id + "?force=#{force}",
|
101
|
-
type: Delete
|
102
|
-
)
|
103
|
-
end
|
104
|
-
|
105
|
-
# Get a list of rooms that are associated with a theme id.
|
106
|
-
#
|
107
|
-
# @param [required, String] theme_id THe ID of the theme to search for rooms associated with.
|
108
|
-
#
|
109
|
-
# @param [optional, Integer] :start_id
|
110
|
-
#
|
111
|
-
# @param [optional, Integer] :end_id
|
112
|
-
#
|
113
|
-
# @param [optional, Integer] :page_size
|
114
|
-
#
|
115
|
-
# @return [Response]
|
116
|
-
#
|
117
|
-
# @see https://developer.vonage.com/en/api/meetings#getRoomsByThemeId
|
118
|
-
def list_rooms(theme_id:, **params)
|
119
|
-
path = "/v1/meetings/themes/" + theme_id + "/rooms"
|
120
|
-
path += "?#{Params.encode(params)}" unless params.empty?
|
121
|
-
|
122
|
-
request(path, response_class: Meetings::Rooms::ListResponse)
|
123
|
-
end
|
124
|
-
|
125
|
-
# Set a logo for a theme.
|
126
|
-
#
|
127
|
-
# @param [required, String] :theme_id The ID of the theme for which the logo should be set
|
128
|
-
#
|
129
|
-
# @param [required, String] :filepath
|
130
|
-
# The filepath of the logo file. Logo files must conform to the following requirements:
|
131
|
-
# - Format: PNG
|
132
|
-
# - Maximum size: 1MB
|
133
|
-
# - Background must be transparent
|
134
|
-
# - Dimensions:
|
135
|
-
# - 1 px - 300 px (`white` and `colored` logos)
|
136
|
-
# - 16 x 16 - 32 x 32 and must be square (favicon)
|
137
|
-
#
|
138
|
-
# @param [required, String] :logo_type
|
139
|
-
# The type of logo to be set. Must be one of `white`, `colored`, `favicon`
|
140
|
-
#
|
141
|
-
# @return [Response]
|
142
|
-
#
|
143
|
-
# @see https://developer.vonage.com/en/meetings/guides/theme-management#uploading-icons-and-logos
|
144
|
-
# @see https://developer.vonage.com/en/api/meetings#getUploadUrlsForTheme
|
145
|
-
# @see https://developer.vonage.com/en/api/meetings#finalizeLogosForTheme
|
146
|
-
#
|
147
|
-
# TODO: add type signature
|
148
|
-
def set_logo(theme_id:, filepath:, logo_type:)
|
149
|
-
pn = Pathname.new(filepath)
|
150
|
-
valid_logo_types = ['white', 'colored', 'favicon']
|
151
|
-
raise ArgumentError, ':filepath not for a file' unless pn.file?
|
152
|
-
raise ArgumentError, 'file at :filepath not readable' unless pn.readable?
|
153
|
-
raise ArgumentError, "logo_type: must be one of #{valid_logo_types}" unless valid_logo_types.include?(logo_type)
|
154
|
-
|
155
|
-
logo_upload_credentials = get_logo_upload_credentials
|
156
|
-
|
157
|
-
filtered_logo_upload_credentials = logo_upload_credentials.select {|cred| cred.fields.logo_type == logo_type }.first
|
158
|
-
|
159
|
-
upload_logo_file(filepath: filepath, credentials: filtered_logo_upload_credentials)
|
160
|
-
|
161
|
-
finalize_logos(theme_id: theme_id, keys: [filtered_logo_upload_credentials.fields.key])
|
162
|
-
end
|
163
|
-
|
164
|
-
private
|
165
|
-
|
166
|
-
def get_logo_upload_credentials
|
167
|
-
request("/v1/meetings/themes/logos-upload-urls", response_class: ListResponse)
|
168
|
-
end
|
169
|
-
|
170
|
-
def upload_logo_file(filepath:, credentials:)
|
171
|
-
pn = Pathname.new(filepath)
|
172
|
-
|
173
|
-
params = format_s3_upload_credentials(credentials)
|
174
|
-
|
175
|
-
multipart_post_request(
|
176
|
-
nil,
|
177
|
-
filepath: filepath,
|
178
|
-
file_name: pn.basename,
|
179
|
-
mime_type: credentials.fields.content_type,
|
180
|
-
params: params,
|
181
|
-
override_uri: credentials.url,
|
182
|
-
no_auth: true
|
183
|
-
)
|
184
|
-
end
|
185
|
-
|
186
|
-
def finalize_logos(theme_id:, keys: [])
|
187
|
-
request(
|
188
|
-
"/v1/meetings/themes/" + theme_id + "/finalizeLogos",
|
189
|
-
params: {
|
190
|
-
keys: keys
|
191
|
-
},
|
192
|
-
type: Put
|
193
|
-
)
|
194
|
-
end
|
195
|
-
|
196
|
-
def format_s3_upload_credentials(credentials)
|
197
|
-
credentials_key_map = {
|
198
|
-
content_type: "Content-Type",
|
199
|
-
logo_type: "logoType",
|
200
|
-
x_amz_algorithm: "X-Amz-Algorithm",
|
201
|
-
x_amz_credential: "X-Amz-Credential",
|
202
|
-
x_amz_date: "X-Amz-Date",
|
203
|
-
x_amz_security_token: "X-Amz-Security-Token",
|
204
|
-
policy: "Policy",
|
205
|
-
x_amz_signature: "X-Amz-Signature"
|
206
|
-
}
|
207
|
-
|
208
|
-
params = credentials.fields.attributes
|
209
|
-
params.transform_keys do |k|
|
210
|
-
if credentials_key_map.keys.include?(k)
|
211
|
-
credentials_key_map[k]
|
212
|
-
else
|
213
|
-
k.to_s
|
214
|
-
end
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
data/lib/vonage/meetings.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Vonage
|
5
|
-
class Meetings < Namespace
|
6
|
-
extend T::Sig
|
7
|
-
|
8
|
-
sig { returns(T.nilable(Vonage::Meetings::Rooms)) }
|
9
|
-
def rooms
|
10
|
-
@rooms ||= Rooms.new(@config)
|
11
|
-
end
|
12
|
-
|
13
|
-
sig { returns(T.nilable(Vonage::Meetings::Recordings)) }
|
14
|
-
def recordings
|
15
|
-
@recordings ||= Recordings.new(@config)
|
16
|
-
end
|
17
|
-
|
18
|
-
sig { returns(T.nilable(Vonage::Meetings::Sessions)) }
|
19
|
-
def sessions
|
20
|
-
@sessions ||= Sessions.new(@config)
|
21
|
-
end
|
22
|
-
|
23
|
-
sig { returns(T.nilable(Vonage::Meetings::Themes)) }
|
24
|
-
def themes
|
25
|
-
@themes ||= Themes.new(@config)
|
26
|
-
end
|
27
|
-
|
28
|
-
sig { returns(T.nilable(Vonage::Meetings::Applications)) }
|
29
|
-
def applications
|
30
|
-
@applications ||= Applications.new(@config)
|
31
|
-
end
|
32
|
-
|
33
|
-
sig { returns(T.nilable(Vonage::Meetings::DialInNumbers)) }
|
34
|
-
def dial_in_numbers
|
35
|
-
@dial_in_numbers ||= DialInNumbers.new(@config)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Vonage
|
5
|
-
class NumberInsight2 < Namespace
|
6
|
-
extend T::Sig
|
7
|
-
|
8
|
-
self.authentication = Basic
|
9
|
-
|
10
|
-
self.request_body = JSON
|
11
|
-
|
12
|
-
# Make fraud check requests with a phone number by looking up fraud score and/or by checking sim swap status.
|
13
|
-
#
|
14
|
-
# @example
|
15
|
-
# response = client.number_insight_2.fraud_check(type: 'phone', phone: '447900000000', insights: ['fraud_score'])
|
16
|
-
#
|
17
|
-
# @param [required, String] :type The type of number to check.
|
18
|
-
# Accepted value is “phone” when a phone number is provided.
|
19
|
-
#
|
20
|
-
# @param [required, String] :phone A single phone number that you need insight about in the E.164 format.
|
21
|
-
#
|
22
|
-
# @param [required, Array] :insights An array of strings indicating the fraud check insights required for the number.
|
23
|
-
# Must be least one of: `fraud_score`, `sim_swap`
|
24
|
-
#
|
25
|
-
# @return [Response]
|
26
|
-
#
|
27
|
-
# @see https://developer.vonage.com/en/api/number-insight.v2#fraud_check
|
28
|
-
#
|
29
|
-
sig { params(type: String, phone: String, insights: T::Array[String]).returns(Vonage::Response) }
|
30
|
-
def fraud_check(type:, phone:, insights:)
|
31
|
-
raise ArgumentError.new("`insights` must not be an empty") if insights.empty?
|
32
|
-
|
33
|
-
request('/v2/ni', params: {type: type, phone: phone, insights: insights}, type: Post)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# typed: true
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Vonage
|
5
|
-
class ProactiveConnect::Events < Namespace
|
6
|
-
extend T::Sig
|
7
|
-
|
8
|
-
self.authentication = BearerToken
|
9
|
-
|
10
|
-
self.host = :vonage_host
|
11
|
-
|
12
|
-
# Find all events
|
13
|
-
#
|
14
|
-
# @example
|
15
|
-
# response = proactive_connect.events.list
|
16
|
-
#
|
17
|
-
# @param [optional, String] :page
|
18
|
-
# Page of results to jump to
|
19
|
-
#
|
20
|
-
# @param [optional, String] :page_size
|
21
|
-
# Number of results per page
|
22
|
-
#
|
23
|
-
# @param [optional, String] order
|
24
|
-
# Sort in either ascending (asc, the default) or descending (desc) order
|
25
|
-
#
|
26
|
-
# @param [optional, String] :run_id
|
27
|
-
# Run IDs to filter by, if not specified, returns events for any run id
|
28
|
-
#
|
29
|
-
# @param [optional, String] :type
|
30
|
-
# Event types to filter by
|
31
|
-
#
|
32
|
-
# @param [optional, String] action_id
|
33
|
-
# Action IDs to filter by.
|
34
|
-
#
|
35
|
-
# @param [optional, String] :invocation_id
|
36
|
-
# Invocation IDs to filter by
|
37
|
-
#
|
38
|
-
# @param [optional, String] :recipient_id
|
39
|
-
# Recipient IDs to filter by
|
40
|
-
#
|
41
|
-
# @param [optional, String] :run_item_id
|
42
|
-
# Run item IDs to filter by
|
43
|
-
#
|
44
|
-
# @param [optional, String] src_ctx
|
45
|
-
# The name of the segment / matcher the item / event to filter by (exact string)
|
46
|
-
#
|
47
|
-
# @param [optional, String] :src_type
|
48
|
-
# Source types to filter by
|
49
|
-
#
|
50
|
-
# @param [optional, String] :trace_id
|
51
|
-
# Trace IDs to filter events by
|
52
|
-
#
|
53
|
-
# @param [optional, String] date_start
|
54
|
-
# ISO-8601 formatted date for when to begin events filter
|
55
|
-
#
|
56
|
-
# @param [optional, String] :date_end
|
57
|
-
# ISO-8601 formatted date for when to end events filter
|
58
|
-
#
|
59
|
-
# @see https://developer.vonage.com/en/api/proactive-connect#eventsFindAll
|
60
|
-
#
|
61
|
-
def list(**params)
|
62
|
-
path = "/v0.1/bulk/events"
|
63
|
-
path += "?#{Params.encode(params)}" unless params.empty?
|
64
|
-
|
65
|
-
request(path, response_class: ListResponse)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,104 +0,0 @@
|
|
1
|
-
# typed: true
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Vonage
|
5
|
-
class ProactiveConnect::Item < Namespace
|
6
|
-
extend T::Sig
|
7
|
-
|
8
|
-
self.authentication = BearerToken
|
9
|
-
|
10
|
-
self.host = :vonage_host
|
11
|
-
|
12
|
-
self.request_body = JSON
|
13
|
-
|
14
|
-
# Create a list item
|
15
|
-
#
|
16
|
-
# @example
|
17
|
-
# response = proactive_connect.item.create(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865', data: {name: 'Joe Bloggs', email: 'joe@email.com'})
|
18
|
-
#
|
19
|
-
# @param [required, String] :list_id
|
20
|
-
# Unique identifier for the list
|
21
|
-
#
|
22
|
-
# @param [required, Hash] :data
|
23
|
-
# A hash of data containing the item's data attributes and values
|
24
|
-
#
|
25
|
-
# @see https://developer.vonage.com/en/api/proactive-connect#itemsCreate
|
26
|
-
#
|
27
|
-
def create(list_id:, data:)
|
28
|
-
raise ArgumentError.new(":data must be a Hash") unless data.is_a? Hash
|
29
|
-
request(
|
30
|
-
"/v0.1/bulk/lists/#{list_id}/items",
|
31
|
-
params: { data: data },
|
32
|
-
type: Post
|
33
|
-
)
|
34
|
-
end
|
35
|
-
|
36
|
-
# Get list item by id
|
37
|
-
#
|
38
|
-
# @example
|
39
|
-
# response = proactive_connect.item.find(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865', item_id: 'd97ebf20-e4de-4e50-921a-7bb4dceb373a')
|
40
|
-
#
|
41
|
-
# @param [required, String] :list_id
|
42
|
-
# Unique identifier for the list
|
43
|
-
#
|
44
|
-
# @param [required, String] :item_id
|
45
|
-
# Unique identifier for the item
|
46
|
-
#
|
47
|
-
# @see https://developer.vonage.com/en/api/proactive-connect#itemsGet
|
48
|
-
#
|
49
|
-
def find(list_id:, item_id:)
|
50
|
-
request("/v0.1/bulk/lists/#{list_id}/items/#{item_id}")
|
51
|
-
end
|
52
|
-
|
53
|
-
# Update list item
|
54
|
-
#
|
55
|
-
# @example
|
56
|
-
# response = proactive_connect.item.create(
|
57
|
-
# list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865',
|
58
|
-
# item_id: 'd97ebf20-e4de-4e50-921a-7bb4dceb373a',
|
59
|
-
# data: {name: 'Jane Bloggs', email: 'joe@email.com'}
|
60
|
-
# )
|
61
|
-
#
|
62
|
-
# @param [required, String] :list_id
|
63
|
-
# Unique identifier for the list
|
64
|
-
#
|
65
|
-
# @param [required, String] :item_id
|
66
|
-
# Unique identifier for the item
|
67
|
-
#
|
68
|
-
# @param [required, Hash] :data
|
69
|
-
# A hash of data containing the item's data attributes and values
|
70
|
-
# All attributes for the item must be passed, even ones for which the value is not changing.
|
71
|
-
# If an attribute is omitted, existing data for that attribute will be deleted.
|
72
|
-
#
|
73
|
-
# @see https://developer.vonage.com/en/api/proactive-connect#itemsUpdate
|
74
|
-
#
|
75
|
-
def update(list_id:, item_id:, data:)
|
76
|
-
raise ArgumentError.new(":data must be a Hash") unless data.is_a? Hash
|
77
|
-
request(
|
78
|
-
"/v0.1/bulk/lists/#{list_id}/items/#{item_id}",
|
79
|
-
params: { data: data },
|
80
|
-
type: Put
|
81
|
-
)
|
82
|
-
end
|
83
|
-
|
84
|
-
# Delete list item
|
85
|
-
#
|
86
|
-
# @example
|
87
|
-
# response = proactive_connect.item.delete(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865', item_id: 'd97ebf20-e4de-4e50-921a-7bb4dceb373a')
|
88
|
-
#
|
89
|
-
# @param [required, String] :list_id
|
90
|
-
# Unique identifier for the list
|
91
|
-
#
|
92
|
-
# @param [required, String] :item_id
|
93
|
-
# Unique identifier for the item
|
94
|
-
#
|
95
|
-
# @see https://developer.vonage.com/en/api/proactive-connect#itemsDelete
|
96
|
-
#
|
97
|
-
def delete(list_id:, item_id:)
|
98
|
-
request(
|
99
|
-
"/v0.1/bulk/lists/#{list_id}/items/#{item_id}",
|
100
|
-
type: Delete
|
101
|
-
)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# typed: true
|
2
|
-
|
3
|
-
class Vonage::ProactiveConnect::Items::FileResponse < Vonage::Response
|
4
|
-
DEFAULT_FILENAME = 'vonage-proactive-connect-list-items.csv'
|
5
|
-
|
6
|
-
attr_accessor :filename
|
7
|
-
|
8
|
-
def initialize(entity=nil, http_response=nil)
|
9
|
-
super
|
10
|
-
self.filename = initial_filename
|
11
|
-
end
|
12
|
-
|
13
|
-
def save(filepath:)
|
14
|
-
pn = Pathname.new(filepath)
|
15
|
-
raise ArgumentError, ':filepath not a directory' unless pn.directory?
|
16
|
-
raise ArgumentError, ':filepath not absolute' unless pn.absolute?
|
17
|
-
raise ArgumentError, ':filepath not writable' unless pn.writable?
|
18
|
-
|
19
|
-
File.open("#{pn.cleanpath}/#{filename}", 'w') {|f| f.write(http_response.body) }
|
20
|
-
end
|
21
|
-
|
22
|
-
def data
|
23
|
-
http_response ? http_response.body : nil
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def initial_filename
|
29
|
-
match_data = http_response['Content-Disposition'].match(/filename=(\"?)(.+)\1/)
|
30
|
-
match_data ? match_data[2] : DEFAULT_FILENAME
|
31
|
-
end
|
32
|
-
end
|
@@ -1,107 +0,0 @@
|
|
1
|
-
# typed: true
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Vonage
|
5
|
-
class ProactiveConnect::Items < Namespace
|
6
|
-
extend T::Sig
|
7
|
-
|
8
|
-
self.authentication = BearerToken
|
9
|
-
|
10
|
-
self.host = :vonage_host
|
11
|
-
|
12
|
-
# Find all list items
|
13
|
-
#
|
14
|
-
# @example
|
15
|
-
# response = proactive_connect.items.list(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865')
|
16
|
-
#
|
17
|
-
# @param [required, String] :list_id
|
18
|
-
# Unique identifier for the list
|
19
|
-
#
|
20
|
-
# @param [optional, String] :page
|
21
|
-
# Page of results to jump to
|
22
|
-
#
|
23
|
-
# @param [optional, String] :page_size
|
24
|
-
# Number of results per page
|
25
|
-
#
|
26
|
-
# @param [optional, String] order
|
27
|
-
# Sort in either ascending (asc, the default) or descending (desc) order
|
28
|
-
#
|
29
|
-
# @see https://developer.vonage.com/en/api/proactive-connect#itemsFindAll
|
30
|
-
#
|
31
|
-
def list(list_id:, **params)
|
32
|
-
path = "/v0.1/bulk/lists/#{list_id}/items"
|
33
|
-
path += "?#{Params.encode(params)}" unless params.empty?
|
34
|
-
|
35
|
-
request(path, response_class: ListResponse)
|
36
|
-
end
|
37
|
-
|
38
|
-
# Download list items as a CSV file format
|
39
|
-
#
|
40
|
-
# @example
|
41
|
-
# response = proactive_connect.items.download_csv(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865')
|
42
|
-
#
|
43
|
-
# @param [required, String] :list_id
|
44
|
-
# ID for the list to download
|
45
|
-
#
|
46
|
-
# @param [optional, String] order
|
47
|
-
# Sort in either ascending (asc, the default) or descending (desc) order
|
48
|
-
#
|
49
|
-
# @param [optional, String] :filename
|
50
|
-
# A name to set for the returned File object. If not set, the File object will use the actual filename (if available)
|
51
|
-
# or a default of `download.csv` if the actual filename is not available.
|
52
|
-
#
|
53
|
-
# @param [optional, String] :filepath
|
54
|
-
# A filepath to a directory where the file should be written.
|
55
|
-
# If not set, the file is not written, though the the file can be written at any time by calling `save` on the returned
|
56
|
-
# object and passing in `:filepath` as an argument to the `save` method, for example:
|
57
|
-
# response = proactive_connect.items.download_csv(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865')
|
58
|
-
# response.save('/files/downloads/')
|
59
|
-
# If set, the filepath must be:
|
60
|
-
# - An absolute path
|
61
|
-
# - For a valid directory
|
62
|
-
# - The directory must be writable
|
63
|
-
#
|
64
|
-
# @see https://developer.vonage.com/en/api/proactive-connect#itemsDownload
|
65
|
-
#
|
66
|
-
def download_csv(list_id:, order: 'asc', **params)
|
67
|
-
response = request("/v0.1/bulk/lists/#{list_id}/items/download?order=#{order}", response_class: FileResponse)
|
68
|
-
|
69
|
-
response.filename = params[:filename] if params[:filename]
|
70
|
-
response.save(filepath: params[:filepath]) if params[:filepath]
|
71
|
-
|
72
|
-
response
|
73
|
-
end
|
74
|
-
|
75
|
-
# Import list items from a CSV file
|
76
|
-
#
|
77
|
-
# @example
|
78
|
-
# response = proactive_connect.items.upload_csv(list_id: 'e546eebe-8e23-4e4d-bb7c-29d4700c9865', filepath: '/files/import.csv')
|
79
|
-
#
|
80
|
-
# @param [required, String] :list_id
|
81
|
-
# ID for the list to download
|
82
|
-
#
|
83
|
-
# @param [optional, String] order
|
84
|
-
# Sort in either ascending (asc, the default) or descending (desc) order
|
85
|
-
#
|
86
|
-
# @param [optional, String] :filename
|
87
|
-
# A name to set for the returned File object. If not set, the File object will use the actual filename (if available)
|
88
|
-
# or a default of `download.csv` if the actual filename is not available.
|
89
|
-
#
|
90
|
-
# @param [required, String] :filepath
|
91
|
-
# A filepath for the file to import. The file must be:
|
92
|
-
# - A valid file
|
93
|
-
# - Readable
|
94
|
-
# - Must have a `.csv` extension
|
95
|
-
#
|
96
|
-
# @see https://developer.vonage.com/en/api/proactive-connect#itemsImport
|
97
|
-
#
|
98
|
-
def upload_csv(list_id:, filepath:)
|
99
|
-
pn = Pathname.new(filepath)
|
100
|
-
raise ArgumentError, ':filepath not for a file' unless pn.file?
|
101
|
-
raise ArgumentError, 'file at :filepath not readable' unless pn.readable?
|
102
|
-
raise ArgumentError, 'file at :filepath not csv' unless pn.extname == '.csv'
|
103
|
-
|
104
|
-
multipart_post_request("/v0.1/bulk/lists/#{list_id}/items/import", filepath: filepath, file_name: pn.basename, mime_type: 'text/csv')
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|