docmago_client 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 427cde4f1b93bca32ad2f0a36ba35a07d480eabc
4
- data.tar.gz: aba13394543c749323a9ac856a65d017db54c33e
3
+ metadata.gz: a9536ecd03665d2dde981f55a9f8fcdbc11c21e6
4
+ data.tar.gz: 8ee2f7771d3f421ceba8d29a21c78ea445a345a4
5
5
  SHA512:
6
- metadata.gz: d176c4ee995dfb48aa7f19b4c6902666a110ebce5ebd45a8f55766aa96d71acc9a109c470fd3c362df5bde26be6acf17b8bec97aa6a0d4d31e37a38819565122
7
- data.tar.gz: 86a8a5c31c85516d14da1a74bdadb05e2853a224fab66fd58e9dc9f8f64b43a84ea95fec918f85fd3b8ea86dba3de8eea8aee227c75561b3e3ef2b0b6dd4ea33
6
+ metadata.gz: 49f5cbdf4eeb7065ef615c7748d8005f6fa2f7329b6fa650ace1aba10da6816ccd4fcb3101a1e81dc0dee87df3452b55821768e638cbeb3552f1c4a5463942fd
7
+ data.tar.gz: 7c3010309e42866505406ba8104a07eaee8817ea5e010546955dedabf8d71c89ff085c48f4958fed5f1120866853535005f99891a4e6a63ed2bf8b3c84f51237
@@ -42,9 +42,7 @@ module DocmagoClient
42
42
 
43
43
  default_options = {
44
44
  name: 'default',
45
- type: 'pdf',
46
- test_mode: false,
47
- raise_exception_on_failure: false
45
+ type: 'pdf'
48
46
  }
49
47
 
50
48
  options = default_options.merge(options)
@@ -58,7 +56,7 @@ module DocmagoClient
58
56
 
59
57
  response = Typhoeus.post "#{base_uri}/documents", body: {
60
58
  auth_token: api_key,
61
- document: { content: options[:content] }
59
+ document: options.slice(:content, :name, :type, :test_mode)
62
60
  }
63
61
  ensure
64
62
  FileUtils.remove_entry_secure tmp_dir
@@ -66,7 +64,7 @@ module DocmagoClient
66
64
  else
67
65
  response = Typhoeus.post "#{base_uri}/documents", body: {
68
66
  auth_token: api_key,
69
- document: options
67
+ document: options.slice(:content, :name, :type, :test_mode)
70
68
  }
71
69
  end
72
70
 
@@ -74,7 +72,7 @@ module DocmagoClient
74
72
  ret_val = nil
75
73
  Tempfile.open('docmago') do |f|
76
74
  f.sync = true
77
- f.write(response.body)
75
+ f.write(response.body.force_encoding('utf-8'))
78
76
  f.rewind
79
77
 
80
78
  ret_val = yield f, response
@@ -21,7 +21,7 @@ module DocmagoClient
21
21
 
22
22
  default_options = {
23
23
  name: filename || controller_name,
24
- test_mode: Rails.env.development?,
24
+ test_mode: Rails.env.development?.to_s,
25
25
  base_uri: url_for(only_path: false),
26
26
  resource_path: Rails.root.join('public').to_s,
27
27
  assets: Rails.application.assets,
@@ -31,13 +31,14 @@ module DocmagoClient
31
31
  options = default_options.merge(options)
32
32
  options[:content] ||= render_to_string(options)
33
33
 
34
- res = DocmagoClient.create(options)
35
- logger.info "Docmago response - status: #{res.code}; size: #{res.body.size}"
34
+ DocmagoClient.create(options) do |file, res|
35
+ logger.info "Docmago response - status: #{res.code}; size: #{res.body.size}"
36
36
 
37
- if res.code == 200
38
- send_data res.body, filename: "#{options[:name]}.pdf", type: 'application/pdf', disposition: 'attachment'
39
- else
40
- render inline: res.body, status: res.code
37
+ if res.code == 200
38
+ send_file file, filename: "#{options[:name]}.pdf", type: 'application/pdf', disposition: 'attachment'
39
+ else
40
+ render inline: res.body, status: res.code
41
+ end
41
42
  end
42
43
  end
43
44
  end
@@ -1,3 +1,3 @@
1
1
  module DocmagoClient
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '0.5.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docmago_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Habermann