blob: 2aaf7aee7e997a0d9ce54fb6a22ce1dfdc4356ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
defmodule Zendex.Ticket do
@moduledoc """
Allows interaction with the Zendesk Ticket API, to so things such as creating
and listing tickets.
"""
alias Zendex.CommonHelpers
@url "/api/v2/tickets.json"
@doc """
List all tickets.
"""
@spec list(Zendex.Connection.t) :: map
def list(connection) do
"#{connection.base_url}#{@url}"
|> HTTPoison.get!(CommonHelpers.get_headers(connection.authentication))
|> CommonHelpers.decode_response
end
@doc """
Create a new ticket.
"""
@spec create(Zendex.Connection.t, map) :: map
def create(connection, ticket) do
"#{connection.base_url}#{@url}"
|> HTTPoison.post!(Poison.encode!(ticket),
CommonHelpers.get_headers(connection.authentication,
%{content_type: :json}))
|> CommonHelpers.decode_response
end
end
|