Skip to content

Instantly share code, notes, and snippets.

@ivarvong
Last active August 29, 2015 14:09
Show Gist options
  • Save ivarvong/8086065c515c920857ab to your computer and use it in GitHub Desktop.
Save ivarvong/8086065c515c920857ab to your computer and use it in GitHub Desktop.
class Document < ActiveRecord::Base
include HTTParty
format :json
base_uri "https://www.documentcloud.org"
debug_output $stdout # optional
def update_published_url
self.class.put("/api/documents/#{self.dc_id}.json",
basic_auth: {
username: ENV['DOCUMENTCLOUD_USERNAME'],
password: ENV['DOCUMENTCLOUD_PASSWORD']
},
body: {
"published_url" => "#{ENV['DOCUMENT_URL_BASE']}/#{self.dc_id}"
}
)
end
# other stuff
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment