blob: 3be67896ec55ef81c3968ddd46a2acd4820c14d6 (
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
|
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"
@http_client Application.get_env(:zendex, :http_client)
@spec list(Zendex.Connection.t) :: map
def list(connection) do
connection.base_url
|> Kernel.<>(@url)
|> @http_client.get!(CommonHelpers.get_headers(connection.authentication))
|> CommonHelpers.decode_response
end
@spec create(Zendex.Connection.t, map) :: map
def create(connection, ticket) do
connection.base_url
|> Kernel.<>(@url)
|> @http_client.post!(Poison.encode!(ticket),
CommonHelpers.get_headers(connection.authentication,
%{content_type: :json}))
|> CommonHelpers.decode_response
end
end
|