pamfaxr 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.bundle/config +2 -0
 - data/.document +5 -0
 - data/Gemfile +11 -0
 - data/Gemfile.lock +32 -0
 - data/LICENSE +21 -0
 - data/README.md +45 -0
 - data/Rakefile +46 -0
 - data/VERSION +1 -0
 - data/examples/R-intro.pdf +0 -0
 - data/examples/example.rb +93 -0
 - data/lib/pamfaxr/multipart.rb +75 -0
 - data/lib/pamfaxr/pamfaxr.rb +799 -0
 - data/lib/pamfaxr.rb +2 -0
 - data/pamfaxr.gemspec +78 -0
 - data/spec/pamfaxr_spec.rb +504 -0
 - data/spec/pdf-test.pdf +0 -0
 - data/spec/spec.opts +1 -0
 - data/spec/spec_helper.rb +11 -0
 - metadata +176 -0
 
    
        data/lib/pamfaxr.rb
    ADDED
    
    
    
        data/pamfaxr.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,78 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Generated by jeweler
         
     | 
| 
      
 2 
     | 
    
         
            +
            # DO NOT EDIT THIS FILE DIRECTLY
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
         
     | 
| 
      
 4 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 7 
     | 
    
         
            +
              s.name = %q{pamfaxr}
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.version = "0.0.1"
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         
     | 
| 
      
 11 
     | 
    
         
            +
              s.authors = ["Jason Goecke"]
         
     | 
| 
      
 12 
     | 
    
         
            +
              s.date = %q{2011-01-26}
         
     | 
| 
      
 13 
     | 
    
         
            +
              s.description = %q{Ruby library for the FaxJob portion of the PamFax API.}
         
     | 
| 
      
 14 
     | 
    
         
            +
              s.email = %q{jsgoecke@voxeo.com}
         
     | 
| 
      
 15 
     | 
    
         
            +
              s.extra_rdoc_files = [
         
     | 
| 
      
 16 
     | 
    
         
            +
                "LICENSE",
         
     | 
| 
      
 17 
     | 
    
         
            +
                "README.md"
         
     | 
| 
      
 18 
     | 
    
         
            +
              ]
         
     | 
| 
      
 19 
     | 
    
         
            +
              s.files = [
         
     | 
| 
      
 20 
     | 
    
         
            +
                ".bundle/config",
         
     | 
| 
      
 21 
     | 
    
         
            +
                ".document",
         
     | 
| 
      
 22 
     | 
    
         
            +
                "Gemfile",
         
     | 
| 
      
 23 
     | 
    
         
            +
                "Gemfile.lock",
         
     | 
| 
      
 24 
     | 
    
         
            +
                "LICENSE",
         
     | 
| 
      
 25 
     | 
    
         
            +
                "README.md",
         
     | 
| 
      
 26 
     | 
    
         
            +
                "Rakefile",
         
     | 
| 
      
 27 
     | 
    
         
            +
                "VERSION",
         
     | 
| 
      
 28 
     | 
    
         
            +
                "examples/R-intro.pdf",
         
     | 
| 
      
 29 
     | 
    
         
            +
                "examples/example.rb",
         
     | 
| 
      
 30 
     | 
    
         
            +
                "lib/pamfaxr.rb",
         
     | 
| 
      
 31 
     | 
    
         
            +
                "lib/pamfaxr/multipart.rb",
         
     | 
| 
      
 32 
     | 
    
         
            +
                "lib/pamfaxr/pamfaxr.rb",
         
     | 
| 
      
 33 
     | 
    
         
            +
                "pamfaxr.gemspec",
         
     | 
| 
      
 34 
     | 
    
         
            +
                "spec/pamfaxr_spec.rb",
         
     | 
| 
      
 35 
     | 
    
         
            +
                "spec/pdf-test.pdf",
         
     | 
| 
      
 36 
     | 
    
         
            +
                "spec/spec.opts",
         
     | 
| 
      
 37 
     | 
    
         
            +
                "spec/spec_helper.rb"
         
     | 
| 
      
 38 
     | 
    
         
            +
              ]
         
     | 
| 
      
 39 
     | 
    
         
            +
              s.homepage = %q{http://github.com/tropo/pamfaxr}
         
     | 
| 
      
 40 
     | 
    
         
            +
              s.licenses = ["MIT"]
         
     | 
| 
      
 41 
     | 
    
         
            +
              s.require_paths = ["lib"]
         
     | 
| 
      
 42 
     | 
    
         
            +
              s.rubygems_version = %q{1.3.7}
         
     | 
| 
      
 43 
     | 
    
         
            +
              s.summary = %q{Ruby library for the PamFax API.}
         
     | 
| 
      
 44 
     | 
    
         
            +
              s.test_files = [
         
     | 
| 
      
 45 
     | 
    
         
            +
                "examples/example.rb",
         
     | 
| 
      
 46 
     | 
    
         
            +
                "spec/pamfaxr_spec.rb",
         
     | 
| 
      
 47 
     | 
    
         
            +
                "spec/spec_helper.rb"
         
     | 
| 
      
 48 
     | 
    
         
            +
              ]
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
              if s.respond_to? :specification_version then
         
     | 
| 
      
 51 
     | 
    
         
            +
                current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
         
     | 
| 
      
 52 
     | 
    
         
            +
                s.specification_version = 3
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
         
     | 
| 
      
 55 
     | 
    
         
            +
                  s.add_runtime_dependency(%q<mime-types>, [">= 0"])
         
     | 
| 
      
 56 
     | 
    
         
            +
                  s.add_runtime_dependency(%q<json>, [">= 0"])
         
     | 
| 
      
 57 
     | 
    
         
            +
                  s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
         
     | 
| 
      
 58 
     | 
    
         
            +
                  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
         
     | 
| 
      
 59 
     | 
    
         
            +
                  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
         
     | 
| 
      
 60 
     | 
    
         
            +
                  s.add_development_dependency(%q<rcov>, [">= 0"])
         
     | 
| 
      
 61 
     | 
    
         
            +
                else
         
     | 
| 
      
 62 
     | 
    
         
            +
                  s.add_dependency(%q<mime-types>, [">= 0"])
         
     | 
| 
      
 63 
     | 
    
         
            +
                  s.add_dependency(%q<json>, [">= 0"])
         
     | 
| 
      
 64 
     | 
    
         
            +
                  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
         
     | 
| 
      
 65 
     | 
    
         
            +
                  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
         
     | 
| 
      
 66 
     | 
    
         
            +
                  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
         
     | 
| 
      
 67 
     | 
    
         
            +
                  s.add_dependency(%q<rcov>, [">= 0"])
         
     | 
| 
      
 68 
     | 
    
         
            +
                end
         
     | 
| 
      
 69 
     | 
    
         
            +
              else
         
     | 
| 
      
 70 
     | 
    
         
            +
                s.add_dependency(%q<mime-types>, [">= 0"])
         
     | 
| 
      
 71 
     | 
    
         
            +
                s.add_dependency(%q<json>, [">= 0"])
         
     | 
| 
      
 72 
     | 
    
         
            +
                s.add_dependency(%q<rspec>, ["~> 2.3.0"])
         
     | 
| 
      
 73 
     | 
    
         
            +
                s.add_dependency(%q<bundler>, ["~> 1.0.0"])
         
     | 
| 
      
 74 
     | 
    
         
            +
                s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
         
     | 
| 
      
 75 
     | 
    
         
            +
                s.add_dependency(%q<rcov>, [">= 0"])
         
     | 
| 
      
 76 
     | 
    
         
            +
              end
         
     | 
| 
      
 77 
     | 
    
         
            +
            end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,504 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            PAMFAX_URI      = 'https://sandbox-api.pamfax.biz'
         
     | 
| 
      
 4 
     | 
    
         
            +
            PAMFAX_KEY      = 'name'
         
     | 
| 
      
 5 
     | 
    
         
            +
            PAMFAX_SECRET   = 'abd123'
         
     | 
| 
      
 6 
     | 
    
         
            +
            PAMFAX_USERNAME = 'fooey'
         
     | 
| 
      
 7 
     | 
    
         
            +
            PAMFAX_PASSWORD = 'foobar'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            FakeWeb.allow_net_connect = false
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            describe "PamFaxr" do
         
     | 
| 
      
 12 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 13 
     | 
    
         
            +
                
         
     | 
| 
      
 14 
     | 
    
         
            +
                @user_found = { "result" => 
         
     | 
| 
      
 15 
     | 
    
         
            +
                                { "code"                => "success", 
         
     | 
| 
      
 16 
     | 
    
         
            +
                                  "count"               => 2, 
         
     | 
| 
      
 17 
     | 
    
         
            +
                                  "message"             => "" }, 
         
     | 
| 
      
 18 
     | 
    
         
            +
                                "User"                  => 
         
     | 
| 
      
 19 
     | 
    
         
            +
                                 { "name"               => "Tropo", 
         
     | 
| 
      
 20 
     | 
    
         
            +
                                   "affiliatepartnerid" => 154, 
         
     | 
| 
      
 21 
     | 
    
         
            +
                                   "free_credit"        => 0, 
         
     | 
| 
      
 22 
     | 
    
         
            +
                                   "uuid"               => "yAS5AOLr4SKqAJ", 
         
     | 
| 
      
 23 
     | 
    
         
            +
                                   "username"           => "tropo-test", 
         
     | 
| 
      
 24 
     | 
    
         
            +
                                   "credit"             => 0, 
         
     | 
| 
      
 25 
     | 
    
         
            +
                                   "is_member"          => 0, 
         
     | 
| 
      
 26 
     | 
    
         
            +
                                   "email"              => "jsgoecke@voxeo.com",
         
     | 
| 
      
 27 
     | 
    
         
            +
                                   "created"            => "2010-10-21 15:22:49" }, 
         
     | 
| 
      
 28 
     | 
    
         
            +
                                 "UserToken"            => { "token" => "m3cv0d9gqb69taajcu76nqv5eccht76t" } }
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                @user_not_found = { "result" => 
         
     | 
| 
      
 31 
     | 
    
         
            +
                                    { "code"    => "user_not_found", 
         
     | 
| 
      
 32 
     | 
    
         
            +
                                      "count"   => 0, 
         
     | 
| 
      
 33 
     | 
    
         
            +
                                      "message" => "Unknown user name or incorrect password" } }
         
     | 
| 
      
 34 
     | 
    
         
            +
                
         
     | 
| 
      
 35 
     | 
    
         
            +
                @create_result = { "result" => 
         
     | 
| 
      
 36 
     | 
    
         
            +
                                   { "code"                 => "success", 
         
     | 
| 
      
 37 
     | 
    
         
            +
                                     "count"                => 1, 
         
     | 
| 
      
 38 
     | 
    
         
            +
                                     "message"              => ""}, 
         
     | 
| 
      
 39 
     | 
    
         
            +
                                   "FaxContainer"           => 
         
     | 
| 
      
 40 
     | 
    
         
            +
                                     { "price"              => 0, 
         
     | 
| 
      
 41 
     | 
    
         
            +
                                       "send_mail"          => 0, 
         
     | 
| 
      
 42 
     | 
    
         
            +
                                       "uuid"               => "x0RXuwLhP7qKU2", 
         
     | 
| 
      
 43 
     | 
    
         
            +
                                       "error_notification" => 0, 
         
     | 
| 
      
 44 
     | 
    
         
            +
                                       "group_notification" => 0, 
         
     | 
| 
      
 45 
     | 
    
         
            +
                                       "send_sms"           => 0, 
         
     | 
| 
      
 46 
     | 
    
         
            +
                                       "currency_rate"      => 0.7712, 
         
     | 
| 
      
 47 
     | 
    
         
            +
                                       "cover_page_length"  => nil, 
         
     | 
| 
      
 48 
     | 
    
         
            +
                                       "send_chat"          => 0, 
         
     | 
| 
      
 49 
     | 
    
         
            +
                                       "pages"              => nil, 
         
     | 
| 
      
 50 
     | 
    
         
            +
                                       "cover_id"           => 0, 
         
     | 
| 
      
 51 
     | 
    
         
            +
                                       "currency"           => "USD", 
         
     | 
| 
      
 52 
     | 
    
         
            +
                                       "affiliatepartner"   => "154", 
         
     | 
| 
      
 53 
     | 
    
         
            +
                                       "updated"            => nil, 
         
     | 
| 
      
 54 
     | 
    
         
            +
                                       "cover_text"         => nil, 
         
     | 
| 
      
 55 
     | 
    
         
            +
                                       "processing_started" => nil, 
         
     | 
| 
      
 56 
     | 
    
         
            +
                                       "created"            => "2010-10-22 14:13:57", 
         
     | 
| 
      
 57 
     | 
    
         
            +
                                       "state"              => "editing" } }
         
     | 
| 
      
 58 
     | 
    
         
            +
                                               
         
     | 
| 
      
 59 
     | 
    
         
            +
                @add_recipient_result = { "result" => 
         
     | 
| 
      
 60 
     | 
    
         
            +
                                         { "code"                  => "success", 
         
     | 
| 
      
 61 
     | 
    
         
            +
                                           "count"                 => 1, 
         
     | 
| 
      
 62 
     | 
    
         
            +
                                           "message"               => "" }, 
         
     | 
| 
      
 63 
     | 
    
         
            +
                                         "FaxRecipient"            => 
         
     | 
| 
      
 64 
     | 
    
         
            +
                                           { "price"               => 0, 
         
     | 
| 
      
 65 
     | 
    
         
            +
                                             "duration"            => 0, 
         
     | 
| 
      
 66 
     | 
    
         
            +
                                             "name"                => "", 
         
     | 
| 
      
 67 
     | 
    
         
            +
                                             "delivery_started"    => nil, 
         
     | 
| 
      
 68 
     | 
    
         
            +
                                             "price_per_page"      => 0.12, 
         
     | 
| 
      
 69 
     | 
    
         
            +
                                             "number"              => "+14155551212", 
         
     | 
| 
      
 70 
     | 
    
         
            +
                                             "price_source"        => "PNR", 
         
     | 
| 
      
 71 
     | 
    
         
            +
                                             "country"             => "US", 
         
     | 
| 
      
 72 
     | 
    
         
            +
                                             "sent"                => nil, 
         
     | 
| 
      
 73 
     | 
    
         
            +
                                             "completed"           => nil, 
         
     | 
| 
      
 74 
     | 
    
         
            +
                                             "area_code"           => "415", 
         
     | 
| 
      
 75 
     | 
    
         
            +
                                             "zone"                => "1", 
         
     | 
| 
      
 76 
     | 
    
         
            +
                                             "uuid"                => "6WSLyy0ophkgoO", 
         
     | 
| 
      
 77 
     | 
    
         
            +
                                             "currency_rate"       => "0.7712", 
         
     | 
| 
      
 78 
     | 
    
         
            +
                                             "id"                  => 18164, 
         
     | 
| 
      
 79 
     | 
    
         
            +
                                             "pages"               => nil, 
         
     | 
| 
      
 80 
     | 
    
         
            +
                                             "status_code"         => 0, 
         
     | 
| 
      
 81 
     | 
    
         
            +
                                             "number_type"         => "FIXED", 
         
     | 
| 
      
 82 
     | 
    
         
            +
                                             "transmission_report" => "", 
         
     | 
| 
      
 83 
     | 
    
         
            +
                                             "currency"            => "USD", 
         
     | 
| 
      
 84 
     | 
    
         
            +
                                             "description"         => "California (CA)", 
         
     | 
| 
      
 85 
     | 
    
         
            +
                                             "updated"             => "2010-10-22 14:24:44", 
         
     | 
| 
      
 86 
     | 
    
         
            +
                                             "status_message"      => nil, 
         
     | 
| 
      
 87 
     | 
    
         
            +
                                             "created"             => "2010-10-22 14:24:44", 
         
     | 
| 
      
 88 
     | 
    
         
            +
                                             "state"               => "unknown"} }
         
     | 
| 
      
 89 
     | 
    
         
            +
                                               
         
     | 
| 
      
 90 
     | 
    
         
            +
                @state = {
         
     | 
| 
      
 91 
     | 
    
         
            +
                                   "result" => {
         
     | 
| 
      
 92 
     | 
    
         
            +
                                    "code" => "success",
         
     | 
| 
      
 93 
     | 
    
         
            +
                                   "count" => 2,
         
     | 
| 
      
 94 
     | 
    
         
            +
                                 "message" => ""
         
     | 
| 
      
 95 
     | 
    
         
            +
                             },
         
     | 
| 
      
 96 
     | 
    
         
            +
                               "converting" => true,
         
     | 
| 
      
 97 
     | 
    
         
            +
                                    "Files" => {
         
     | 
| 
      
 98 
     | 
    
         
            +
                                    "type" => "list",
         
     | 
| 
      
 99 
     | 
    
         
            +
                                 "content" => [
         
     | 
| 
      
 100 
     | 
    
         
            +
                                         {
         
     | 
| 
      
 101 
     | 
    
         
            +
                                         "file_order" => 0,
         
     | 
| 
      
 102 
     | 
    
         
            +
                                              "state" => "converting"
         
     | 
| 
      
 103 
     | 
    
         
            +
                                     },
         
     | 
| 
      
 104 
     | 
    
         
            +
                                         {
         
     | 
| 
      
 105 
     | 
    
         
            +
                                         "file_order" => 1,
         
     | 
| 
      
 106 
     | 
    
         
            +
                                              "state" => "converting"
         
     | 
| 
      
 107 
     | 
    
         
            +
                                     }
         
     | 
| 
      
 108 
     | 
    
         
            +
                                 ]
         
     | 
| 
      
 109 
     | 
    
         
            +
                             },
         
     | 
| 
      
 110 
     | 
    
         
            +
                             "FaxContainer" => {
         
     | 
| 
      
 111 
     | 
    
         
            +
                                              "price" => 0,
         
     | 
| 
      
 112 
     | 
    
         
            +
                                           "sms_cost" => 0,
         
     | 
| 
      
 113 
     | 
    
         
            +
                                          "send_mail" => "0",
         
     | 
| 
      
 114 
     | 
    
         
            +
                                               "uuid" => "mVRLR725Ei1zhU",
         
     | 
| 
      
 115 
     | 
    
         
            +
                                 "error_notification" => "0",
         
     | 
| 
      
 116 
     | 
    
         
            +
                                 "group_notification" => "0",
         
     | 
| 
      
 117 
     | 
    
         
            +
                                           "send_sms" => "0",
         
     | 
| 
      
 118 
     | 
    
         
            +
                                      "currency_rate" => 1,
         
     | 
| 
      
 119 
     | 
    
         
            +
                                  "cover_page_length" => "1",
         
     | 
| 
      
 120 
     | 
    
         
            +
                                          "send_chat" => "0",
         
     | 
| 
      
 121 
     | 
    
         
            +
                                              "pages" => nil,
         
     | 
| 
      
 122 
     | 
    
         
            +
                                           "cover_id" => 3,
         
     | 
| 
      
 123 
     | 
    
         
            +
                                           "currency" => "1",
         
     | 
| 
      
 124 
     | 
    
         
            +
                                   "affiliatepartner" => nil,
         
     | 
| 
      
 125 
     | 
    
         
            +
                                            "updated" => "2011-01-17 18:27:27",
         
     | 
| 
      
 126 
     | 
    
         
            +
                                         "cover_text" => "Foobar is here!",
         
     | 
| 
      
 127 
     | 
    
         
            +
                                 "processing_started" => nil,
         
     | 
| 
      
 128 
     | 
    
         
            +
                                            "created" => "2011-01-17 18:27:08",
         
     | 
| 
      
 129 
     | 
    
         
            +
                                              "state" => "editing"
         
     | 
| 
      
 130 
     | 
    
         
            +
                             }
         
     | 
| 
      
 131 
     | 
    
         
            +
                         }
         
     | 
| 
      
 132 
     | 
    
         
            +
                
         
     | 
| 
      
 133 
     | 
    
         
            +
                @available_covers = { "result"                 => 
         
     | 
| 
      
 134 
     | 
    
         
            +
                                      { "code"                 => "success", 
         
     | 
| 
      
 135 
     | 
    
         
            +
                                        "count"                => 1, 
         
     | 
| 
      
 136 
     | 
    
         
            +
                                        "message"              => "" }, 
         
     | 
| 
      
 137 
     | 
    
         
            +
                                        "Covers"               => 
         
     | 
| 
      
 138 
     | 
    
         
            +
                                          { "type"             => "list", 
         
     | 
| 
      
 139 
     | 
    
         
            +
                                            "content"          =>
         
     | 
| 
      
 140 
     | 
    
         
            +
                                              [{ "title"       => "(none)", 
         
     | 
| 
      
 141 
     | 
    
         
            +
                                                 "creator"     => 0, 
         
     | 
| 
      
 142 
     | 
    
         
            +
                                                 "id"          => 0, 
         
     | 
| 
      
 143 
     | 
    
         
            +
                                                 "thumb_id"    => "0266e33d3f546cb5436a10798e657d97", 
         
     | 
| 
      
 144 
     | 
    
         
            +
                                                 "preview_id"  => "9188905e74c28e489b44e954ec0b9bca"}, 
         
     | 
| 
      
 145 
     | 
    
         
            +
                                               { "template_id" => "eae27d77ca20db309e056e3d2dcd7d69",
         
     | 
| 
      
 146 
     | 
    
         
            +
                                                 "title"       => "Basic", 
         
     | 
| 
      
 147 
     | 
    
         
            +
                                                 "creator"     => 0, 
         
     | 
| 
      
 148 
     | 
    
         
            +
                                                 "id"          => 1, 
         
     | 
| 
      
 149 
     | 
    
         
            +
                                                 "thumb_id"    => "091d584fced301b442654dd8c23b3fc9", 
         
     | 
| 
      
 150 
     | 
    
         
            +
                                                 "description" => nil, 
         
     | 
| 
      
 151 
     | 
    
         
            +
                                                 "preview_id"  => "7eabe3a1649ffa2b3ff8c02ebfd5659f" }, 
         
     | 
| 
      
 152 
     | 
    
         
            +
                                               { "template_id" => "ca46c1b9512a7a8315fa3c5a946e8265", 
         
     | 
| 
      
 153 
     | 
    
         
            +
                                                 "title"       => "Flowers", 
         
     | 
| 
      
 154 
     | 
    
         
            +
                                                 "creator"     => 0, 
         
     | 
| 
      
 155 
     | 
    
         
            +
                                                 "id"          => 3, 
         
     | 
| 
      
 156 
     | 
    
         
            +
                                                 "thumb_id"    => "45fbc6d3e05ebd93369ce542e8f2322d", 
         
     | 
| 
      
 157 
     | 
    
         
            +
                                                 "description" => nil, 
         
     | 
| 
      
 158 
     | 
    
         
            +
                                                 "preview_id"  => "979d472a84804b9f647bc185a877a8b5" }, 
         
     | 
| 
      
 159 
     | 
    
         
            +
                                               { "template_id" => "e96ed478dab8595a7dbda4cbcbee168f", 
         
     | 
| 
      
 160 
     | 
    
         
            +
                                                 "title"       => "Message", 
         
     | 
| 
      
 161 
     | 
    
         
            +
                                                 "creator"     => 0, 
         
     | 
| 
      
 162 
     | 
    
         
            +
                                                 "id"          => 4, 
         
     | 
| 
      
 163 
     | 
    
         
            +
                                                 "thumb_id"    => "ec8ce6abb3e952a85b8551ba726a1227", 
         
     | 
| 
      
 164 
     | 
    
         
            +
                                                 "description" => nil, 
         
     | 
| 
      
 165 
     | 
    
         
            +
                                                 "preview_id"  => "63dc7ed1010d3c3b8269faf0ba7491d4" }, 
         
     | 
| 
      
 166 
     | 
    
         
            +
                                               { "template_id" => "f340f1b1f65b6df5b5e3f94d95b11daf", 
         
     | 
| 
      
 167 
     | 
    
         
            +
                                                 "title"       => "Simple", 
         
     | 
| 
      
 168 
     | 
    
         
            +
                                                 "creator"     => 0, 
         
     | 
| 
      
 169 
     | 
    
         
            +
                                                 "id"          => 5, 
         
     | 
| 
      
 170 
     | 
    
         
            +
                                                 "thumb_id"    => "335f5352088d7d9bf74191e006d8e24c", 
         
     | 
| 
      
 171 
     | 
    
         
            +
                                                 "description" => nil, 
         
     | 
| 
      
 172 
     | 
    
         
            +
                                                 "preview_id"  => "cb70ab375662576bd1ac5aaf16b3fca4" }] } }
         
     | 
| 
      
 173 
     | 
    
         
            +
                                                 
         
     | 
| 
      
 174 
     | 
    
         
            +
                @page =  {
         
     | 
| 
      
 175 
     | 
    
         
            +
                                        "result" => {
         
     | 
| 
      
 176 
     | 
    
         
            +
                                     "code" => "success",
         
     | 
| 
      
 177 
     | 
    
         
            +
                                    "count" => 1,
         
     | 
| 
      
 178 
     | 
    
         
            +
                                  "message" => ""
         
     | 
| 
      
 179 
     | 
    
         
            +
                              },
         
     | 
| 
      
 180 
     | 
    
         
            +
                              "FaxContainerFile" => {
         
     | 
| 
      
 181 
     | 
    
         
            +
                                        "name" => "R-intro.pdf",
         
     | 
| 
      
 182 
     | 
    
         
            +
                                  "file_order" => 0,
         
     | 
| 
      
 183 
     | 
    
         
            +
                                         "ext" => "pdf",
         
     | 
| 
      
 184 
     | 
    
         
            +
                                   "file_uuid" => "OQskZYr9D0MANw",
         
     | 
| 
      
 185 
     | 
    
         
            +
                                        "mime" => "application/pdf",
         
     | 
| 
      
 186 
     | 
    
         
            +
                                       "state" => ""
         
     | 
| 
      
 187 
     | 
    
         
            +
                              }
         
     | 
| 
      
 188 
     | 
    
         
            +
                          }
         
     | 
| 
      
 189 
     | 
    
         
            +
                
         
     | 
| 
      
 190 
     | 
    
         
            +
                @local_file_upload = {
         
     | 
| 
      
 191 
     | 
    
         
            +
                                                    "result" => {
         
     | 
| 
      
 192 
     | 
    
         
            +
                                                 "code" => "success",
         
     | 
| 
      
 193 
     | 
    
         
            +
                                                "count" => 1,
         
     | 
| 
      
 194 
     | 
    
         
            +
                                              "message" => ""
         
     | 
| 
      
 195 
     | 
    
         
            +
                                          },
         
     | 
| 
      
 196 
     | 
    
         
            +
                                          "FaxContainerFile" => {
         
     | 
| 
      
 197 
     | 
    
         
            +
                                                    "name" => "R-intro.pdf",
         
     | 
| 
      
 198 
     | 
    
         
            +
                                              "file_order" => 0,
         
     | 
| 
      
 199 
     | 
    
         
            +
                                                     "ext" => "pdf",
         
     | 
| 
      
 200 
     | 
    
         
            +
                                               "file_uuid" => "OuH2JbbGKhDp8o",
         
     | 
| 
      
 201 
     | 
    
         
            +
                                                    "mime" => "application/pdf",
         
     | 
| 
      
 202 
     | 
    
         
            +
                                                   "state" => ""
         
     | 
| 
      
 203 
     | 
    
         
            +
                                          }
         
     | 
| 
      
 204 
     | 
    
         
            +
                                      }
         
     | 
| 
      
 205 
     | 
    
         
            +
                
         
     | 
| 
      
 206 
     | 
    
         
            +
                @no_files = {
         
     | 
| 
      
 207 
     | 
    
         
            +
                                "result" => {
         
     | 
| 
      
 208 
     | 
    
         
            +
                                       "code" => "no_files_in_fax",
         
     | 
| 
      
 209 
     | 
    
         
            +
                                      "count" => 0,
         
     | 
| 
      
 210 
     | 
    
         
            +
                                    "message" => "No files in fax found"
         
     | 
| 
      
 211 
     | 
    
         
            +
                                }
         
     | 
| 
      
 212 
     | 
    
         
            +
                            }
         
     | 
| 
      
 213 
     | 
    
         
            +
                            
         
     | 
| 
      
 214 
     | 
    
         
            +
                @fax_files = {
         
     | 
| 
      
 215 
     | 
    
         
            +
                                  "result" => {
         
     | 
| 
      
 216 
     | 
    
         
            +
                                         "code" => "success",
         
     | 
| 
      
 217 
     | 
    
         
            +
                                        "count" => 1,
         
     | 
| 
      
 218 
     | 
    
         
            +
                                      "message" => ""
         
     | 
| 
      
 219 
     | 
    
         
            +
                                  },
         
     | 
| 
      
 220 
     | 
    
         
            +
                                   "Files" => {
         
     | 
| 
      
 221 
     | 
    
         
            +
                                         "type" => "list",
         
     | 
| 
      
 222 
     | 
    
         
            +
                                      "content" => [
         
     | 
| 
      
 223 
     | 
    
         
            +
                                              {
         
     | 
| 
      
 224 
     | 
    
         
            +
                                                    "name" => "R-intro.pdf",
         
     | 
| 
      
 225 
     | 
    
         
            +
                                                    "size" => 646768,
         
     | 
| 
      
 226 
     | 
    
         
            +
                                               "extension" => "pdf",
         
     | 
| 
      
 227 
     | 
    
         
            +
                                                    "uuid" => "aMzeebWS9O8GKz",
         
     | 
| 
      
 228 
     | 
    
         
            +
                                                   "pages" => 0,
         
     | 
| 
      
 229 
     | 
    
         
            +
                                              "contentmd5" => "fd898b168b9780212a2ddd5bfbd79d65",
         
     | 
| 
      
 230 
     | 
    
         
            +
                                                "mimetype" => "application/pdf",
         
     | 
| 
      
 231 
     | 
    
         
            +
                                                 "created" => "2011-01-17 14:55:57"
         
     | 
| 
      
 232 
     | 
    
         
            +
                                          },
         
     | 
| 
      
 233 
     | 
    
         
            +
                                              {
         
     | 
| 
      
 234 
     | 
    
         
            +
                                                    "name" => "examples/R-intro.pdf",
         
     | 
| 
      
 235 
     | 
    
         
            +
                                                    "size" => 646768,
         
     | 
| 
      
 236 
     | 
    
         
            +
                                               "extension" => "pdf",
         
     | 
| 
      
 237 
     | 
    
         
            +
                                                    "uuid" => "BVMJzRmu1zAlSZ",
         
     | 
| 
      
 238 
     | 
    
         
            +
                                                   "pages" => 0,
         
     | 
| 
      
 239 
     | 
    
         
            +
                                              "contentmd5" => "fd898b168b9780212a2ddd5bfbd79d65",
         
     | 
| 
      
 240 
     | 
    
         
            +
                                                "mimetype" => "application/pdf",
         
     | 
| 
      
 241 
     | 
    
         
            +
                                                 "created" => "2011-01-17 14:56:02"
         
     | 
| 
      
 242 
     | 
    
         
            +
                                          }
         
     | 
| 
      
 243 
     | 
    
         
            +
                                      ]
         
     | 
| 
      
 244 
     | 
    
         
            +
                                  }
         
     | 
| 
      
 245 
     | 
    
         
            +
                              }
         
     | 
| 
      
 246 
     | 
    
         
            +
                
         
     | 
| 
      
 247 
     | 
    
         
            +
                
         
     | 
| 
      
 248 
     | 
    
         
            +
                @recipients = {
         
     | 
| 
      
 249 
     | 
    
         
            +
                                      "result" => {
         
     | 
| 
      
 250 
     | 
    
         
            +
                                         "code" => "success",
         
     | 
| 
      
 251 
     | 
    
         
            +
                                        "count" => 1,
         
     | 
| 
      
 252 
     | 
    
         
            +
                                      "message" => ""
         
     | 
| 
      
 253 
     | 
    
         
            +
                                  },
         
     | 
| 
      
 254 
     | 
    
         
            +
                                  "Recipients" => {
         
     | 
| 
      
 255 
     | 
    
         
            +
                                         "type" => "list",
         
     | 
| 
      
 256 
     | 
    
         
            +
                                      "content" => [
         
     | 
| 
      
 257 
     | 
    
         
            +
                                              {
         
     | 
| 
      
 258 
     | 
    
         
            +
                                                            "price" => 0,
         
     | 
| 
      
 259 
     | 
    
         
            +
                                                         "duration" => 0,
         
     | 
| 
      
 260 
     | 
    
         
            +
                                                             "name" => "",
         
     | 
| 
      
 261 
     | 
    
         
            +
                                                 "delivery_started" => nil,
         
     | 
| 
      
 262 
     | 
    
         
            +
                                                   "price_per_page" => 0.09,
         
     | 
| 
      
 263 
     | 
    
         
            +
                                                           "number" => "+14155551212",
         
     | 
| 
      
 264 
     | 
    
         
            +
                                                     "price_source" => "PNR",
         
     | 
| 
      
 265 
     | 
    
         
            +
                                                          "country" => "US",
         
     | 
| 
      
 266 
     | 
    
         
            +
                                                             "sent" => nil,
         
     | 
| 
      
 267 
     | 
    
         
            +
                                                        "completed" => nil,
         
     | 
| 
      
 268 
     | 
    
         
            +
                                                        "area_code" => "415",
         
     | 
| 
      
 269 
     | 
    
         
            +
                                                 "formatted_number" => "+1 415 5551212",
         
     | 
| 
      
 270 
     | 
    
         
            +
                                                             "zone" => "1",
         
     | 
| 
      
 271 
     | 
    
         
            +
                                                             "uuid" => "4x4W2JDn29HOR6",
         
     | 
| 
      
 272 
     | 
    
         
            +
                                                    "currency_rate" => "1",
         
     | 
| 
      
 273 
     | 
    
         
            +
                                                            "pages" => nil,
         
     | 
| 
      
 274 
     | 
    
         
            +
                                                      "status_code" => 0,
         
     | 
| 
      
 275 
     | 
    
         
            +
                                                      "number_type" => "FIXED",
         
     | 
| 
      
 276 
     | 
    
         
            +
                                              "transmission_report" => "",
         
     | 
| 
      
 277 
     | 
    
         
            +
                                                         "currency" => "1",
         
     | 
| 
      
 278 
     | 
    
         
            +
                                                      "description" => "California (CA)",
         
     | 
| 
      
 279 
     | 
    
         
            +
                                                          "updated" => "2011-01-17 14:56:04",
         
     | 
| 
      
 280 
     | 
    
         
            +
                                                   "status_message" => nil,
         
     | 
| 
      
 281 
     | 
    
         
            +
                                                          "created" => "2011-01-17 14:56:04",
         
     | 
| 
      
 282 
     | 
    
         
            +
                                                            "state" => "unknown"
         
     | 
| 
      
 283 
     | 
    
         
            +
                                          }
         
     | 
| 
      
 284 
     | 
    
         
            +
                                      ]
         
     | 
| 
      
 285 
     | 
    
         
            +
                                  }
         
     | 
| 
      
 286 
     | 
    
         
            +
                              }
         
     | 
| 
      
 287 
     | 
    
         
            +
                            
         
     | 
| 
      
 288 
     | 
    
         
            +
                @success = {
         
     | 
| 
      
 289 
     | 
    
         
            +
                                "result" => {
         
     | 
| 
      
 290 
     | 
    
         
            +
                                       "code" => "success",
         
     | 
| 
      
 291 
     | 
    
         
            +
                                      "count" => 0,
         
     | 
| 
      
 292 
     | 
    
         
            +
                                    "message" => ""
         
     | 
| 
      
 293 
     | 
    
         
            +
                                }
         
     | 
| 
      
 294 
     | 
    
         
            +
                            }
         
     | 
| 
      
 295 
     | 
    
         
            +
                       
         
     | 
| 
      
 296 
     | 
    
         
            +
                @fax_preview = {
         
     | 
| 
      
 297 
     | 
    
         
            +
                                      "Status" => {
         
     | 
| 
      
 298 
     | 
    
         
            +
                                        "open" => 5,
         
     | 
| 
      
 299 
     | 
    
         
            +
                                        "done" => 0
         
     | 
| 
      
 300 
     | 
    
         
            +
                                    },
         
     | 
| 
      
 301 
     | 
    
         
            +
                                          "result" => {
         
     | 
| 
      
 302 
     | 
    
         
            +
                                           "code" => "success",
         
     | 
| 
      
 303 
     | 
    
         
            +
                                          "count" => 2,
         
     | 
| 
      
 304 
     | 
    
         
            +
                                        "message" => ""
         
     | 
| 
      
 305 
     | 
    
         
            +
                                    },
         
     | 
| 
      
 306 
     | 
    
         
            +
                                    "PreviewPages" => {
         
     | 
| 
      
 307 
     | 
    
         
            +
                                        "type" => "list"
         
     | 
| 
      
 308 
     | 
    
         
            +
                                    }
         
     | 
| 
      
 309 
     | 
    
         
            +
                                }
         
     | 
| 
      
 310 
     | 
    
         
            +
             
     | 
| 
      
 311 
     | 
    
         
            +
                # Addresses
         
     | 
| 
      
 312 
     | 
    
         
            +
                FakeWeb.register_uri(:get, 
         
     | 
| 
      
 313 
     | 
    
         
            +
                                     "https://sandbox-api.pamfax.biz/Session/VerifyUser/?apikey=#{PAMFAX_KEY}&apisecret=#{PAMFAX_SECRET}&apioutputformat=API_FORMAT_JSON&username=#{PAMFAX_USERNAME}&password=#{PAMFAX_PASSWORD}", 
         
     | 
| 
      
 314 
     | 
    
         
            +
                                     :body => @user_found.to_json, 
         
     | 
| 
      
 315 
     | 
    
         
            +
                                     :content_type => "application/json")
         
     | 
| 
      
 316 
     | 
    
         
            +
             
     | 
| 
      
 317 
     | 
    
         
            +
                FakeWeb.register_uri(:get, 
         
     | 
| 
      
 318 
     | 
    
         
            +
                                     "https://sandbox-api.pamfax.biz/Session/VerifyUser/?apikey=tropo&apisecret=abc123&apioutputformat=API_FORMAT_JSON&username=fooey&password=looey", 
         
     | 
| 
      
 319 
     | 
    
         
            +
                                     :body => @user_not_found.to_json, 
         
     | 
| 
      
 320 
     | 
    
         
            +
                                     :content_type => "application/json")
         
     | 
| 
      
 321 
     | 
    
         
            +
                
         
     | 
| 
      
 322 
     | 
    
         
            +
                FakeWeb.register_uri(:get, 
         
     | 
| 
      
 323 
     | 
    
         
            +
                                     %r|https://sandbox-api.pamfax.biz/FaxJob/Create|, 
         
     | 
| 
      
 324 
     | 
    
         
            +
                                     :body => @create_result.to_json,
         
     | 
| 
      
 325 
     | 
    
         
            +
                                     :content_type => "application/json")
         
     | 
| 
      
 326 
     | 
    
         
            +
             
     | 
| 
      
 327 
     | 
    
         
            +
                FakeWeb.register_uri(:get, 
         
     | 
| 
      
 328 
     | 
    
         
            +
                                     %r|https://sandbox-api.pamfax.biz/FaxJob/AddRecipient|, 
         
     | 
| 
      
 329 
     | 
    
         
            +
                                     :body => @add_recipient_result.to_json,
         
     | 
| 
      
 330 
     | 
    
         
            +
                                     :content_type => "application/json")
         
     | 
| 
      
 331 
     | 
    
         
            +
             
     | 
| 
      
 332 
     | 
    
         
            +
                FakeWeb.register_uri(:get, 
         
     | 
| 
      
 333 
     | 
    
         
            +
                                     "https://sandbox-api.pamfax.biz/FaxJob/GetFaxState?apikey=name&apisecret=abd123&apioutputformat=API_FORMAT_JSON&usertoken=m3cv0d9gqb69taajcu76nqv5eccht76t", 
         
     | 
| 
      
 334 
     | 
    
         
            +
                                     :body => @state.to_json,
         
     | 
| 
      
 335 
     | 
    
         
            +
                                     :content_type => "application/json")
         
     | 
| 
      
 336 
     | 
    
         
            +
             
     | 
| 
      
 337 
     | 
    
         
            +
                FakeWeb.register_uri(:get, 
         
     | 
| 
      
 338 
     | 
    
         
            +
                                     %r|https://sandbox-api.pamfax.biz/FaxJob/Send|, 
         
     | 
| 
      
 339 
     | 
    
         
            +
                                     :body => @no_files.to_json,
         
     | 
| 
      
 340 
     | 
    
         
            +
                                     :content_type => "application/json")
         
     | 
| 
      
 341 
     | 
    
         
            +
             
     | 
| 
      
 342 
     | 
    
         
            +
                FakeWeb.register_uri(:get, 
         
     | 
| 
      
 343 
     | 
    
         
            +
                                      "https://sandbox-api.pamfax.biz/FaxJob/ListAvailableCovers?apikey=name&apisecret=abd123&apioutputformat=API_FORMAT_JSON&usertoken=m3cv0d9gqb69taajcu76nqv5eccht76t", 
         
     | 
| 
      
 344 
     | 
    
         
            +
                                      :body => @available_covers.to_json,
         
     | 
| 
      
 345 
     | 
    
         
            +
                                      :content_type => "application/json")
         
     | 
| 
      
 346 
     | 
    
         
            +
                                                
         
     | 
| 
      
 347 
     | 
    
         
            +
                FakeWeb.register_uri(:post, 
         
     | 
| 
      
 348 
     | 
    
         
            +
                                     "https://sandbox-api.pamfax.biz/FaxJob/AddFile?apikey=name&apisecret=abd123&apioutputformat=API_FORMAT_JSON&usertoken=m3cv0d9gqb69taajcu76nqv5eccht76t",
         
     | 
| 
      
 349 
     | 
    
         
            +
                                     :body => @local_file_upload.to_json,
         
     | 
| 
      
 350 
     | 
    
         
            +
                                     :content_type => "application/json",
         
     | 
| 
      
 351 
     | 
    
         
            +
                                     :status => ["200", "OK"])
         
     | 
| 
      
 352 
     | 
    
         
            +
                                      
         
     | 
| 
      
 353 
     | 
    
         
            +
                FakeWeb.register_uri(:get, 
         
     | 
| 
      
 354 
     | 
    
         
            +
                                     "https://sandbox-api.pamfax.biz/FaxJob/SetCover?apikey=name&apisecret=abd123&apioutputformat=API_FORMAT_JSON&usertoken=m3cv0d9gqb69taajcu76nqv5eccht76t&template_id=f340f1b1f65b6df5b5e3f94d95b11daf&text=Hi%20foobar!",
         
     | 
| 
      
 355 
     | 
    
         
            +
                                     :body => ({ "result" => { "code" => "success", "count" => 0, "message" => "" } }).to_json,
         
     | 
| 
      
 356 
     | 
    
         
            +
                                     :content_type => "application/json",
         
     | 
| 
      
 357 
     | 
    
         
            +
                                     :status => ["200", "OK"])
         
     | 
| 
      
 358 
     | 
    
         
            +
             
     | 
| 
      
 359 
     | 
    
         
            +
               FakeWeb.register_uri(:get, 
         
     | 
| 
      
 360 
     | 
    
         
            +
                                    "https://sandbox-api.pamfax.biz/FaxJob/AddRemoteFile?apikey=name&apisecret=abd123&apioutputformat=API_FORMAT_JSON&usertoken=m3cv0d9gqb69taajcu76nqv5eccht76t&url=https://s3.amazonaws.com/pamfax-test/R-intro.pdf",
         
     | 
| 
      
 361 
     | 
    
         
            +
                                    :body => @page.to_json,
         
     | 
| 
      
 362 
     | 
    
         
            +
                                    :content_type => "application/json",
         
     | 
| 
      
 363 
     | 
    
         
            +
                                    :status => ["200", "OK"])
         
     | 
| 
      
 364 
     | 
    
         
            +
                                    
         
     | 
| 
      
 365 
     | 
    
         
            +
                FakeWeb.register_uri(:get, 
         
     | 
| 
      
 366 
     | 
    
         
            +
                                      "https://sandbox-api.pamfax.biz/FaxJob/ListFaxFiles?apikey=name&apisecret=abd123&apioutputformat=API_FORMAT_JSON&usertoken=m3cv0d9gqb69taajcu76nqv5eccht76t",
         
     | 
| 
      
 367 
     | 
    
         
            +
                                      :body => @fax_files.to_json,
         
     | 
| 
      
 368 
     | 
    
         
            +
                                      :content_type => "application/json",
         
     | 
| 
      
 369 
     | 
    
         
            +
                                      :status => ["200", "OK"])
         
     | 
| 
      
 370 
     | 
    
         
            +
             
     | 
| 
      
 371 
     | 
    
         
            +
                FakeWeb.register_uri(:get, 
         
     | 
| 
      
 372 
     | 
    
         
            +
                                      "https://sandbox-api.pamfax.biz/FaxJob/ListRecipients?apikey=name&apisecret=abd123&apioutputformat=API_FORMAT_JSON&usertoken=m3cv0d9gqb69taajcu76nqv5eccht76t",
         
     | 
| 
      
 373 
     | 
    
         
            +
                                      :body => @recipients.to_json,
         
     | 
| 
      
 374 
     | 
    
         
            +
                                      :content_type => "application/json",
         
     | 
| 
      
 375 
     | 
    
         
            +
                                      :status => ["200", "OK"])
         
     | 
| 
      
 376 
     | 
    
         
            +
             
     | 
| 
      
 377 
     | 
    
         
            +
                FakeWeb.register_uri(:get, 
         
     | 
| 
      
 378 
     | 
    
         
            +
                                      "https://sandbox-api.pamfax.biz/FaxJob/Cancel?apikey=name&apisecret=abd123&apioutputformat=API_FORMAT_JSON&usertoken=m3cv0d9gqb69taajcu76nqv5eccht76t&uuid=JfTenDWumWZZBq",
         
     | 
| 
      
 379 
     | 
    
         
            +
                                      :body => @success.to_json,
         
     | 
| 
      
 380 
     | 
    
         
            +
                                      :content_type => "application/json",
         
     | 
| 
      
 381 
     | 
    
         
            +
                                      :status => ["200", "OK"])
         
     | 
| 
      
 382 
     | 
    
         
            +
             
     | 
| 
      
 383 
     | 
    
         
            +
                FakeWeb.register_uri(:get, 
         
     | 
| 
      
 384 
     | 
    
         
            +
                                      "https://sandbox-api.pamfax.biz/FaxJob/GetPreview?apikey=name&apisecret=abd123&apioutputformat=API_FORMAT_JSON&usertoken=m3cv0d9gqb69taajcu76nqv5eccht76t&uuid=JfTenDWumWZZBq",
         
     | 
| 
      
 385 
     | 
    
         
            +
                                      :body => @fax_preview.to_json,
         
     | 
| 
      
 386 
     | 
    
         
            +
                                      :content_type => "application/json",
         
     | 
| 
      
 387 
     | 
    
         
            +
                                      :status => ["200", "OK"])
         
     | 
| 
      
 388 
     | 
    
         
            +
             
     | 
| 
      
 389 
     | 
    
         
            +
                FakeWeb.register_uri(:get, 
         
     | 
| 
      
 390 
     | 
    
         
            +
                                      "https://sandbox-api.pamfax.biz/FaxJob/GetPreview?apikey=name&apisecret=abd123&apioutputformat=API_FORMAT_JSON&usertoken=m3cv0d9gqb69taajcu76nqv5eccht76t&uuid=JfTenDWumWZZBq",
         
     | 
| 
      
 391 
     | 
    
         
            +
                                      :body => @fax_preview.to_json,
         
     | 
| 
      
 392 
     | 
    
         
            +
                                      :content_type => "application/json",
         
     | 
| 
      
 393 
     | 
    
         
            +
                                      :status => ["200", "OK"])
         
     | 
| 
      
 394 
     | 
    
         
            +
             
     | 
| 
      
 395 
     | 
    
         
            +
                FakeWeb.register_uri(:get, 
         
     | 
| 
      
 396 
     | 
    
         
            +
                                      %r|https://sandbox-api.pamfax.biz/FaxJob/Remove|,
         
     | 
| 
      
 397 
     | 
    
         
            +
                                      :body => @success.to_json,
         
     | 
| 
      
 398 
     | 
    
         
            +
                                      :content_type => "application/json",
         
     | 
| 
      
 399 
     | 
    
         
            +
                                      :status => ["200", "OK"])
         
     | 
| 
      
 400 
     | 
    
         
            +
                                                                                      
         
     | 
| 
      
 401 
     | 
    
         
            +
                # Our testing URI
         
     | 
| 
      
 402 
     | 
    
         
            +
                @pamfaxr = PamFaxr.new :base_uri => PAMFAX_URI,
         
     | 
| 
      
 403 
     | 
    
         
            +
                                       :key      => PAMFAX_KEY, 
         
     | 
| 
      
 404 
     | 
    
         
            +
                                       :secret   => PAMFAX_SECRET, 
         
     | 
| 
      
 405 
     | 
    
         
            +
                                       :username => PAMFAX_USERNAME, 
         
     | 
| 
      
 406 
     | 
    
         
            +
                                       :password => PAMFAX_PASSWORD
         
     | 
| 
      
 407 
     | 
    
         
            +
             
     | 
| 
      
 408 
     | 
    
         
            +
              end
         
     | 
| 
      
 409 
     | 
    
         
            +
              
         
     | 
| 
      
 410 
     | 
    
         
            +
              it "should create an instance of PamFax" do
         
     | 
| 
      
 411 
     | 
    
         
            +
                @pamfaxr.instance_of?(PamFaxr).should == true
         
     | 
| 
      
 412 
     | 
    
         
            +
              end
         
     | 
| 
      
 413 
     | 
    
         
            +
              
         
     | 
| 
      
 414 
     | 
    
         
            +
              it "should get an error if invalid user details are requested" do
         
     | 
| 
      
 415 
     | 
    
         
            +
                begin
         
     | 
| 
      
 416 
     | 
    
         
            +
                  pamfax = PamFaxr.new :base_uri => PAMFAX_URI,
         
     | 
| 
      
 417 
     | 
    
         
            +
                                       :key      => 'tropo', 
         
     | 
| 
      
 418 
     | 
    
         
            +
                                       :secret   => 'abc123', 
         
     | 
| 
      
 419 
     | 
    
         
            +
                                       :username => 'fooey', 
         
     | 
| 
      
 420 
     | 
    
         
            +
                                       :password => 'looey'
         
     | 
| 
      
 421 
     | 
    
         
            +
                rescue => e
         
     | 
| 
      
 422 
     | 
    
         
            +
                  e.to_s.should == "Unknown user name or incorrect password"
         
     | 
| 
      
 423 
     | 
    
         
            +
                end
         
     | 
| 
      
 424 
     | 
    
         
            +
              end
         
     | 
| 
      
 425 
     | 
    
         
            +
              
         
     | 
| 
      
 426 
     | 
    
         
            +
              it "should raise an error if an unknown method is called" do
         
     | 
| 
      
 427 
     | 
    
         
            +
                begin
         
     | 
| 
      
 428 
     | 
    
         
            +
                  @pamfaxr.foobar
         
     | 
| 
      
 429 
     | 
    
         
            +
                rescue => e
         
     | 
| 
      
 430 
     | 
    
         
            +
                  e.to_s.should == 'Unknown method foobar'
         
     | 
| 
      
 431 
     | 
    
         
            +
                end
         
     | 
| 
      
 432 
     | 
    
         
            +
              end
         
     | 
| 
      
 433 
     | 
    
         
            +
              
         
     | 
| 
      
 434 
     | 
    
         
            +
              it "should create a new fax instance" do
         
     | 
| 
      
 435 
     | 
    
         
            +
                @pamfaxr.create_fax_job.should == @create_result
         
     | 
| 
      
 436 
     | 
    
         
            +
              end
         
     | 
| 
      
 437 
     | 
    
         
            +
              
         
     | 
| 
      
 438 
     | 
    
         
            +
              it "should create a new fax receipient" do
         
     | 
| 
      
 439 
     | 
    
         
            +
                @pamfaxr.add_recipient('+14155551212').should == @add_recipient_result
         
     | 
| 
      
 440 
     | 
    
         
            +
              end
         
     | 
| 
      
 441 
     | 
    
         
            +
              
         
     | 
| 
      
 442 
     | 
    
         
            +
              it "should add a new fax cover" do
         
     | 
| 
      
 443 
     | 
    
         
            +
                @pamfaxr.set_cover('f340f1b1f65b6df5b5e3f94d95b11daf', 'Hi foobar!').should == { "result" => { "code" => "success", "count" => 0, "message" => "" } }
         
     | 
| 
      
 444 
     | 
    
         
            +
              end
         
     | 
| 
      
 445 
     | 
    
         
            +
              
         
     | 
| 
      
 446 
     | 
    
         
            +
              it "should return the fax state when no files attached" do
         
     | 
| 
      
 447 
     | 
    
         
            +
                @pamfaxr.get_state.should == @state
         
     | 
| 
      
 448 
     | 
    
         
            +
              end
         
     | 
| 
      
 449 
     | 
    
         
            +
              
         
     | 
| 
      
 450 
     | 
    
         
            +
              it "should reject the fax send request if no pages added" do
         
     | 
| 
      
 451 
     | 
    
         
            +
                @pamfaxr.send_fax.should == @no_files
         
     | 
| 
      
 452 
     | 
    
         
            +
              end
         
     | 
| 
      
 453 
     | 
    
         
            +
              
         
     | 
| 
      
 454 
     | 
    
         
            +
              it "should add a file to the fax job" do
         
     | 
| 
      
 455 
     | 
    
         
            +
                @pamfaxr.add_remote_file('https://s3.amazonaws.com/pamfax-test/R-intro.pdf').should == @page
         
     | 
| 
      
 456 
     | 
    
         
            +
                @pamfaxr.add_file('examples/R-intro.pdf').should == @local_file_upload
         
     | 
| 
      
 457 
     | 
    
         
            +
              end
         
     | 
| 
      
 458 
     | 
    
         
            +
              
         
     | 
| 
      
 459 
     | 
    
         
            +
              it "should list the available fax cover templates" do
         
     | 
| 
      
 460 
     | 
    
         
            +
                @pamfaxr.list_available_covers.should == @available_covers
         
     | 
| 
      
 461 
     | 
    
         
            +
              end
         
     | 
| 
      
 462 
     | 
    
         
            +
              
         
     | 
| 
      
 463 
     | 
    
         
            +
              it 'should list the assoicated files' do
         
     | 
| 
      
 464 
     | 
    
         
            +
                @pamfaxr.list_fax_files.should == @fax_files
         
     | 
| 
      
 465 
     | 
    
         
            +
              end
         
     | 
| 
      
 466 
     | 
    
         
            +
              
         
     | 
| 
      
 467 
     | 
    
         
            +
              it 'should list the recipients' do
         
     | 
| 
      
 468 
     | 
    
         
            +
                @pamfaxr.list_recipients.should == @recipients
         
     | 
| 
      
 469 
     | 
    
         
            +
              end
         
     | 
| 
      
 470 
     | 
    
         
            +
              
         
     | 
| 
      
 471 
     | 
    
         
            +
              it 'should cancel an outstanding fax request' do
         
     | 
| 
      
 472 
     | 
    
         
            +
                @pamfaxr.cancel('JfTenDWumWZZBq').should == @success
         
     | 
| 
      
 473 
     | 
    
         
            +
              end
         
     | 
| 
      
 474 
     | 
    
         
            +
              
         
     | 
| 
      
 475 
     | 
    
         
            +
              it 'should clone a fax' do
         
     | 
| 
      
 476 
     | 
    
         
            +
                pending('Can not send from the sandbox, so fax is never in a state to see a valid response.')
         
     | 
| 
      
 477 
     | 
    
         
            +
              end
         
     | 
| 
      
 478 
     | 
    
         
            +
              
         
     | 
| 
      
 479 
     | 
    
         
            +
              it 'should allow us to preview all of the pages' do
         
     | 
| 
      
 480 
     | 
    
         
            +
                @pamfaxr.get_preview('JfTenDWumWZZBq').should == @fax_preview
         
     | 
| 
      
 481 
     | 
    
         
            +
              end
         
     | 
| 
      
 482 
     | 
    
         
            +
              
         
     | 
| 
      
 483 
     | 
    
         
            +
              it 'should send the fax later' do
         
     | 
| 
      
 484 
     | 
    
         
            +
                @pamfaxr.send_fax_later.should == @no_files
         
     | 
| 
      
 485 
     | 
    
         
            +
              end
         
     | 
| 
      
 486 
     | 
    
         
            +
              
         
     | 
| 
      
 487 
     | 
    
         
            +
              describe 'remove' do
         
     | 
| 
      
 488 
     | 
    
         
            +
                it 'should remove all files' do
         
     | 
| 
      
 489 
     | 
    
         
            +
                  @pamfaxr.remove_all_files.should == @success
         
     | 
| 
      
 490 
     | 
    
         
            +
                end
         
     | 
| 
      
 491 
     | 
    
         
            +
                
         
     | 
| 
      
 492 
     | 
    
         
            +
                it 'should remove all recipients' do
         
     | 
| 
      
 493 
     | 
    
         
            +
                  @pamfaxr.remove_all_recipients.should == @success
         
     | 
| 
      
 494 
     | 
    
         
            +
                end
         
     | 
| 
      
 495 
     | 
    
         
            +
                
         
     | 
| 
      
 496 
     | 
    
         
            +
                it 'should remove the cover' do
         
     | 
| 
      
 497 
     | 
    
         
            +
                  @pamfaxr.remove_cover.should == @success
         
     | 
| 
      
 498 
     | 
    
         
            +
                end
         
     | 
| 
      
 499 
     | 
    
         
            +
                
         
     | 
| 
      
 500 
     | 
    
         
            +
                it 'should remove the cover' do
         
     | 
| 
      
 501 
     | 
    
         
            +
                  @pamfaxr.remove_file('1234').should == @success
         
     | 
| 
      
 502 
     | 
    
         
            +
                end
         
     | 
| 
      
 503 
     | 
    
         
            +
              end
         
     | 
| 
      
 504 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/pdf-test.pdf
    ADDED
    
    | 
         Binary file 
     | 
    
        data/spec/spec.opts
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --color
         
     | 
    
        data/spec/spec_helper.rb
    ADDED