Class: InterFAX::Documents
- Inherits:
-
Object
- Object
- InterFAX::Documents
- Defined in:
- lib/interfax/documents.rb
Instance Method Summary collapse
- #all(options = {}) ⇒ Object
- #cancel(document_id) ⇒ Object
- #create(name, size, options = {}) ⇒ Object
- #find(document_id) ⇒ Object
-
#initialize(client) ⇒ Documents
constructor
A new instance of Documents.
- #upload(document_id, range_start, range_end, chunk) ⇒ Object
Constructor Details
#initialize(client) ⇒ Documents
Returns a new instance of Documents.
3 4 5 |
# File 'lib/interfax/documents.rb', line 3 def initialize client @client = client end |
Instance Method Details
#all(options = {}) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/interfax/documents.rb', line 23 def all = {} valid_keys = [:limit, :offset] @client.get("/outbound/documents", , valid_keys).map do |document| document[:client] = @client InterFAX::Document.new(document) end end |
#cancel(document_id) ⇒ Object
37 38 39 40 |
# File 'lib/interfax/documents.rb', line 37 def cancel document_id @client.delete("/outbound/documents/#{document_id}") true end |
#create(name, size, options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/interfax/documents.rb', line 7 def create name, size, = {} [:name] = name [:size] = size valid_keys = [:name, :size, :disposition, :shared] uri = @client.post("/outbound/documents", , valid_keys) InterFAX::Document.new(uri: uri, client: @client) end |
#find(document_id) ⇒ Object
31 32 33 34 35 |
# File 'lib/interfax/documents.rb', line 31 def find document_id document = @client.get("/outbound/documents/#{document_id}") document[:client] = @client InterFAX::Document.new(document) end |
#upload(document_id, range_start, range_end, chunk) ⇒ Object
17 18 19 20 21 |
# File 'lib/interfax/documents.rb', line 17 def upload document_id, range_start, range_end, chunk headers = { 'Range' => "bytes=#{range_start}-#{range_end}" } @client.post("/outbound/documents/#{document_id}", {}, {}, headers, chunk) true end |