Sha256: d1ba944bc91f2f38531365bca3818d677b260a306f2b43807ea1d9f2fe3c7cad

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

module Eligible
  class Ticket < APIResource
    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

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

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

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

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

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eligible-3.1.0.beta4 lib/eligible/ticket.rb
eligible-3.1.0.beta3 lib/eligible/ticket.rb
eligible-3.1.0.beta2 lib/eligible/ticket.rb
eligible-3.1.0.beta1 lib/eligible/ticket.rb