Class: FreshdeskApiclient::REST::Resources

Inherits:
Object
  • Object
show all
Defined in:
lib/freshdesk_apiclient/rest/resources.rb

Direct Known Subclasses

Tickets

Constant Summary collapse

ACCEPT_HEADER =
{Accept: 'application/json'}.freeze
ACCEPT_AND_CONTENT_HEADERS =
ACCEPT_HEADER.merge('Content-Type': 'application/json')

Instance Method Summary collapse

Constructor Details

#initialize(base_url, options = {}) ⇒ Resources

Returns a new instance of Resources.



14
15
16
17
18
# File 'lib/freshdesk_apiclient/rest/resources.rb', line 14

def initialize(base_url, options={})
  @base_url = base_url
  @credentials = options[:credentials]
  RestClient.log = options[:logger]
end

Instance Method Details

#create(json_payload) ⇒ Object



25
26
27
28
# File 'lib/freshdesk_apiclient/rest/resources.rb', line 25

def create(json_payload)
  url = full_url
  execute(url: url, method: :post, headers: ACCEPT_AND_CONTENT_HEADERS, payload: json_payload)
end

#list(path = nil) ⇒ Object



20
21
22
23
# File 'lib/freshdesk_apiclient/rest/resources.rb', line 20

def list(path=nil)
  url = full_url path
  execute(url: url, method: :get, headers: ACCEPT_HEADER)
end