rightsignature-railstyle 1.1.9
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.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/CONTRIBUTING.md +26 -0
- data/Gemfile +2 -0
- data/README.md +443 -0
- data/Rakefile +2 -0
- data/lib/rightsignature.rb +15 -0
- data/lib/rightsignature/account.rb +37 -0
- data/lib/rightsignature/connection.rb +207 -0
- data/lib/rightsignature/connection/oauth_connection.rb +109 -0
- data/lib/rightsignature/connection/token_connection.rb +36 -0
- data/lib/rightsignature/document.rb +333 -0
- data/lib/rightsignature/errors.rb +51 -0
- data/lib/rightsignature/helpers/normalizing.rb +137 -0
- data/lib/rightsignature/helpers/refine_hash_to_indifferent_access.rb +23 -0
- data/lib/rightsignature/rails_style.rb +89 -0
- data/lib/rightsignature/template.rb +299 -0
- data/lib/rightsignature/version.rb +3 -0
- data/rightsignature-api.gemspec +26 -0
- data/spec/account_spec.rb +54 -0
- data/spec/api_token_connection_spec.rb +27 -0
- data/spec/configuration_spec.rb +98 -0
- data/spec/connection_spec.rb +224 -0
- data/spec/document_spec.rb +301 -0
- data/spec/errors_spec.rb +153 -0
- data/spec/normalizing_spec.rb +85 -0
- data/spec/oauth_connnection_spec.rb +143 -0
- data/spec/rails_style_spec.rb +331 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/template_spec.rb +408 -0
- metadata +143 -0
    
        data/spec/spec_helper.rb
    ADDED
    
    | @@ -0,0 +1,12 @@ | |
| 1 | 
            +
            require 'rubygems'
         | 
| 2 | 
            +
            require 'rspec'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            require File.dirname(__FILE__) + '/../lib/rightsignature'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            RSpec.configure do |c|
         | 
| 7 | 
            +
              c.mock_with :rspec
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              c.before(:each) do
         | 
| 10 | 
            +
                @rs = RightSignature::Connection.new({:consumer_key => "Consumer123", :consumer_secret => "Secret098", :access_token => "AccessToken098", :access_secret => "AccessSecret123", :api_token => "APITOKEN"})
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
            end
         | 
| @@ -0,0 +1,408 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/spec_helper.rb'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe RightSignature::Template do 
         | 
| 4 | 
            +
              describe "templates_list" do
         | 
| 5 | 
            +
                it "should GET /api/templates.xml" do
         | 
| 6 | 
            +
                  @rs.should_receive(:get).with('/api/templates.xml', {})
         | 
| 7 | 
            +
                  @rs.templates_list
         | 
| 8 | 
            +
                end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                it "should pass search options to /api/templates.xml" do
         | 
| 11 | 
            +
                  @rs.should_receive(:get).with('/api/templates.xml', {:search => "search", :page => 2})
         | 
| 12 | 
            +
                  @rs.templates_list(:search => "search", :page => 2)
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
                
         | 
| 15 | 
            +
                it "should convert tags array of mixed strings and hashes into into normalized Tag string" do
         | 
| 16 | 
            +
                  @rs.should_receive(:get).with('/api/templates.xml', {:tags => "hello,abc:def,there"})
         | 
| 17 | 
            +
                  @rs.templates_list(:tags => ["hello", {"abc" => "def"}, "there"])
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                it "should keep tags as string if :tags is a string" do
         | 
| 21 | 
            +
                  @rs.should_receive(:get).with('/api/templates.xml', {:tags => "voice,no:way,microphone"})
         | 
| 22 | 
            +
                  @rs.templates_list(:tags => "voice,no:way,microphone")
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
              
         | 
| 26 | 
            +
              describe "template_details" do
         | 
| 27 | 
            +
                it "should GET /api/templates/MYGUID.xml" do
         | 
| 28 | 
            +
                  @rs.should_receive(:get).with('/api/templates/MYGUID.xml', {})
         | 
| 29 | 
            +
                  @rs.template_details('MYGUID')
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
              describe "prepackage" do
         | 
| 34 | 
            +
                it "should POST /api/templates/MYGUID/prepackage.xml" do
         | 
| 35 | 
            +
                  @rs.should_receive(:post).with('/api/templates/MYGUID/prepackage.xml', {})
         | 
| 36 | 
            +
                  @rs.prepackage('MYGUID')
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
              
         | 
| 41 | 
            +
              describe "prepackage_and_send" do
         | 
| 42 | 
            +
                it "should POST /api/templates/GUID123/prepackage.xml and POST /api/templates.xml using guid, and subject from prepackage response" do
         | 
| 43 | 
            +
                  @rs.should_receive(:post).with('/api/templates/GUID123/prepackage.xml', 
         | 
| 44 | 
            +
                    {}
         | 
| 45 | 
            +
                  ).and_return({"template" => {
         | 
| 46 | 
            +
                    "guid" => "a_123985_1z9v8pd654",
         | 
| 47 | 
            +
                    "subject" => "subject template",
         | 
| 48 | 
            +
                    "message" => "Default message here"
         | 
| 49 | 
            +
                  }})
         | 
| 50 | 
            +
                  @rs.should_receive(:post).with('/api/templates.xml', {:template => {
         | 
| 51 | 
            +
                      :guid => "a_123985_1z9v8pd654", 
         | 
| 52 | 
            +
                      :action => "send", 
         | 
| 53 | 
            +
                      :subject => "sign me", 
         | 
| 54 | 
            +
                      :roles => []
         | 
| 55 | 
            +
                    }})
         | 
| 56 | 
            +
                  @rs.prepackage_and_send("GUID123", [], {:subject => "sign me"})
         | 
| 57 | 
            +
                end
         | 
| 58 | 
            +
                
         | 
| 59 | 
            +
                it "should default subject to one in Template prepackage response" do
         | 
| 60 | 
            +
                  @rs.should_receive(:post).with('/api/templates/GUID123/prepackage.xml', 
         | 
| 61 | 
            +
                    {}
         | 
| 62 | 
            +
                  ).and_return({"template" => {
         | 
| 63 | 
            +
                    "guid" => "a_123985_1z9v8pd654",
         | 
| 64 | 
            +
                    "subject" => "subject template",
         | 
| 65 | 
            +
                    "message" => "Default message here"
         | 
| 66 | 
            +
                  }})
         | 
| 67 | 
            +
                  @rs.should_receive(:post).with('/api/templates.xml', {:template => {
         | 
| 68 | 
            +
                      :guid => "a_123985_1z9v8pd654", 
         | 
| 69 | 
            +
                      :action => "send", 
         | 
| 70 | 
            +
                      :subject => "subject template", 
         | 
| 71 | 
            +
                      :roles => []
         | 
| 72 | 
            +
                    }})
         | 
| 73 | 
            +
                  @rs.prepackage_and_send("GUID123", [])
         | 
| 74 | 
            +
                end
         | 
| 75 | 
            +
              end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
              describe "prefill/send_template" do
         | 
| 78 | 
            +
                it "should POST /api/templates.xml with action of 'prefill', MYGUID guid, roles, and \"sign me\" subject in template hash" do
         | 
| 79 | 
            +
                  @rs.should_receive(:post).with('/api/templates.xml', {:template => {:guid => "MYGUID", :action => "prefill", :subject => "sign me", :roles => []}})
         | 
| 80 | 
            +
                  @rs.prefill("MYGUID", "sign me", [])
         | 
| 81 | 
            +
                end
         | 
| 82 | 
            +
                
         | 
| 83 | 
            +
                it "should add \"@role_name\"=>'Employee' key to roles in xml hash" do
         | 
| 84 | 
            +
                  @rs.should_receive(:post).with('/api/templates.xml', {
         | 
| 85 | 
            +
                    :template => {
         | 
| 86 | 
            +
                      :guid => "MYGUID", 
         | 
| 87 | 
            +
                      :action => "prefill",
         | 
| 88 | 
            +
                      :subject => "sign me", 
         | 
| 89 | 
            +
                      :roles => [
         | 
| 90 | 
            +
                        {:role => {
         | 
| 91 | 
            +
                          :name => "John Employee", 
         | 
| 92 | 
            +
                          :email => "john@employee.com", 
         | 
| 93 | 
            +
                          "@role_name" => "Employee"
         | 
| 94 | 
            +
                        }}
         | 
| 95 | 
            +
                      ]
         | 
| 96 | 
            +
                    }
         | 
| 97 | 
            +
                  })
         | 
| 98 | 
            +
                  @rs.prefill("MYGUID", "sign me", [{"Employee" => {:name => "John Employee", :email => "john@employee.com"}}])
         | 
| 99 | 
            +
                end
         | 
| 100 | 
            +
                
         | 
| 101 | 
            +
                it "should add \"@role_id\"=>'signer_A' key to roles in xml hash" do
         | 
| 102 | 
            +
                  @rs.should_receive(:post).with('/api/templates.xml', {
         | 
| 103 | 
            +
                    :template => {
         | 
| 104 | 
            +
                      :guid => "MYGUID", 
         | 
| 105 | 
            +
                      :action => "prefill",
         | 
| 106 | 
            +
                      :subject => "sign me", 
         | 
| 107 | 
            +
                      :roles => [
         | 
| 108 | 
            +
                        {:role => {
         | 
| 109 | 
            +
                          :name => "John Employee", 
         | 
| 110 | 
            +
                          :email => "john@employee.com", 
         | 
| 111 | 
            +
                          "@role_id" => "signer_A"
         | 
| 112 | 
            +
                        }}
         | 
| 113 | 
            +
                      ]
         | 
| 114 | 
            +
                    }
         | 
| 115 | 
            +
                  })
         | 
| 116 | 
            +
                  @rs.prefill("MYGUID", "sign me", [{"signer_A" => {:name => "John Employee", :email => "john@employee.com"}}])
         | 
| 117 | 
            +
                end
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                describe "optional options" do
         | 
| 120 | 
            +
                  it "should add \"@merge_field_name\"=>'Tax_id' key to merge_fields in xml hash" do
         | 
| 121 | 
            +
                    @rs.should_receive(:post).with('/api/templates.xml', {
         | 
| 122 | 
            +
                      :template => {
         | 
| 123 | 
            +
                        :guid => "MYGUID", 
         | 
| 124 | 
            +
                        :action => "prefill",
         | 
| 125 | 
            +
                        :subject => "sign me", 
         | 
| 126 | 
            +
                        :roles => [
         | 
| 127 | 
            +
                        ],
         | 
| 128 | 
            +
                        :merge_fields => [{:merge_field => {:value => "123456", "@merge_field_name" => "Tax_id"}}]
         | 
| 129 | 
            +
                      }
         | 
| 130 | 
            +
                    })
         | 
| 131 | 
            +
                    @rs.prefill("MYGUID", "sign me", [], {:merge_fields => [{"Tax_id" => "123456"}]})
         | 
| 132 | 
            +
                  end
         | 
| 133 | 
            +
             | 
| 134 | 
            +
                  it "should add \"@merge_field_id\"=>'123_abc_78' key to merge_fields in xml hash" do
         | 
| 135 | 
            +
                    @rs.should_receive(:post).with('/api/templates.xml', {
         | 
| 136 | 
            +
                      :template => {
         | 
| 137 | 
            +
                        :guid => "MYGUID", 
         | 
| 138 | 
            +
                        :action => "prefill",
         | 
| 139 | 
            +
                        :subject => "sign me", 
         | 
| 140 | 
            +
                        :roles => [
         | 
| 141 | 
            +
                        ],
         | 
| 142 | 
            +
                        :merge_fields => [{:merge_field => {:value => "123456", "@merge_field_id" => "123_abc_78"}}]
         | 
| 143 | 
            +
                      }
         | 
| 144 | 
            +
                    })
         | 
| 145 | 
            +
                    @rs.prefill("MYGUID", "sign me", [], {:merge_fields => [{"123_abc_78" => "123456"}], :use_merge_field_ids => true})
         | 
| 146 | 
            +
                  end
         | 
| 147 | 
            +
             | 
| 148 | 
            +
                  it "should add \"tag\" key to tags in xml hash" do
         | 
| 149 | 
            +
                    @rs.should_receive(:post).with('/api/templates.xml', {
         | 
| 150 | 
            +
                      :template => {
         | 
| 151 | 
            +
                        :guid => "MYGUID", 
         | 
| 152 | 
            +
                        :action => "prefill",
         | 
| 153 | 
            +
                        :subject => "sign me", 
         | 
| 154 | 
            +
                        :roles => [],
         | 
| 155 | 
            +
                        :tags => [{:tag => {:name => "I_Key", :value => "I_Value"}}, {:tag => {:name => "Alone"}}]
         | 
| 156 | 
            +
                      }
         | 
| 157 | 
            +
                    })
         | 
| 158 | 
            +
                    @rs.prefill("MYGUID", "sign me", [], {:tags => [{"I_Key" => "I_Value"}, "Alone"]})
         | 
| 159 | 
            +
                  end
         | 
| 160 | 
            +
             | 
| 161 | 
            +
                  it "should include options :expires_in, :description, :redirect_location, :document_data, and :callback_location" do
         | 
| 162 | 
            +
                    @rs.should_receive(:post).with('/api/templates.xml', {
         | 
| 163 | 
            +
                      :template => {
         | 
| 164 | 
            +
                        :guid => "MYGUID", 
         | 
| 165 | 
            +
                        :action => "prefill",
         | 
| 166 | 
            +
                        :subject => "sign me", 
         | 
| 167 | 
            +
                        :roles => [],
         | 
| 168 | 
            +
                        :expires_in => 15, 
         | 
| 169 | 
            +
                        :description => "Hey, I'm a description", 
         | 
| 170 | 
            +
                        :redirect_location => 'http://example.com/redirectme',
         | 
| 171 | 
            +
                        :document_data => {:type => 'base64', :filename => "originalfile.pdf", :value => "mOio90cv"},
         | 
| 172 | 
            +
                        :callback_location => 'http://example.com/callie'
         | 
| 173 | 
            +
                      }
         | 
| 174 | 
            +
                    })
         | 
| 175 | 
            +
                    @rs.prefill("MYGUID", "sign me", [], {:expires_in => 15, :description => "Hey, I'm a description", :redirect_location => 'http://example.com/redirectme', :callback_location => "http://example.com/callie", :document_data => {:type => 'base64', :filename => "originalfile.pdf", :value => "mOio90cv"}})
         | 
| 176 | 
            +
                  end
         | 
| 177 | 
            +
             | 
| 178 | 
            +
                  it "should include extra options" do
         | 
| 179 | 
            +
                    @rs.should_receive(:post).with('/api/templates.xml', {
         | 
| 180 | 
            +
                      :template => {
         | 
| 181 | 
            +
                        :guid => "MYGUID", 
         | 
| 182 | 
            +
                        :action => "prefill",
         | 
| 183 | 
            +
                        :subject => "sign me", 
         | 
| 184 | 
            +
                        :roles => [
         | 
| 185 | 
            +
                          {:role => {
         | 
| 186 | 
            +
                            :name => "John Employee", 
         | 
| 187 | 
            +
                            :email => "john@employee.com", 
         | 
| 188 | 
            +
                            "@role_id" => "signer_A"
         | 
| 189 | 
            +
                        }}],
         | 
| 190 | 
            +
                        :expires_in => 15, 
         | 
| 191 | 
            +
                        :description => "Hey, I'm a description", 
         | 
| 192 | 
            +
                        :redirect_location => 'http://example.com/redirectme',
         | 
| 193 | 
            +
                        :document_data => {:type => 'base64', :filename => "originalfile.pdf", :value => "mOio90cv"},
         | 
| 194 | 
            +
                        :callback_location => 'http://example.com/callie',
         | 
| 195 | 
            +
                        :something_else => "else",
         | 
| 196 | 
            +
                        :merge_fields => [{:merge_field => {:value => "123456", "@merge_field_id" => "123_abc_78"}}]
         | 
| 197 | 
            +
                      }
         | 
| 198 | 
            +
                    })
         | 
| 199 | 
            +
                    @rs.prefill("MYGUID", "sign me", [{"signer_A" => {:name => "John Employee", :email => "john@employee.com"}}], {:expires_in => 15, :description => "Hey, I'm a description", :redirect_location => 'http://example.com/redirectme', :callback_location => "http://example.com/callie", :document_data => {:type => 'base64', :filename => "originalfile.pdf", :value => "mOio90cv"}, :merge_fields => [{"123_abc_78" => "123456"}], :use_merge_field_ids => true, :something_else => "else"})
         | 
| 200 | 
            +
                  end
         | 
| 201 | 
            +
                end
         | 
| 202 | 
            +
             | 
| 203 | 
            +
                it "should POST /api/templates.xml with action of 'send', MYGUID guid, roles, and \"sign me\" subject in template hash" do
         | 
| 204 | 
            +
                  @rs.should_receive(:post).with('/api/templates.xml', {:template => {:guid => "MYGUID", :action => "send", :subject => "sign me", :roles => []}})
         | 
| 205 | 
            +
                  @rs.send_template("MYGUID", "sign me", [])
         | 
| 206 | 
            +
                end
         | 
| 207 | 
            +
              end
         | 
| 208 | 
            +
              
         | 
| 209 | 
            +
              describe "generate_build_url" do
         | 
| 210 | 
            +
                it "should POST /api/templates/generate_build_token.xml" do
         | 
| 211 | 
            +
                  @rs.should_receive(:post).with("/api/templates/generate_build_token.xml", {:template => {}}).and_return({"token"=>{"redirect_token" => "REDIRECT_TOKEN"}})
         | 
| 212 | 
            +
                  @rs.generate_build_url
         | 
| 213 | 
            +
                end
         | 
| 214 | 
            +
             | 
| 215 | 
            +
                it "should return https://rightsignature.com/builder/new?rt=REDIRECT_TOKEN" do
         | 
| 216 | 
            +
                  @rs.should_receive(:post).with("/api/templates/generate_build_token.xml", {:template => {}}).and_return({"token"=>{"redirect_token" => "REDIRECT_TOKEN"}})
         | 
| 217 | 
            +
                  @rs.generate_build_url.should == "#{@rs.site}/builder/new?rt=REDIRECT_TOKEN"
         | 
| 218 | 
            +
                end
         | 
| 219 | 
            +
             | 
| 220 | 
            +
                describe "options" do
         | 
| 221 | 
            +
                  it "should include normalized :acceptable_merge_field_names in params" do
         | 
| 222 | 
            +
                    @rs.should_receive(:post).with("/api/templates/generate_build_token.xml", {:template => 
         | 
| 223 | 
            +
                      {:acceptable_merge_field_names => 
         | 
| 224 | 
            +
                        [
         | 
| 225 | 
            +
                          {:name => "Site ID"}, 
         | 
| 226 | 
            +
                          {:name => "Starting City"}
         | 
| 227 | 
            +
                        ]}
         | 
| 228 | 
            +
                    }).and_return({"token"=>{"redirect_token" => "REDIRECT_TOKEN"}})
         | 
| 229 | 
            +
                    @rs.generate_build_url(:acceptable_merge_field_names => ["Site ID", "Starting City"])
         | 
| 230 | 
            +
                  end
         | 
| 231 | 
            +
             | 
| 232 | 
            +
                  it "should include normalized :acceptable_role_names, in params" do
         | 
| 233 | 
            +
                    @rs.should_receive(:post).with("/api/templates/generate_build_token.xml", {:template => 
         | 
| 234 | 
            +
                      {:acceptable_role_names => 
         | 
| 235 | 
            +
                        [
         | 
| 236 | 
            +
                          {:name => "Http Monster"}, 
         | 
| 237 | 
            +
                          {:name => "Party Monster"}
         | 
| 238 | 
            +
                        ]}
         | 
| 239 | 
            +
                    }).and_return({"token"=>{"redirect_token" => "REDIRECT_TOKEN"}})
         | 
| 240 | 
            +
                    @rs.generate_build_url(:acceptable_role_names => ["Http Monster", "Party Monster"])
         | 
| 241 | 
            +
                  end
         | 
| 242 | 
            +
             | 
| 243 | 
            +
                  it "should include normalized :tags in params" do
         | 
| 244 | 
            +
                    @rs.should_receive(:post).with("/api/templates/generate_build_token.xml", {:template => 
         | 
| 245 | 
            +
                      {:tags => 
         | 
| 246 | 
            +
                        [
         | 
| 247 | 
            +
                          {:tag => {:name => "Site"}}, 
         | 
| 248 | 
            +
                          {:tag => {:name => "Starting City", :value => "NY"}}
         | 
| 249 | 
            +
                        ]}
         | 
| 250 | 
            +
                    }).and_return({"token"=>{"redirect_token" => "REDIRECT_TOKEN"}})
         | 
| 251 | 
            +
                    @rs.generate_build_url(:tags => ["Site", "Starting City" => "NY"])
         | 
| 252 | 
            +
                  end
         | 
| 253 | 
            +
                  
         | 
| 254 | 
            +
                  it "should include :callback_location and :redirect_location in params" do
         | 
| 255 | 
            +
                    @rs.should_receive(:post).with("/api/templates/generate_build_token.xml", {:template => {
         | 
| 256 | 
            +
                      :callback_location => "http://example.com/done_signing", 
         | 
| 257 | 
            +
                      :redirect_location => "http://example.com/come_back_here"
         | 
| 258 | 
            +
                    }}).and_return({"token"=>{"redirect_token" => "REDIRECT_TOKEN"}})
         | 
| 259 | 
            +
             | 
| 260 | 
            +
                    @rs.generate_build_url(:callback_location => "http://example.com/done_signing", :redirect_location => "http://example.com/come_back_here")
         | 
| 261 | 
            +
                  end
         | 
| 262 | 
            +
             | 
| 263 | 
            +
                  it "should include other extra options in params" do
         | 
| 264 | 
            +
                    @rs.should_receive(:post).with("/api/templates/generate_build_token.xml", {:template => {
         | 
| 265 | 
            +
                      :tags => 
         | 
| 266 | 
            +
                        [
         | 
| 267 | 
            +
                          {:tag => {:name => "Site"}}
         | 
| 268 | 
            +
                        ],
         | 
| 269 | 
            +
                      :acceptable_merge_field_names => 
         | 
| 270 | 
            +
                        [
         | 
| 271 | 
            +
                          {:name => "Site ID"}, 
         | 
| 272 | 
            +
                          {:name => "Starting City"}
         | 
| 273 | 
            +
                        ],
         | 
| 274 | 
            +
                      :acceptable_role_names => 
         | 
| 275 | 
            +
                        [
         | 
| 276 | 
            +
                          {:name => "Http Party"}
         | 
| 277 | 
            +
                        ],
         | 
| 278 | 
            +
                      :callback_location => "http://example.com/done_signing", 
         | 
| 279 | 
            +
                      :redirect_location => "http://example.com/come_back_here",
         | 
| 280 | 
            +
                      :extras => "stuff here"
         | 
| 281 | 
            +
                    }}).and_return({"token"=>{"redirect_token" => "REDIRECT_TOKEN"}})
         | 
| 282 | 
            +
             | 
| 283 | 
            +
                    @rs.generate_build_url(:tags => ["Site"], :acceptable_merge_field_names => ["Site ID", "Starting City"], :acceptable_role_names => ["Http Party"], :callback_location => "http://example.com/done_signing", :redirect_location => "http://example.com/come_back_here", :extras => "stuff here")
         | 
| 284 | 
            +
                  end
         | 
| 285 | 
            +
                end
         | 
| 286 | 
            +
              end
         | 
| 287 | 
            +
              
         | 
| 288 | 
            +
              describe "send_as_self_signers" do
         | 
| 289 | 
            +
                before do
         | 
| 290 | 
            +
                  @prepackage_response = {"template"=>{
         | 
| 291 | 
            +
                    "type"=>"Document",
         | 
| 292 | 
            +
                    "guid"=>"a_123_456",
         | 
| 293 | 
            +
                    "created_at"=>"2012-09-25T14:51:44-07:00",
         | 
| 294 | 
            +
                    "filename"=>"assets-363-demo_document.pdf",
         | 
| 295 | 
            +
                    "size"=>"14597",
         | 
| 296 | 
            +
                    "content_type"=>"pdf",
         | 
| 297 | 
            +
                    "page_count"=>"1",
         | 
| 298 | 
            +
                    "subject"=>"subject template",
         | 
| 299 | 
            +
                    "message"=>"Default message here",
         | 
| 300 | 
            +
                    "tags"=>"template_id:31,user:1",
         | 
| 301 | 
            +
                    "processing_state"=>"done-processing",
         | 
| 302 | 
            +
                    "roles"=>
         | 
| 303 | 
            +
                    {"role"=>
         | 
| 304 | 
            +
                      [{"role"=>"Document Sender",
         | 
| 305 | 
            +
                        "name"=>"Document Sender",
         | 
| 306 | 
            +
                        "must_sign"=>"false",
         | 
| 307 | 
            +
                        "document_role_id"=>"cc_A",
         | 
| 308 | 
            +
                        "is_sender"=>"true"},
         | 
| 309 | 
            +
                       {"role"=>"Leasee",
         | 
| 310 | 
            +
                        "name"=>"Leasee",
         | 
| 311 | 
            +
                        "must_sign"=>"true",
         | 
| 312 | 
            +
                        "document_role_id"=>"signer_A",
         | 
| 313 | 
            +
                        "is_sender"=>"false"},
         | 
| 314 | 
            +
                       {"role"=>"Leaser",
         | 
| 315 | 
            +
                        "name"=>"Leaser",
         | 
| 316 | 
            +
                        "must_sign"=>"true",
         | 
| 317 | 
            +
                        "document_role_id"=>"signer_B",
         | 
| 318 | 
            +
                        "is_sender"=>"true"}]},
         | 
| 319 | 
            +
                    "merge_fields"=>nil,
         | 
| 320 | 
            +
                    "pages"=>
         | 
| 321 | 
            +
                      {"page"=>
         | 
| 322 | 
            +
                        {"page_number"=>"1",
         | 
| 323 | 
            +
                         "original_template_guid"=>"GUID123",
         | 
| 324 | 
            +
                         "original_template_filename"=>"demo_document.pdf"}
         | 
| 325 | 
            +
                      },
         | 
| 326 | 
            +
                    "thumbnail_url"=>
         | 
| 327 | 
            +
                    "https%3A%2F%2Fs3.amazonaws.com%3A443%2Frightsignature.com%2Fassets%2F1464%2Fabcde_p1_t.png%3FSignature%3D1234AC",
         | 
| 328 | 
            +
                    "redirect_token"=>
         | 
| 329 | 
            +
                    "123456bcde"
         | 
| 330 | 
            +
                  }}
         | 
| 331 | 
            +
                  
         | 
| 332 | 
            +
                  @sent_document_response = {"document"=> {
         | 
| 333 | 
            +
                    "status"=>"sent", 
         | 
| 334 | 
            +
                    "guid"=>"ABCDEFGH123"
         | 
| 335 | 
            +
                  }}
         | 
| 336 | 
            +
                  
         | 
| 337 | 
            +
                end
         | 
| 338 | 
            +
                
         | 
| 339 | 
            +
                it "should prepackage template, send template with reciepents with noemail@rightsignature.com and return self-signer links" do
         | 
| 340 | 
            +
                  @rs.should_receive(:post).with('/api/templates/TGUID/prepackage.xml', 
         | 
| 341 | 
            +
                    {}
         | 
| 342 | 
            +
                  ).and_return(@prepackage_response)
         | 
| 343 | 
            +
                  @rs.should_receive(:post).with('/api/templates.xml', {:template => {
         | 
| 344 | 
            +
                      :guid => "a_123_456", 
         | 
| 345 | 
            +
                      :action => "send", 
         | 
| 346 | 
            +
                      :subject => "subject template",
         | 
| 347 | 
            +
                      :roles => [
         | 
| 348 | 
            +
                        {:role => {:name => "John Bellingham", :email => "noemail@rightsignature.com", "@role_name" => "Leasee"}},
         | 
| 349 | 
            +
                        {:role => {:name => "Tim Else", :email => "noemail@rightsignature.com", "@role_name" => "Leaser"}}
         | 
| 350 | 
            +
                      ]
         | 
| 351 | 
            +
                    }}).and_return(@sent_document_response)
         | 
| 352 | 
            +
                  @rs.should_receive(:get).with("/api/documents/ABCDEFGH123/signer_links.xml", {}).and_return({"document" => {
         | 
| 353 | 
            +
                    "signer_links" => {"signer_link" => [
         | 
| 354 | 
            +
                      {"name" => "John Bellingham", "role" => "signer_A", "signer_token" => "slkfj2"},
         | 
| 355 | 
            +
                      {"name" => "Tim Else", "role" => "signer_B", "signer_token" => "asfd1"}
         | 
| 356 | 
            +
                    ]}
         | 
| 357 | 
            +
                  }})
         | 
| 358 | 
            +
                  
         | 
| 359 | 
            +
                  
         | 
| 360 | 
            +
                  results = @rs.send_as_embedded_signers("TGUID", [
         | 
| 361 | 
            +
                    {"Leasee" => {:name => "John Bellingham"}}, 
         | 
| 362 | 
            +
                    {"Leaser" => {:name => "Tim Else"}}
         | 
| 363 | 
            +
                  ])
         | 
| 364 | 
            +
                  results.size.should == 2
         | 
| 365 | 
            +
                  results.include?({"name" => "John Bellingham", "url" => "#{@rs.site}/signatures/embedded?rt=slkfj2"})
         | 
| 366 | 
            +
                  results.include?({"name" => "Tim Else", "url" => "#{@rs.site}/signatures/embedded?rt=asfd1"})
         | 
| 367 | 
            +
                end
         | 
| 368 | 
            +
                
         | 
| 369 | 
            +
                it "should not overwrite email if one is already set for receipient" do
         | 
| 370 | 
            +
                  @rs.should_receive(:post).with('/api/templates/TGUID/prepackage.xml', 
         | 
| 371 | 
            +
                    {}
         | 
| 372 | 
            +
                  ).and_return(@prepackage_response)
         | 
| 373 | 
            +
                  @rs.should_receive(:post).with('/api/templates.xml', {:template => {
         | 
| 374 | 
            +
                      :guid => "a_123_456", 
         | 
| 375 | 
            +
                      :action => "send", 
         | 
| 376 | 
            +
                      :subject => "subject template",
         | 
| 377 | 
            +
                      :roles => [
         | 
| 378 | 
            +
                        {:role => {:name => "John Bellingham", :email => "dontchange@example.com", "@role_name" => "Leasee"}},
         | 
| 379 | 
            +
                        {:role => {:name => "Tim Else", :email => "noemail@rightsignature.com", "@role_name" => "Leaser"}}
         | 
| 380 | 
            +
                      ]
         | 
| 381 | 
            +
                    }}).and_return(@sent_document_response)
         | 
| 382 | 
            +
                  @rs.should_receive(:get).with("/api/documents/ABCDEFGH123/signer_links.xml", {}).and_return({"document" => {
         | 
| 383 | 
            +
                    "signer_links" => {"signer_link" => [
         | 
| 384 | 
            +
                      {"name" => "John Bellingham", "email" => "dontchange@example.com", "role" => "signer_A", "signer_token" => "slkfj2"},
         | 
| 385 | 
            +
                      {"name" => "Tim Else", "role" => "signer_B", "signer_token" => "asfd1"}
         | 
| 386 | 
            +
                    ]}
         | 
| 387 | 
            +
                  }})
         | 
| 388 | 
            +
                  
         | 
| 389 | 
            +
                  results = @rs.send_as_embedded_signers("TGUID", [
         | 
| 390 | 
            +
                    {"Leasee" => {:name => "John Bellingham", :email => "dontchange@example.com"}}, 
         | 
| 391 | 
            +
                    {"Leaser" => {:name => "Tim Else"}}
         | 
| 392 | 
            +
                  ])
         | 
| 393 | 
            +
                  results.size.should == 2
         | 
| 394 | 
            +
                  results.include?({"name" => "John Bellingham", "url" => "#{@rs.site}/signatures/embedded?rt=slkfj2"})
         | 
| 395 | 
            +
                  results.include?({"name" => "Tim Else", "url" => "#{@rs.site}/signatures/embedded?rt=asfd1"})
         | 
| 396 | 
            +
                end
         | 
| 397 | 
            +
                
         | 
| 398 | 
            +
                it "should pass in options"
         | 
| 399 | 
            +
              end
         | 
| 400 | 
            +
             | 
| 401 | 
            +
              describe "trash" do
         | 
| 402 | 
            +
                it "should DELETE /api/templates/MYGUID.xml" do
         | 
| 403 | 
            +
                  expect(@rs).to receive(:delete).with('/api/templates/MYGUID.xml')
         | 
| 404 | 
            +
                  @rs.trash_template('MYGUID')
         | 
| 405 | 
            +
                end
         | 
| 406 | 
            +
              end
         | 
| 407 | 
            +
             | 
| 408 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,143 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: rightsignature-railstyle
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 1.1.9
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Nick Barone
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2017-03-21 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: bundler
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - ">="
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: 1.0.0
         | 
| 20 | 
            +
              type: :development
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - ">="
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: 1.0.0
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: rspec
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ">="
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: 2.11.0
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - ">="
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: 2.11.0
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: oauth
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - ">="
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: 0.4.0
         | 
| 48 | 
            +
              type: :runtime
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - ">="
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: 0.4.0
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: httparty
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ">="
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: 0.9.0
         | 
| 62 | 
            +
              type: :runtime
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - ">="
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: 0.9.0
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: xml-fu
         | 
| 71 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                requirements:
         | 
| 73 | 
            +
                - - ">="
         | 
| 74 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                    version: 0.2.0
         | 
| 76 | 
            +
              type: :runtime
         | 
| 77 | 
            +
              prerelease: false
         | 
| 78 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
                requirements:
         | 
| 80 | 
            +
                - - ">="
         | 
| 81 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                    version: 0.2.0
         | 
| 83 | 
            +
            description: Provides a wrapper for the RightSignature API.
         | 
| 84 | 
            +
            email:
         | 
| 85 | 
            +
            - ''
         | 
| 86 | 
            +
            executables: []
         | 
| 87 | 
            +
            extensions: []
         | 
| 88 | 
            +
            extra_rdoc_files: []
         | 
| 89 | 
            +
            files:
         | 
| 90 | 
            +
            - ".gitignore"
         | 
| 91 | 
            +
            - CONTRIBUTING.md
         | 
| 92 | 
            +
            - Gemfile
         | 
| 93 | 
            +
            - README.md
         | 
| 94 | 
            +
            - Rakefile
         | 
| 95 | 
            +
            - lib/rightsignature.rb
         | 
| 96 | 
            +
            - lib/rightsignature/account.rb
         | 
| 97 | 
            +
            - lib/rightsignature/connection.rb
         | 
| 98 | 
            +
            - lib/rightsignature/connection/oauth_connection.rb
         | 
| 99 | 
            +
            - lib/rightsignature/connection/token_connection.rb
         | 
| 100 | 
            +
            - lib/rightsignature/document.rb
         | 
| 101 | 
            +
            - lib/rightsignature/errors.rb
         | 
| 102 | 
            +
            - lib/rightsignature/helpers/normalizing.rb
         | 
| 103 | 
            +
            - lib/rightsignature/helpers/refine_hash_to_indifferent_access.rb
         | 
| 104 | 
            +
            - lib/rightsignature/rails_style.rb
         | 
| 105 | 
            +
            - lib/rightsignature/template.rb
         | 
| 106 | 
            +
            - lib/rightsignature/version.rb
         | 
| 107 | 
            +
            - rightsignature-api.gemspec
         | 
| 108 | 
            +
            - spec/account_spec.rb
         | 
| 109 | 
            +
            - spec/api_token_connection_spec.rb
         | 
| 110 | 
            +
            - spec/configuration_spec.rb
         | 
| 111 | 
            +
            - spec/connection_spec.rb
         | 
| 112 | 
            +
            - spec/document_spec.rb
         | 
| 113 | 
            +
            - spec/errors_spec.rb
         | 
| 114 | 
            +
            - spec/normalizing_spec.rb
         | 
| 115 | 
            +
            - spec/oauth_connnection_spec.rb
         | 
| 116 | 
            +
            - spec/rails_style_spec.rb
         | 
| 117 | 
            +
            - spec/spec_helper.rb
         | 
| 118 | 
            +
            - spec/template_spec.rb
         | 
| 119 | 
            +
            homepage: http://github.com/narfanator/rightsignature-api
         | 
| 120 | 
            +
            licenses:
         | 
| 121 | 
            +
            - MIT
         | 
| 122 | 
            +
            metadata: {}
         | 
| 123 | 
            +
            post_install_message: 
         | 
| 124 | 
            +
            rdoc_options: []
         | 
| 125 | 
            +
            require_paths:
         | 
| 126 | 
            +
            - lib
         | 
| 127 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 128 | 
            +
              requirements:
         | 
| 129 | 
            +
              - - ">="
         | 
| 130 | 
            +
                - !ruby/object:Gem::Version
         | 
| 131 | 
            +
                  version: '0'
         | 
| 132 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 133 | 
            +
              requirements:
         | 
| 134 | 
            +
              - - ">="
         | 
| 135 | 
            +
                - !ruby/object:Gem::Version
         | 
| 136 | 
            +
                  version: '0'
         | 
| 137 | 
            +
            requirements: []
         | 
| 138 | 
            +
            rubyforge_project: 
         | 
| 139 | 
            +
            rubygems_version: 2.6.8
         | 
| 140 | 
            +
            signing_key: 
         | 
| 141 | 
            +
            specification_version: 4
         | 
| 142 | 
            +
            summary: API wrapper for RightSignature
         | 
| 143 | 
            +
            test_files: []
         |