From 20b38a6afaa3ccedc003bc5c384e0e633678f8f4 Mon Sep 17 00:00:00 2001 From: MaicolBen Date: Mon, 17 Aug 2020 14:56:04 -0300 Subject: [PATCH] Add company API --- lib/freshdesk.rb | 1 + lib/freshdesk/contact.rb | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 lib/freshdesk/contact.rb diff --git a/lib/freshdesk.rb b/lib/freshdesk.rb index 61e8895..3b58e67 100644 --- a/lib/freshdesk.rb +++ b/lib/freshdesk.rb @@ -3,6 +3,7 @@ require "freshdesk/freshdesk_object" require "freshdesk/resource" require "freshdesk/ticket" +require "freshdesk/contact" module Freshdesk end diff --git a/lib/freshdesk/contact.rb b/lib/freshdesk/contact.rb new file mode 100644 index 0000000..49c50e0 --- /dev/null +++ b/lib/freshdesk/contact.rb @@ -0,0 +1,31 @@ +module Freshdesk + class Contact < FreshdeskObject + class << self + def create(params: {}) + response = new('/contacts').resource(params: params).post + set_attrs_from_response(response) + end + + def retrieve(id:, query: '') + response = new("/contacts/#{id}#{query}").resource(id: id).get + set_attrs_from_response(response) + end + + def list(query: '') + new("/contacts#{query}").resource.get + end + + def update(id:, params: {}) + new("/contacts/#{id}").resource(id: id, params: params).put + end + + def delete(id:) + new("/contacts/#{id}").resource(id: id).delete + end + + def list_all_fields + new('/contacts_fields').resource.get + end + end + end +end