Class: Eligible::Ticket

Inherits:
APIResource show all
Defined in:
lib/eligible/ticket.rb

Instance Attribute Summary

Attributes inherited from EligibleObject

#api_key, #eligible_id

Class Method Summary collapse

Methods inherited from APIResource

api_url, class_name, endpoint_name, require_param, required_param_validation, rest_api_params, send_request, url

Methods inherited from EligibleObject

#[], #[]=, construct_from, #each, #error, #initialize, #keys, #refresh_from, #to_hash, #to_json, #values

Constructor Details

This class inherits a constructor from Eligible::EligibleObject

Class Method Details

.all(params, opts = {}) ⇒ Object



24
25
26
# File 'lib/eligible/ticket.rb', line 24

def self.all(params, opts = {})
  send_request :get, ticket_url, params, **opts
end

.comments(params, opts = {}) ⇒ Object



20
21
22
# File 'lib/eligible/ticket.rb', line 20

def self.comments(params, opts = {})
  send_request :post, ticket_url(params, true), params, **opts.merge(required_params: [:id])
end

.create(params, opts = {}) ⇒ Object



16
17
18
# File 'lib/eligible/ticket.rb', line 16

def self.create(params, opts = {})
  send_request :post, ticket_url, params, **opts
end

.delete(params, opts = {}) ⇒ Object



32
33
34
# File 'lib/eligible/ticket.rb', line 32

def self.delete(params, opts = {})
  send_request :delete, ticket_url(params), params, **opts.merge(required_params: [:id])
end

.get(params, opts = {}) ⇒ Object



28
29
30
# File 'lib/eligible/ticket.rb', line 28

def self.get(params, opts = {})
  send_request :get, ticket_url(params), params, **opts.merge(required_params: [:id])
end

.ticket_url(params = nil, comments = false) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/eligible/ticket.rb', line 3

def self.ticket_url(params = nil, comments = false)
  if params.nil?
    '/tickets'
  else
    id = Util.value(params, :id)
    if comments
      "/tickets/#{id}/comments"
    else
      "/tickets/#{id}"
    end
  end
end

.update(params, opts = {}) ⇒ Object



36
37
38
# File 'lib/eligible/ticket.rb', line 36

def self.update(params, opts = {})
  send_request :put, ticket_url(params), params, **opts.merge(required_params: [:id])
end