Packages

Desk.com client library for elixir.

Current section

2 Versions

Jump to

Compare versions

4 files changed
+63 additions
-3 deletions
  @@ -19,3 +19,50 @@ The package can be installed via:
19 19 def application do
20 20 [applications: [:exdesk]]
21 21 end
22 +
23 + ## Usage and examples
24 + To configure the authorization globally, you can either call `ExDesk.configure`:
25 +
26 + ExDesk.configure(
27 + site_name: "yoursite.desk.com",
28 + email: "your@email.com",
29 + password: "yourpassword"
30 + )
31 + Or set a `EXDESK_CONFIG` environment variable with site_name, email and password separated by commas.
32 + * this environment variable will override all config calls from within the application.
33 +
34 + $ EXDESK_CONFIG=test.desk.com,your@email.com,yourpassword iex -S mix
35 + Or you can scope to config to the current process:
36 +
37 + ExDesk.configure(:process,
38 + site_name: "yoursite.desk.com",
39 + email: "your@email.com",
40 + password: "yourpassword"
41 + )
42 +
43 + All responses will be a `Map` of the response from This will return a `Map` ozf the JSON response described here:
44 + [http://dev.desk.com/API/using-the-api]( http://dev.desk.com/API/using-the-api )
45 +
46 + Fetching a list of the first ten cases:
47 +
48 + ExDesk.list("cases", [per_page: 10, sort_field: "created_at", sort_direction: "asc"])
49 +
50 + Creating a new resource:
51 +
52 + ExDesk.create("labels", [name: "A Label", description: "a description", types: ["case"], enabled: true, color: "purple"])
53 +
54 + Fetching a single resource:
55 +
56 + ExDesk.show("cases/12345")
57 +
58 + Searching for a resource:
59 +
60 + ExDesk.list("labels/search", [name: "Feedback"])
61 +
62 + Updating a resource:
63 +
64 + ExDesk.update("labels/12345", [color: "red"])
65 +
66 + Deleting a resource:
67 +
68 + ExDesk.delete("labels/12345")
\ No newline at end of file
  @@ -19,4 +19,4 @@
19 19 [{<<"app">>,<<"poison">>},
20 20 {<<"optional">>,false},
21 21 {<<"requirement">>,<<"~> 1.5">>}]}]}.
22 - {<<"version">>,<<"0.1.0">>}.
22 + {<<"version">>,<<"0.2.0">>}.
  @@ -4,13 +4,26 @@ defmodule ExDesk.Config do
4 4 end
5 5
6 6 def get, do: get(current_scope)
7 - defp get(:global), do: Application.get_env(:exdesk, :auth, nil)
7 +
8 + defp get(:global) do
9 + case System.get_env("EXDESK_CONFIG") do
10 + nil -> Application.get_env(:exdesk, :auth, nil)
11 + "" -> Application.get_env(:exdesk, :auth, nil)
12 + config ->
13 + [sn, e, p] = String.split(config, ",")
14 + [site_name: sn, email: e, password: p]
15 + end
16 + end
17 +
8 18 defp get(:process), do: Process.get(:exdesk_auth, nil)
9 19
10 20 def set(value), do: set(current_scope, value)
21 +
11 22 def set(:global, value), do: Application.put_env(:exdesk, :auth, value)
23 +
12 24 def set(:process, value) do
13 25 Process.put(:exdesk_auth, value)
14 26 :ok
15 27 end
28 +
16 29 end
  @@ -3,7 +3,7 @@ defmodule ExDesk.Mixfile do
3 3
4 4 def project do
5 5 [app: :exdesk,
6 - version: "0.1.0",
6 + version: "0.2.0",
7 7 elixir: "~> 1.1",
8 8 description: description,
9 9 package: package,