hyperpdf 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/hyperpdf.gemspec +1 -0
- data/lib/hyperpdf.rb +10 -17
- data/lib/hyperpdf/version.rb +1 -1
- metadata +19 -3
data/hyperpdf.gemspec
CHANGED
data/lib/hyperpdf.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require "json"
|
3
3
|
require "hyperpdf/exceptions"
|
4
|
+
require 'httparty'
|
4
5
|
|
5
6
|
class HyperPDF
|
6
7
|
|
@@ -20,7 +21,6 @@ class HyperPDF
|
|
20
21
|
@user = @options.delete(:user) || ENV["HYPERPDF_USER"]
|
21
22
|
@password = @options.delete(:password) || ENV["HYPERPDF_PASSWORD"]
|
22
23
|
|
23
|
-
@req = Net::HTTP::Post.new('/pdf', {'Content-Type' => 'application/json'})
|
24
24
|
@request_body = { user: @user, password: @password, content: @content, options: @options }
|
25
25
|
end
|
26
26
|
|
@@ -45,22 +45,15 @@ class HyperPDF
|
|
45
45
|
|
46
46
|
private
|
47
47
|
|
48
|
-
def make_request
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
case resp.code
|
58
|
-
when "400" then raise HyperPDF::ContentRequired
|
59
|
-
when "401" then raise HyperPDF::AuthorizationRequired
|
60
|
-
when "402" then raise HyperPDF::PaymentRequired
|
61
|
-
when "404" then raise HyperPDF::NoSuchBucket
|
62
|
-
when "500" then raise HyperPDF::InternalServerError
|
63
|
-
end
|
48
|
+
def make_request(options={})
|
49
|
+
resp = HTTParty.post('https://api.hyper-pdf.com/pdf', options.merge(body: @request_body))
|
50
|
+
case resp.code
|
51
|
+
when 200 then resp
|
52
|
+
when 400 then raise HyperPDF::ContentRequired
|
53
|
+
when 401 then raise HyperPDF::AuthorizationRequired
|
54
|
+
when 402 then raise HyperPDF::PaymentRequired
|
55
|
+
when 404 then raise HyperPDF::NoSuchBucket
|
56
|
+
when 500 then raise HyperPDF::InternalServerError
|
64
57
|
end
|
65
58
|
end
|
66
59
|
|
data/lib/hyperpdf/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyperpdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
13
|
-
dependencies:
|
12
|
+
date: 2013-03-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httparty
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.10.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.10.0
|
14
30
|
description: Ruby wrapper around the HyperPDF API
|
15
31
|
email:
|
16
32
|
- up.redfield@gmail.com
|