Coder Social home page Coder Social logo

freshdesk-rest's Introduction

freshdesk-rest

Build Status

Requirements

  • Create a read-only API key in Freshdesk
  • Set an ENV var with FRESHDESK_API_KEY
  • Set an ENV var with FRESHDESK_DOMAIN

DISCLAIMER

This is still a BETA!

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.

Configuration

Freshdesk::Rest.configure do |config|
  config.api_key = ENV['FRESHDESK_API_KEY']
  config.domain = ENV['FRESHDESK_DOMAIN']
end

Usage

Get the api client using the factory

api = Freshdesk::Rest::Factory.api

List of contacts

resource = Freshdesk::Rest::Factory.contact_resource
resource.list.each do |p|
  puts "#{c[:name]} #{c[:email]} #{c[:updated_at]}"
end

List of contacts filtered by a filed

resource = Freshdesk::Rest::Factory.contact_resource
resource.list(params: { unique_external_id: '1234567890' }).each do |c|
  puts "#{c[:name]} #{c[:email]}"
end

Contact

resource = Freshdesk::Rest::Factory.contact_resource
resource.get(id: '1234567890').tap do |c|
  puts "#{c[:name]} #{c[:email]}"
end

Create contact

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

Update contact

resource = Freshdesk::Rest::Factory.contact_resource
resource.put(id: 1234567890, data: { email: '[email protected]' }).tap do |c|
  puts "#{c[:name]} #{c[:email]}"
end

Soft delete contact

resource = Freshdesk::Rest::Factory.contact_resource
resource.delete(id: 1234567890)

Freshdesk Api reference

https://developers.freshdesk.com/api

freshdesk-rest's People

Contributors

placek avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.