Module: QboApi::Attachment
- Included in:
- QboApi
- Defined in:
- lib/qbo_api/attachment.rb
Instance Method Summary collapse
- #attachment_connection ⇒ Object
-
#delete_attachment(attachable:) ⇒ Object
The ‘attachable` must be the full payload returned in the read response.
- #read_attachment(id:) ⇒ Object
- #upload_attachment(payload:, attachment:) ⇒ Object
Instance Method Details
#attachment_connection ⇒ Object
35 36 37 |
# File 'lib/qbo_api/attachment.rb', line 35 def @attachment_connection ||= (endpoint_url) end |
#delete_attachment(attachable:) ⇒ Object
The ‘attachable` must be the full payload returned in the read response
26 27 28 29 30 31 32 33 |
# File 'lib/qbo_api/attachment.rb', line 26 def (attachable:) raw_response = connection.post do |request| request.url "#{realm_id}/attachable?operation=delete" request.body = attachable.to_json end response(raw_response, entity: :attachable) end |
#read_attachment(id:) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/qbo_api/attachment.rb', line 3 def (id:) raw_response = connection.get do |request| request.url "#{realm_id}/attachable/#{id}" end response(raw_response, entity: :attachable) end |
#upload_attachment(payload:, attachment:) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/qbo_api/attachment.rb', line 10 def (payload:, attachment:) content_type = payload['ContentType'] || payload[:ContentType] file_name = payload['FileName'] || payload[:FileName] raw_response = .post do |request| request.url "#{realm_id}/upload" request.body = { 'file_metadata_01': Faraday::UploadIO.new(StringIO.new(payload.to_json), 'application/json', 'attachment.json'), 'file_content_01': Faraday::UploadIO.new(, content_type, file_name) } end response(raw_response, entity: :attachable) end |