Ziggeo 1.01 → 1.2

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 CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YjQxNTcwN2EyMjIyZTYxMjUxMTAwYzZmZDMxNjZiMTc4ZDkwZTRmNw==
5
- data.tar.gz: !binary |-
6
- NDRlYjVhNjJkZWI1ZjI3NmNlOThmNzExZDVkM2I1M2UyMTc1NDliNQ==
2
+ SHA1:
3
+ metadata.gz: 612ed7455de95c4d5dda5f4aacf16185c77b8ce9
4
+ data.tar.gz: 97f59156819e6ee4266c26a578abe4d3f6ccc601
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- YzNhMGJmNDllN2E2NWYyNjk5NDZlMTM0ZGE2YjIwNWI4YWMwYTU4MmU0Y2Q0
10
- ZGYyNDY5ZDJlMzY2Njk4MGVmNTllOTMxYTJhZTUzNzkxZDM2ZGNiZTYwZDli
11
- ZTk4NjZiMWNhZmFmYmRhNjAyYmExMWViMjU3ZDRiNDVmODU4ZTg=
12
- data.tar.gz: !binary |-
13
- YWY1MjkyMjVmYmRmMzkwOWY0NjkyNTIwNjdlN2FkNDNkNzcwMmQ5NDdhNjY2
14
- NzA0M2MyYjk0YmE4NTA3ZmUzMTE0ZDY5YzA0YTMzYjkwY2UzNThlMTgwYzU0
15
- ODlhM2ExNDM5NTYxMmQ0NTZkNmIzODlmNDY5OTdiOTEyY2I0ODk=
6
+ metadata.gz: ab12a6038677cb7c74b39b1b6381ff7e6e86361a78b6bda6adf8c7ebb898d06895c878e7f24b0374dc10b24cc346805bc22b2a6c7b347553735b3edc4b2d2946
7
+ data.tar.gz: f111ddd0a335314da71872386f239969fdb6f8826a93f4e5792f9224710d8701cdac3f8f5ae52180cc7c5ba8801939ee121410f048f4bf7b93b595097f5bc4fd
data/README.md CHANGED
@@ -1,12 +1,585 @@
1
- Ziggeo Ruby Server SDK
2
- ======================
1
+ # Ziggeo Ruby Server SDK 1.2
3
2
 
4
- Ziggeo API (http://ziggeo.com) allows you to integrate video recording and playback with only
5
- two lines of code in your site, service or app. This is the Ruby Server SDK repository. It's open source,
6
- so if you want to improve on it, feel free to add a pull request.
3
+ Ziggeo API (https://ziggeo.com) allows you to integrate video recording and playback with only
4
+ two lines of code in your site, service or app. This is the Ruby Server SDK repository.
5
+
6
+ Pull requests welcome.
7
+
8
+
9
+ ## Installation
7
10
 
8
11
  For Rails applications, you can simply install this repository as a gem.
9
12
 
10
13
  gem "Ziggeo"
11
14
 
12
- Copyright (c) 2014-2015 Ziggeo
15
+
16
+ ## Client-Side Integration
17
+
18
+ For the client-side integration, you need to add these assets to your html file:
19
+
20
+ ```html
21
+ <link rel="stylesheet" href="//assets-cdn.ziggeo.com/v2-stable/ziggeo.css" />
22
+ <script src="//assets-cdn.ziggeo.com/v2-stable/ziggeo.js"></script>
23
+ ```
24
+
25
+ Then, you need to specify your api token:
26
+ ```html
27
+ <script>
28
+ var ziggeoApplication = new ZiggeoApi.V2.Application({
29
+ token: "APPLICATION_TOKEN"
30
+ });
31
+ </script>
32
+ ```
33
+
34
+ You can specify other global options, [see here](https://ziggeo.com/docs).
35
+
36
+ To fire up a recorder on your page, add:
37
+ ```html
38
+ <ziggeorecorder></ziggeorecorder>
39
+ ```
40
+
41
+ To embed a player for an existing video, add:
42
+ ```html
43
+ <ziggeoplayer ziggeo-video='video-token'></ziggeoplayer>
44
+ ```
45
+
46
+ For the full documentation, please visit [ziggeo.com](https://ziggeo.com/docs).
47
+
48
+
49
+
50
+ ## Server-Side Integration
51
+
52
+ You can integrate the Server SDK as follows:
53
+
54
+ ```ruby
55
+ @ziggeo = Ziggeo.new("*token*", "*private_key*", "*encryption_key*")
56
+ ```
57
+
58
+
59
+ ## Server-Side Methods
60
+
61
+ ### Videos
62
+
63
+ The videos resource allows you to access all single videos. Each video may contain more than one stream.
64
+
65
+
66
+ #### Index
67
+
68
+ Query an array of videos (will return at most 50 videos by default). Newest videos come first.
69
+
70
+ ```ruby
71
+ ziggeo.videos().index(arguments = nil)
72
+ ```
73
+
74
+ Arguments
75
+ - limit: *Limit the number of returned videos. Can be set up to 100.*
76
+ - skip: *Skip the first [n] entries.*
77
+ - reverse: *Reverse the order in which videos are returned.*
78
+ - states: *Filter videos by state*
79
+ - tags: *Filter the search result to certain tags, encoded as a comma-separated string*
80
+
81
+
82
+ #### Count
83
+
84
+ Get the video count for the application.
85
+
86
+ ```ruby
87
+ ziggeo.videos().count(arguments = nil)
88
+ ```
89
+
90
+ Arguments
91
+ - states: *Filter videos by state*
92
+ - tags: *Filter the search result to certain tags, encoded as a comma-separated string*
93
+
94
+
95
+ #### Get
96
+
97
+ Get a single video by token or key.
98
+
99
+ ```ruby
100
+ ziggeo.videos().get(token_or_key)
101
+ ```
102
+
103
+
104
+
105
+ #### Get Bulk
106
+
107
+ Get multiple videos by tokens or keys.
108
+
109
+ ```ruby
110
+ ziggeo.videos().get_bulk(arguments = nil)
111
+ ```
112
+
113
+ Arguments
114
+ - tokens_or_keys: *Comma-separated list with the desired videos tokens or keys (Limit: 100 tokens or keys).*
115
+
116
+
117
+ #### Download Video
118
+
119
+ Download the video data file
120
+
121
+ ```ruby
122
+ ziggeo.videos().download_video(token_or_key)
123
+ ```
124
+
125
+
126
+
127
+ #### Download Image
128
+
129
+ Download the image data file
130
+
131
+ ```ruby
132
+ ziggeo.videos().download_image(token_or_key)
133
+ ```
134
+
135
+
136
+
137
+ #### Push To Service
138
+
139
+ Push a video to a provided push service.
140
+
141
+ ```ruby
142
+ ziggeo.videos().push_to_service(token_or_key, arguments = nil)
143
+ ```
144
+
145
+ Arguments
146
+ - pushservicetoken: *Push Services's token (from the Push Services configured for the app)*
147
+
148
+
149
+ #### Apply Effect
150
+
151
+ Apply an effect profile to a video.
152
+
153
+ ```ruby
154
+ ziggeo.videos().apply_effect(token_or_key, arguments = nil)
155
+ ```
156
+
157
+ Arguments
158
+ - effectprofiletoken: *Effect Profile token (from the Effect Profiles configured for the app)*
159
+
160
+
161
+ #### Update
162
+
163
+ Update single video by token or key.
164
+
165
+ ```ruby
166
+ ziggeo.videos().update(token_or_key, arguments = nil)
167
+ ```
168
+
169
+ Arguments
170
+ - min_duration: *Minimal duration of video*
171
+ - max_duration: *Maximal duration of video*
172
+ - tags: *Video Tags*
173
+ - key: *Unique (optional) name of video*
174
+ - volatile: *Automatically removed this video if it remains empty*
175
+ - expiration_days: *After how many days will this video be deleted*
176
+
177
+
178
+ #### Update Bulk
179
+
180
+ Update multiple videos by token or key.
181
+
182
+ ```ruby
183
+ ziggeo.videos().update_bulk(arguments = nil)
184
+ ```
185
+
186
+ Arguments
187
+ - tokens_or_keys: *Comma-separated list with the desired videos tokens or keys (Limit: 100 tokens or keys).*
188
+ - min_duration: *Minimal duration of video*
189
+ - max_duration: *Maximal duration of video*
190
+ - tags: *Video Tags*
191
+ - volatile: *Automatically removed this video if it remains empty*
192
+ - expiration_days: *After how many days will this video be deleted*
193
+
194
+
195
+ #### Delete
196
+
197
+ Delete a single video by token or key.
198
+
199
+ ```ruby
200
+ ziggeo.videos().delete(token_or_key)
201
+ ```
202
+
203
+
204
+
205
+ #### Create
206
+
207
+ Create a new video.
208
+
209
+ ```ruby
210
+ ziggeo.videos().create(arguments = nil, file = nil)
211
+ ```
212
+
213
+ Arguments
214
+ - file: *Video file to be uploaded*
215
+ - min_duration: *Minimal duration of video*
216
+ - max_duration: *Maximal duration of video*
217
+ - tags: *Video Tags*
218
+ - key: *Unique (optional) name of video*
219
+ - volatile: *Automatically removed this video if it remains empty*
220
+
221
+
222
+ #### Analytics
223
+
224
+ Get analytics for a specific videos with the given params
225
+
226
+ ```ruby
227
+ ziggeo.videos().analytics(token_or_key, arguments = nil)
228
+ ```
229
+
230
+ Arguments
231
+ - from: *A UNIX timestamp in microseconds used as the start date of the query*
232
+ - to: *A UNIX timestamp in microseconds used as the end date of the query*
233
+ - date: *A UNIX timestamp in microseconds to retrieve data from a single date. If set, it overwrites the from and to params.*
234
+ - query: *The query you want to run. It can be one of the following: device_views_by_os, device_views_by_date, total_plays_by_country, full_plays_by_country, total_plays_by_hour, full_plays_by_hour, total_plays_by_browser, full_plays_by_browser*
235
+
236
+
237
+ ### Streams
238
+
239
+ The streams resource allows you to directly access all streams associated with a single video.
240
+
241
+
242
+ #### Index
243
+
244
+ Return all streams associated with a video
245
+
246
+ ```ruby
247
+ ziggeo.streams().index(video_token_or_key, arguments = nil)
248
+ ```
249
+
250
+ Arguments
251
+ - states: *Filter streams by state*
252
+
253
+
254
+ #### Get
255
+
256
+ Get a single stream
257
+
258
+ ```ruby
259
+ ziggeo.streams().get(video_token_or_key, token_or_key)
260
+ ```
261
+
262
+
263
+
264
+ #### Download Video
265
+
266
+ Download the video data associated with the stream
267
+
268
+ ```ruby
269
+ ziggeo.streams().download_video(video_token_or_key, token_or_key)
270
+ ```
271
+
272
+
273
+
274
+ #### Download Image
275
+
276
+ Download the image data associated with the stream
277
+
278
+ ```ruby
279
+ ziggeo.streams().download_image(video_token_or_key, token_or_key)
280
+ ```
281
+
282
+
283
+
284
+ #### Push To Service
285
+
286
+ Push a stream to a provided push service.
287
+
288
+ ```ruby
289
+ ziggeo.streams().push_to_service(video_token_or_key, token_or_key, arguments = nil)
290
+ ```
291
+
292
+ Arguments
293
+ - pushservicetoken: *Push Services's token (from the Push Services configured for the app)*
294
+
295
+
296
+ #### Delete
297
+
298
+ Delete the stream
299
+
300
+ ```ruby
301
+ ziggeo.streams().delete(video_token_or_key, token_or_key)
302
+ ```
303
+
304
+
305
+
306
+ #### Create
307
+
308
+ Create a new stream
309
+
310
+ ```ruby
311
+ ziggeo.streams().create(video_token_or_key, arguments = nil, file = nil)
312
+ ```
313
+
314
+ Arguments
315
+ - file: *Video file to be uploaded*
316
+
317
+
318
+ #### Attach Image
319
+
320
+ Attaches an image to a new stream
321
+
322
+ ```ruby
323
+ ziggeo.streams().attach_image(video_token_or_key, token_or_key, arguments = nil, file = nil)
324
+ ```
325
+
326
+ Arguments
327
+ - file: *Image file to be attached*
328
+
329
+
330
+ #### Attach Video
331
+
332
+ Attaches a video to a new stream
333
+
334
+ ```ruby
335
+ ziggeo.streams().attach_video(video_token_or_key, token_or_key, arguments = nil, file = nil)
336
+ ```
337
+
338
+ Arguments
339
+ - file: *Video file to be attached*
340
+
341
+
342
+ #### Bind
343
+
344
+ Closes and submits the stream
345
+
346
+ ```ruby
347
+ ziggeo.streams().bind(video_token_or_key, token_or_key, arguments = nil)
348
+ ```
349
+
350
+
351
+
352
+ ### Authtokens
353
+
354
+ The auth token resource allows you to manage authorization settings for video objects.
355
+
356
+
357
+ #### Get
358
+
359
+ Get a single auth token by token.
360
+
361
+ ```ruby
362
+ ziggeo.authtokens().get(token)
363
+ ```
364
+
365
+
366
+
367
+ #### Update
368
+
369
+ Update single auth token by token.
370
+
371
+ ```ruby
372
+ ziggeo.authtokens().update(token_or_key, arguments = nil)
373
+ ```
374
+
375
+ Arguments
376
+ - volatile: *Will this object automatically be deleted if it remains empty?*
377
+ - hidden: *If hidden, the token cannot be used directly.*
378
+ - expiration_date: *Expiration date for the auth token*
379
+ - usage_experitation_time: *Expiration time per session*
380
+ - session_limit: *Maximal number of sessions*
381
+ - grants: *Permissions this tokens grants*
382
+
383
+
384
+ #### Delete
385
+
386
+ Delete a single auth token by token.
387
+
388
+ ```ruby
389
+ ziggeo.authtokens().delete(token_or_key)
390
+ ```
391
+
392
+
393
+
394
+ #### Create
395
+
396
+ Create a new auth token.
397
+
398
+ ```ruby
399
+ ziggeo.authtokens().create(arguments = nil)
400
+ ```
401
+
402
+ Arguments
403
+ - volatile: *Will this object automatically be deleted if it remains empty?*
404
+ - hidden: *If hidden, the token cannot be used directly.*
405
+ - expiration_date: *Expiration date for the auth token*
406
+ - usage_experitation_time: *Expiration time per session*
407
+ - session_limit: *Maximal number of sessions*
408
+ - grants: *Permissions this tokens grants*
409
+
410
+
411
+ ### EffectProfiles
412
+
413
+ The effect profiles resource allows you to access and create effect profiles for your app. Each effect profile may contain one process or more.
414
+
415
+
416
+ #### Create
417
+
418
+ Create a new effect profile.
419
+
420
+ ```ruby
421
+ ziggeo.effectProfiles().create(arguments = nil)
422
+ ```
423
+
424
+ Arguments
425
+ - key: *Effect profile key.*
426
+ - title: *Effect profile title.*
427
+
428
+
429
+ #### Index
430
+
431
+ Get list of effect profiles.
432
+
433
+ ```ruby
434
+ ziggeo.effectProfiles().index(arguments = nil)
435
+ ```
436
+
437
+ Arguments
438
+ - limit: *Limit the number of returned effect profiles. Can be set up to 100.*
439
+ - skip: *Skip the first [n] entries.*
440
+ - reverse: *Reverse the order in which effect profiles are returned.*
441
+
442
+
443
+ #### Get
444
+
445
+ Get a single effect profile
446
+
447
+ ```ruby
448
+ ziggeo.effectProfiles().get(token_or_key)
449
+ ```
450
+
451
+
452
+
453
+ #### Delete
454
+
455
+ Delete the effect profile
456
+
457
+ ```ruby
458
+ ziggeo.effectProfiles().delete(token_or_key)
459
+ ```
460
+
461
+
462
+
463
+ ### EffectProfileProcess
464
+
465
+ The process resource allows you to directly access all process associated with a single effect profile.
466
+
467
+
468
+ #### Index
469
+
470
+ Return all processes associated with a effect profile
471
+
472
+ ```ruby
473
+ ziggeo.effectProfileProcess().index(effect_token_or_key, arguments = nil)
474
+ ```
475
+
476
+ Arguments
477
+ - states: *Filter streams by state*
478
+
479
+
480
+ #### Get
481
+
482
+ Get a single process
483
+
484
+ ```ruby
485
+ ziggeo.effectProfileProcess().get(effect_token_or_key, token_or_key)
486
+ ```
487
+
488
+
489
+
490
+ #### Delete
491
+
492
+ Delete the process
493
+
494
+ ```ruby
495
+ ziggeo.effectProfileProcess().delete(effect_token_or_key, token_or_key)
496
+ ```
497
+
498
+
499
+
500
+ #### Create Filter Process
501
+
502
+ Create a new filter effect process
503
+
504
+ ```ruby
505
+ ziggeo.effectProfileProcess().create_filter_process(effect_token_or_key, arguments = nil)
506
+ ```
507
+
508
+ Arguments
509
+ - effect: *Effect to be applied in the process*
510
+
511
+
512
+ #### Create Watermark Process
513
+
514
+ Attaches an image to a new stream
515
+
516
+ ```ruby
517
+ ziggeo.effectProfileProcess().create_watermark_process(effect_token_or_key, arguments = nil, file = nil)
518
+ ```
519
+
520
+ Arguments
521
+ - file: *Image file to be attached*
522
+ - vertical: *Specify the vertical position of your watermark (a value between 0.0 and 1.0)*
523
+ - horizontal: *Specify the horizontal position of your watermark (a value between 0.0 and 1.0)*
524
+ - scale: *Specify the image scale of your watermark (a value between 0.0 and 1.0)*
525
+
526
+
527
+ ### Webhooks
528
+
529
+ The webhooks resource allows you to create or delete webhooks related to a given application.
530
+
531
+
532
+ #### Create
533
+
534
+ Create a new webhook for the given url to catch the given events.
535
+
536
+ ```ruby
537
+ ziggeo.webhooks().create(arguments = nil)
538
+ ```
539
+
540
+ Arguments
541
+ - target_url: *The url that will catch the events*
542
+ - encoding: *Data encoding to be used by the webhook to send the events.*
543
+ - events: *Comma-separated list of the events the webhook will catch. They must be valid webhook type events.*
544
+
545
+
546
+ #### Delete
547
+
548
+ Delete a webhook using its URL.
549
+
550
+ ```ruby
551
+ ziggeo.webhooks().delete(arguments = nil)
552
+ ```
553
+
554
+ Arguments
555
+ - target_url: *The url that will catch the events*
556
+
557
+
558
+ ### Analytics
559
+
560
+ The analytics resource allows you to access the analytics for the given application
561
+
562
+
563
+ #### Get
564
+
565
+ Get analytics for the given params
566
+
567
+ ```ruby
568
+ ziggeo.analytics().get(arguments = nil)
569
+ ```
570
+
571
+ Arguments
572
+ - from: *A UNIX timestamp in microseconds used as the start date of the query*
573
+ - to: *A UNIX timestamp in microseconds used as the end date of the query*
574
+ - date: *A UNIX timestamp in microseconds to retrieve data from a single date. If set, it overwrites the from and to params.*
575
+ - query: *The query you want to run. It can be one of the following: device_views_by_os, device_views_by_date, total_plays_by_country, full_plays_by_country, total_plays_by_hour, full_plays_by_hour, total_plays_by_browser, full_plays_by_browser*
576
+
577
+
578
+
579
+
580
+
581
+ ## License
582
+
583
+ Copyright (c) 2013-2018 Ziggeo
584
+
585
+ Apache 2.0 License
@@ -7,11 +7,11 @@ require_relative "classes/ZiggeoConfig"
7
7
  require_relative "classes/ZiggeoConnect"
8
8
  require_relative "classes/ZiggeoVideos"
9
9
  require_relative "classes/ZiggeoStreams"
10
+ require_relative "classes/ZiggeoEffectProfiles"
11
+ require_relative "classes/ZiggeoEffectProfileProcess"
10
12
  require_relative "classes/ZiggeoAuthtokens"
11
13
  require_relative "classes/ZiggeoAuth"
12
14
 
13
- # TODO: https://github.com/nicksieger/multipart-post
14
-
15
15
  class Ziggeo
16
16
 
17
17
  attr_accessor :token, :private_key, :encryption_key, :config, :connect
@@ -23,6 +23,8 @@ class Ziggeo
23
23
  @connect = ZiggeoConnect.new(self)
24
24
  @videos = nil
25
25
  @streams = nil
26
+ @effectProfiles = nil
27
+ @effectProfileProcess = nil
26
28
  @authtokens = nil
27
29
  @auth = nil
28
30
  if (ENV["ZIGGEO_URL"] != nil)
@@ -49,6 +51,20 @@ class Ziggeo
49
51
  return @streams
50
52
  end
51
53
 
54
+ def effectProfiles()
55
+ if (@effectProfiles == nil)
56
+ @effectProfiles = ZiggeoEffectProfiles.new(self)
57
+ end
58
+ return @effectProfiles
59
+ end
60
+
61
+ def effectProfileProcess()
62
+ if (@effectProfileProcess == nil)
63
+ @effectProfileProcess = ZiggeoEffectProfileProcess.new(self)
64
+ end
65
+ return @effectProfileProcess
66
+ end
67
+
52
68
  def authtokens()
53
69
  if (@authtokens == nil)
54
70
  @authtokens = ZiggeoAuthtokens.new(self)
@@ -0,0 +1,11 @@
1
+ class ZiggeoAnalytics
2
+
3
+ def initialize(application)
4
+ @application = application
5
+ end
6
+
7
+ def get(data = nil)
8
+ return @application.connect.postJSON('/analytics/get', data)
9
+ end
10
+
11
+ end
@@ -1,7 +1,10 @@
1
1
  class ZiggeoConfig
2
- attr_accessor :server_api_url
2
+ attr_accessor :server_api_url, :request_timeout, :request_timeout_per_mb, :regions
3
3
 
4
4
  def initialize()
5
+ @request_timeout = 30 # seconds
6
+ @request_timeout_per_mb = 20 # seconds per MB of uploaded file
5
7
  @server_api_url = "https://srvapi.ziggeo.com"
8
+ @regions = {"r1" => "https://srvapi-eu-west-1.ziggeo.com", }
6
9
  end
7
10
  end
@@ -1,5 +1,7 @@
1
1
  require 'net/http'
2
2
  require 'json'
3
+ require 'httparty'
4
+ require 'httmultiparty'
3
5
 
4
6
  class ZiggeoConnect
5
7
  def initialize(application)
@@ -7,37 +9,50 @@ class ZiggeoConnect
7
9
  end
8
10
 
9
11
  def request(method, path, data = nil, file = nil)
10
- url = URI.parse(@application.config.server_api_url + '/v1' + path)
11
- if (method == "GET")
12
- if (data != nil)
13
- url.query = URI.encode_www_form(data)
12
+ server_api_url = @application.config.server_api_url
13
+ regions = @application.config.regions
14
+ regions.each do |key, value|
15
+ if (@application.token.start_with?(key))
16
+ server_api_url = value
14
17
  end
15
- req = Net::HTTP::Get.new(url.to_s)
16
- elsif (method == "POST")
17
- req = Net::HTTP::Post.new(url.to_s)
18
- if (data != nil)
19
- req.set_form_data(data)
18
+ end
19
+
20
+ url = URI.parse(server_api_url + '/v1' + path)
21
+ auth = { username: @application.token, password: @application.private_key }
22
+ timeout_in_seconds = @application.config.request_timeout.to_i
23
+
24
+ method.downcase!
25
+ allowed_methods = %w(get post delete)
26
+ return unless allowed_methods.include?(method)
27
+ if (file.nil?)
28
+ if (method == "get")
29
+ begin
30
+ HTTParty.send(method, url.to_s, query: data, basic_auth: auth, timeout: timeout_in_seconds).body
31
+ rescue Net::ReadTimeout => error
32
+ self.timeout_error_message timeout_in_seconds, error
33
+ end
34
+ else
35
+ begin
36
+ HTTParty.send(method, url.to_s, body: data, basic_auth: auth, timeout: timeout_in_seconds).body
37
+ rescue Net::ReadTimeout => error
38
+ self.timeout_error_message timeout_in_seconds, error
39
+ end
20
40
  end
21
- elsif (method == "DELETE")
22
- req = Net::HTTP::Delete.new(url.to_s)
23
- if (data != nil)
24
- req.set_form_data(data)
41
+ else
42
+ data = data.nil? ? {} : data;
43
+ data["file"] = File.new(file)
44
+ timeout_in_seconds = ( ( File.size(file).to_f / 2**20 ).round(0) * @application.config.request_timeout_per_mb.to_i ).to_i;
45
+
46
+ begin
47
+ HTTMultiParty.send(method, url.to_s, body: data, basic_auth: auth, timeout: timeout_in_seconds).body
48
+ rescue Net::ReadTimeout => error
49
+ self.timeout_error_message timeout_in_seconds, error
25
50
  end
26
51
  end
27
- req.basic_auth(@application.token, @application.private_key)
28
- http = Net::HTTP.new(url.host, url.port)
29
- if (url.scheme == "https")
30
- http.use_ssl = true
31
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
32
- end
33
- res = http.start() {|agent|
34
- agent.request(req)
35
- }
36
- return res.body
37
52
  end
38
53
 
39
54
  def requestJSON(method, path, data = nil, file = nil)
40
- return JSON.parse self.request(method, path, data, file)
55
+ return JSON.parse(self.request(method, path, data, file))
41
56
  end
42
57
 
43
58
  def get(path, data = nil, file = nil)
@@ -64,4 +79,12 @@ class ZiggeoConnect
64
79
  return self.requestJSON("DELETE", path, data, file)
65
80
  end
66
81
 
82
+ protected
83
+
84
+ def timeout_error_message( timeout_in_seconds, error )
85
+ puts "Error source: " + error.message
86
+ puts "Server not responding. Host: #{@application.config.server_api_url} not responded in #{timeout_in_seconds} seconds."
87
+ exit(1)
88
+ end
89
+
67
90
  end
@@ -0,0 +1,27 @@
1
+ class ZiggeoEffectProfileProcess
2
+
3
+ def initialize(application)
4
+ @application = application
5
+ end
6
+
7
+ def index(effect_token_or_key, data = nil)
8
+ return @application.connect.getJSON('/effects/' + effect_token_or_key + '/process', data)
9
+ end
10
+
11
+ def get(effect_token_or_key, token_or_key)
12
+ return @application.connect.getJSON('/effects/' + effect_token_or_key + '/process/' + token_or_key + '')
13
+ end
14
+
15
+ def delete(effect_token_or_key, token_or_key)
16
+ return @application.connect.delete('/effects/' + effect_token_or_key + '/process/' + token_or_key + '')
17
+ end
18
+
19
+ def create_filter_process(effect_token_or_key, data = nil)
20
+ return @application.connect.postJSON('/effects/' + effect_token_or_key + '/process/filter', data)
21
+ end
22
+
23
+ def create_watermark_process(effect_token_or_key, data = nil, file = nil)
24
+ return @application.connect.postJSON('/effects/' + effect_token_or_key + '/process/watermark', data, file)
25
+ end
26
+
27
+ end
@@ -0,0 +1,23 @@
1
+ class ZiggeoEffectProfiles
2
+
3
+ def initialize(application)
4
+ @application = application
5
+ end
6
+
7
+ def create(data = nil)
8
+ return @application.connect.postJSON('/effects/', data)
9
+ end
10
+
11
+ def index(data = nil)
12
+ return @application.connect.getJSON('/effects/', data)
13
+ end
14
+
15
+ def get(token_or_key)
16
+ return @application.connect.getJSON('/effects/' + token_or_key + '')
17
+ end
18
+
19
+ def delete(token_or_key)
20
+ return @application.connect.delete('/effects/' + token_or_key + '')
21
+ end
22
+
23
+ end
@@ -20,6 +20,10 @@ class ZiggeoStreams
20
20
  return @application.connect.get('/videos/' + video_token_or_key + '/streams/' + token_or_key + '/image')
21
21
  end
22
22
 
23
+ def push_to_service(video_token_or_key, token_or_key, data = nil)
24
+ return @application.connect.postJSON('/videos/' + video_token_or_key + '/streams/' + token_or_key + '/push', data)
25
+ end
26
+
23
27
  def delete(video_token_or_key, token_or_key)
24
28
  return @application.connect.delete('/videos/' + video_token_or_key + '/streams/' + token_or_key + '')
25
29
  end
@@ -28,4 +32,16 @@ class ZiggeoStreams
28
32
  return @application.connect.postJSON('/videos/' + video_token_or_key + '/streams', data, file)
29
33
  end
30
34
 
35
+ def attach_image(video_token_or_key, token_or_key, data = nil, file = nil)
36
+ return @application.connect.postJSON('/videos/' + video_token_or_key + '/streams/' + token_or_key + '/image', data, file)
37
+ end
38
+
39
+ def attach_video(video_token_or_key, token_or_key, data = nil, file = nil)
40
+ return @application.connect.postJSON('/videos/' + video_token_or_key + '/streams/' + token_or_key + '/video', data, file)
41
+ end
42
+
43
+ def bind(video_token_or_key, token_or_key)
44
+ return @application.connect.postJSON('/videos/' + video_token_or_key + '/streams/' + token_or_key + '/bind')
45
+ end
46
+
31
47
  end
@@ -8,10 +8,18 @@ class ZiggeoVideos
8
8
  return @application.connect.getJSON('/videos/', data)
9
9
  end
10
10
 
11
+ def count(data = nil)
12
+ return @application.connect.getJSON('/videos/count', data)
13
+ end
14
+
11
15
  def get(token_or_key)
12
16
  return @application.connect.getJSON('/videos/' + token_or_key + '')
13
17
  end
14
18
 
19
+ def get_bulk(data = nil)
20
+ return @application.connect.postJSON('/videos/get_bulk', data)
21
+ end
22
+
15
23
  def download_video(token_or_key)
16
24
  return @application.connect.get('/videos/' + token_or_key + '/video')
17
25
  end
@@ -20,10 +28,22 @@ class ZiggeoVideos
20
28
  return @application.connect.get('/videos/' + token_or_key + '/image')
21
29
  end
22
30
 
31
+ def push_to_service(token_or_key, data = nil)
32
+ return @application.connect.postJSON('/videos/' + token_or_key + '/push', data)
33
+ end
34
+
35
+ def apply_effect(token_or_key, data = nil)
36
+ return @application.connect.postJSON('/videos/' + token_or_key + '/effect', data)
37
+ end
38
+
23
39
  def update(token_or_key, data = nil)
24
40
  return @application.connect.postJSON('/videos/' + token_or_key + '', data)
25
41
  end
26
42
 
43
+ def update_bulk(data = nil)
44
+ return @application.connect.postJSON('/videos/update_bulk', data)
45
+ end
46
+
27
47
  def delete(token_or_key)
28
48
  return @application.connect.delete('/videos/' + token_or_key + '')
29
49
  end
@@ -32,4 +52,8 @@ class ZiggeoVideos
32
52
  return @application.connect.postJSON('/videos/', data, file)
33
53
  end
34
54
 
55
+ def analytics(token_or_key, data = nil)
56
+ return @application.connect.postJSON('/videos/' + token_or_key + '/analytics', data)
57
+ end
58
+
35
59
  end
@@ -0,0 +1,15 @@
1
+ class ZiggeoWebhooks
2
+
3
+ def initialize(application)
4
+ @application = application
5
+ end
6
+
7
+ def create(data = nil)
8
+ return @application.connect.post('/api/hook', data)
9
+ end
10
+
11
+ def delete(data = nil)
12
+ return @application.connect.post('/api/removehook', data)
13
+ end
14
+
15
+ end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Ziggeo
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.01'
4
+ version: '1.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ziggeo, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-04 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2018-05-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.13.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.13.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: httmultiparty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  description: The Ziggeo Ruby and Rails Server SDK.
14
42
  email:
15
43
  - support@ziggeo.com
@@ -19,15 +47,19 @@ extra_rdoc_files: []
19
47
  files:
20
48
  - README.md
21
49
  - lib/Ziggeo.rb
50
+ - lib/classes/ZiggeoAnalytics.rb
22
51
  - lib/classes/ZiggeoAuth.rb
23
52
  - lib/classes/ZiggeoAuthtokens.rb
24
53
  - lib/classes/ZiggeoConfig.rb
25
54
  - lib/classes/ZiggeoConnect.rb
55
+ - lib/classes/ZiggeoEffectProfileProcess.rb
56
+ - lib/classes/ZiggeoEffectProfiles.rb
26
57
  - lib/classes/ZiggeoStreams.rb
27
58
  - lib/classes/ZiggeoVideos.rb
28
- homepage: http://ziggeo.com
59
+ - lib/classes/ZiggeoWebhooks.rb
60
+ homepage: https://ziggeo.com
29
61
  licenses:
30
- - MIT
62
+ - Apache-2.0
31
63
  metadata: {}
32
64
  post_install_message:
33
65
  rdoc_options: []
@@ -35,17 +67,17 @@ require_paths:
35
67
  - lib
36
68
  required_ruby_version: !ruby/object:Gem::Requirement
37
69
  requirements:
38
- - - ! '>='
70
+ - - ">="
39
71
  - !ruby/object:Gem::Version
40
72
  version: '0'
41
73
  required_rubygems_version: !ruby/object:Gem::Requirement
42
74
  requirements:
43
- - - ! '>='
75
+ - - ">="
44
76
  - !ruby/object:Gem::Version
45
77
  version: '0'
46
78
  requirements: []
47
79
  rubyforge_project:
48
- rubygems_version: 2.4.6
80
+ rubygems_version: 2.5.2
49
81
  signing_key:
50
82
  specification_version: 4
51
83
  summary: The Ziggeo ServerSDK gem.