Skip to content

Instantly share code, notes, and snippets.

@jcfischer
Created May 31, 2010 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcfischer/419925 to your computer and use it in GitHub Desktop.
Save jcfischer/419925 to your computer and use it in GitHub Desktop.
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