- Create a read-only API key in Freshdesk
- Set an ENV var with
FRESHDESK_API_KEY
- Set an ENV var with
FRESHDESK_DOMAIN
Some of the methods signatures could change. I aim to keep always backward compatibility, but until the first major version (1.x.x) is released, it's still in beta.
Freshdesk::Rest.configure do |config|
config.api_key = ENV['FRESHDESK_API_KEY']
config.domain = ENV['FRESHDESK_DOMAIN']
end
Get the api client using the factory
api = Freshdesk::Rest::Factory.api
resource = Freshdesk::Rest::Factory.contact_resource
resource.list.each do |p|
puts "#{c[:name]} #{c[:email]} #{c[:updated_at]}"
end
resource = Freshdesk::Rest::Factory.contact_resource
resource.list(params: { unique_external_id: '1234567890' }).each do |c|
puts "#{c[:name]} #{c[:email]}"
end
resource = Freshdesk::Rest::Factory.contact_resource
resource.get(id: '1234567890').tap do |c|
puts "#{c[:name]} #{c[:email]}"
end
resource = Freshdesk::Rest::Factory.contact_resource
resource.post(data: { name: 'Paweł Placzyński', email: '[email protected]' }).tap do |c|
puts "#{c[:name]} #{c[:email]}"
end
resource = Freshdesk::Rest::Factory.contact_resource
resource.put(id: 1234567890, data: { email: '[email protected]' }).tap do |c|
puts "#{c[:name]} #{c[:email]}"
end
resource = Freshdesk::Rest::Factory.contact_resource
resource.delete(id: 1234567890)