Ziggeo 1.04 → 1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa447331b1f96c31a3256ef764d2632ee8daa3a9
4
- data.tar.gz: 6ef3e83a47414b397347c912d1c58ea31b80520d
3
+ metadata.gz: c9fe90508511b991b4a875c418506fd36b359175
4
+ data.tar.gz: 247c2ae35713a2146cb1b84bb65aa10fc1399e46
5
5
  SHA512:
6
- metadata.gz: c653ac9d8c37c46cba2057feafae04b0137b59b88292db4f62209f39e67bf3dedaf3b82de535a573c6e746cd884f7218d940ab214548adc70e7d6b0675fbfcff
7
- data.tar.gz: 0cfb734dfaacaf93b379c91fffc5c324a62bf47c72a9df1e0bc85b5541f2c8e3882f06a0fb61d8a047921d2305543333c60bf19b153586fdc8e014b1aa3cee70
6
+ metadata.gz: 890361ffc3366f5a91428f61139f03e51011d2129a26dc080d4bf2f7a8f3ee5a713270fd16b106a3026991d2113117883c83ffb96adc0d9806e63d952265bb0b
7
+ data.tar.gz: 26a21f6b126f811cbcf05ff4f14d60fcd84bfad1d337551a933b2767a0b4b68a93c5900a0843d75214e3874c73786f36b8b08a84af0271fe3b46d32abdf44a47
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
- # Ziggeo Ruby Server SDK
1
+ # Ziggeo Ruby Server SDK 1.5
2
2
 
3
-
4
- Ziggeo API (http://ziggeo.com) allows you to integrate video recording and playback with only
3
+ Ziggeo API (https://ziggeo.com) allows you to integrate video recording and playback with only
5
4
  two lines of code in your site, service or app. This is the Ruby Server SDK repository.
6
5
 
7
6
  Pull requests welcome.
@@ -19,30 +18,33 @@ gem "Ziggeo"
19
18
  For the client-side integration, you need to add these assets to your html file:
20
19
 
21
20
  ```html
22
- <link rel="stylesheet" href="//assets-cdn.ziggeo.com/css/ziggeo-v1.css" />
23
- <script src="//assets-csn.ziggeo.com/js/ziggeo-v1.js"></script>
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>
24
23
  ```
25
24
 
26
25
  Then, you need to specify your api token:
27
26
  ```html
28
27
  <script>
29
- ZiggeoApi.token = "APPLICATION_TOKEN";
28
+ var ziggeoApplication = new ZiggeoApi.V2.Application({
29
+ token: "APPLICATION_TOKEN"
30
+ });
30
31
  </script>
31
32
  ```
32
33
 
33
- You can specify other global options, [see here](http://ziggeo.com/docs#client-integration-header).
34
+ You can specify other global options, [see here](https://ziggeo.com/docs).
34
35
 
35
36
  To fire up a recorder on your page, add:
36
37
  ```html
37
- <ziggeo></ziggeo>
38
+ <ziggeorecorder></ziggeorecorder>
38
39
  ```
39
40
 
40
41
  To embed a player for an existing video, add:
41
42
  ```html
42
- <ziggeo ziggeo-video='video-token'></ziggeo>
43
+ <ziggeoplayer ziggeo-video='video-token'></ziggeoplayer>
43
44
  ```
44
45
 
45
- For the full documentation, please visit [ziggeo.com](http://ziggeo.com/docs).
46
+ For the full documentation, please visit [ziggeo.com](https://ziggeo.com/docs).
47
+
46
48
 
47
49
 
48
50
  ## Server-Side Integration
@@ -57,7 +59,7 @@ You can integrate the Server SDK as follows:
57
59
  ## Server-Side Methods
58
60
 
59
61
  ### Videos
60
-
62
+
61
63
  The videos resource allows you to access all single videos. Each video may contain more than one stream.
62
64
 
63
65
 
@@ -74,7 +76,20 @@ Arguments
74
76
  - skip: *Skip the first [n] entries.*
75
77
  - reverse: *Reverse the order in which videos are returned.*
76
78
  - states: *Filter videos by state*
77
- - tags: *Filter the search result to certain tags*
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*
78
93
 
79
94
 
80
95
  #### Get
@@ -87,6 +102,31 @@ ziggeo.videos().get(token_or_key)
87
102
 
88
103
 
89
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
+ #### Stats Bulk
118
+
119
+ Get stats for multiple videos by tokens or keys.
120
+
121
+ ```ruby
122
+ ziggeo.videos().stats_bulk(arguments = nil)
123
+ ```
124
+
125
+ Arguments
126
+ - tokens_or_keys: *Comma-separated list with the desired videos tokens or keys (Limit: 100 tokens or keys).*
127
+ - summarize: *Boolean. Set it to TRUE to get the stats summarized. Set it to FALSE to get the stats for each video in a separate array. Default: TRUE.*
128
+
129
+
90
130
  #### Download Video
91
131
 
92
132
  Download the video data file
@@ -107,6 +147,40 @@ ziggeo.videos().download_image(token_or_key)
107
147
 
108
148
 
109
149
 
150
+ #### Get Stats
151
+
152
+ Get the video's stats
153
+
154
+ ```ruby
155
+ ziggeo.videos().get_stats(token_or_key)
156
+ ```
157
+
158
+
159
+
160
+ #### Push To Service
161
+
162
+ Push a video to a provided push service.
163
+
164
+ ```ruby
165
+ ziggeo.videos().push_to_service(token_or_key, arguments = nil)
166
+ ```
167
+
168
+ Arguments
169
+ - pushservicetoken: *Push Services's token (from the Push Services configured for the app)*
170
+
171
+
172
+ #### Apply Effect
173
+
174
+ Apply an effect profile to a video.
175
+
176
+ ```ruby
177
+ ziggeo.videos().apply_effect(token_or_key, arguments = nil)
178
+ ```
179
+
180
+ Arguments
181
+ - effectprofiletoken: *Effect Profile token (from the Effect Profiles configured for the app)*
182
+
183
+
110
184
  #### Update
111
185
 
112
186
  Update single video by token or key.
@@ -124,6 +198,23 @@ Arguments
124
198
  - expiration_days: *After how many days will this video be deleted*
125
199
 
126
200
 
201
+ #### Update Bulk
202
+
203
+ Update multiple videos by token or key.
204
+
205
+ ```ruby
206
+ ziggeo.videos().update_bulk(arguments = nil)
207
+ ```
208
+
209
+ Arguments
210
+ - tokens_or_keys: *Comma-separated list with the desired videos tokens or keys (Limit: 100 tokens or keys).*
211
+ - min_duration: *Minimal duration of video*
212
+ - max_duration: *Maximal duration of video*
213
+ - tags: *Video Tags*
214
+ - volatile: *Automatically removed this video if it remains empty*
215
+ - expiration_days: *After how many days will this video be deleted*
216
+
217
+
127
218
  #### Delete
128
219
 
129
220
  Delete a single video by token or key.
@@ -151,8 +242,23 @@ Arguments
151
242
  - volatile: *Automatically removed this video if it remains empty*
152
243
 
153
244
 
154
- ### Streams
245
+ #### Analytics
155
246
 
247
+ Get analytics for a specific videos with the given params
248
+
249
+ ```ruby
250
+ ziggeo.videos().analytics(token_or_key, arguments = nil)
251
+ ```
252
+
253
+ Arguments
254
+ - from: *A UNIX timestamp in microseconds used as the start date of the query*
255
+ - to: *A UNIX timestamp in microseconds used as the end date of the query*
256
+ - date: *A UNIX timestamp in microseconds to retrieve data from a single date. If set, it overwrites the from and to params.*
257
+ - 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*
258
+
259
+
260
+ ### Streams
261
+
156
262
  The streams resource allows you to directly access all streams associated with a single video.
157
263
 
158
264
 
@@ -198,6 +304,18 @@ ziggeo.streams().download_image(video_token_or_key, token_or_key)
198
304
 
199
305
 
200
306
 
307
+ #### Push To Service
308
+
309
+ Push a stream to a provided push service.
310
+
311
+ ```ruby
312
+ ziggeo.streams().push_to_service(video_token_or_key, token_or_key, arguments = nil)
313
+ ```
314
+
315
+ Arguments
316
+ - pushservicetoken: *Push Services's token (from the Push Services configured for the app)*
317
+
318
+
201
319
  #### Delete
202
320
 
203
321
  Delete the stream
@@ -255,7 +373,7 @@ ziggeo.streams().bind(video_token_or_key, token_or_key, arguments = nil)
255
373
 
256
374
 
257
375
  ### Authtokens
258
-
376
+
259
377
  The auth token resource allows you to manage authorization settings for video objects.
260
378
 
261
379
 
@@ -313,11 +431,297 @@ Arguments
313
431
  - grants: *Permissions this tokens grants*
314
432
 
315
433
 
434
+ ### EffectProfiles
435
+
436
+ The effect profiles resource allows you to access and create effect profiles for your app. Each effect profile may contain one process or more.
437
+
438
+
439
+ #### Create
440
+
441
+ Create a new effect profile.
442
+
443
+ ```ruby
444
+ ziggeo.effectProfiles().create(arguments = nil)
445
+ ```
446
+
447
+ Arguments
448
+ - key: *Effect profile key.*
449
+ - title: *Effect profile title.*
450
+
451
+
452
+ #### Index
453
+
454
+ Get list of effect profiles.
455
+
456
+ ```ruby
457
+ ziggeo.effectProfiles().index(arguments = nil)
458
+ ```
459
+
460
+ Arguments
461
+ - limit: *Limit the number of returned effect profiles. Can be set up to 100.*
462
+ - skip: *Skip the first [n] entries.*
463
+ - reverse: *Reverse the order in which effect profiles are returned.*
464
+
465
+
466
+ #### Get
467
+
468
+ Get a single effect profile
469
+
470
+ ```ruby
471
+ ziggeo.effectProfiles().get(token_or_key)
472
+ ```
473
+
474
+
475
+
476
+ #### Delete
477
+
478
+ Delete the effect profile
479
+
480
+ ```ruby
481
+ ziggeo.effectProfiles().delete(token_or_key)
482
+ ```
483
+
484
+
485
+
486
+ ### EffectProfileProcess
487
+
488
+ The process resource allows you to directly access all process associated with a single effect profile.
489
+
490
+
491
+ #### Index
492
+
493
+ Return all processes associated with a effect profile
494
+
495
+ ```ruby
496
+ ziggeo.effectProfileProcess().index(effect_token_or_key, arguments = nil)
497
+ ```
498
+
499
+ Arguments
500
+ - states: *Filter streams by state*
501
+
502
+
503
+ #### Get
504
+
505
+ Get a single process
506
+
507
+ ```ruby
508
+ ziggeo.effectProfileProcess().get(effect_token_or_key, token_or_key)
509
+ ```
510
+
511
+
512
+
513
+ #### Delete
514
+
515
+ Delete the process
516
+
517
+ ```ruby
518
+ ziggeo.effectProfileProcess().delete(effect_token_or_key, token_or_key)
519
+ ```
520
+
521
+
522
+
523
+ #### Create Filter Process
524
+
525
+ Create a new filter effect process
526
+
527
+ ```ruby
528
+ ziggeo.effectProfileProcess().create_filter_process(effect_token_or_key, arguments = nil)
529
+ ```
530
+
531
+ Arguments
532
+ - effect: *Effect to be applied in the process*
533
+
534
+
535
+ #### Create Watermark Process
536
+
537
+ Attaches an image to a new stream
538
+
539
+ ```ruby
540
+ ziggeo.effectProfileProcess().create_watermark_process(effect_token_or_key, arguments = nil, file = nil)
541
+ ```
542
+
543
+ Arguments
544
+ - file: *Image file to be attached*
545
+ - vertical: *Specify the vertical position of your watermark (a value between 0.0 and 1.0)*
546
+ - horizontal: *Specify the horizontal position of your watermark (a value between 0.0 and 1.0)*
547
+ - scale: *Specify the image scale of your watermark (a value between 0.0 and 1.0)*
548
+
549
+
550
+ ### MetaProfiles
551
+
552
+ The meta profiles resource allows you to access and create meta profiles for your app. Each meta profile may contain one process or more.
553
+
554
+
555
+ #### Create
556
+
557
+ Create a new meta profile.
558
+
559
+ ```ruby
560
+ ziggeo.metaProfiles().create(arguments = nil)
561
+ ```
562
+
563
+ Arguments
564
+ - key: *Meta Profile profile key.*
565
+ - title: *Meta Profile profile title.*
566
+
567
+
568
+ #### Index
569
+
570
+ Get list of meta profiles.
571
+
572
+ ```ruby
573
+ ziggeo.metaProfiles().index(arguments = nil)
574
+ ```
575
+
576
+ Arguments
577
+ - limit: *Limit the number of returned meta profiles. Can be set up to 100.*
578
+ - skip: *Skip the first [n] entries.*
579
+ - reverse: *Reverse the order in which meta profiles are returned.*
580
+
581
+
582
+ #### Get
583
+
584
+ Get a single meta profile
585
+
586
+ ```ruby
587
+ ziggeo.metaProfiles().get(token_or_key)
588
+ ```
589
+
590
+
591
+
592
+ #### Delete
593
+
594
+ Delete the meta profile
595
+
596
+ ```ruby
597
+ ziggeo.metaProfiles().delete(token_or_key)
598
+ ```
599
+
600
+
601
+
602
+ ### MetaProfileProcess
603
+
604
+ The process resource allows you to directly access all process associated with a single meta profile.
605
+
606
+
607
+ #### Index
608
+
609
+ Return all processes associated with a meta profile
610
+
611
+ ```ruby
612
+ ziggeo.metaProfileProcess().index(meta_token_or_key)
613
+ ```
614
+
615
+
616
+
617
+ #### Get
618
+
619
+ Get a single process
620
+
621
+ ```ruby
622
+ ziggeo.metaProfileProcess().get(meta_token_or_key, token_or_key)
623
+ ```
624
+
625
+
626
+
627
+ #### Delete
628
+
629
+ Delete the process
630
+
631
+ ```ruby
632
+ ziggeo.metaProfileProcess().delete(meta_token_or_key, token_or_key)
633
+ ```
634
+
635
+
636
+
637
+ #### Create Video Analysis Process
638
+
639
+ Create a new video analysis meta process
640
+
641
+ ```ruby
642
+ ziggeo.metaProfileProcess().create_video_analysis_process(meta_token_or_key)
643
+ ```
644
+
645
+
646
+
647
+ #### Create Audio Transcription Process
648
+
649
+ Create a new audio transcription meta process
650
+
651
+ ```ruby
652
+ ziggeo.metaProfileProcess().create_audio_transcription_process(meta_token_or_key)
653
+ ```
654
+
655
+
656
+
657
+ #### Create Nsfw Process
658
+
659
+ Create a new nsfw filter meta process
660
+
661
+ ```ruby
662
+ ziggeo.metaProfileProcess().create_nsfw_process(meta_token_or_key, arguments = nil)
663
+ ```
664
+
665
+ Arguments
666
+ - nsfw_action: *One of the following three: approve, reject, nothing.*
667
+
668
+
669
+ ### Webhooks
670
+
671
+ The webhooks resource allows you to create or delete webhooks related to a given application.
672
+
673
+
674
+ #### Create
675
+
676
+ Create a new webhook for the given url to catch the given events.
677
+
678
+ ```ruby
679
+ ziggeo.webhooks().create(arguments = nil)
680
+ ```
681
+
682
+ Arguments
683
+ - target_url: *The url that will catch the events*
684
+ - encoding: *Data encoding to be used by the webhook to send the events.*
685
+ - events: *Comma-separated list of the events the webhook will catch. They must be valid webhook type events.*
686
+
687
+
688
+ #### Delete
689
+
690
+ Delete a webhook using its URL.
691
+
692
+ ```ruby
693
+ ziggeo.webhooks().delete(arguments = nil)
694
+ ```
695
+
696
+ Arguments
697
+ - target_url: *The url that will catch the events*
698
+
699
+
700
+ ### Analytics
701
+
702
+ The analytics resource allows you to access the analytics for the given application
703
+
704
+
705
+ #### Get
706
+
707
+ Get analytics for the given params
708
+
709
+ ```ruby
710
+ ziggeo.analytics().get(arguments = nil)
711
+ ```
712
+
713
+ Arguments
714
+ - from: *A UNIX timestamp in microseconds used as the start date of the query*
715
+ - to: *A UNIX timestamp in microseconds used as the end date of the query*
716
+ - date: *A UNIX timestamp in microseconds to retrieve data from a single date. If set, it overwrites the from and to params.*
717
+ - 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*
718
+
719
+
316
720
 
317
721
 
318
722
 
319
723
  ## License
320
724
 
321
- Copyright (c) 2013-2015 Ziggeo
725
+ Copyright (c) 2013-2018 Ziggeo
322
726
 
323
- Apache 2.0 License
727
+ Apache 2.0 License
@@ -5,60 +5,106 @@ require 'cgi'
5
5
 
6
6
  require_relative "classes/ZiggeoConfig"
7
7
  require_relative "classes/ZiggeoConnect"
8
+ require_relative "classes/ZiggeoAuth"
8
9
  require_relative "classes/ZiggeoVideos"
9
10
  require_relative "classes/ZiggeoStreams"
10
11
  require_relative "classes/ZiggeoAuthtokens"
11
- require_relative "classes/ZiggeoAuth"
12
+ require_relative "classes/ZiggeoEffectProfiles"
13
+ require_relative "classes/ZiggeoEffectProfileProcess"
14
+ require_relative "classes/ZiggeoMetaProfiles"
15
+ require_relative "classes/ZiggeoMetaProfileProcess"
16
+ require_relative "classes/ZiggeoWebhooks"
17
+ require_relative "classes/ZiggeoAnalytics"
12
18
 
13
19
  class Ziggeo
14
20
 
15
- attr_accessor :token, :private_key, :encryption_key, :config, :connect
16
- def initialize(token = nil, private_key = nil, encryption_key = nil)
17
- @token = token
18
- @private_key = private_key
19
- @encryption_key = encryption_key
20
- @config = ZiggeoConfig.new()
21
- @connect = ZiggeoConnect.new(self)
22
- @videos = nil
23
- @streams = nil
24
- @authtokens = nil
25
- @auth = nil
26
- if (ENV["ZIGGEO_URL"] != nil)
27
- uri = URI.parse(ENV["ZIGGEO_URL"])
28
- @config.server_api_url = uri.scheme + "://" + uri.host + ":" + uri.port.to_s
29
- @token = uri.user
30
- @private_key = uri.password
31
- query = CGI::parse(uri.query)
32
- @encryption_key = query["encryption_key"]
33
- end
34
- end
21
+ attr_accessor :token, :private_key, :encryption_key, :config, :connect
35
22
 
36
- def videos()
37
- if (@videos == nil)
38
- @videos = ZiggeoVideos.new(self)
23
+ def initialize(token = nil, private_key = nil, encryption_key = nil)
24
+ @token = token
25
+ @private_key = private_key
26
+ @encryption_key = encryption_key
27
+ @config = ZiggeoConfig.new()
28
+ @connect = ZiggeoConnect.new(self)
29
+ @auth = nil
30
+ @videos = nil
31
+ @streams = nil
32
+ @authtokens = nil
33
+ @effectProfiles = nil
34
+ @effectProfileProcess = nil
35
+ @metaProfiles = nil
36
+ @metaProfileProcess = nil
37
+ @webhooks = nil
38
+ @analytics = nil
39
+ if (ENV["ZIGGEO_URL"] != nil)
40
+ uri = URI.parse(ENV["ZIGGEO_URL"])
41
+ @config.server_api_url = uri.scheme + "://" + uri.host + ":" + uri.port.to_s
42
+ @token = uri.user
43
+ @private_key = uri.password
44
+ query = CGI::parse(uri.query)
45
+ @encryption_key = query["encryption_key"]
46
+ end
39
47
  end
40
- return @videos
41
- end
42
48
 
43
- def streams()
44
- if (@streams == nil)
45
- @streams = ZiggeoStreams.new(self)
46
- end
47
- return @streams
48
- end
49
+ def auth()
50
+ if (@auth == nil)
51
+ @auth = ZiggeoAuth.new(self)
52
+ end
53
+ return @auth end
49
54
 
50
- def authtokens()
51
- if (@authtokens == nil)
52
- @authtokens = ZiggeoAuthtokens.new(self)
53
- end
54
- return @authtokens
55
- end
55
+ def videos()
56
+ if (@videos == nil)
57
+ @videos = ZiggeoVideos.new(self)
58
+ end
59
+ return @videos end
60
+
61
+ def streams()
62
+ if (@streams == nil)
63
+ @streams = ZiggeoStreams.new(self)
64
+ end
65
+ return @streams end
66
+
67
+ def authtokens()
68
+ if (@authtokens == nil)
69
+ @authtokens = ZiggeoAuthtokens.new(self)
70
+ end
71
+ return @authtokens end
72
+
73
+ def effectProfiles()
74
+ if (@effectProfiles == nil)
75
+ @effectProfiles = ZiggeoEffectProfiles.new(self)
76
+ end
77
+ return @effectProfiles end
78
+
79
+ def effectProfileProcess()
80
+ if (@effectProfileProcess == nil)
81
+ @effectProfileProcess = ZiggeoEffectProfileProcess.new(self)
82
+ end
83
+ return @effectProfileProcess end
84
+
85
+ def metaProfiles()
86
+ if (@metaProfiles == nil)
87
+ @metaProfiles = ZiggeoMetaProfiles.new(self)
88
+ end
89
+ return @metaProfiles end
90
+
91
+ def metaProfileProcess()
92
+ if (@metaProfileProcess == nil)
93
+ @metaProfileProcess = ZiggeoMetaProfileProcess.new(self)
94
+ end
95
+ return @metaProfileProcess end
96
+
97
+ def webhooks()
98
+ if (@webhooks == nil)
99
+ @webhooks = ZiggeoWebhooks.new(self)
100
+ end
101
+ return @webhooks end
102
+
103
+ def analytics()
104
+ if (@analytics == nil)
105
+ @analytics = ZiggeoAnalytics.new(self)
106
+ end
107
+ return @analytics end
56
108
 
57
- def auth()
58
- if (@auth == nil)
59
- @auth = ZiggeoAuth.new(self)
60
- end
61
- return @auth
62
- end
63
109
 
64
110
  end
@@ -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,6 +1,7 @@
1
1
  require 'net/http'
2
2
  require 'json'
3
3
  require 'httparty'
4
+ require 'httmultiparty'
4
5
 
5
6
  class ZiggeoConnect
6
7
  def initialize(application)
@@ -8,12 +9,46 @@ class ZiggeoConnect
8
9
  end
9
10
 
10
11
  def request(method, path, data = nil, file = nil)
11
- url = URI.parse(@application.config.server_api_url + '/v1' + path)
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
17
+ end
18
+ end
19
+
20
+ url = URI.parse(server_api_url + '/v1' + path)
12
21
  auth = { username: @application.token, password: @application.private_key }
22
+ timeout_in_seconds = @application.config.request_timeout.to_i
23
+
13
24
  method.downcase!
14
25
  allowed_methods = %w(get post delete)
15
26
  return unless allowed_methods.include?(method)
16
- HTTParty.send(method, url.to_s, body: data, basic_auth: auth).body
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
40
+ end
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
50
+ end
51
+ end
17
52
  end
18
53
 
19
54
  def requestJSON(method, path, data = nil, file = nil)
@@ -44,4 +79,12 @@ class ZiggeoConnect
44
79
  return self.requestJSON("DELETE", path, data, file)
45
80
  end
46
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
+
47
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
@@ -0,0 +1,31 @@
1
+ class ZiggeoMetaProfileProcess
2
+
3
+ def initialize(application)
4
+ @application = application
5
+ end
6
+
7
+ def index(meta_token_or_key)
8
+ return @application.connect.getJSON('/metaprofiles/' + meta_token_or_key + '/process')
9
+ end
10
+
11
+ def get(meta_token_or_key, token_or_key)
12
+ return @application.connect.getJSON('/metaprofiles/' + meta_token_or_key + '/process/' + token_or_key + '')
13
+ end
14
+
15
+ def delete(meta_token_or_key, token_or_key)
16
+ return @application.connect.delete('/metaprofiles/' + meta_token_or_key + '/process/' + token_or_key + '')
17
+ end
18
+
19
+ def create_video_analysis_process(meta_token_or_key)
20
+ return @application.connect.postJSON('/metaprofiles/' + meta_token_or_key + '/process/analysis')
21
+ end
22
+
23
+ def create_audio_transcription_process(meta_token_or_key)
24
+ return @application.connect.postJSON('/metaprofiles/' + meta_token_or_key + '/process/transcription')
25
+ end
26
+
27
+ def create_nsfw_process(meta_token_or_key, data = nil)
28
+ return @application.connect.postJSON('/metaprofiles/' + meta_token_or_key + '/process/nsfw', data)
29
+ end
30
+
31
+ end
@@ -0,0 +1,23 @@
1
+ class ZiggeoMetaProfiles
2
+
3
+ def initialize(application)
4
+ @application = application
5
+ end
6
+
7
+ def create(data = nil)
8
+ return @application.connect.postJSON('/metaprofiles/', data)
9
+ end
10
+
11
+ def index(data = nil)
12
+ return @application.connect.getJSON('/metaprofiles/', data)
13
+ end
14
+
15
+ def get(token_or_key)
16
+ return @application.connect.getJSON('/metaprofiles/' + token_or_key + '')
17
+ end
18
+
19
+ def delete(token_or_key)
20
+ return @application.connect.delete('/metaprofiles/' + 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
@@ -8,10 +8,22 @@ 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
+
23
+ def stats_bulk(data = nil)
24
+ return @application.connect.postJSON('/videos/stats_bulk', data)
25
+ end
26
+
15
27
  def download_video(token_or_key)
16
28
  return @application.connect.get('/videos/' + token_or_key + '/video')
17
29
  end
@@ -20,10 +32,26 @@ class ZiggeoVideos
20
32
  return @application.connect.get('/videos/' + token_or_key + '/image')
21
33
  end
22
34
 
35
+ def get_stats(token_or_key)
36
+ return @application.connect.getJSON('/videos/' + token_or_key + '/stats')
37
+ end
38
+
39
+ def push_to_service(token_or_key, data = nil)
40
+ return @application.connect.postJSON('/videos/' + token_or_key + '/push', data)
41
+ end
42
+
43
+ def apply_effect(token_or_key, data = nil)
44
+ return @application.connect.postJSON('/videos/' + token_or_key + '/effect', data)
45
+ end
46
+
23
47
  def update(token_or_key, data = nil)
24
48
  return @application.connect.postJSON('/videos/' + token_or_key + '', data)
25
49
  end
26
50
 
51
+ def update_bulk(data = nil)
52
+ return @application.connect.postJSON('/videos/update_bulk', data)
53
+ end
54
+
27
55
  def delete(token_or_key)
28
56
  return @application.connect.delete('/videos/' + token_or_key + '')
29
57
  end
@@ -32,4 +60,8 @@ class ZiggeoVideos
32
60
  return @application.connect.postJSON('/videos/', data, file)
33
61
  end
34
62
 
63
+ def analytics(token_or_key, data = nil)
64
+ return @application.connect.postJSON('/videos/' + token_or_key + '/analytics', data)
65
+ end
66
+
35
67
  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,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Ziggeo
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.04'
4
+ version: '1.5'
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-10-31 00:00:00.000000000 Z
11
+ date: 2018-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.13.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
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'
27
41
  description: The Ziggeo Ruby and Rails Server SDK.
28
42
  email:
29
43
  - support@ziggeo.com
@@ -31,17 +45,23 @@ executables: []
31
45
  extensions: []
32
46
  extra_rdoc_files: []
33
47
  files:
48
+ - README.md
49
+ - lib/Ziggeo.rb
50
+ - lib/classes/ZiggeoAnalytics.rb
34
51
  - lib/classes/ZiggeoAuth.rb
35
52
  - lib/classes/ZiggeoAuthtokens.rb
36
53
  - lib/classes/ZiggeoConfig.rb
37
54
  - lib/classes/ZiggeoConnect.rb
55
+ - lib/classes/ZiggeoEffectProfileProcess.rb
56
+ - lib/classes/ZiggeoEffectProfiles.rb
57
+ - lib/classes/ZiggeoMetaProfileProcess.rb
58
+ - lib/classes/ZiggeoMetaProfiles.rb
38
59
  - lib/classes/ZiggeoStreams.rb
39
60
  - lib/classes/ZiggeoVideos.rb
40
- - lib/Ziggeo.rb
41
- - README.md
42
- homepage: http://ziggeo.com
61
+ - lib/classes/ZiggeoWebhooks.rb
62
+ homepage: https://ziggeo.com
43
63
  licenses:
44
- - Apache 2.0
64
+ - Apache-2.0
45
65
  metadata: {}
46
66
  post_install_message:
47
67
  rdoc_options: []
@@ -49,17 +69,17 @@ require_paths:
49
69
  - lib
50
70
  required_ruby_version: !ruby/object:Gem::Requirement
51
71
  requirements:
52
- - - '>='
72
+ - - ">="
53
73
  - !ruby/object:Gem::Version
54
74
  version: '0'
55
75
  required_rubygems_version: !ruby/object:Gem::Requirement
56
76
  requirements:
57
- - - '>='
77
+ - - ">="
58
78
  - !ruby/object:Gem::Version
59
79
  version: '0'
60
80
  requirements: []
61
81
  rubyforge_project:
62
- rubygems_version: 2.0.14
82
+ rubygems_version: 2.5.2.3
63
83
  signing_key:
64
84
  specification_version: 4
65
85
  summary: The Ziggeo ServerSDK gem.