elibri_watermarking 0.7.3 → 0.7.4

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.
@@ -22,6 +22,8 @@ module ElibriWatermarking
22
22
  supplier = args[0]
23
23
  client_symbol = args[1]
24
24
  customer_ip = args[2]
25
+ ssl = args[3]
26
+ ssl = true if ssl.nil?
25
27
  ident =~ /^[0-9]+$/ ? ident_type = 'isbn' : ident_type = 'record_reference'
26
28
  raise WrongFormats.new if formats.is_a?(String) && !formats =~ /^(epub|mobi|pdf|,)+$/
27
29
  raise WrongFormats.new if formats.is_a?(Array) && ((formats - ['epub','mobi','pdf']) != [] || (formats & ['epub','mobi','pdf']).count < 1)
@@ -41,13 +43,15 @@ module ElibriWatermarking
41
43
  req = Net::HTTP::Post.new(uri.path)
42
44
  req.set_form_data(data)
43
45
  http = Net::HTTP.new(uri.host, uri.port)
44
- http.use_ssl = true
45
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
46
+ if ssl
47
+ http.use_ssl = true
48
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
49
+ end
46
50
  res = http.start {|http| http.request(req) }
47
51
  return validate_response(res)
48
52
  end
49
53
 
50
- def deliver(trans_id)
54
+ def deliver(trans_id, ssl=true)
51
55
  uri = URI(self.url + '/deliver')
52
56
  timestamp = Time.now.to_i
53
57
  sig = CGI.escape(Base64.encode64(OpenSSL::HMAC.digest('sha1', timestamp.to_s, self.secret)).strip)
@@ -55,13 +59,15 @@ module ElibriWatermarking
55
59
  req = Net::HTTP::Post.new(uri.path)
56
60
  req.set_form_data(data)
57
61
  http = Net::HTTP.new(uri.host, uri.port)
58
- http.use_ssl = true
59
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
62
+ if ssl
63
+ http.use_ssl = true
64
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
65
+ end
60
66
  res = http.start {|http| http.request(req) }
61
67
  return validate_response(res)
62
68
  end
63
69
 
64
- def retry(trans_id)
70
+ def retry(trans_id, ssl=true)
65
71
  uri = URI(self.url + '/retry')
66
72
  timestamp = Time.now.to_i
67
73
  sig = CGI.escape(Base64.encode64(OpenSSL::HMAC.digest('sha1', timestamp.to_s, self.secret)).strip)
@@ -69,13 +75,15 @@ module ElibriWatermarking
69
75
  req = Net::HTTP::Post.new(uri.path)
70
76
  req.set_form_data(data)
71
77
  http = Net::HTTP.new(uri.host, uri.port)
72
- http.use_ssl = true
73
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
78
+ if ssl
79
+ http.use_ssl = true
80
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
81
+ end
74
82
  res = http.start {|http| http.request(req) }
75
83
  return validate_response(res)
76
84
  end
77
85
 
78
- def available_files
86
+ def available_files(ssl=true)
79
87
  uri = URI(self.url + '/available_files.json')
80
88
  timestamp = Time.now.to_i
81
89
  sig = CGI.escape(Base64.encode64(OpenSSL::HMAC.digest('sha1', timestamp.to_s, self.secret)).strip)
@@ -83,13 +91,15 @@ module ElibriWatermarking
83
91
  req = Net::HTTP::Get.new(uri.path)
84
92
  req.set_form_data(data)
85
93
  http = Net::HTTP.new(uri.host, uri.port)
86
- http.use_ssl = true
87
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
94
+ if ssl
95
+ http.use_ssl = true
96
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
97
+ end
88
98
  res = http.start {|http| http.request(req) }
89
99
  return JSON.parse(validate_response(res))
90
100
  end
91
101
 
92
- def soon_available_files
102
+ def soon_available_files(ssl=true)
93
103
  uri = URI(self.url + '/soon_available_files.json')
94
104
  timestamp = Time.now.to_i
95
105
  sig = CGI.escape(Base64.encode64(OpenSSL::HMAC.digest('sha1', timestamp.to_s, self.secret)).strip)
@@ -97,13 +107,15 @@ module ElibriWatermarking
97
107
  req = Net::HTTP::Get.new(uri.path)
98
108
  req.set_form_data(data)
99
109
  http = Net::HTTP.new(uri.host, uri.port)
100
- http.use_ssl = true
101
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
110
+ if ssl
111
+ http.use_ssl = true
112
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
113
+ end
102
114
  res = http.start {|http| http.request(req) }
103
115
  return JSON.parse(validate_response(res))
104
116
  end
105
117
 
106
- def check_suppliers(ident)
118
+ def check_suppliers(ident, ssl=true)
107
119
  ident =~ /^[0-9]+$/ ? ident_type = 'isbn' : ident_type = 'record_reference'
108
120
  uri = URI(self.url + '/check_suppliers')
109
121
  timestamp = Time.now.to_i
@@ -112,13 +124,15 @@ module ElibriWatermarking
112
124
  req = Net::HTTP::Get.new(uri.path)
113
125
  req.set_form_data(data)
114
126
  http = Net::HTTP.new(uri.host, uri.port)
115
- http.use_ssl = true
116
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
127
+ if ssl
128
+ http.use_ssl = true
129
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
130
+ end
117
131
  res = http.start {|http| http.request(req) }
118
132
  return validate_response(res).split(",").map { |x| x.to_i }
119
133
  end
120
134
 
121
- def get_supplier(id)
135
+ def get_supplier(id, ssl=true)
122
136
  uri = URI(self.url + '/get_supplier')
123
137
  timestamp = Time.now.to_i
124
138
  sig = CGI.escape(Base64.encode64(OpenSSL::HMAC.digest('sha1', timestamp.to_s, self.secret)).strip)
@@ -126,8 +140,10 @@ module ElibriWatermarking
126
140
  req = Net::HTTP::Get.new(uri.path)
127
141
  req.set_form_data(data)
128
142
  http = Net::HTTP.new(uri.host, uri.port)
129
- http.use_ssl = true
130
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
143
+ if ssl
144
+ http.use_ssl = true
145
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
146
+ end
131
147
  res = http.start {|http| http.request(req) }
132
148
  return validate_response(res)
133
149
  end
@@ -135,7 +151,8 @@ module ElibriWatermarking
135
151
  def watermark_and_deliver(ident, formats, visible_watermark, title_postfix, *args)
136
152
  supplier = args[0]
137
153
  client_symbol = args[1]
138
- trans_id = watermark(ident, formats, visible_watermark, title_postfix, supplier, client_symbol)
154
+ ssl = args[2]
155
+ trans_id = watermark(ident, formats, visible_watermark, title_postfix, supplier, client_symbol, ssl)
139
156
  return trans_id if deliver(trans_id) == "OK"
140
157
  end
141
158
 
@@ -1,3 +1,3 @@
1
1
  module ElibriWatermarking
2
- VERSION = "0.7.3"
2
+ VERSION = "0.7.4"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elibri_watermarking
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 3
10
- version: 0.7.3
9
+ - 4
10
+ version: 0.7.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Piotr Szmielew