Class: Faxage::InformationGathering
- Inherits:
-
Object
- Object
- Faxage::InformationGathering
- Includes:
- HTTParty
- Defined in:
- lib/faxage/information_gathering.rb
Instance Attribute Summary collapse
-
#company ⇒ Object
readonly
Assigned FAXAGE username.
-
#password ⇒ Object
readonly
Assigned FAXAGE username.
-
#username ⇒ Object
readonly
Assigned FAXAGE username.
Instance Method Summary collapse
- #auditlog(**options) ⇒ Object
- #busycalls ⇒ Object
- #dlstatus(jobid:, viewtype: 'pdf') ⇒ Object
- #handlecount ⇒ Object
- #incomingcalls ⇒ Object
-
#initialize(username:, company:, password:) ⇒ InformationGathering
constructor
A new instance of InformationGathering.
- #pendcount ⇒ Object
- #portstatus ⇒ Object
- #qstatus ⇒ Object
Constructor Details
#initialize(username:, company:, password:) ⇒ InformationGathering
Returns a new instance of InformationGathering.
12 13 14 15 16 |
# File 'lib/faxage/information_gathering.rb', line 12 def initialize(username:, company:, password:) @username = username @company = company @password = password end |
Instance Attribute Details
#company ⇒ Object (readonly)
Assigned FAXAGE username
8 9 10 |
# File 'lib/faxage/information_gathering.rb', line 8 def company @company end |
#password ⇒ Object (readonly)
Assigned FAXAGE username
8 9 10 |
# File 'lib/faxage/information_gathering.rb', line 8 def password @password end |
#username ⇒ Object (readonly)
Assigned FAXAGE username
8 9 10 |
# File 'lib/faxage/information_gathering.rb', line 8 def username @username end |
Instance Method Details
#auditlog(**options) ⇒ Object
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/faxage/information_gathering.rb', line 256 def auditlog(**) # This operation allows you to retrieve audit logs for your FAXAGE account. The # FAXAGE auditing system is a comprehensive system that keeps a trail of all activities # within your account. See the FAXAGE Internet Fax Auditing Documentation for details # as to the structure of audit logs and what data is contained within each type of auditable # operation. subdirectory = "/httpsfax.php" body = { operation: "auditlog", username: username, company: company, password: password }.merge!() response = self.class.post(subdirectory, body: body ) if response.parsed_response.nil? raise NoResponseError.new("An empty response was returned from Faxage.") elsif response.parsed_response.include?("ERR02: Login incorrect") raise LoginError.new("One or more of username, company, password is incorrect or your account is disabled for some reason.") elsif response.parsed_response.include?("ERR01: Database connection failed") raise FaxageInternalError.new("Internal FAXAGE error.") elsif response.parsed_response.include?("ERR08: Unknown operation") raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes. #{response.parsed_response}") else # TODO - parse response # <audit-id><tab><timestamp><tab><login><tab><ipaddress><tab><interface><tab><web # sessid><tab><auditop><tab><opstat><tab><requestdetail><tab><response-detail> # Each of the above fields is defined in detail in the # Internet Fax Auditing Documentation as previously # noted return response.parsed_response end end |
#busycalls ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/faxage/information_gathering.rb', line 169 def busycalls # This operation allows you to see incoming calls that have experienced a busy signal # because more calls were in progress at the time the call came than your account was # configured to support. subdirectory = "/httpsfax.php" body = { operation: "busycalls", username: username, company: company, password: password } response = self.class.post(subdirectory, body: body ) if response.parsed_response.nil? raise NoResponseError.new("An empty response was returned from Faxage.") elsif response.parsed_response.include?("ERR02: Login incorrect") raise LoginError.new("One or more of username, company, password is incorrect or your account is disabled for some reason.") elsif response.parsed_response.include?("ERR01: Database connection failed") raise FaxageInternalError.new("Internal FAXAGE error.") elsif response.parsed_response.include?("ERR08: Unknown operation") raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes. #{response.parsed_response}") else # TODO - parse response # New-line separated records, formatted as follows: # <number-called><tab><number-calling><tab><time> # Where: # Number-called – Your number that was called # Number-calling – The Caller ID for the caller # Time – YYYY-MM-DD HH:MM:SS format return response.parsed_response end end |
#dlstatus(jobid:, viewtype: 'pdf') ⇒ Object
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/faxage/information_gathering.rb', line 297 def dlstatus(jobid:, viewtype: 'pdf') # This operation is used to download a sent fax image. subdirectory = "/httpsfax.php" body = { operation: "dlstatus", username: username, company: company, password: password, jobid: jobid, viewtype: viewtype } response = self.class.post(subdirectory, body: body) if response.parsed_response.nil? raise NoResponseError.new("An empty response was returned from Faxage.") elsif response.parsed_response.include?("ERR01: Database connection failed") raise FaxageInternalError.new("Internal FAXAGE error.") elsif response.parsed_response.include?("ERR02: Login incorrect") raise LoginError.new("One or more of username, company, password is incorrect or your account is disabled for some reason.") elsif response.parsed_response.include?("ERR06: No jobs to display or job id specified not found") raise InvalidJobIdError.new("The jobid you passed was not found") elsif response.parsed_response.include?("ERR08: Unknown operation") raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes. #{response.parsed_response}") elsif response.parsed_response.include?("ERR24: File is not yet converted") raise NoFilesError.new("Images can only be retrieved after the file(s) have actually been imaged (I.e.: The fax must either be In Queue or completed to be able to retrieve an image)") elsif response.parsed_response.include?("ERR25: File does not exist") raise NoFilesError.new("This can be either an internal error, or if the status is a ‘Failed Conversion’, then there is no image to retrieve") else return response.parsed_response end end |
#handlecount ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/faxage/information_gathering.rb', line 18 def handlecount # This operation allows you to see how many incoming faxes are stored within FAXAGE # and, of those, how many you have marked as handled using the handled operation. subdirectory = "/httpsfax.php" body = { operation: "handlecount", username: username, company: company, password: password } response = self.class.post(subdirectory, body: body ) if response.parsed_response.nil? raise NoResponseError.new("An empty response was returned from Faxage.") elsif response.parsed_response.include?("ERR02: Login incorrect") raise LoginError.new("One or more of username, company, password is incorrect or your account is disabled for some reason.") elsif response.parsed_response.include?("ERR01: Database connection failed") raise FaxageInternalError.new("Internal FAXAGE error.") elsif response.parsed_response.include?("ERR08: Unknown operation") raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes. #{response.parsed_response}") else parsed_response = response.parsed_response.gsub("\n", "").split("~") data = { total_count: parsed_response[0].to_i, handled_count: parsed_response[1].to_i } return data end end |
#incomingcalls ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/faxage/information_gathering.rb', line 133 def incomingcalls # This operation allows you to see how many incoming calls are currently in progress to # your account and how many maximum total simultaneous calls your account is currently # configured to allow without sending a busy signal. subdirectory = "/httpsfax.php" body = { operation: "incomingcalls", username: username, company: company, password: password } response = self.class.post(subdirectory, body: body ) if response.parsed_response.nil? raise NoResponseError.new("An empty response was returned from Faxage.") elsif response.parsed_response.include?("ERR02: Login incorrect") raise LoginError.new("One or more of username, company, password is incorrect or your account is disabled for some reason.") elsif response.parsed_response.include?("ERR01: Database connection failed") raise FaxageInternalError.new("Internal FAXAGE error.") elsif response.parsed_response.include?("ERR08: Unknown operation") raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes. #{response.parsed_response}") else parsed_response = response.parsed_response.gsub("\n", "").split("~") data = { incoming_count: parsed_response[0].to_i, allocated_count: parsed_response[1].to_i } return data end end |
#pendcount ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/faxage/information_gathering.rb', line 52 def pendcount # This operation allows you to see how many outgoing faxes are currently pending to be # sent on your FAXAGE account. subdirectory = "/httpsfax.php" body = { operation: "pendcount", username: username, company: company, password: password } response = self.class.post(subdirectory, body: body ) if response.parsed_response.nil? raise NoResponseError.new("An empty response was returned from Faxage.") elsif response.parsed_response.include?("ERR02: Login incorrect") raise LoginError.new("One or more of username, company, password is incorrect or your account is disabled for some reason.") elsif response.parsed_response.include?("ERR01: Database connection failed") raise FaxageInternalError.new("Internal FAXAGE error.") elsif response.parsed_response.include?("ERR08: Unknown operation") raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes. #{response.parsed_response}") else parsed_response = response.parsed_response.gsub("\n", "").to_i data = { pending_count: parsed_response } return data end end |
#portstatus ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/faxage/information_gathering.rb', line 209 def portstatus # This operation allows you to see the status of port requests you have in progress or that # have been completed with FAXAGE. subdirectory = "/httpsfax.php" body = { operation: "portstatus", username: username, company: company, password: password } response = self.class.post(subdirectory, body: body ) if response.parsed_response.nil? raise NoResponseError.new("An empty response was returned from Faxage.") elsif response.parsed_response.include?("ERR02: Login incorrect") raise LoginError.new("One or more of username, company, password is incorrect or your account is disabled for some reason.") elsif response.parsed_response.include?("ERR01: Database connection failed") raise FaxageInternalError.new("Internal FAXAGE error.") elsif response.parsed_response.include?("ERR08: Unknown operation") raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes. #{response.parsed_response}") else # TODO - parse response # New-line separated records, formatted as follows: # <number><tab><request-date><tab><duedate><tab><completedate><tab><status><tab><comment><tab><complete> # Where: # Number – The number you are porting # Request-date – YYYY-MM-DD date of request # Due-date – YYYY-MM-DD expected completion date # Complete-date – YYYY-MM-DD date actually # completed 0000-00-00 for requests in progress # Status – One of ‘Initial’, ‘SOA PEND’, ‘Reject’, # ‘Completed’ or ‘Canceled’. SOA PEND means the # carrier has accepted for completion on the Due-date # Comment – Free-form comment about the current # status. FAXAGE staff enters these as ports are worked # Complete – Yes or No return response.parsed_response end end |
#qstatus ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/faxage/information_gathering.rb', line 86 def qstatus # This operation allows you to gather details about how your outgoing pending faxes are # currently queued. When you have more than one line on your FAXAGE account, the # system automatically load-levels outgoing faxes across however many lines you have. # Using this operation, you can see all of your pending outgoing faxes and which line(s) # they are queued on, in order to analyze how your outgoing traffic is being distributed for # sending by FAXAGE. subdirectory = "/httpsfax.php" body = { operation: "qstatus", username: username, company: company, password: password } response = self.class.post(subdirectory, body: body ) if response.parsed_response.nil? raise NoResponseError.new("An empty response was returned from Faxage.") elsif response.parsed_response.include?("ERR02: Login incorrect") raise LoginError.new("One or more of username, company, password is incorrect or your account is disabled for some reason.") elsif response.parsed_response.include?("ERR01: Database connection failed") raise FaxageInternalError.new("Internal FAXAGE error.") elsif response.parsed_response.include?("ERR08: Unknown operation") raise UnknownOperationError.new("Either operation is not correctly hard coded or the POST was bad, the POST contents are returned for debugging purposes. #{response.parsed_response}") else # TODO - parse response # New-line separated records, as follows: # <jobid><tab><callerID><tab><destination><tab><lineid # ><tab><pagecount> # See qstatus record definition below. # CallerID – The caller ID you have requested when making the sendfax request, or your # account’s default if you do not set separate caller ID’s for outgoing faxes # Destination – The destination fax number for this outgoing fax # LineID – Unique numeric ‘line’ ID. If you see more than one fax with the same LineID, # that means FAXAGE has queued those faxes to the same line to be sent and one will # have to wait for the other to finish before it will dial # Pagecount – The number of pages associated with a given fax return response.parsed_response end end |