Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def transfer(data, document)
if document.cl_document_url != nil
self.uri = URI.parse(document.cl_document_url )
h = Net::HTTP.new(self.uri.host, self.uri.port)
response = h.post(self.uri, data, {'Content-Type' => 'application/xml'})
else
h = Net::HTTP.new(self.uri.host, self.uri.port)
response = h.post("/tasks", data, {'Content-Type' => 'application/xml'})
end
response_code = response.code.to_i
if response_code == 201
location = response['Location']
document.cl_document_url = location
document.save!
else
nil
end
[response_code, location]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment