elibri_watermarking 0.9.8 → 0.9.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6e4394f2e780277a4f1af2f3b7f300eb1d2f227bbd8754f119fdd703d6579ad3
4
+ data.tar.gz: 181e49e2706b89a0d4e91a0c62e5e6dee253abb091643d0779843d95463a0903
5
+ SHA512:
6
+ metadata.gz: c5dd5582b26c565803ea05503c070dff608aa115eac3d875c30c183117ebd64fc2e3060665f0b1a2081be5a028f71df6c8f31d8f0fa6d72c022c15d4a9cd95aa
7
+ data.tar.gz: 30945672795695797bbe608d8da37a2b27f82729ca20497b0f605d659bd8d45ed786a8aa269c65b3115cf50a4fd006f4200e383c5c913be92d11d5e274e2a251
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 eLibri
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -10,16 +10,16 @@ require 'json'
10
10
 
11
11
  module ElibriWatermarking
12
12
  class Client
13
-
13
+
14
14
  attr_accessor :token, :secret, :logger, :servers
15
-
15
+
16
16
  def initialize(token, secret, servers = nil)
17
17
  self.token = token
18
18
  self.secret = secret
19
19
  self.servers = servers
20
20
  end
21
-
22
- def watermark(ident, formats, visible_watermark, title_postfix, customer_ip, client_symbol = nil, supplier = nil,
21
+
22
+ def watermark(ident, formats, visible_watermark, title_postfix, customer_ip, client_symbol = nil, supplier = nil,
23
23
  delivery_form = nil, price = nil, promotion_id = nil, low_priority = false)
24
24
  if ident =~ /^[0-9]+$/ && ident.size == 13
25
25
  ident_type = 'isbn'
@@ -40,7 +40,7 @@ module ElibriWatermarking
40
40
  data.merge!(:low_priority => low_priority) if low_priority
41
41
  try_with_different_servers('watermark') do |uri|
42
42
  return get_response_from_server(uri, data, Net::HTTP::Post)
43
- end
43
+ end
44
44
  end
45
45
 
46
46
  def deliver(trans_id, low_priority = false)
@@ -70,7 +70,7 @@ module ElibriWatermarking
70
70
  return JSON.parse(get_response_from_server(uri, {}, Net::HTTP::Get))
71
71
  end
72
72
  end
73
-
73
+
74
74
  def soon_unavailable_files
75
75
  try_with_different_servers('soon_unavailable_files.json') do |uri|
76
76
  return JSON.parse(get_response_from_server(uri, {}, Net::HTTP::Get))
@@ -85,22 +85,30 @@ module ElibriWatermarking
85
85
  end
86
86
 
87
87
  def get_supplier(id)
88
- get_response_from_server(URI('https://www.elibri.com.pl/watermarking/get_supplier'), {:id => id}, Net::HTTP::Get)
88
+ get_response_from_server(construct_main_server_url('/watermarking/get_supplier'), {:id => id}, Net::HTTP::Get)
89
89
  #to chyba moze byc tylko z glownego serwera?
90
90
  end
91
-
91
+
92
92
  def check_api
93
93
  try_with_different_servers('ver') do |uri|
94
94
  return get_response_from_server(uri, {}, Net::HTTP::Get)
95
95
  end
96
96
  end
97
-
97
+
98
98
  def new_complaint(trans_id, reason)
99
- get_response_from_server(URI('https://www.elibri.com.pl/api_complaints'), {:trans_id => trans_id, :reason => reason}, Net::HTTP::Post)
99
+ get_response_from_server(construct_main_server_url('/api_complaints'), {:trans_id => trans_id, :reason => reason}, Net::HTTP::Post)
100
100
  end
101
101
 
102
102
  protected
103
103
 
104
+ def construct_main_server_url(path)
105
+ if server.starts_with?("https:")
106
+ URI("#{server}#{path}")
107
+ else
108
+ URI("https://www.elibri.com.pl#{path}")
109
+ end
110
+ end
111
+
104
112
  def get_response_from_server(uri, data, request_class)
105
113
  logger.info("doing #{uri}") if logger
106
114
  timestamp = Time.now.to_i.to_s
@@ -118,7 +126,11 @@ module ElibriWatermarking
118
126
  txt_record = self.servers || Net::DNS::Resolver.start("transactional-servers.elibri.com.pl", Net::DNS::TXT).answer.first.txt
119
127
  servers = txt_record.split(",").sort_by { rand }.map(&:strip)
120
128
  servers.each do |server|
121
- uri = URI("https://#{server}.elibri.com.pl/watermarking/#{action}")
129
+ if server.starts_with?("https:")
130
+ uri = URI("#{server}/watermarking/#{action}")
131
+ else
132
+ uri = URI("https://#{server}.elibri.com.pl/watermarking/#{action}")
133
+ end
122
134
  logger.info("trying #{uri}") if logger
123
135
  begin
124
136
  yield uri
@@ -145,8 +157,9 @@ module ElibriWatermarking
145
157
  raise RequestExpired.new(res.body)
146
158
  when "Net::HTTPOK"
147
159
  return res.body
160
+ else
161
+ raise ServerException.new(res.body)
148
162
  end
149
- return res.body
150
163
  end
151
164
  end
152
165
  end
@@ -1,3 +1,3 @@
1
1
  module ElibriWatermarking
2
- VERSION = "0.9.8"
2
+ VERSION = "0.9.11"
3
3
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elibri_watermarking
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.8
5
- prerelease:
4
+ version: 0.9.11
6
5
  platform: ruby
7
6
  authors:
8
7
  - Piotr Szmielew
@@ -10,38 +9,34 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2014-12-08 00:00:00.000000000 Z
12
+ date: 2022-07-04 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rake
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - ">="
21
19
  - !ruby/object:Gem::Version
22
20
  version: '0'
23
21
  type: :development
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - ">="
29
26
  - !ruby/object:Gem::Version
30
27
  version: '0'
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: net-dns
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - ">="
37
33
  - !ruby/object:Gem::Version
38
34
  version: '0'
39
35
  type: :runtime
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - ">="
45
40
  - !ruby/object:Gem::Version
46
41
  version: '0'
47
42
  description: Gem designed to help in use of Elibri watermarking API.
@@ -52,8 +47,9 @@ executables: []
52
47
  extensions: []
53
48
  extra_rdoc_files: []
54
49
  files:
55
- - .gitignore
50
+ - ".gitignore"
56
51
  - Gemfile
52
+ - LICENSE
57
53
  - README.md
58
54
  - Rakefile
59
55
  - elibri_watermarking.gemspec
@@ -63,27 +59,24 @@ files:
63
59
  - lib/elibri_watermarking/version.rb
64
60
  homepage: http://elibri.com.pl
65
61
  licenses: []
62
+ metadata: {}
66
63
  post_install_message:
67
64
  rdoc_options: []
68
65
  require_paths:
69
66
  - lib
70
67
  required_ruby_version: !ruby/object:Gem::Requirement
71
- none: false
72
68
  requirements:
73
- - - ! '>='
69
+ - - ">="
74
70
  - !ruby/object:Gem::Version
75
71
  version: '0'
76
72
  required_rubygems_version: !ruby/object:Gem::Requirement
77
- none: false
78
73
  requirements:
79
- - - ! '>='
74
+ - - ">="
80
75
  - !ruby/object:Gem::Version
81
76
  version: '0'
82
77
  requirements: []
83
- rubyforge_project: elibri_watermarking
84
- rubygems_version: 1.8.23
78
+ rubygems_version: 3.1.6
85
79
  signing_key:
86
- specification_version: 3
80
+ specification_version: 4
87
81
  summary: Gem designed to help in use of Elibri watermarking API.
88
82
  test_files: []
89
- has_rdoc: