Sha256: e7e0105bf55e36a738a89909d1b881441a91a3430d848a79712fd375fcaba343

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 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, api_key = nil)
      send_request(:post, ticket_url, api_key, **params)
    end

    def self.comments(params, api_key = nil)
      send_request(:post, ticket_url(params, true), api_key, params, :id)
    end

    def self.all(params, api_key = nil)
      send_request(:get, ticket_url, api_key, **params)
    end

    def self.get(params, api_key = nil)
      send_request(:get, ticket_url(params), api_key, params, :id)
    end

    def self.delete(params, api_key = nil)
      send_request(:delete, ticket_url(params), api_key, params, :id)
    end

    def self.update(params, api_key = nil)
      send_request(:put, ticket_url(params), api_key, params, :id)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
eligible-3.0.2 lib/eligible/ticket.rb
eligible-3.0.1 lib/eligible/ticket.rb
eligible-3.0.0 lib/eligible/ticket.rb