faxage 0.1.0 → 0.1.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
  SHA256:
3
- metadata.gz: 9bf0a54daaaf950f2b5ad56aeafc9e81b6097cdba4a76ca7db165b07ae91e40d
4
- data.tar.gz: bb3ee8132869fbf8216e190c837390926ab87457418d69cb8051b43a4bde056f
3
+ metadata.gz: f4b8bb8101b2ee151ff6dd04b9013e43b9c8c08e2c5b6df850e2daf6ec877e4f
4
+ data.tar.gz: 8720b2c3b0f7f544d1a9c227266e81533c6ccba388f1a4186c6ef965b2ec3cbe
5
5
  SHA512:
6
- metadata.gz: 9ce41be4d2b5e2d70f32d511c4084e07b2ba5d8deeafb4ba65e6c5161a33c1bdb5d4c51876879c097ff913baaa3e2c8eea4f27cec3ba3c9edbb09d0f9496e0fd
7
- data.tar.gz: 26bb746a3c90321dc3316c7eb51d6fb9b2a36d82ae1516210df56e55ca7dc95bb7614f0c434aaa906b20397cf12dde32c24c36438451fbb11b04eba945ebbb82
6
+ metadata.gz: a9ce2d548767ab2f9f36d44b2d25013ae7e273d8dc57fab11c490f9c00736aba98d7057135c89dc5fc766141b5c5ad575fcd3b6760aaeb982c08f3a6f392d5ed
7
+ data.tar.gz: 7c82e22e5c0e341cfc78bd7deeed0951828cdb3d2812c2892cea2dde3bb9405924626b1486e6b023edc1c667763c522a9030373aaf59bf3534bbb94b789ee94a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- faxage (0.1.0)
4
+ faxage (0.1.1)
5
5
  httparty
6
6
 
7
7
  GEM
data/lib/faxage.rb CHANGED
@@ -1,3 +1,27 @@
1
1
  require "faxage/version"
2
2
  require "faxage/send_fax"
3
- require "faxage/information_gathering"
3
+ require "faxage/information_gathering"
4
+
5
+ class LoginError < StandardError
6
+ end
7
+
8
+ class FaxageInternalError < StandardError
9
+ end
10
+
11
+ class UnknownOperationError < StandardError
12
+ end
13
+
14
+ class NoResponseError < StandardError
15
+ end
16
+
17
+ class InvalidJobIdError < StandardError
18
+ end
19
+
20
+ class InvalidFaxNoError < StandardError
21
+ end
22
+
23
+ class NoFilesError < StandardError
24
+ end
25
+
26
+ class BlockedNumberError < StandardError
27
+ end
@@ -1,18 +1,6 @@
1
1
  require 'httparty'
2
2
 
3
3
  module Faxage
4
- class LoginError < StandardError
5
- end
6
-
7
- class FaxageInternalError < StandardError
8
- end
9
-
10
- class UnknownOperationError < StandardError
11
- end
12
-
13
- class NoResponseError < StandardError
14
- end
15
-
16
4
  class InformationGathering
17
5
  include HTTParty
18
6
  base_uri "https://api.faxage.com"
@@ -52,9 +52,34 @@ module Faxage
52
52
  faxfiledata: faxfiledata
53
53
  }.merge!(options)
54
54
 
55
- self.class.post(subdirectory,
55
+ response = self.class.post(subdirectory,
56
56
  body: body
57
57
  )
58
+
59
+ if response.parsed_response.nil?
60
+ raise NoResponseError.new("An empty response was returned from Faxage.")
61
+ elsif response.parsed_response.include?("ERR01: Database connection failed")
62
+ raise FaxageInternalError.new("Internal FAXAGE error.")
63
+ elsif response.parsed_response.include?("ERR02: Login incorrect")
64
+ raise LoginError.new("One or more of username, company, password is incorrect or your account is disabled for some reason.")
65
+ elsif response.parsed_response.include?("ERR03: No files to fax")
66
+ raise NoFilesError.new("No valid files were found in faxfilenames[] and/or faxfiledata[].")
67
+ elsif response.parsed_response.include?("ERR04: Fax number")
68
+ raise InvalidFaxNoError.new("The faxno variable does not contain a 10-digit numeric only string.")
69
+ elsif response.parsed_response.include?("ERR05")
70
+ raise BlockedNumberError.new("The number you tried to fax to was blocked (outside of continental US, Canada and Hawaii or a 555, 911, or other invalid/blocked type of number).")
71
+ elsif response.parsed_response.include?("ERR08: Unknown operation")
72
+ raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes.")
73
+ elsif response.parsed_response.include?("ERR15: Invalid Job ID")
74
+ raise InvalidJobIdError.new("Internal FAXAGE error – the job was not properly inserted into our database.")
75
+ else
76
+ parsed_response = response.parsed_response.gsub("JOBID:", "").gsub(" ", "")
77
+ data = {
78
+ job_id: parsed_response.to_i
79
+ }
80
+ return data
81
+ end
82
+ return response.parsed_response
58
83
  end
59
84
  end
60
85
  end
@@ -1,3 +1,3 @@
1
1
  module Faxage
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faxage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Dias