Class: Dotloop::Document
- Inherits:
-
Object
- Object
- Dotloop::Document
- Defined in:
- lib/dotloop/document.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #all(profile_id:, loop_view_id:) ⇒ Object
- #get(profile_id:, loop_view_id:, document_id:, document_name:) ⇒ Object
-
#initialize(client:) ⇒ Document
constructor
A new instance of Document.
Constructor Details
#initialize(client:) ⇒ Document
Returns a new instance of Document.
5 6 7 |
# File 'lib/dotloop/document.rb', line 5 def initialize(client:) @client = client end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
3 4 5 |
# File 'lib/dotloop/document.rb', line 3 def client @client end |
Instance Method Details
#all(profile_id:, loop_view_id:) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/dotloop/document.rb', line 9 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.profile_id = profile_id.to_i doc.loop_view_id = loop_view_id.to_i doc end end |
#get(profile_id:, loop_view_id:, document_id:, document_name:) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dotloop/document.rb', line 19 def get(profile_id:, loop_view_id:, document_id:, document_name:) document_name = CGI.escape(document_name.delete('/')) sio = StringIO.new sio.set_encoding(Encoding::ASCII_8BIT) sio.write( @client.raw( "/profile/#{profile_id.to_i}/loop/#{loop_view_id.to_i}/document/#{document_id}/#{document_name}.pdf" ) ) sio.flush sio.close sio end |