cielo24 0.0.13 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cielo24.rb +10 -11
- data/lib/cielo24/actions.rb +249 -245
- data/lib/cielo24/enums.rb +153 -145
- data/lib/cielo24/options.rb +219 -219
- data/lib/cielo24/version.rb +2 -2
- data/lib/cielo24/web_utils.rb +63 -65
- metadata +32 -22
- checksums.yaml +0 -7
data/lib/cielo24/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Cielo24
|
2
|
-
VERSION =
|
1
|
+
module Cielo24
|
2
|
+
VERSION = '0.0.15'
|
3
3
|
end
|
data/lib/cielo24/web_utils.rb
CHANGED
@@ -1,66 +1,64 @@
|
|
1
|
-
module Cielo24
|
2
|
-
class WebUtils
|
3
|
-
|
4
|
-
require 'json'
|
5
|
-
require 'httpclient'
|
6
|
-
require 'timeout'
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
http_client =
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
response
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
end
|
65
|
-
end
|
1
|
+
module Cielo24
|
2
|
+
class WebUtils
|
3
|
+
|
4
|
+
require 'json'
|
5
|
+
require 'httpclient'
|
6
|
+
require 'timeout'
|
7
|
+
require 'logger'
|
8
|
+
include JSON
|
9
|
+
|
10
|
+
BASIC_TIMEOUT = 60 # seconds (1 minute)
|
11
|
+
DOWNLOAD_TIMEOUT = 300 # seconds (5 minutes)
|
12
|
+
UPLOAD_TIMEOUT = 60*60*24*7 # seconds (1 week)
|
13
|
+
LOGGER = Logger.new(STDOUT)
|
14
|
+
|
15
|
+
def self.get_json(uri, method, timeout, query=nil, headers=nil, body=nil)
|
16
|
+
response = http_request(uri, method, timeout, query, headers, body)
|
17
|
+
return JSON.parse(response)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.http_request(uri, method, timeout, query=nil, headers=nil, body=nil)
|
21
|
+
http_client = HTTPClient.new
|
22
|
+
http_client.cookie_manager = nil
|
23
|
+
http_client.send_timeout = UPLOAD_TIMEOUT
|
24
|
+
LOGGER.info(uri + (query.nil? ? '' : '?' + URI.encode_www_form(query)))
|
25
|
+
|
26
|
+
# Timeout block:
|
27
|
+
begin
|
28
|
+
# Error is raised if the following block fails to execute in 'timeout' sec:
|
29
|
+
Timeout.timeout(timeout) { # nil timeout = infinite
|
30
|
+
|
31
|
+
response = http_client.request(method, uri, query, body, headers, nil)
|
32
|
+
# Handle web errors
|
33
|
+
if response.status_code == 200 or response.status_code == 204
|
34
|
+
return response.body
|
35
|
+
else
|
36
|
+
json = JSON.parse(response.body)
|
37
|
+
raise WebError.new(json['ErrorType'], json['ErrorComment'])
|
38
|
+
end
|
39
|
+
|
40
|
+
}
|
41
|
+
rescue Timeout::Error
|
42
|
+
raise TimeoutError.new('The HTTP session has timed out.')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class WebError < StandardError
|
48
|
+
attr_reader :type
|
49
|
+
def initialize(type, comment)
|
50
|
+
super(comment)
|
51
|
+
@type = type
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_s
|
55
|
+
return @type + ' - ' + super.to_s
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class TimeoutError < StandardError
|
60
|
+
def initialize(message)
|
61
|
+
super(message)
|
62
|
+
end
|
63
|
+
end
|
66
64
|
end
|
metadata
CHANGED
@@ -1,71 +1,80 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cielo24
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- cielo24
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2015-08-03 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
21
|
+
version: 1.10.6
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
29
|
+
version: 1.10.6
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: rake
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
37
|
+
version: 10.4.2
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ~>
|
39
44
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
45
|
+
version: 10.4.2
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: httpclient
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- -
|
51
|
+
- - ~>
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
53
|
+
version: 2.6.0.1
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - ~>
|
53
60
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
61
|
+
version: 2.6.0.1
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: hashie
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
|
-
- -
|
67
|
+
- - ~>
|
60
68
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
69
|
+
version: 3.4.2
|
62
70
|
type: :runtime
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
|
-
- -
|
75
|
+
- - ~>
|
67
76
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
77
|
+
version: 3.4.2
|
69
78
|
description: This gem allows you to interact with the cielo24 public REST API.
|
70
79
|
email:
|
71
80
|
- support@cielo24.com
|
@@ -73,33 +82,34 @@ executables: []
|
|
73
82
|
extensions: []
|
74
83
|
extra_rdoc_files: []
|
75
84
|
files:
|
76
|
-
- lib/cielo24/actions.rb
|
77
|
-
- lib/cielo24/enums.rb
|
78
85
|
- lib/cielo24/options.rb
|
79
|
-
- lib/cielo24/version.rb
|
80
86
|
- lib/cielo24/web_utils.rb
|
87
|
+
- lib/cielo24/version.rb
|
88
|
+
- lib/cielo24/enums.rb
|
89
|
+
- lib/cielo24/actions.rb
|
81
90
|
- lib/cielo24.rb
|
82
91
|
homepage: http://cielo24.com
|
83
92
|
licenses: []
|
84
|
-
metadata: {}
|
85
93
|
post_install_message:
|
86
94
|
rdoc_options: []
|
87
95
|
require_paths:
|
88
96
|
- lib
|
89
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
90
99
|
requirements:
|
91
|
-
- - '>='
|
100
|
+
- - ! '>='
|
92
101
|
- !ruby/object:Gem::Version
|
93
102
|
version: '0'
|
94
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
95
105
|
requirements:
|
96
|
-
- - '>='
|
106
|
+
- - ! '>='
|
97
107
|
- !ruby/object:Gem::Version
|
98
108
|
version: '0'
|
99
109
|
requirements: []
|
100
110
|
rubyforge_project:
|
101
|
-
rubygems_version:
|
111
|
+
rubygems_version: 1.8.23
|
102
112
|
signing_key:
|
103
|
-
specification_version:
|
113
|
+
specification_version: 3
|
104
114
|
summary: Cielo24 API gem.
|
105
115
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: f88e51bd3f448a402c5f811d76dbf0f5870074a0
|
4
|
-
data.tar.gz: 9b826d4adc30c34d66b497e0b8cec264c82461f3
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: e0113e5e3ef2e0083f4732b3334ef1985e16c6418d3beac389f9eab7b4115b99006ab55bc452d37a3e0298da6ddd736e4501fe764a77720f0b08a9e0a054a0b8
|
7
|
-
data.tar.gz: fab07a40a2ab041b348d4d56dd5607f076e3313789f45e786ebb6cec5751fee714ce942d373f33eccc590912e3b50975084dca27d4b52a3d3822f91cbe2f4a4f
|