pdfserve_client 2.0.1 → 2.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d153b8a5ff8112445c47ded72e265cb5cc06ae776a7311dc81efe0c6d27a643f
4
- data.tar.gz: d76bead370c4ddca6764bc1d2a05ae8b29fb53300d57afda8c2fe176ce5e85d3
3
+ metadata.gz: 6bda63ed2b57602e119910e3c0e48bcb34daf395b9abd1d83d7d4e37e6f9752d
4
+ data.tar.gz: efd6730b309387ea93c4ebaee10c401150d34b18af4fe2d4547174d41b2122b1
5
5
  SHA512:
6
- metadata.gz: '0789afd569c402b16aed0b1eb7df08fc720a033097e6ab85bfc990db8f2d6ca15455cffa7aecd0b05a3ae1ea41e22421996859be522b52ce0ddfc667ed251f4c'
7
- data.tar.gz: 74394ec2bb6eb1ff0edbbe149524b14bb4cc68881779bdfd59dc7b2914839259ed626dec863fb29ee5805a3954aa0bef22a974d6006ee84071d27a2ca587f1ec
6
+ metadata.gz: 945c3fe84944a2dbbda2f9198ab5c96370e3a484269a7581284d276bc97ebd0db875480455b2a44215dc01645abe087cd33d799b2cd3b61d6721cc9a80cfb948
7
+ data.tar.gz: 56b53b1daa7f45defea6d840d85bf5e9af32ada99450a4a2ad13f03388927020770ecbfd958ca33b0779b7c2261ee9baf5b964e864de9bb6ec4e148f9696c2db
@@ -1,18 +1,16 @@
1
- require_relative "merge"
2
- require_relative "stamp"
3
- require_relative "split"
1
+ require_relative 'merge'
2
+ require_relative 'stamp'
3
+ require_relative 'split'
4
4
 
5
5
  module Pdfserve
6
6
  class Client
7
- attr_reader :merge_service, :stamp_service, :split_service
8
-
9
7
  def initialize(api_endpoint:, api_token:)
10
8
  @api_endpoint = api_endpoint
11
9
  @api_token = api_token
12
10
  end
13
11
 
14
- def merge(file_urls:, output_path:)
15
- merge_service.merge(file_urls, output_path)
12
+ def merge(file_urls:, output_path:, rotations: nil)
13
+ merge_service.merge(file_urls, output_path, rotations:)
16
14
  end
17
15
 
18
16
  def stamp(file_url:, stamp_text:)
@@ -1,39 +1,41 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "version"
4
- require "net/http"
5
- require "uri"
6
- require "json"
3
+ require_relative 'version'
4
+ require 'net/http'
5
+ require 'uri'
6
+ require 'json'
7
+ require 'ostruct'
7
8
 
8
9
  module Pdfserve
9
10
  class Error < StandardError; end
10
11
 
11
12
  class Merge
12
- PATH = "/api/v1/pdf/merge"
13
+ PATH = '/api/v1/pdf/merge'
13
14
 
14
15
  def initialize(api_endpoint:, api_token: nil)
15
16
  @api_endpoint = api_endpoint + PATH
16
17
  @api_token = api_token
17
18
  end
18
19
 
19
- def merge(file_urls, output_path)
20
+ def merge(file_urls, output_path, rotations: nil)
20
21
  uri = URI(api_endpoint)
22
+ uri.query = URI.encode_www_form(rotations.map { |angle| ['rotations', angle] }) if rotations && !rotations.empty?
21
23
  request = Net::HTTP::Post.new(uri)
22
- request["token"] = api_token unless api_token.nil?
23
- form_data = file_urls.map { |url| ["files", url] }
24
+ request['token'] = api_token unless api_token.nil?
25
+ form_data = file_urls.map { |url| ['files', url] }
24
26
 
25
- request.set_form form_data, "multipart/form-data"
27
+ request.set_form form_data, 'multipart/form-data'
26
28
 
27
- response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
29
+ response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
28
30
  http.request(request)
29
31
  end
30
32
 
31
33
  if response.is_a?(Net::HTTPSuccess)
32
- File.open(output_path, "wb") { |file| file.write(response.body) }
33
- puts "Success!"
34
- OpenStruct.new(success: true, errors: "")
34
+ File.binwrite(output_path, response.body)
35
+ puts 'Success!'
36
+ OpenStruct.new(success: true, errors: '')
35
37
  else
36
- puts "Failed!"
38
+ puts 'Failed!'
37
39
  OpenStruct.new(success: false, errors: response.message)
38
40
  end
39
41
  end
@@ -1,15 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "version"
4
- require "net/http"
5
- require "uri"
6
- require "json"
3
+ require_relative 'version'
4
+ require 'net/http'
5
+ require 'uri'
6
+ require 'json'
7
+ require 'ostruct'
7
8
 
8
9
  module Pdfserve
9
10
  class Error < StandardError; end
10
11
 
11
12
  class Split
12
- PATH = "/api/v1/pdf/split"
13
+ PATH = '/api/v1/pdf/split'
13
14
 
14
15
  def initialize(api_endpoint:, api_token: nil)
15
16
  @api_endpoint = api_endpoint + PATH
@@ -18,29 +19,29 @@ module Pdfserve
18
19
 
19
20
  def split(file_url:, pages:)
20
21
  uri = URI(api_endpoint)
21
- uri.query = URI.encode_www_form({ pages: pages })
22
+ uri.query = URI.encode_www_form({ pages: })
22
23
 
23
24
  http = Net::HTTP.new(uri.host, uri.port)
24
- http.use_ssl = uri.scheme == "https"
25
+ http.use_ssl = uri.scheme == 'https'
25
26
  request = Net::HTTP::Post.new(uri.request_uri)
26
27
 
27
- request["token"] = api_token unless api_token.nil?
28
- form_data = [["splitfile", file_url]]
28
+ request['token'] = api_token unless api_token.nil?
29
+ form_data = [['splitfile', file_url]]
29
30
 
30
- request.set_form form_data, "multipart/form-data"
31
+ request.set_form form_data, 'multipart/form-data'
31
32
 
32
33
  response = http.request(request)
33
34
 
34
35
  if response.is_a?(Net::HTTPSuccess)
35
- puts "Successful split!"
36
- content_disposition = response.header["Content-Disposition"]
37
- filename = content_disposition[/filename="?([^"]+)"?/, 1] || "archive.tar.gz"
36
+ puts 'Successful split!'
37
+ content_disposition = response.header['Content-Disposition']
38
+ filename = content_disposition[/filename="?([^"]+)"?/, 1] || 'archive.tar.gz'
38
39
 
39
40
  OpenStruct.new(
40
- success: true, response: response.read_body, filename: filename, errors: ""
41
+ success: true, response: response.read_body, filename:, errors: ''
41
42
  )
42
43
  else
43
- puts "Failed!"
44
+ puts 'Failed!'
44
45
  OpenStruct.new(
45
46
  success: false, response: response.body, errors: response.message
46
47
  )
@@ -1,15 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "version"
4
- require "net/http"
5
- require "uri"
6
- require "json"
3
+ require_relative 'version'
4
+ require 'net/http'
5
+ require 'uri'
6
+ require 'json'
7
+ require 'ostruct'
7
8
 
8
9
  module Pdfserve
9
10
  class Error < StandardError; end
10
11
 
11
12
  class Stamp
12
- PATH = "/api/v1/pdf/stamp"
13
+ PATH = '/api/v1/pdf/stamp'
13
14
 
14
15
  def initialize(api_endpoint:, api_token: nil)
15
16
  @api_endpoint = api_endpoint + PATH
@@ -19,26 +20,26 @@ module Pdfserve
19
20
  def call(file_url, stamp_text)
20
21
  uri = URI(api_endpoint)
21
22
  http = Net::HTTP.new(uri.host, uri.port)
22
- http.use_ssl = uri.scheme == "https"
23
+ http.use_ssl = uri.scheme == 'https'
23
24
  request = Net::HTTP::Post.new(uri.request_uri)
24
25
 
25
- request["token"] = api_token unless api_token.nil?
26
+ request['token'] = api_token unless api_token.nil?
26
27
  form_data = [
27
- ["files", file_url],
28
- ["stamp_text", { "text" => stamp_text, "color" => "0,0,0", "position_name" => "tr", "over" => "true" }.to_json]
28
+ ['files', file_url],
29
+ ['stamp_text', { 'text' => stamp_text, 'color' => '0,0,0', 'position_name' => 'tr', 'over' => 'true' }.to_json]
29
30
  ]
30
31
 
31
- request.set_form form_data, "multipart/form-data"
32
+ request.set_form form_data, 'multipart/form-data'
32
33
 
33
34
  response = http.request(request)
34
35
 
35
36
  if response.is_a?(Net::HTTPSuccess)
36
- puts "Successful stamp!"
37
+ puts 'Successful stamp!'
37
38
  OpenStruct.new(
38
- success: true, response: response.body, errors: ""
39
+ success: true, response: response.body, errors: ''
39
40
  )
40
41
  else
41
- puts "Failed!"
42
+ puts 'Failed!'
42
43
  OpenStruct.new(
43
44
  success: false, response: response.body, errors: response.message
44
45
  )
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pdfserve
4
- VERSION = "2.0.1"
4
+ VERSION = '2.1.0'
5
5
  end
metadata CHANGED
@@ -1,16 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdfserve_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Isabel Garcia
8
8
  - Antoine Legrand
9
9
  - Lakhan Pasari
10
- autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2025-01-29 00:00:00.000000000 Z
12
+ date: 1980-01-02 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: net-http
@@ -45,8 +44,8 @@ files:
45
44
  homepage: https://github.com/mietright/pdf_merger
46
45
  licenses:
47
46
  - MIT
48
- metadata: {}
49
- post_install_message:
47
+ metadata:
48
+ rubygems_mfa_required: 'true'
50
49
  rdoc_options: []
51
50
  require_paths:
52
51
  - lib
@@ -54,15 +53,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
54
53
  requirements:
55
54
  - - ">="
56
55
  - !ruby/object:Gem::Version
57
- version: '0'
56
+ version: '3.3'
58
57
  required_rubygems_version: !ruby/object:Gem::Requirement
59
58
  requirements:
60
59
  - - ">="
61
60
  - !ruby/object:Gem::Version
62
61
  version: '0'
63
62
  requirements: []
64
- rubygems_version: 3.5.23
65
- signing_key:
63
+ rubygems_version: 4.0.10
66
64
  specification_version: 4
67
65
  summary: A gem for merging, stamping, and splitting PDFs using an external API
68
66
  test_files: []