Sha256: 499f8aa2ea339ccc9ca71c850018fd7fdba96615f5b6433bd1411dcb172835dc
Contents?: true
Size: 1.62 KB
Versions: 1
Compression:
Stored size: 1.62 KB
Contents
module PostalMethods module SendLetter def send_letter(doc, description) raise PostalMethods::NoPreparationException unless self.prepared ## push a letter over the api self.document = doc rv = @rpc_driver.sendLetter(:Username => self.username, :Password => self.password, :FileExtension => self.document[:extension], :FileBinaryData => self.document[:bytes], :MyDescription => description) status_code = rv.sendLetterResult.to_i if status_code > 0 return rv elsif API_STATUS_CODES.has_key?(status_code) instance_eval("raise APIStatusCode#{status_code.to_s.gsub(/( |\-)/,'')}Exception") end end def send_letter_and_address(doc, description, address) raise PostalMethods::NoPreparationException unless self.prepared raise PostalMethods::AddressNotHashException unless (address.class == Hash) ## setup the document self.document = doc opts = {:Username => self.username, :Password => self.password, :FileExtension => self.document[:extension], :FileBinaryData => self.document[:bytes], :MyDescription => description} opts.merge!(address) ## push a letter over the api rv = @rpc_driver.sendLetterAndAddress(opts) status_code = rv.sendLetterAndAddressResult.to_i if status_code > 0 return rv elsif API_STATUS_CODES.has_key?(status_code) instance_eval("raise APIStatusCode#{status_code.to_s.gsub(/( |\-)/,'')}Exception") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
postalmethods-1.0.0 | lib/postalmethods/send_letter.rb |