twilio-ruby 5.25.2 → 5.25.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +11 -0
- data/README.md +2 -2
- data/lib/twilio-ruby/rest/authy.rb +8 -8
- data/lib/twilio-ruby/rest/authy/v1.rb +15 -15
- data/lib/twilio-ruby/rest/client.rb +7 -0
- data/lib/twilio-ruby/rest/conversations.rb +53 -0
- data/lib/twilio-ruby/rest/conversations/v1.rb +51 -0
- data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +471 -0
- data/lib/twilio-ruby/rest/conversations/v1/conversation/message.rb +416 -0
- data/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb +407 -0
- data/lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb +432 -0
- data/lib/twilio-ruby/rest/conversations/v1/webhook.rb +272 -0
- data/lib/twilio-ruby/rest/flex_api.rb +6 -6
- data/lib/twilio-ruby/rest/flex_api/v1.rb +7 -7
- data/lib/twilio-ruby/rest/messaging.rb +8 -8
- data/lib/twilio-ruby/rest/messaging/v1.rb +14 -14
- data/lib/twilio-ruby/rest/preview.rb +20 -20
- data/lib/twilio-ruby/rest/preview/marketplace.rb +13 -13
- data/lib/twilio-ruby/rest/preview/trusted_comms.rb +14 -14
- data/lib/twilio-ruby/rest/serverless/v1/service/build.rb +14 -0
- data/lib/twilio-ruby/rest/serverless/v1/service/environment.rb +30 -0
- data/lib/twilio-ruby/rest/serverless/v1/service/environment/log.rb +370 -0
- data/lib/twilio-ruby/rest/video.rb +9 -9
- data/lib/twilio-ruby/rest/video/v1.rb +16 -16
- data/lib/twilio-ruby/rest/wireless.rb +6 -6
- data/lib/twilio-ruby/rest/wireless/v1.rb +9 -8
- data/lib/twilio-ruby/rest/wireless/v1/rate_plan.rb +27 -18
- data/lib/twilio-ruby/twiml/voice_response.rb +161 -11
- data/lib/twilio-ruby/version.rb +1 -1
- data/spec/integration/conversations/v1/conversation/message_spec.rb +223 -0
- data/spec/integration/conversations/v1/conversation/participant_spec.rb +265 -0
- data/spec/integration/conversations/v1/conversation/webhook_spec.rb +286 -0
- data/spec/integration/conversations/v1/conversation_spec.rb +218 -0
- data/spec/integration/conversations/v1/webhook_spec.rb +88 -0
- data/spec/integration/serverless/v1/service/build_spec.rb +28 -0
- data/spec/integration/serverless/v1/service/environment/log_spec.rb +98 -0
- data/spec/integration/serverless/v1/service/environment_spec.rb +4 -2
- data/spec/integration/verify/v2/service/verification_spec.rb +36 -0
- data/spec/integration/wireless/v1/rate_plan_spec.rb +12 -12
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd77745a32efbf1a49af3c876422268d4f97ef2ffe20232d1017601a9794a0c0
|
4
|
+
data.tar.gz: 7d2dc0964c166398c12b1ab1022cc83ca5bd94418ae52a8a60a970c43b9f2dd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f6db888d496163430367b37eb030b8eba4c5e58e2186f2abd895a034c688f9872753a1ed62bdb063e64d1f1370b9bf0f8c8fbca49a9623b44f3cb229e4b1e75
|
7
|
+
data.tar.gz: df9c5bc3cb0f1caab8cb278625dc275cc3643f4f846ea7489eac804e656dadf085af2b6bc126bbefe61970fe7a5c2d5311f819def58857dbf0b1accc716814cc
|
data/CHANGES.md
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
twilio-ruby changelog
|
2
2
|
=====================
|
3
3
|
|
4
|
+
[2019-08-05] Version 5.25.3
|
5
|
+
----------------------------
|
6
|
+
**Preview**
|
7
|
+
- Added support for the header `Twilio-Sandbox-Mode` to mock all Voice dependencies
|
8
|
+
|
9
|
+
**Twiml**
|
10
|
+
- Add support for `<Siprec>` noun
|
11
|
+
- Add support for `<Stream>` noun
|
12
|
+
- Create verbs `<Start>` and `<Stop>`
|
13
|
+
|
14
|
+
|
4
15
|
[2019-07-24] Version 5.25.2
|
5
16
|
----------------------------
|
6
17
|
**Insights**
|
data/README.md
CHANGED
@@ -26,13 +26,13 @@ in-line code documentation here in the library.
|
|
26
26
|
To install using [Bundler][bundler] grab the latest stable version:
|
27
27
|
|
28
28
|
```ruby
|
29
|
-
gem 'twilio-ruby', '~> 5.25.
|
29
|
+
gem 'twilio-ruby', '~> 5.25.3'
|
30
30
|
```
|
31
31
|
|
32
32
|
To manually install `twilio-ruby` via [Rubygems][rubygems] simply gem install:
|
33
33
|
|
34
34
|
```bash
|
35
|
-
gem install twilio-ruby -v 5.25.
|
35
|
+
gem install twilio-ruby -v 5.25.3
|
36
36
|
```
|
37
37
|
|
38
38
|
To build and install the development branch yourself from the latest source:
|
@@ -28,6 +28,14 @@ module Twilio
|
|
28
28
|
@v1 ||= V1.new self
|
29
29
|
end
|
30
30
|
|
31
|
+
##
|
32
|
+
# @param [String] sid A 34 character string that uniquely identifies this Service.
|
33
|
+
# @return [Twilio::REST::Authy::V1::ServiceInstance] if sid was passed.
|
34
|
+
# @return [Twilio::REST::Authy::V1::ServiceList]
|
35
|
+
def services(sid=:unset)
|
36
|
+
self.v1.services(sid)
|
37
|
+
end
|
38
|
+
|
31
39
|
##
|
32
40
|
# @param [form.FormTypes] form_type The Type of this Form. One of `form-app-push`,
|
33
41
|
# `form-sms` or `form-totp`.
|
@@ -37,14 +45,6 @@ module Twilio
|
|
37
45
|
self.v1.forms(form_type)
|
38
46
|
end
|
39
47
|
|
40
|
-
##
|
41
|
-
# @param [String] sid A 34 character string that uniquely identifies this Service.
|
42
|
-
# @return [Twilio::REST::Authy::V1::ServiceInstance] if sid was passed.
|
43
|
-
# @return [Twilio::REST::Authy::V1::ServiceList]
|
44
|
-
def services(sid=:unset)
|
45
|
-
self.v1.services(sid)
|
46
|
-
end
|
47
|
-
|
48
48
|
##
|
49
49
|
# Provide a user friendly representation
|
50
50
|
def to_s
|
@@ -15,8 +15,22 @@ module Twilio
|
|
15
15
|
def initialize(domain)
|
16
16
|
super
|
17
17
|
@version = 'v1'
|
18
|
-
@forms = nil
|
19
18
|
@services = nil
|
19
|
+
@forms = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
##
|
23
|
+
# @param [String] sid A 34 character string that uniquely identifies this Service.
|
24
|
+
# @return [Twilio::REST::Authy::V1::ServiceContext] if sid was passed.
|
25
|
+
# @return [Twilio::REST::Authy::V1::ServiceList]
|
26
|
+
def services(sid=:unset)
|
27
|
+
if sid.nil?
|
28
|
+
raise ArgumentError, 'sid cannot be nil'
|
29
|
+
elsif sid == :unset
|
30
|
+
@services ||= ServiceList.new self
|
31
|
+
else
|
32
|
+
ServiceContext.new(self, sid)
|
33
|
+
end
|
20
34
|
end
|
21
35
|
|
22
36
|
##
|
@@ -34,20 +48,6 @@ module Twilio
|
|
34
48
|
end
|
35
49
|
end
|
36
50
|
|
37
|
-
##
|
38
|
-
# @param [String] sid A 34 character string that uniquely identifies this Service.
|
39
|
-
# @return [Twilio::REST::Authy::V1::ServiceContext] if sid was passed.
|
40
|
-
# @return [Twilio::REST::Authy::V1::ServiceList]
|
41
|
-
def services(sid=:unset)
|
42
|
-
if sid.nil?
|
43
|
-
raise ArgumentError, 'sid cannot be nil'
|
44
|
-
elsif sid == :unset
|
45
|
-
@services ||= ServiceList.new self
|
46
|
-
else
|
47
|
-
ServiceContext.new(self, sid)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
51
|
##
|
52
52
|
# Provide a user friendly representation
|
53
53
|
def to_s
|
@@ -30,6 +30,7 @@ module Twilio
|
|
30
30
|
@authy = nil
|
31
31
|
@autopilot = nil
|
32
32
|
@chat = nil
|
33
|
+
@conversations = nil
|
33
34
|
@fax = nil
|
34
35
|
@flex_api = nil
|
35
36
|
@insights = nil
|
@@ -130,6 +131,12 @@ module Twilio
|
|
130
131
|
@chat ||= Chat.new self
|
131
132
|
end
|
132
133
|
|
134
|
+
##
|
135
|
+
# Access the Conversations Twilio Domain
|
136
|
+
def conversations
|
137
|
+
@conversations ||= Conversations.new self
|
138
|
+
end
|
139
|
+
|
133
140
|
##
|
134
141
|
# Access the Fax Twilio Domain
|
135
142
|
def fax
|
@@ -0,0 +1,53 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
#
|
7
|
+
# frozen_string_literal: true
|
8
|
+
|
9
|
+
module Twilio
|
10
|
+
module REST
|
11
|
+
class Conversations < Domain
|
12
|
+
##
|
13
|
+
# Initialize the Conversations Domain
|
14
|
+
def initialize(twilio)
|
15
|
+
super
|
16
|
+
|
17
|
+
@base_url = 'https://conversations.twilio.com'
|
18
|
+
@host = 'conversations.twilio.com'
|
19
|
+
@port = 443
|
20
|
+
|
21
|
+
# Versions
|
22
|
+
@v1 = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
##
|
26
|
+
# Version v1 of conversations
|
27
|
+
def v1
|
28
|
+
@v1 ||= V1.new self
|
29
|
+
end
|
30
|
+
|
31
|
+
##
|
32
|
+
# @param [String] sid A 34 character string that uniquely identifies this
|
33
|
+
# resource.
|
34
|
+
# @return [Twilio::REST::Conversations::V1::ConversationInstance] if sid was passed.
|
35
|
+
# @return [Twilio::REST::Conversations::V1::ConversationList]
|
36
|
+
def conversations(sid=:unset)
|
37
|
+
self.v1.conversations(sid)
|
38
|
+
end
|
39
|
+
|
40
|
+
##
|
41
|
+
# @return [Twilio::REST::Conversations::V1::WebhookInstance]
|
42
|
+
def webhooks
|
43
|
+
self.v1.webhooks()
|
44
|
+
end
|
45
|
+
|
46
|
+
##
|
47
|
+
# Provide a user friendly representation
|
48
|
+
def to_s
|
49
|
+
'#<Twilio::REST::Conversations>'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
#
|
7
|
+
# frozen_string_literal: true
|
8
|
+
|
9
|
+
module Twilio
|
10
|
+
module REST
|
11
|
+
class Conversations
|
12
|
+
class V1 < Version
|
13
|
+
##
|
14
|
+
# Initialize the V1 version of Conversations
|
15
|
+
def initialize(domain)
|
16
|
+
super
|
17
|
+
@version = 'v1'
|
18
|
+
@conversations = nil
|
19
|
+
@webhooks = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
##
|
23
|
+
# @param [String] sid A 34 character string that uniquely identifies this
|
24
|
+
# resource.
|
25
|
+
# @return [Twilio::REST::Conversations::V1::ConversationContext] if sid was passed.
|
26
|
+
# @return [Twilio::REST::Conversations::V1::ConversationList]
|
27
|
+
def conversations(sid=:unset)
|
28
|
+
if sid.nil?
|
29
|
+
raise ArgumentError, 'sid cannot be nil'
|
30
|
+
elsif sid == :unset
|
31
|
+
@conversations ||= ConversationList.new self
|
32
|
+
else
|
33
|
+
ConversationContext.new(self, sid)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
##
|
38
|
+
# @return [Twilio::REST::Conversations::V1::WebhookContext]
|
39
|
+
def webhooks
|
40
|
+
@webhooks ||= WebhookContext.new self
|
41
|
+
end
|
42
|
+
|
43
|
+
##
|
44
|
+
# Provide a user friendly representation
|
45
|
+
def to_s
|
46
|
+
'<Twilio::REST::Conversations::V1>'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,471 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
#
|
7
|
+
# frozen_string_literal: true
|
8
|
+
|
9
|
+
module Twilio
|
10
|
+
module REST
|
11
|
+
class Conversations < Domain
|
12
|
+
class V1 < Version
|
13
|
+
##
|
14
|
+
# PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
|
15
|
+
class ConversationList < ListResource
|
16
|
+
##
|
17
|
+
# Initialize the ConversationList
|
18
|
+
# @param [Version] version Version that contains the resource
|
19
|
+
# @return [ConversationList] ConversationList
|
20
|
+
def initialize(version)
|
21
|
+
super(version)
|
22
|
+
|
23
|
+
# Path Solution
|
24
|
+
@solution = {}
|
25
|
+
@uri = "/Conversations"
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Retrieve a single page of ConversationInstance records from the API.
|
30
|
+
# Request is executed immediately.
|
31
|
+
# @param [String] friendly_name The human-readable name of this conversation,
|
32
|
+
# limited to 256 characters. Optional.
|
33
|
+
# @param [Time] date_created The date that this resource was created.
|
34
|
+
# @param [Time] date_updated The date that this resource was last updated.
|
35
|
+
# @param [String] messaging_service_sid The unique id of the [SMS
|
36
|
+
# Service](https://www.twilio.com/docs/sms/services/api) this conversation belongs
|
37
|
+
# to.
|
38
|
+
# @return [ConversationInstance] Newly created ConversationInstance
|
39
|
+
def create(friendly_name: :unset, date_created: :unset, date_updated: :unset, messaging_service_sid: :unset)
|
40
|
+
data = Twilio::Values.of({
|
41
|
+
'FriendlyName' => friendly_name,
|
42
|
+
'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
|
43
|
+
'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
|
44
|
+
'MessagingServiceSid' => messaging_service_sid,
|
45
|
+
})
|
46
|
+
|
47
|
+
payload = @version.create(
|
48
|
+
'POST',
|
49
|
+
@uri,
|
50
|
+
data: data
|
51
|
+
)
|
52
|
+
|
53
|
+
ConversationInstance.new(@version, payload, )
|
54
|
+
end
|
55
|
+
|
56
|
+
##
|
57
|
+
# Lists ConversationInstance records from the API as a list.
|
58
|
+
# Unlike stream(), this operation is eager and will load `limit` records into
|
59
|
+
# memory before returning.
|
60
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
61
|
+
# guarantees to never return more than limit. Default is no limit
|
62
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
63
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
64
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
65
|
+
# efficient page size, i.e. min(limit, 1000)
|
66
|
+
# @return [Array] Array of up to limit results
|
67
|
+
def list(limit: nil, page_size: nil)
|
68
|
+
self.stream(limit: limit, page_size: page_size).entries
|
69
|
+
end
|
70
|
+
|
71
|
+
##
|
72
|
+
# Streams ConversationInstance records from the API as an Enumerable.
|
73
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
74
|
+
# is reached.
|
75
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
76
|
+
# guarantees to never return more than limit. Default is no limit.
|
77
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
78
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
79
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
80
|
+
# efficient page size, i.e. min(limit, 1000)
|
81
|
+
# @return [Enumerable] Enumerable that will yield up to limit results
|
82
|
+
def stream(limit: nil, page_size: nil)
|
83
|
+
limits = @version.read_limits(limit, page_size)
|
84
|
+
|
85
|
+
page = self.page(page_size: limits[:page_size], )
|
86
|
+
|
87
|
+
@version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
|
88
|
+
end
|
89
|
+
|
90
|
+
##
|
91
|
+
# When passed a block, yields ConversationInstance records from the API.
|
92
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
93
|
+
# is reached.
|
94
|
+
def each
|
95
|
+
limits = @version.read_limits
|
96
|
+
|
97
|
+
page = self.page(page_size: limits[:page_size], )
|
98
|
+
|
99
|
+
@version.stream(page,
|
100
|
+
limit: limits[:limit],
|
101
|
+
page_limit: limits[:page_limit]).each {|x| yield x}
|
102
|
+
end
|
103
|
+
|
104
|
+
##
|
105
|
+
# Retrieve a single page of ConversationInstance records from the API.
|
106
|
+
# Request is executed immediately.
|
107
|
+
# @param [String] page_token PageToken provided by the API
|
108
|
+
# @param [Integer] page_number Page Number, this value is simply for client state
|
109
|
+
# @param [Integer] page_size Number of records to return, defaults to 50
|
110
|
+
# @return [Page] Page of ConversationInstance
|
111
|
+
def page(page_token: :unset, page_number: :unset, page_size: :unset)
|
112
|
+
params = Twilio::Values.of({
|
113
|
+
'PageToken' => page_token,
|
114
|
+
'Page' => page_number,
|
115
|
+
'PageSize' => page_size,
|
116
|
+
})
|
117
|
+
response = @version.page(
|
118
|
+
'GET',
|
119
|
+
@uri,
|
120
|
+
params
|
121
|
+
)
|
122
|
+
ConversationPage.new(@version, response, @solution)
|
123
|
+
end
|
124
|
+
|
125
|
+
##
|
126
|
+
# Retrieve a single page of ConversationInstance records from the API.
|
127
|
+
# Request is executed immediately.
|
128
|
+
# @param [String] target_url API-generated URL for the requested results page
|
129
|
+
# @return [Page] Page of ConversationInstance
|
130
|
+
def get_page(target_url)
|
131
|
+
response = @version.domain.request(
|
132
|
+
'GET',
|
133
|
+
target_url
|
134
|
+
)
|
135
|
+
ConversationPage.new(@version, response, @solution)
|
136
|
+
end
|
137
|
+
|
138
|
+
##
|
139
|
+
# Provide a user friendly representation
|
140
|
+
def to_s
|
141
|
+
'#<Twilio.Conversations.V1.ConversationList>'
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
##
|
146
|
+
# PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
|
147
|
+
class ConversationPage < Page
|
148
|
+
##
|
149
|
+
# Initialize the ConversationPage
|
150
|
+
# @param [Version] version Version that contains the resource
|
151
|
+
# @param [Response] response Response from the API
|
152
|
+
# @param [Hash] solution Path solution for the resource
|
153
|
+
# @return [ConversationPage] ConversationPage
|
154
|
+
def initialize(version, response, solution)
|
155
|
+
super(version, response)
|
156
|
+
|
157
|
+
# Path Solution
|
158
|
+
@solution = solution
|
159
|
+
end
|
160
|
+
|
161
|
+
##
|
162
|
+
# Build an instance of ConversationInstance
|
163
|
+
# @param [Hash] payload Payload response from the API
|
164
|
+
# @return [ConversationInstance] ConversationInstance
|
165
|
+
def get_instance(payload)
|
166
|
+
ConversationInstance.new(@version, payload, )
|
167
|
+
end
|
168
|
+
|
169
|
+
##
|
170
|
+
# Provide a user friendly representation
|
171
|
+
def to_s
|
172
|
+
'<Twilio.Conversations.V1.ConversationPage>'
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
##
|
177
|
+
# PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
|
178
|
+
class ConversationContext < InstanceContext
|
179
|
+
##
|
180
|
+
# Initialize the ConversationContext
|
181
|
+
# @param [Version] version Version that contains the resource
|
182
|
+
# @param [String] sid A 34 character string that uniquely identifies this
|
183
|
+
# resource.
|
184
|
+
# @return [ConversationContext] ConversationContext
|
185
|
+
def initialize(version, sid)
|
186
|
+
super(version)
|
187
|
+
|
188
|
+
# Path Solution
|
189
|
+
@solution = {sid: sid, }
|
190
|
+
@uri = "/Conversations/#{@solution[:sid]}"
|
191
|
+
|
192
|
+
# Dependents
|
193
|
+
@participants = nil
|
194
|
+
@messages = nil
|
195
|
+
@webhooks = nil
|
196
|
+
end
|
197
|
+
|
198
|
+
##
|
199
|
+
# Update the ConversationInstance
|
200
|
+
# @param [String] friendly_name The human-readable name of this conversation,
|
201
|
+
# limited to 256 characters. Optional.
|
202
|
+
# @param [Time] date_created The date that this resource was created.
|
203
|
+
# @param [Time] date_updated The date that this resource was last updated.
|
204
|
+
# @return [ConversationInstance] Updated ConversationInstance
|
205
|
+
def update(friendly_name: :unset, date_created: :unset, date_updated: :unset)
|
206
|
+
data = Twilio::Values.of({
|
207
|
+
'FriendlyName' => friendly_name,
|
208
|
+
'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
|
209
|
+
'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
|
210
|
+
})
|
211
|
+
|
212
|
+
payload = @version.update(
|
213
|
+
'POST',
|
214
|
+
@uri,
|
215
|
+
data: data,
|
216
|
+
)
|
217
|
+
|
218
|
+
ConversationInstance.new(@version, payload, sid: @solution[:sid], )
|
219
|
+
end
|
220
|
+
|
221
|
+
##
|
222
|
+
# Deletes the ConversationInstance
|
223
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
224
|
+
def delete
|
225
|
+
@version.delete('delete', @uri)
|
226
|
+
end
|
227
|
+
|
228
|
+
##
|
229
|
+
# Fetch a ConversationInstance
|
230
|
+
# @return [ConversationInstance] Fetched ConversationInstance
|
231
|
+
def fetch
|
232
|
+
params = Twilio::Values.of({})
|
233
|
+
|
234
|
+
payload = @version.fetch(
|
235
|
+
'GET',
|
236
|
+
@uri,
|
237
|
+
params,
|
238
|
+
)
|
239
|
+
|
240
|
+
ConversationInstance.new(@version, payload, sid: @solution[:sid], )
|
241
|
+
end
|
242
|
+
|
243
|
+
##
|
244
|
+
# Access the participants
|
245
|
+
# @return [ParticipantList]
|
246
|
+
# @return [ParticipantContext] if sid was passed.
|
247
|
+
def participants(sid=:unset)
|
248
|
+
raise ArgumentError, 'sid cannot be nil' if sid.nil?
|
249
|
+
|
250
|
+
if sid != :unset
|
251
|
+
return ParticipantContext.new(@version, @solution[:sid], sid, )
|
252
|
+
end
|
253
|
+
|
254
|
+
unless @participants
|
255
|
+
@participants = ParticipantList.new(@version, conversation_sid: @solution[:sid], )
|
256
|
+
end
|
257
|
+
|
258
|
+
@participants
|
259
|
+
end
|
260
|
+
|
261
|
+
##
|
262
|
+
# Access the messages
|
263
|
+
# @return [MessageList]
|
264
|
+
# @return [MessageContext] if sid was passed.
|
265
|
+
def messages(sid=:unset)
|
266
|
+
raise ArgumentError, 'sid cannot be nil' if sid.nil?
|
267
|
+
|
268
|
+
if sid != :unset
|
269
|
+
return MessageContext.new(@version, @solution[:sid], sid, )
|
270
|
+
end
|
271
|
+
|
272
|
+
unless @messages
|
273
|
+
@messages = MessageList.new(@version, conversation_sid: @solution[:sid], )
|
274
|
+
end
|
275
|
+
|
276
|
+
@messages
|
277
|
+
end
|
278
|
+
|
279
|
+
##
|
280
|
+
# Access the webhooks
|
281
|
+
# @return [WebhookList]
|
282
|
+
# @return [WebhookContext] if sid was passed.
|
283
|
+
def webhooks(sid=:unset)
|
284
|
+
raise ArgumentError, 'sid cannot be nil' if sid.nil?
|
285
|
+
|
286
|
+
if sid != :unset
|
287
|
+
return WebhookContext.new(@version, @solution[:sid], sid, )
|
288
|
+
end
|
289
|
+
|
290
|
+
unless @webhooks
|
291
|
+
@webhooks = WebhookList.new(@version, conversation_sid: @solution[:sid], )
|
292
|
+
end
|
293
|
+
|
294
|
+
@webhooks
|
295
|
+
end
|
296
|
+
|
297
|
+
##
|
298
|
+
# Provide a user friendly representation
|
299
|
+
def to_s
|
300
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
301
|
+
"#<Twilio.Conversations.V1.ConversationContext #{context}>"
|
302
|
+
end
|
303
|
+
|
304
|
+
##
|
305
|
+
# Provide a detailed, user friendly representation
|
306
|
+
def inspect
|
307
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
308
|
+
"#<Twilio.Conversations.V1.ConversationContext #{context}>"
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
##
|
313
|
+
# PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
|
314
|
+
class ConversationInstance < InstanceResource
|
315
|
+
##
|
316
|
+
# Initialize the ConversationInstance
|
317
|
+
# @param [Version] version Version that contains the resource
|
318
|
+
# @param [Hash] payload payload that contains response from Twilio
|
319
|
+
# @param [String] sid A 34 character string that uniquely identifies this
|
320
|
+
# resource.
|
321
|
+
# @return [ConversationInstance] ConversationInstance
|
322
|
+
def initialize(version, payload, sid: nil)
|
323
|
+
super(version)
|
324
|
+
|
325
|
+
# Marshaled Properties
|
326
|
+
@properties = {
|
327
|
+
'account_sid' => payload['account_sid'],
|
328
|
+
'chat_service_sid' => payload['chat_service_sid'],
|
329
|
+
'messaging_service_sid' => payload['messaging_service_sid'],
|
330
|
+
'sid' => payload['sid'],
|
331
|
+
'friendly_name' => payload['friendly_name'],
|
332
|
+
'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
|
333
|
+
'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
|
334
|
+
'url' => payload['url'],
|
335
|
+
'links' => payload['links'],
|
336
|
+
}
|
337
|
+
|
338
|
+
# Context
|
339
|
+
@instance_context = nil
|
340
|
+
@params = {'sid' => sid || @properties['sid'], }
|
341
|
+
end
|
342
|
+
|
343
|
+
##
|
344
|
+
# Generate an instance context for the instance, the context is capable of
|
345
|
+
# performing various actions. All instance actions are proxied to the context
|
346
|
+
# @return [ConversationContext] ConversationContext for this ConversationInstance
|
347
|
+
def context
|
348
|
+
unless @instance_context
|
349
|
+
@instance_context = ConversationContext.new(@version, @params['sid'], )
|
350
|
+
end
|
351
|
+
@instance_context
|
352
|
+
end
|
353
|
+
|
354
|
+
##
|
355
|
+
# @return [String] The unique id of the Account responsible for this conversation.
|
356
|
+
def account_sid
|
357
|
+
@properties['account_sid']
|
358
|
+
end
|
359
|
+
|
360
|
+
##
|
361
|
+
# @return [String] The unique id of the Chat Service this conversation belongs to.
|
362
|
+
def chat_service_sid
|
363
|
+
@properties['chat_service_sid']
|
364
|
+
end
|
365
|
+
|
366
|
+
##
|
367
|
+
# @return [String] The unique id of the SMS Service this conversation belongs to.
|
368
|
+
def messaging_service_sid
|
369
|
+
@properties['messaging_service_sid']
|
370
|
+
end
|
371
|
+
|
372
|
+
##
|
373
|
+
# @return [String] A 34 character string that uniquely identifies this resource.
|
374
|
+
def sid
|
375
|
+
@properties['sid']
|
376
|
+
end
|
377
|
+
|
378
|
+
##
|
379
|
+
# @return [String] The human-readable name of this conversation.
|
380
|
+
def friendly_name
|
381
|
+
@properties['friendly_name']
|
382
|
+
end
|
383
|
+
|
384
|
+
##
|
385
|
+
# @return [Time] The date that this resource was created.
|
386
|
+
def date_created
|
387
|
+
@properties['date_created']
|
388
|
+
end
|
389
|
+
|
390
|
+
##
|
391
|
+
# @return [Time] The date that this resource was last updated.
|
392
|
+
def date_updated
|
393
|
+
@properties['date_updated']
|
394
|
+
end
|
395
|
+
|
396
|
+
##
|
397
|
+
# @return [String] An absolute URL for this conversation.
|
398
|
+
def url
|
399
|
+
@properties['url']
|
400
|
+
end
|
401
|
+
|
402
|
+
##
|
403
|
+
# @return [String] Absolute URLs to access the Participants of this Conversation.
|
404
|
+
def links
|
405
|
+
@properties['links']
|
406
|
+
end
|
407
|
+
|
408
|
+
##
|
409
|
+
# Update the ConversationInstance
|
410
|
+
# @param [String] friendly_name The human-readable name of this conversation,
|
411
|
+
# limited to 256 characters. Optional.
|
412
|
+
# @param [Time] date_created The date that this resource was created.
|
413
|
+
# @param [Time] date_updated The date that this resource was last updated.
|
414
|
+
# @return [ConversationInstance] Updated ConversationInstance
|
415
|
+
def update(friendly_name: :unset, date_created: :unset, date_updated: :unset)
|
416
|
+
context.update(friendly_name: friendly_name, date_created: date_created, date_updated: date_updated, )
|
417
|
+
end
|
418
|
+
|
419
|
+
##
|
420
|
+
# Deletes the ConversationInstance
|
421
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
422
|
+
def delete
|
423
|
+
context.delete
|
424
|
+
end
|
425
|
+
|
426
|
+
##
|
427
|
+
# Fetch a ConversationInstance
|
428
|
+
# @return [ConversationInstance] Fetched ConversationInstance
|
429
|
+
def fetch
|
430
|
+
context.fetch
|
431
|
+
end
|
432
|
+
|
433
|
+
##
|
434
|
+
# Access the participants
|
435
|
+
# @return [participants] participants
|
436
|
+
def participants
|
437
|
+
context.participants
|
438
|
+
end
|
439
|
+
|
440
|
+
##
|
441
|
+
# Access the messages
|
442
|
+
# @return [messages] messages
|
443
|
+
def messages
|
444
|
+
context.messages
|
445
|
+
end
|
446
|
+
|
447
|
+
##
|
448
|
+
# Access the webhooks
|
449
|
+
# @return [webhooks] webhooks
|
450
|
+
def webhooks
|
451
|
+
context.webhooks
|
452
|
+
end
|
453
|
+
|
454
|
+
##
|
455
|
+
# Provide a user friendly representation
|
456
|
+
def to_s
|
457
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
458
|
+
"<Twilio.Conversations.V1.ConversationInstance #{values}>"
|
459
|
+
end
|
460
|
+
|
461
|
+
##
|
462
|
+
# Provide a detailed, user friendly representation
|
463
|
+
def inspect
|
464
|
+
values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
|
465
|
+
"<Twilio.Conversations.V1.ConversationInstance #{values}>"
|
466
|
+
end
|
467
|
+
end
|
468
|
+
end
|
469
|
+
end
|
470
|
+
end
|
471
|
+
end
|