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 CHANGED
@@ -17,4 +17,5 @@ Gem::Specification.new do |gem|
17
17
  gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
+ gem.add_dependency "httparty", ">=0.10.0"
20
21
  end
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
- @req.body = @request_body.to_json
50
- session = Net::HTTP.new('api.hyper-pdf.com', 443)
51
- session.use_ssl = true
52
- resp = session.request(@req)
53
-
54
- if resp.is_a? Net::HTTPOK
55
- resp
56
- else
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
 
@@ -1,3 +1,3 @@
1
1
  class HyperPDF
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.1
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-02-24 00:00:00.000000000 Z
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