Ziggeo 1.15 → 1.17

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: 7c24a8a8b298521892c34a16986009d04fe70715
4
- data.tar.gz: 06ccd77a9d10738e9d1df23429acd2caba35a211
3
+ metadata.gz: 32e29236f72378b9a8832c2f04cb79f409db8006
4
+ data.tar.gz: b794253cb141cefddf1cdbe4a3ee1c83055db231
5
5
  SHA512:
6
- metadata.gz: 7001e5455e4c0c9681cdbb13779c1e0e0f12e0e583410543f08bdef5c4242b54e43e8e665b1d00e64e5aab08a177b6932296082945685f97436609ddca9cc54a
7
- data.tar.gz: 3359a648fc52b7ddb22db9066c41986a83ffc95507004432cf2c8ec43f971e2173e06986cbdbd5589631e9eda3facb463566668478067fab47e8a3dd3e07d89f
6
+ metadata.gz: 5875a8d9040ba0a92b70416032f4081ad167a4c87f39a768d2727832b0c9994bc79121b84ae09cd0049eb3529dd3f8965e45b4b2cd2529d561b66a76fac2fa23
7
+ data.tar.gz: 84ea85ac18802c81fad122f196dab73e67656a03c15dc1d3b8f8c106921a6c54b691f9988cb46788a4b4a9c8bbec409e3f04d0d6039ad44e6f6dcead700244eb
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Ziggeo Ruby Server SDK 1.15
1
+ # Ziggeo Ruby Server SDK 1.17
2
2
 
3
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.
@@ -29,7 +29,7 @@ Then, you need to specify your api token:
29
29
  </script>
30
30
  ```
31
31
 
32
- You can specify other global options, [see here](http://ziggeo.com/docs).
32
+ You can specify other global options, [see here](https://ziggeo.com/docs).
33
33
 
34
34
  To fire up a recorder on your page, add:
35
35
  ```html
@@ -41,7 +41,7 @@ To embed a player for an existing video, add:
41
41
  <ziggeo ziggeo-video='video-token'></ziggeo>
42
42
  ```
43
43
 
44
- For the full documentation, please visit [ziggeo.com](http://ziggeo.com/docs).
44
+ For the full documentation, please visit [ziggeo.com](https://ziggeo.com/docs).
45
45
 
46
46
 
47
47
  ## Server-Side Integration
@@ -341,6 +341,6 @@ Arguments
341
341
 
342
342
  ## License
343
343
 
344
- Copyright (c) 2013-2016 Ziggeo
344
+ Copyright (c) 2013-2017 Ziggeo
345
345
 
346
346
  Apache 2.0 License
@@ -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,22 +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
28
  if (method == "get")
19
- HTTParty.send(method, url.to_s, query: data, basic_auth: auth).body
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
20
34
  else
21
- HTTParty.send(method, url.to_s, body: data, basic_auth: auth).body
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
22
40
  end
23
41
  else
24
42
  data = data.nil? ? {} : data;
25
43
  data["file"] = File.new(file)
26
- HTTMultiParty.send(method, url.to_s, body: data, basic_auth: auth).body
27
- 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
28
52
  end
29
53
 
30
54
  def requestJSON(method, path, data = nil, file = nil)
@@ -55,4 +79,12 @@ class ZiggeoConnect
55
79
  return self.requestJSON("DELETE", path, data, file)
56
80
  end
57
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
+
58
90
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Ziggeo
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.15'
4
+ version: '1.17'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ziggeo, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-04 00:00:00.000000000 Z
11
+ date: 2017-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -53,7 +53,7 @@ files:
53
53
  - lib/classes/ZiggeoVideos.rb
54
54
  - lib/Ziggeo.rb
55
55
  - README.md
56
- homepage: http://ziggeo.com
56
+ homepage: https://ziggeo.com
57
57
  licenses:
58
58
  - Apache 2.0
59
59
  metadata: {}