elibri_watermarking 0.5.0 → 0.7.3
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.
- data/README.md +12 -11
- data/lib/elibri_watermarking/client.rb +61 -6
- data/lib/elibri_watermarking/version.rb +1 -1
- metadata +48 -37
data/README.md
CHANGED
|
@@ -33,26 +33,27 @@ client = ElibriWatermarking::Client.new('token', 'secret')
|
|
|
33
33
|
|
|
34
34
|
Biblioteka daje nam do dyspozycji parę metod, odpowiadających wywołaniom metod API watermarkingu elibri:
|
|
35
35
|
|
|
36
|
-
* watermark (przyjmuje parametry: identyfikator [ISBN bez myślników lub record_reference], formaty [zapisana po przecinku lista formatów do watermarkingu - najcześciej "epub,mobi"], widoczny watermark [tekst widoczny na końcu każdego rozdziału], dopisek [krótki tekst dopisany do tytułu], zwraca identyfikator transakcji, który klient zobowiązany jest zapisać i przechowywać) - wywołuje żądanie watermarku na podanym produkcie, w podanych formatach
|
|
36
|
+
* watermark (przyjmuje parametry: identyfikator [ISBN bez myślników lub record_reference], formaty [zapisana po przecinku lista formatów do watermarkingu - najcześciej "epub,mobi"], widoczny watermark [tekst widoczny na końcu każdego rozdziału], dopisek [krótki tekst dopisany do tytułu], supplier [numeryczny identyfikator dostawcy pliki], client_symbol [alfanumeryczny identyfikator zapisany przy transakcji], customer_ip [ip klienta końcowego, do celów statystycznych] - zwraca identyfikator transakcji, który klient zobowiązany jest zapisać i przechowywać) - wywołuje żądanie watermarku na podanym produkcie, w podanych formatach
|
|
37
37
|
* deliver (przyjmuje jeden parametr: identifykator transacji [otrzymany od watermark]) - wywołuje żądanie dostarczenia zwatermarkowanego pliku do bucketu klienta na s3
|
|
38
38
|
* watermark_and_deliver (przyjmuje parametry identyczne jak watermark, zwraca identyfikator transacji, który klient zobowiązany jest zapisać i przechowywać) - wywołuje watermarkowanie pliku, a następnie żąda jego dostarczenia do bucketu klienta na s3
|
|
39
39
|
* retry (przyjmuje jako parametr identyfikator transakcji, zwraca identyfikator nowej transakcji) - wywołuje żądanie ponowienia watermarkingu pliku, który został już ściągnięty (uwaga - sklep jest zobowiązany do przetrzymywanie zwatermarkowanego pliku przynajmniej przez 7 dni, dopiero po tym czasie możliwe jest wywołanie retry). Watermarking wykonywany jest z identycznymi parametrami, jak poprzedni. Klient zobowiązany jest zapisać i przechowywać nowy identyfikator transakcji. Po komendzie retry, niezbędne jest wywołanie komendy deliver w celu dostarczeni pliku do bucketu s3. Uwaga! Każdą transakcję retryować mozna tylko raz - w przypadku kolejnego żądania retry, konieczne jest podanie identyfikatora transakcji otrzymanego od poprzedniej komendy retry.
|
|
40
40
|
* available_files - zwraca listę dostępnych do watermarkingu przez klienta plików. Pliki są zwracane w postaci tablicy hashów, postaci:
|
|
41
41
|
```ruby
|
|
42
42
|
[
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
43
|
+
{
|
|
44
|
+
:record_reference => 'a'
|
|
45
|
+
:publisher_name => 'b'
|
|
46
|
+
:publisher_id => 1
|
|
47
|
+
:isbn => '1234'
|
|
48
|
+
:title => 'Tytuł',
|
|
49
|
+
:formats => ["epub", "mobi"]
|
|
50
|
+
:available_date => "data od kiedy plik jest dostępny - jeśli pole nie występuje, znaczy to, że plik jest dostępny"
|
|
51
|
+
:suppliers => [1, 2, 3] #tablica zawierająca identyfikatora dostawców, mogących dostarczyć plik dla danego klienta
|
|
53
52
|
}
|
|
54
53
|
]
|
|
55
54
|
```
|
|
55
|
+
* check_suppliers (przyjmuje jeden parametr: identyfikator [ISBN bez myślników lub record_reference]) - zwraca listę dostawców danego pliku, w postaci tablicy zawierającej numeryczne identyfikatory dostawców
|
|
56
|
+
* get_supplier (przyjmuje jeden parametr: numeryczny identyfikator dostawcy w systemie eLibri) - zwraca nazwę dostawcy o podanym identyfikatorze
|
|
56
57
|
|
|
57
58
|
## Błędy
|
|
58
59
|
|
|
@@ -18,16 +18,26 @@ module ElibriWatermarking
|
|
|
18
18
|
self.url = url
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
def watermark(ident, formats, visible_watermark, title_postfix)
|
|
21
|
+
def watermark(ident, formats, visible_watermark, title_postfix, *args)
|
|
22
|
+
supplier = args[0]
|
|
23
|
+
client_symbol = args[1]
|
|
24
|
+
customer_ip = args[2]
|
|
22
25
|
ident =~ /^[0-9]+$/ ? ident_type = 'isbn' : ident_type = 'record_reference'
|
|
23
|
-
raise WrongFormats.new if formats.is_a?(String) && !formats =~ /^(epub|mobi|,)+$/
|
|
24
|
-
raise WrongFormats.new if formats.is_a?(Array) && (formats
|
|
26
|
+
raise WrongFormats.new if formats.is_a?(String) && !formats =~ /^(epub|mobi|pdf|,)+$/
|
|
27
|
+
raise WrongFormats.new if formats.is_a?(Array) && ((formats - ['epub','mobi','pdf']) != [] || (formats & ['epub','mobi','pdf']).count < 1)
|
|
25
28
|
uri = URI(self.url + '/watermark')
|
|
26
29
|
formats = formats.join(",") if formats.is_a?(Array)
|
|
27
30
|
timestamp = Time.now.to_i
|
|
28
31
|
sig = CGI.escape(Base64.encode64(OpenSSL::HMAC.digest('sha1', timestamp.to_s, self.secret)).strip)
|
|
29
32
|
data = {ident_type => ident, 'formats' => formats, 'visible_watermark' => visible_watermark,
|
|
30
|
-
'title_postfix' => title_postfix, 'stamp' => timestamp, 'sig' => sig, 'token' => self.token
|
|
33
|
+
'title_postfix' => title_postfix, 'stamp' => timestamp, 'sig' => sig, 'token' => self.token,
|
|
34
|
+
'client_symbol' => client_symbol}
|
|
35
|
+
if supplier
|
|
36
|
+
data.merge!(:supplier => supplier)
|
|
37
|
+
end
|
|
38
|
+
if customer_ip
|
|
39
|
+
data.merge!(:customer_ip => customer_ip)
|
|
40
|
+
end
|
|
31
41
|
req = Net::HTTP::Post.new(uri.path)
|
|
32
42
|
req.set_form_data(data)
|
|
33
43
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
@@ -79,8 +89,53 @@ module ElibriWatermarking
|
|
|
79
89
|
return JSON.parse(validate_response(res))
|
|
80
90
|
end
|
|
81
91
|
|
|
82
|
-
def
|
|
83
|
-
|
|
92
|
+
def soon_available_files
|
|
93
|
+
uri = URI(self.url + '/soon_available_files.json')
|
|
94
|
+
timestamp = Time.now.to_i
|
|
95
|
+
sig = CGI.escape(Base64.encode64(OpenSSL::HMAC.digest('sha1', timestamp.to_s, self.secret)).strip)
|
|
96
|
+
data = {'stamp' => timestamp, 'sig' => sig, 'token' => self.token}
|
|
97
|
+
req = Net::HTTP::Get.new(uri.path)
|
|
98
|
+
req.set_form_data(data)
|
|
99
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
100
|
+
http.use_ssl = true
|
|
101
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
102
|
+
res = http.start {|http| http.request(req) }
|
|
103
|
+
return JSON.parse(validate_response(res))
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def check_suppliers(ident)
|
|
107
|
+
ident =~ /^[0-9]+$/ ? ident_type = 'isbn' : ident_type = 'record_reference'
|
|
108
|
+
uri = URI(self.url + '/check_suppliers')
|
|
109
|
+
timestamp = Time.now.to_i
|
|
110
|
+
sig = CGI.escape(Base64.encode64(OpenSSL::HMAC.digest('sha1', timestamp.to_s, self.secret)).strip)
|
|
111
|
+
data = {'stamp' => timestamp, 'sig' => sig, 'token' => self.token, ident_type => ident}
|
|
112
|
+
req = Net::HTTP::Get.new(uri.path)
|
|
113
|
+
req.set_form_data(data)
|
|
114
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
115
|
+
http.use_ssl = true
|
|
116
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
117
|
+
res = http.start {|http| http.request(req) }
|
|
118
|
+
return validate_response(res).split(",").map { |x| x.to_i }
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def get_supplier(id)
|
|
122
|
+
uri = URI(self.url + '/get_supplier')
|
|
123
|
+
timestamp = Time.now.to_i
|
|
124
|
+
sig = CGI.escape(Base64.encode64(OpenSSL::HMAC.digest('sha1', timestamp.to_s, self.secret)).strip)
|
|
125
|
+
data = {'stamp' => timestamp, 'sig' => sig, 'token' => self.token, 'id' => id}
|
|
126
|
+
req = Net::HTTP::Get.new(uri.path)
|
|
127
|
+
req.set_form_data(data)
|
|
128
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
129
|
+
http.use_ssl = true
|
|
130
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
131
|
+
res = http.start {|http| http.request(req) }
|
|
132
|
+
return validate_response(res)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def watermark_and_deliver(ident, formats, visible_watermark, title_postfix, *args)
|
|
136
|
+
supplier = args[0]
|
|
137
|
+
client_symbol = args[1]
|
|
138
|
+
trans_id = watermark(ident, formats, visible_watermark, title_postfix, supplier, client_symbol)
|
|
84
139
|
return trans_id if deliver(trans_id) == "OK"
|
|
85
140
|
end
|
|
86
141
|
|
metadata
CHANGED
|
@@ -1,39 +1,46 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: elibri_watermarking
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 5
|
|
5
5
|
prerelease:
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 7
|
|
9
|
+
- 3
|
|
10
|
+
version: 0.7.3
|
|
6
11
|
platform: ruby
|
|
7
|
-
authors:
|
|
12
|
+
authors:
|
|
8
13
|
- Piotr Szmielew
|
|
9
14
|
autorequire:
|
|
10
15
|
bindir: bin
|
|
11
16
|
cert_chain: []
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
|
|
18
|
+
date: 2012-10-16 00:00:00 Z
|
|
19
|
+
dependencies:
|
|
20
|
+
- !ruby/object:Gem::Dependency
|
|
15
21
|
name: rake
|
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
|
17
|
-
none: false
|
|
18
|
-
requirements:
|
|
19
|
-
- - ! '>='
|
|
20
|
-
- !ruby/object:Gem::Version
|
|
21
|
-
version: '0'
|
|
22
|
-
type: :development
|
|
23
22
|
prerelease: false
|
|
24
|
-
|
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
25
24
|
none: false
|
|
26
|
-
requirements:
|
|
27
|
-
- -
|
|
28
|
-
- !ruby/object:Gem::Version
|
|
29
|
-
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
hash: 3
|
|
29
|
+
segments:
|
|
30
|
+
- 0
|
|
31
|
+
version: "0"
|
|
32
|
+
type: :development
|
|
33
|
+
version_requirements: *id001
|
|
30
34
|
description: Gem designed to help in use of Elibri watermarking API.
|
|
31
|
-
email:
|
|
35
|
+
email:
|
|
32
36
|
- p.szmielew@ava.waw.pl
|
|
33
37
|
executables: []
|
|
38
|
+
|
|
34
39
|
extensions: []
|
|
40
|
+
|
|
35
41
|
extra_rdoc_files: []
|
|
36
|
-
|
|
42
|
+
|
|
43
|
+
files:
|
|
37
44
|
- .gitignore
|
|
38
45
|
- Gemfile
|
|
39
46
|
- README.md
|
|
@@ -45,32 +52,36 @@ files:
|
|
|
45
52
|
- lib/elibri_watermarking/version.rb
|
|
46
53
|
homepage: http://elibri.com.pl
|
|
47
54
|
licenses: []
|
|
55
|
+
|
|
48
56
|
post_install_message:
|
|
49
57
|
rdoc_options: []
|
|
50
|
-
|
|
58
|
+
|
|
59
|
+
require_paths:
|
|
51
60
|
- lib
|
|
52
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
53
62
|
none: false
|
|
54
|
-
requirements:
|
|
55
|
-
- -
|
|
56
|
-
- !ruby/object:Gem::Version
|
|
57
|
-
|
|
58
|
-
segments:
|
|
63
|
+
requirements:
|
|
64
|
+
- - ">="
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
hash: 3
|
|
67
|
+
segments:
|
|
59
68
|
- 0
|
|
60
|
-
|
|
61
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
|
+
version: "0"
|
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
71
|
none: false
|
|
63
|
-
requirements:
|
|
64
|
-
- -
|
|
65
|
-
- !ruby/object:Gem::Version
|
|
66
|
-
|
|
67
|
-
segments:
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
hash: 3
|
|
76
|
+
segments:
|
|
68
77
|
- 0
|
|
69
|
-
|
|
78
|
+
version: "0"
|
|
70
79
|
requirements: []
|
|
80
|
+
|
|
71
81
|
rubyforge_project: elibri_watermarking
|
|
72
|
-
rubygems_version: 1.8.
|
|
82
|
+
rubygems_version: 1.8.21
|
|
73
83
|
signing_key:
|
|
74
84
|
specification_version: 3
|
|
75
85
|
summary: Gem designed to help in use of Elibri watermarking API.
|
|
76
86
|
test_files: []
|
|
87
|
+
|