Skip to content

Commit

Permalink
Merge pull request #6 from Loft47/chore/refactor-document
Browse files Browse the repository at this point in the history
The Document endpoint was consuming the loop_view_id, not the loop_id
  • Loading branch information
theabuitendyk committed Jul 27, 2016
2 parents f3f07ba + 931677d commit c04b5b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions lib/dotloop/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ def initialize(client:)
@client = client
end

def all(profile_id:, loop_id:)
@client.get("/profile/#{profile_id.to_i}/loop/#{loop_id.to_i}/document").map do |document_attrs|
def all(profile_id:, loop_view_id:)
@client.get("/profile/#{profile_id.to_i}/loop/#{loop_view_id.to_i}/document").map do |document_attrs|
doc = Dotloop::Models::Document.new(document_attrs)
doc.client = client
doc
end
end

def get(profile_id:, loop_id:, document_id:, document_name:)
def get(profile_id:, loop_view_id:, document_id:, document_name:)
document_name = CGI.escape(document_name)
StringIO.new(
@client.raw("/profile/#{profile_id.to_i}/loop/#{loop_id.to_i}/document/#{document_id}/#{document_name}.pdf")
@client.raw(
"/profile/#{profile_id.to_i}/loop/#{loop_view_id.to_i}/document/#{document_id}/#{document_name}.pdf"
)
)
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/dotloop/document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
describe '#all' do
it 'should return a list of documents' do
dotloop_mock(:documents)
documents = subject.all(profile_id: 1_234, loop_id: 76_046)
documents = subject.all(profile_id: 1_234, loop_view_id: 76_046)
expect(documents).to_not be_empty
expect(documents).to all(be_a(Dotloop::Models::Document))
expect(documents.first).to have_attributes(
Expand All @@ -38,7 +38,7 @@
it 'should get pdf data' do
dotloop_pdf
document = subject.get(profile_id: 1_234,
loop_id: 76_046,
loop_view_id: 76_046,
document_id: 561_622,
document_name: 'AgencyDisclosureStatementSeller')
expect(document.string).to eq(disclosure_file_data)
Expand Down

0 comments on commit c04b5b4

Please sign in to comment.