Class: Ubiquity::Envoi::API::Client
- Inherits:
-
Object
- Object
- Ubiquity::Envoi::API::Client
show all
- Defined in:
- lib/ubiquity/envoi/api/client.rb,
lib/ubiquity/envoi/api/client/http_client.rb,
lib/ubiquity/envoi/api/client/requests/base_request.rb
Defined Under Namespace
Modules: Requests
Classes: HTTPClient, Paginator
Instance Attribute Summary collapse
-
#content(args = { }, options = { }) ⇒ Object
############################################################################################################## #.
-
#content_create(args = { }, options = { }) ⇒ Object
-
#content_details(args = { }, options = { }) ⇒ Object
-
#content_field_details(args = { }, options = { }) ⇒ Object
-
#content_fieldset_details(args = { }, options = { }) ⇒ Object
-
#content_fieldsets(args = { }, options = { }) ⇒ Object
-
#content_type_details(args = { }, options = { }) ⇒ Object
-
#content_types(args = { }, options = { }) ⇒ Object
(also: #content_types_get)
-
#file_get(args = { }, options = { }) ⇒ Object
-
#media_file_add_file(args = { }, options = { }) ⇒ Object
(also: #media_file_file_add)
-
#media_file_create(args = { }, options = { }) ⇒ Object
-
#media_file_delete(args = { }, options = { }) ⇒ Object
-
#media_file_files_get(args = { }, options = { }) ⇒ Object
-
#media_file_get(args = { }, options = { }) ⇒ Object
-
#media_file_secured_get(args = { }, options = { }) ⇒ Object
-
#media_file_transcode(args = { }, options = { }) ⇒ Object
-
#media_file_transcode_parameters_get(args = { }, options = { }) ⇒ Object
-
#media_file_transcoders_get(args = { }, options = { }) ⇒ Object
-
#media_file_update(args = { }, options = { }) ⇒ Object
-
#media_files_detailed_get(args = { }, options = { }) ⇒ Object
-
#media_files_get(args = { }, options = { }) ⇒ Object
-
#project_get(args = { }, options = { }) ⇒ Object
-
#projects_get(args = { }, options = { }) ⇒ Object
-
#storages_get(args = { }, options = { }) ⇒ Object
-
#user_create(args = { }, options = { }) ⇒ Object
-
#who ⇒ Object
Instance Method Summary
collapse
Constructor Details
#initialize(args = { }) ⇒ Client
Returns a new instance of Client.
14
15
16
17
|
# File 'lib/ubiquity/envoi/api/client.rb', line 14
def initialize(args = { })
@http_client = HTTPClient.new(args)
@logger = http_client.logger
end
|
Instance Attribute Details
#http_client ⇒ Object
Returns the value of attribute http_client.
12
13
14
|
# File 'lib/ubiquity/envoi/api/client.rb', line 12
def http_client
@http_client
end
|
#logger ⇒ Object
Returns the value of attribute logger.
12
13
14
|
# File 'lib/ubiquity/envoi/api/client.rb', line 12
def logger
@logger
end
|
#request ⇒ Object
Returns the value of attribute request.
12
13
14
|
# File 'lib/ubiquity/envoi/api/client.rb', line 12
def request
@request
end
|
#response ⇒ Object
Returns the value of attribute response.
12
13
14
|
# File 'lib/ubiquity/envoi/api/client.rb', line 12
def response
@response
end
|
Instance Method Details
#content(args = { }, options = { }) ⇒ Object
############################################################################################################## #
73
74
75
|
# File 'lib/ubiquity/envoi/api/client.rb', line 73
def content(args = { }, options = { })
http :get, 'content'
end
|
#content_create(args = { }, options = { }) ⇒ Object
77
78
79
|
# File 'lib/ubiquity/envoi/api/client.rb', line 77
def content_create(args = { }, options = { })
end
|
#content_details(args = { }, options = { }) ⇒ Object
81
82
83
|
# File 'lib/ubiquity/envoi/api/client.rb', line 81
def content_details(args = { }, options = { })
http :get, "content/#{args[:id]}"
end
|
#content_field_details(args = { }, options = { }) ⇒ Object
85
86
87
|
# File 'lib/ubiquity/envoi/api/client.rb', line 85
def content_field_details(args = { }, options = { })
http :get, "content-field/#{args[:id]}"
end
|
#content_fieldset_details(args = { }, options = { }) ⇒ Object
89
90
91
|
# File 'lib/ubiquity/envoi/api/client.rb', line 89
def content_fieldset_details(args = { }, options = { })
http :get, "content-fieldset/#{args[:id]}"
end
|
#content_fieldsets(args = { }, options = { }) ⇒ Object
97
98
99
|
# File 'lib/ubiquity/envoi/api/client.rb', line 97
def content_fieldsets(args = { }, options = { })
http :get, 'content-fieldset'
end
|
#content_type_details(args = { }, options = { }) ⇒ Object
93
94
95
|
# File 'lib/ubiquity/envoi/api/client.rb', line 93
def content_type_details(args = { }, options = { })
http :get, "content-type/#{args[:id]}"
end
|
#content_types(args = { }, options = { }) ⇒ Object
Also known as:
content_types_get
101
102
103
|
# File 'lib/ubiquity/envoi/api/client.rb', line 101
def content_types(args = { }, options = { })
http :get, 'content-type'
end
|
#file_get(args = { }, options = { }) ⇒ Object
106
107
108
109
110
|
# File 'lib/ubiquity/envoi/api/client.rb', line 106
def file_get(args = { }, options = { })
id = args[:id]
http(:get, "file/#{id}")
end
|
#http(method, *args) ⇒ Object
63
64
65
66
67
68
|
# File 'lib/ubiquity/envoi/api/client.rb', line 63
def http(method, *args)
@request = nil
@response = http_client.send(method, *args)
@request = http_client.request
@response
end
|
134
135
136
|
# File 'lib/ubiquity/envoi/api/client.rb', line 134
def media_file_add_file(args = { }, options = { })
process_request_using_class(Requests::MediaFileAddFile, args, options)
end
|
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/ubiquity/envoi/api/client.rb', line 112
def media_file_create(args = { }, options = { })
process_request_using_class(Requests::MediaFileCreate, args, options)
end
|
139
140
141
142
143
|
# File 'lib/ubiquity/envoi/api/client.rb', line 139
def media_file_delete(args = { }, options = { })
id = args[:id]
http(:delete, "media-files/media-file/#{id}")
end
|
151
152
153
154
155
|
# File 'lib/ubiquity/envoi/api/client.rb', line 151
def media_file_files_get(args = { }, options = { })
id = args[:id] || args[:media_file_id]
http(:get, "media-files/media-file/#{id}/files")
end
|
145
146
147
148
149
|
# File 'lib/ubiquity/envoi/api/client.rb', line 145
def media_file_get(args = { }, options = { })
id = args[:id] || args[:media_file_id]
http(:get, "media-files/media-file/#{id}")
end
|
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
# File 'lib/ubiquity/envoi/api/client.rb', line 157
def media_file_secured_get(args = { }, options = { })
_request = Requests::BaseRequest.new(
args,
{
:http_path => 'media-files/media-file/#{path_arguments[:media_file_id]}/secure',
:http_method => :post,
:parameters => [
{ :name => :media_file_id, :aliases => [ :id ], :send_in => :path },
{ :name => :email, :send_in => :body },
]
}
)
process_request(_request, options)
end
|
181
182
183
184
185
186
187
|
# File 'lib/ubiquity/envoi/api/client.rb', line 181
def media_file_transcode(args = { }, options = { })
media_file_id = args[:media_file_id]
transcoder_id = args[:transcoder_id]
transcoder_args = args[:transcoder_args] || {}
http(:post, "media-files/media-file/#{media_file_id}/action/transcode/#{transcoder_id}", transcoder_args)
end
|
189
190
191
192
193
194
|
# File 'lib/ubiquity/envoi/api/client.rb', line 189
def media_file_transcode_parameters_get(args = { }, options = { })
media_file_id = args[:media_file_id]
transcoder_id = args[:transcoder_id]
http(:get, "media-files/media-file/#{media_file_id}/action/transcode/#{transcoder_id}")
end
|
196
197
198
199
200
|
# File 'lib/ubiquity/envoi/api/client.rb', line 196
def media_file_transcoders_get(args = { }, options = { })
media_file_id = args[:media_file_id] || args[:id]
http(:get, "media-files/media-file/#{media_file_id}/action/transcode")
end
|
202
203
204
|
# File 'lib/ubiquity/envoi/api/client.rb', line 202
def media_file_update(args = { }, options = { })
process_request_using_class(Requests::MediaFileUpdate, args, options)
end
|
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
# File 'lib/ubiquity/envoi/api/client.rb', line 222
def media_files_detailed_get(args = { }, options = { })
_request = Requests::BaseRequest.new(
args,
{
:http_path => 'media-files/media-file-detailed',
:parameters => [
{ :name => :_perPage, :aliases => [ :perPage ], :default_value => '200' },
{ :name => :_page, :alises => [ :page ], :default_value => '1' }
]
}
)
process_request(_request, options)
end
|
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
# File 'lib/ubiquity/envoi/api/client.rb', line 206
def media_files_get(args = { }, options = { })
_request = Requests::BaseRequest.new(
args,
{
:http_path => 'media-files/media-file',
:parameters => [
{ :name => :_perPage, :default_value => '200' },
{ :name => :_page, :default_value => '1' }
]
}
)
process_request(_request, options)
end
|
#paginator ⇒ Object
51
52
53
|
# File 'lib/ubiquity/envoi/api/client.rb', line 51
def paginator
@paginator ||= Paginator.new(self, { :logger => logger }) if @response
end
|
#process_request(request, options = nil) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/ubiquity/envoi/api/client.rb', line 19
def process_request(request, options = nil)
@paginator = nil
@response = nil
@request = request
logger.warn { "Request is Missing Required Arguments: #{request.missing_required_arguments.inspect}" } unless request.missing_required_arguments.empty?
if ([:all, 'all'].include?(request.arguments[:_page]))
request.arguments[:_page] = 1
include_remaining_pages = true
else
include_remaining_pages = false
end
request.client = self unless request.client
options ||= request.options
return (options.fetch(:return_request, true) ? request : nil) unless options.fetch(:execute_request, true)
@response = request.execute
if request.respond_to?(:success?) && !request.success?
raise "Request failed. #{request.response.code} #{response.body}"
end
if include_remaining_pages
return paginator.include_remaining_pages
end
@response
end
|
#process_request_using_class(request_class, args, options = { }) ⇒ Object
55
56
57
58
59
|
# File 'lib/ubiquity/envoi/api/client.rb', line 55
def process_request_using_class(request_class, args, options = { })
@response = nil
@request = request_class.new(args, options.merge(:client => self))
process_request(@request, options)
end
|
#project_get(args = { }, options = { }) ⇒ Object
238
239
240
241
242
243
244
245
246
247
248
249
250
|
# File 'lib/ubiquity/envoi/api/client.rb', line 238
def project_get(args = { }, options = { })
_request = Requests::BaseRequest.new(
args,
{
:http_path => 'production/project/#{path_arguments[:project_id]}',
:parameters => [
{ :name => :project_id, :aliases => [ :id ], :send_in => :path }
]
}
)
process_request(_request, options)
end
|
#projects_get(args = { }, options = { }) ⇒ Object
252
253
254
255
256
257
258
259
260
261
262
263
264
|
# File 'lib/ubiquity/envoi/api/client.rb', line 252
def projects_get(args = { }, options = { })
_request = Requests::BaseRequest.new(
args,
{
:http_path => 'production/project',
:parameters => [
]
}
)
process_request(_request, options)
end
|
#storages_get(args = { }, options = { }) ⇒ Object
266
267
268
|
# File 'lib/ubiquity/envoi/api/client.rb', line 266
def storages_get(args = { }, options = { })
http(:get, 'media-files/storage')
end
|
#user_create(args = { }, options = { }) ⇒ Object
270
271
272
|
# File 'lib/ubiquity/envoi/api/client.rb', line 270
def user_create(args = { }, options = { })
end
|
#who ⇒ Object
274
275
276
|
# File 'lib/ubiquity/envoi/api/client.rb', line 274
def who
http :get, 'who'
end
|