Class: Quickbooks::Service::Upload
- Inherits:
-
BaseService
- Object
- BaseService
- Quickbooks::Service::Upload
- Defined in:
- lib/quickbooks/service/upload.rb
Constant Summary collapse
- XML_NODE =
"AttachableResponse"
Constants inherited from BaseService
BaseService::BASE_DOMAIN, BaseService::HTTP_ACCEPT, BaseService::HTTP_ACCEPT_ENCODING, BaseService::HTTP_CONTENT_TYPE, BaseService::SANDBOX_DOMAIN, BaseService::XML_NS
Instance Attribute Summary
Attributes inherited from BaseService
#base_uri, #company_id, #last_response_body, #last_response_xml, #oauth
Instance Method Summary collapse
- #download(uploadId) ⇒ Object
-
#upload(path_to_file, mime_type, attachable = nil) ⇒ Object
path_to_file: String - path to file mime_type: String - the MIME type of the file, e.g.
Methods inherited from BaseService
#access_token=, #default_model_query, #initialize, #realm_id=, #url_for_base, #url_for_query, #url_for_resource
Methods included from ServiceCrud
#create, #delete, #delete_by_query_string, #fetch_by_id, #query, #query_in_batches
Methods included from Util::Logging
Constructor Details
This class inherits a constructor from Quickbooks::Service::BaseService
Instance Method Details
#download(uploadId) ⇒ Object
22 23 24 25 |
# File 'lib/quickbooks/service/upload.rb', line 22 def download(uploadId) url = url_for_resource("download/#{uploadId}") do_http_get(url, {}, headers) end |
#upload(path_to_file, mime_type, attachable = nil) ⇒ Object
path_to_file: String - path to file mime_type: String - the MIME type of the file, e.g. image/jpeg attachable: Quickbooks::Model::Attachable meta-data details, can be null
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/quickbooks/service/upload.rb', line 10 def upload(path_to_file, mime_type, attachable = nil) url = url_for_resource("upload") uploadIO = UploadIO.new(path_to_file, mime_type) response = do_http_file_upload(uploadIO, url, attachable) prefix = "AttachableResponse/xmlns:Attachable" if response.code.to_i == 200 model.from_xml(parse_singular_entity_response(model, response.plain_body, prefix)) else nil end end |