freshworks / fresh-samples

Samples of code created by freshdesk
184 stars 181 forks source link

Please document freshplug api helper methods #5

Closed blak3r closed 9 years ago

blak3r commented 9 years ago

Would be nice to have a little more documentation on say the freshdesk proxy

var proxy = new Freshdesk.Widget(opts);

And what you can and cannot do with the CustomWidget.include_js() like will it handle placeholders inside my widget? Can i include html/style in it as well? So, that i don't need to keep pasting it in to the Freshplug ui.

subwiz commented 9 years ago

Helping you with a quick document (we are revamping our documentation, and this info will be part of it later):

Freshdesk.Widget is a proxy API to be used with third-party APIs when developing FreshPlugs. FreshPlugs being JS based, cannot make API requests to third-party services due to limitations of CORS. Freshdesk.Widget routes API calls via Freshdesk backend.

var proxyBundle = { domain:'https://api.example.com', 
                    ssl_enabled: true, 
                    auth_type : "Basic", 
                    username: 'xxxx',
                    password: 'xxxx' }

auth_type can either be OAuth, NoAuth, UAuth or Basic.

If the type is OAuth, he has to send a auhtorization request store auth token, then second a request to fetch or post details.

If the URL for sending request is https://api.example.com/customers.json, we split into into domain and rest_url. We use domain above in the bundle, remaining part of URl below in the request.

Below is an example of simple request.

var customerRequest = { 
    method:"get",
    body:"",
    rest_url:"customers.json",
    on_success: function(data) { 
  console.log(data.responseJSON);
    },
    on_failure: function(data) {
        console.log(data.responseJSON);
    }
}

var proxy = new Freshdesk.Widget(proxyBundle);
proxy.request(customerRequest);
prasadmunna commented 8 years ago

hi.. i am using text summer text editor for posting data on fresh desk ticket, but after i inserted image it was post as html content like this

test

Can you please help me , i am using PHP api for reply fresh desk ticket.

Thanks