Integration
Ruby backend integration.
Use this general server-side example as the starting point for jobs, articles, products, listings, events, announcements, or custom content.
Ruby
How this integration works
Use this in Rails or a Ruby backend service object.
Keep your zedgad API key on the server. The integration sends a title, summary, public URL, optional image URL, and any useful metadata to the project webhook.
- Place the service in app/services/zedgad_service.rb or a similar backend folder.
- Keep ZEDGAD_API_KEY in your server environment.
- Call the service from a job, callback, or publish action after content is public.
Ruby
Create app/services/zedgad_service.rb
Replace the sample content fields with your own model fields. The important part is that zedgad receives a stable ID, content type, title, summary, public URL, optional image URL, and any metadata you want to keep with the post.
app/services/zedgad_service.rb
require 'net/http'
require 'json'
require 'uri'
class ZedgadService
WEBHOOK_URL = 'https://api.zedgad.com/api/webhooks/content/'
def self.send_content(content)
uri = URI(WEBHOOK_URL)
request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{ENV.fetch('ZEDGAD_API_KEY')}"
request['Content-Type'] = 'application/json'
request.body = {
external_id: content.id.to_s,
type: content.type || 'article',
title: content.title,
summary: content.summary,
url: content.public_url,
image_url: content.image_url,
metadata: {
source: content.source || 'website',
category: content.category
}
}.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
http.request(request)
end
raise "zedgad request failed: #{response.code}" unless response.is_a?(Net::HTTPSuccess)
JSON.parse(response.body)
end
end