Ziggeo 1.06 → 1.7

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 44cfadc51a8a4831af6b9963799637a578792688
4
- data.tar.gz: 968b38dee3416f98cf54c4d42cd7bb6d46418f5d
3
+ metadata.gz: 60c24bd2eae6716a724c20a49103f93a673174bf
4
+ data.tar.gz: f4bdc91094ae8448d61c087de9ae25879663c9d0
5
5
  SHA512:
6
- metadata.gz: 9de05bd413549b5e7dc5b8564725d2b963add066cf8d960120f282bb4387f718a28097b4769404396de5599f25c76512c1b6fabe458a14642ac1005e1ad894ea
7
- data.tar.gz: 2e903bc600db791fb4524cabe0db3ddaf516c727de8202fb92b7d56d9534c7d765a2c95766ae0bbdd289631344be5d0befa169ca7f6307ae2f7921e42df221da
6
+ metadata.gz: 9201ab2f973fd86ba6b6de6c577f156762d62961d692f1cf2e3c3830adb1cf95622515a57b0e236088e2f4ef5564d989a907768edbd5277f3118876c408265b8
7
+ data.tar.gz: afcffd6127cd5720d536a5828ea487b8751fc673d843d92bb87e9f194295a63b4021f77b6eb21037bca94fa7f5052c943c9dcfb70588540040c350ff810a0bea
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Ziggeo Ruby Server SDK 1.06
1
+ # Ziggeo Ruby Server SDK 1.7
2
2
 
3
- 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
4
4
  two lines of code in your site, service or app. This is the Ruby Server SDK repository.
5
5
 
6
6
  Pull requests welcome.
@@ -18,30 +18,33 @@ gem "Ziggeo"
18
18
  For the client-side integration, you need to add these assets to your html file:
19
19
 
20
20
  ```html
21
- <link rel="stylesheet" href="//assets-cdn.ziggeo.com/v1-latest/ziggeo.css" />
22
- <script src="//assets-cdn.ziggeo.com/v1-latest/ziggeo.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>
23
23
  ```
24
24
 
25
25
  Then, you need to specify your api token:
26
26
  ```html
27
27
  <script>
28
- ZiggeoApi.token = "APPLICATION_TOKEN";
28
+ var ziggeoApplication = new ZiggeoApi.V2.Application({
29
+ token: "APPLICATION_TOKEN"
30
+ });
29
31
  </script>
30
32
  ```
31
33
 
32
- You can specify other global options, [see here](http://ziggeo.com/docs).
34
+ You can specify other global options, [see here](https://ziggeo.com/docs).
33
35
 
34
36
  To fire up a recorder on your page, add:
35
37
  ```html
36
- <ziggeo></ziggeo>
38
+ <ziggeorecorder></ziggeorecorder>
37
39
  ```
38
40
 
39
41
  To embed a player for an existing video, add:
40
42
  ```html
41
- <ziggeo ziggeo-video='video-token'></ziggeo>
43
+ <ziggeoplayer ziggeo-video='video-token'></ziggeoplayer>
42
44
  ```
43
45
 
44
- 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
+
45
48
 
46
49
 
47
50
  ## Server-Side Integration
@@ -56,7 +59,7 @@ You can integrate the Server SDK as follows:
56
59
  ## Server-Side Methods
57
60
 
58
61
  ### Videos
59
-
62
+
60
63
  The videos resource allows you to access all single videos. Each video may contain more than one stream.
61
64
 
62
65
 
@@ -73,7 +76,20 @@ Arguments
73
76
  - skip: *Skip the first [n] entries.*
74
77
  - reverse: *Reverse the order in which videos are returned.*
75
78
  - states: *Filter videos by state*
76
- - 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*
77
93
 
78
94
 
79
95
  #### Get
@@ -86,6 +102,31 @@ ziggeo.videos().get(token_or_key)
86
102
 
87
103
 
88
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
+
89
130
  #### Download Video
90
131
 
91
132
  Download the video data file
@@ -106,6 +147,52 @@ ziggeo.videos().download_image(token_or_key)
106
147
 
107
148
 
108
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
+
184
+ #### Apply Meta
185
+
186
+ Apply a meta profile to a video.
187
+
188
+ ```ruby
189
+ ziggeo.videos().apply_meta(token_or_key, arguments = nil)
190
+ ```
191
+
192
+ Arguments
193
+ - metaprofiletoken: *Meta Profile token (from the Meta Profiles configured for the app)*
194
+
195
+
109
196
  #### Update
110
197
 
111
198
  Update single video by token or key.
@@ -123,6 +210,23 @@ Arguments
123
210
  - expiration_days: *After how many days will this video be deleted*
124
211
 
125
212
 
213
+ #### Update Bulk
214
+
215
+ Update multiple videos by token or key.
216
+
217
+ ```ruby
218
+ ziggeo.videos().update_bulk(arguments = nil)
219
+ ```
220
+
221
+ Arguments
222
+ - tokens_or_keys: *Comma-separated list with the desired videos tokens or keys (Limit: 100 tokens or keys).*
223
+ - min_duration: *Minimal duration of video*
224
+ - max_duration: *Maximal duration of video*
225
+ - tags: *Video Tags*
226
+ - volatile: *Automatically removed this video if it remains empty*
227
+ - expiration_days: *After how many days will this video be deleted*
228
+
229
+
126
230
  #### Delete
127
231
 
128
232
  Delete a single video by token or key.
@@ -150,8 +254,23 @@ Arguments
150
254
  - volatile: *Automatically removed this video if it remains empty*
151
255
 
152
256
 
153
- ### Streams
257
+ #### Analytics
154
258
 
259
+ Get analytics for a specific videos with the given params
260
+
261
+ ```ruby
262
+ ziggeo.videos().analytics(token_or_key, arguments = nil)
263
+ ```
264
+
265
+ Arguments
266
+ - from: *A UNIX timestamp in microseconds used as the start date of the query*
267
+ - to: *A UNIX timestamp in microseconds used as the end date of the query*
268
+ - date: *A UNIX timestamp in microseconds to retrieve data from a single date. If set, it overwrites the from and to params.*
269
+ - 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*
270
+
271
+
272
+ ### Streams
273
+
155
274
  The streams resource allows you to directly access all streams associated with a single video.
156
275
 
157
276
 
@@ -197,6 +316,18 @@ ziggeo.streams().download_image(video_token_or_key, token_or_key)
197
316
 
198
317
 
199
318
 
319
+ #### Push To Service
320
+
321
+ Push a stream to a provided push service.
322
+
323
+ ```ruby
324
+ ziggeo.streams().push_to_service(video_token_or_key, token_or_key, arguments = nil)
325
+ ```
326
+
327
+ Arguments
328
+ - pushservicetoken: *Push Services's token (from the Push Services configured for the app)*
329
+
330
+
200
331
  #### Delete
201
332
 
202
333
  Delete the stream
@@ -254,7 +385,7 @@ ziggeo.streams().bind(video_token_or_key, token_or_key, arguments = nil)
254
385
 
255
386
 
256
387
  ### Authtokens
257
-
388
+
258
389
  The auth token resource allows you to manage authorization settings for video objects.
259
390
 
260
391
 
@@ -312,11 +443,297 @@ Arguments
312
443
  - grants: *Permissions this tokens grants*
313
444
 
314
445
 
446
+ ### EffectProfiles
447
+
448
+ The effect profiles resource allows you to access and create effect profiles for your app. Each effect profile may contain one process or more.
449
+
450
+
451
+ #### Create
452
+
453
+ Create a new effect profile.
454
+
455
+ ```ruby
456
+ ziggeo.effectProfiles().create(arguments = nil)
457
+ ```
458
+
459
+ Arguments
460
+ - key: *Effect profile key.*
461
+ - title: *Effect profile title.*
462
+
463
+
464
+ #### Index
465
+
466
+ Get list of effect profiles.
467
+
468
+ ```ruby
469
+ ziggeo.effectProfiles().index(arguments = nil)
470
+ ```
471
+
472
+ Arguments
473
+ - limit: *Limit the number of returned effect profiles. Can be set up to 100.*
474
+ - skip: *Skip the first [n] entries.*
475
+ - reverse: *Reverse the order in which effect profiles are returned.*
476
+
477
+
478
+ #### Get
479
+
480
+ Get a single effect profile
481
+
482
+ ```ruby
483
+ ziggeo.effectProfiles().get(token_or_key)
484
+ ```
485
+
486
+
487
+
488
+ #### Delete
489
+
490
+ Delete the effect profile
491
+
492
+ ```ruby
493
+ ziggeo.effectProfiles().delete(token_or_key)
494
+ ```
495
+
496
+
497
+
498
+ ### EffectProfileProcess
499
+
500
+ The process resource allows you to directly access all process associated with a single effect profile.
501
+
502
+
503
+ #### Index
504
+
505
+ Return all processes associated with a effect profile
506
+
507
+ ```ruby
508
+ ziggeo.effectProfileProcess().index(effect_token_or_key, arguments = nil)
509
+ ```
510
+
511
+ Arguments
512
+ - states: *Filter streams by state*
513
+
514
+
515
+ #### Get
516
+
517
+ Get a single process
518
+
519
+ ```ruby
520
+ ziggeo.effectProfileProcess().get(effect_token_or_key, token_or_key)
521
+ ```
522
+
523
+
524
+
525
+ #### Delete
526
+
527
+ Delete the process
528
+
529
+ ```ruby
530
+ ziggeo.effectProfileProcess().delete(effect_token_or_key, token_or_key)
531
+ ```
532
+
533
+
534
+
535
+ #### Create Filter Process
536
+
537
+ Create a new filter effect process
538
+
539
+ ```ruby
540
+ ziggeo.effectProfileProcess().create_filter_process(effect_token_or_key, arguments = nil)
541
+ ```
542
+
543
+ Arguments
544
+ - effect: *Effect to be applied in the process*
545
+
546
+
547
+ #### Create Watermark Process
548
+
549
+ Attaches an image to a new stream
550
+
551
+ ```ruby
552
+ ziggeo.effectProfileProcess().create_watermark_process(effect_token_or_key, arguments = nil, file = nil)
553
+ ```
554
+
555
+ Arguments
556
+ - file: *Image file to be attached*
557
+ - vertical: *Specify the vertical position of your watermark (a value between 0.0 and 1.0)*
558
+ - horizontal: *Specify the horizontal position of your watermark (a value between 0.0 and 1.0)*
559
+ - scale: *Specify the image scale of your watermark (a value between 0.0 and 1.0)*
560
+
561
+
562
+ ### MetaProfiles
563
+
564
+ The meta profiles resource allows you to access and create meta profiles for your app. Each meta profile may contain one process or more.
565
+
566
+
567
+ #### Create
568
+
569
+ Create a new meta profile.
570
+
571
+ ```ruby
572
+ ziggeo.metaProfiles().create(arguments = nil)
573
+ ```
574
+
575
+ Arguments
576
+ - key: *Meta Profile profile key.*
577
+ - title: *Meta Profile profile title.*
578
+
579
+
580
+ #### Index
581
+
582
+ Get list of meta profiles.
583
+
584
+ ```ruby
585
+ ziggeo.metaProfiles().index(arguments = nil)
586
+ ```
587
+
588
+ Arguments
589
+ - limit: *Limit the number of returned meta profiles. Can be set up to 100.*
590
+ - skip: *Skip the first [n] entries.*
591
+ - reverse: *Reverse the order in which meta profiles are returned.*
592
+
593
+
594
+ #### Get
595
+
596
+ Get a single meta profile
597
+
598
+ ```ruby
599
+ ziggeo.metaProfiles().get(token_or_key)
600
+ ```
601
+
602
+
603
+
604
+ #### Delete
605
+
606
+ Delete the meta profile
607
+
608
+ ```ruby
609
+ ziggeo.metaProfiles().delete(token_or_key)
610
+ ```
611
+
612
+
613
+
614
+ ### MetaProfileProcess
615
+
616
+ The process resource allows you to directly access all process associated with a single meta profile.
617
+
618
+
619
+ #### Index
620
+
621
+ Return all processes associated with a meta profile
622
+
623
+ ```ruby
624
+ ziggeo.metaProfileProcess().index(meta_token_or_key)
625
+ ```
626
+
627
+
628
+
629
+ #### Get
630
+
631
+ Get a single process
632
+
633
+ ```ruby
634
+ ziggeo.metaProfileProcess().get(meta_token_or_key, token_or_key)
635
+ ```
636
+
637
+
638
+
639
+ #### Delete
640
+
641
+ Delete the process
642
+
643
+ ```ruby
644
+ ziggeo.metaProfileProcess().delete(meta_token_or_key, token_or_key)
645
+ ```
646
+
647
+
648
+
649
+ #### Create Video Analysis Process
650
+
651
+ Create a new video analysis meta process
652
+
653
+ ```ruby
654
+ ziggeo.metaProfileProcess().create_video_analysis_process(meta_token_or_key)
655
+ ```
656
+
657
+
658
+
659
+ #### Create Audio Transcription Process
660
+
661
+ Create a new audio transcription meta process
662
+
663
+ ```ruby
664
+ ziggeo.metaProfileProcess().create_audio_transcription_process(meta_token_or_key)
665
+ ```
666
+
667
+
668
+
669
+ #### Create Nsfw Process
670
+
671
+ Create a new nsfw filter meta process
672
+
673
+ ```ruby
674
+ ziggeo.metaProfileProcess().create_nsfw_process(meta_token_or_key, arguments = nil)
675
+ ```
676
+
677
+ Arguments
678
+ - nsfw_action: *One of the following three: approve, reject, nothing.*
679
+
680
+
681
+ ### Webhooks
682
+
683
+ The webhooks resource allows you to create or delete webhooks related to a given application.
684
+
685
+
686
+ #### Create
687
+
688
+ Create a new webhook for the given url to catch the given events.
689
+
690
+ ```ruby
691
+ ziggeo.webhooks().create(arguments = nil)
692
+ ```
693
+
694
+ Arguments
695
+ - target_url: *The url that will catch the events*
696
+ - encoding: *Data encoding to be used by the webhook to send the events.*
697
+ - events: *Comma-separated list of the events the webhook will catch. They must be valid webhook type events.*
698
+
699
+
700
+ #### Delete
701
+
702
+ Delete a webhook using its URL.
703
+
704
+ ```ruby
705
+ ziggeo.webhooks().delete(arguments = nil)
706
+ ```
707
+
708
+ Arguments
709
+ - target_url: *The url that will catch the events*
710
+
711
+
712
+ ### Analytics
713
+
714
+ The analytics resource allows you to access the analytics for the given application
715
+
716
+
717
+ #### Get
718
+
719
+ Get analytics for the given params
720
+
721
+ ```ruby
722
+ ziggeo.analytics().get(arguments = nil)
723
+ ```
724
+
725
+ Arguments
726
+ - from: *A UNIX timestamp in microseconds used as the start date of the query*
727
+ - to: *A UNIX timestamp in microseconds used as the end date of the query*
728
+ - date: *A UNIX timestamp in microseconds to retrieve data from a single date. If set, it overwrites the from and to params.*
729
+ - 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*
730
+
731
+
315
732
 
316
733
 
317
734
 
318
735
  ## License
319
736
 
320
- Copyright (c) 2013-2016 Ziggeo
737
+ Copyright (c) 2013-2018 Ziggeo
321
738
 
322
- Apache 2.0 License
739
+ 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
@@ -9,18 +9,46 @@ class ZiggeoConnect
9
9
  end
10
10
 
11
11
  def request(method, path, data = nil, file = nil)
12
- 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)
13
21
  auth = { username: @application.token, password: @application.private_key }
22
+ timeout_in_seconds = @application.config.request_timeout.to_i
23
+
14
24
  method.downcase!
15
25
  allowed_methods = %w(get post delete)
16
26
  return unless allowed_methods.include?(method)
17
27
  if (file.nil?)
18
- HTTParty.send(method, url.to_s, body: data, basic_auth: auth).body
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
19
41
  else
20
42
  data = data.nil? ? {} : data;
21
43
  data["file"] = File.new(file)
22
- HTTMultiParty.send(method, url.to_s, body: data, basic_auth: auth).body
23
- end
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
24
52
  end
25
53
 
26
54
  def requestJSON(method, path, data = nil, file = nil)
@@ -51,4 +79,12 @@ class ZiggeoConnect
51
79
  return self.requestJSON("DELETE", path, data, file)
52
80
  end
53
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
+
54
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,30 @@ 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
+
47
+ def apply_meta(token_or_key, data = nil)
48
+ return @application.connect.postJSON('/videos/' + token_or_key + '/metaprofile', data)
49
+ end
50
+
23
51
  def update(token_or_key, data = nil)
24
52
  return @application.connect.postJSON('/videos/' + token_or_key + '', data)
25
53
  end
26
54
 
55
+ def update_bulk(data = nil)
56
+ return @application.connect.postJSON('/videos/update_bulk', data)
57
+ end
58
+
27
59
  def delete(token_or_key)
28
60
  return @application.connect.delete('/videos/' + token_or_key + '')
29
61
  end
@@ -32,4 +64,8 @@ class ZiggeoVideos
32
64
  return @application.connect.postJSON('/videos/', data, file)
33
65
  end
34
66
 
67
+ def analytics(token_or_key, data = nil)
68
+ return @application.connect.postJSON('/videos/' + token_or_key + '/analytics', data)
69
+ end
70
+
35
71
  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,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Ziggeo
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.06'
4
+ version: '1.7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ziggeo, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-11 00:00:00.000000000 Z
11
+ date: 2018-08-27 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
27
  - !ruby/object:Gem::Dependency
28
28
  name: httmultiparty
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: The Ziggeo Ruby and Rails Server SDK.
@@ -45,17 +45,23 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - README.md
49
+ - lib/Ziggeo.rb
50
+ - lib/classes/ZiggeoAnalytics.rb
48
51
  - lib/classes/ZiggeoAuth.rb
49
52
  - lib/classes/ZiggeoAuthtokens.rb
50
53
  - lib/classes/ZiggeoConfig.rb
51
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
52
59
  - lib/classes/ZiggeoStreams.rb
53
60
  - lib/classes/ZiggeoVideos.rb
54
- - lib/Ziggeo.rb
55
- - README.md
56
- homepage: http://ziggeo.com
61
+ - lib/classes/ZiggeoWebhooks.rb
62
+ homepage: https://ziggeo.com
57
63
  licenses:
58
- - Apache 2.0
64
+ - Apache-2.0
59
65
  metadata: {}
60
66
  post_install_message:
61
67
  rdoc_options: []
@@ -63,17 +69,17 @@ require_paths:
63
69
  - lib
64
70
  required_ruby_version: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - '>='
72
+ - - ">="
67
73
  - !ruby/object:Gem::Version
68
74
  version: '0'
69
75
  required_rubygems_version: !ruby/object:Gem::Requirement
70
76
  requirements:
71
- - - '>='
77
+ - - ">="
72
78
  - !ruby/object:Gem::Version
73
79
  version: '0'
74
80
  requirements: []
75
81
  rubyforge_project:
76
- rubygems_version: 2.0.14
82
+ rubygems_version: 2.5.2.3
77
83
  signing_key:
78
84
  specification_version: 4
79
85
  summary: The Ziggeo ServerSDK gem.