README.md

# Freshdesk Export
A simple tool that will retrieve all of the tickets from your Freshdesk instance and export it into a JSON format.

## Table of Contents
* [Installation](#installation)
* [Quick-Start Examples](#quick-start-examples)
* [Documentation](#documentation)

## <a id="installation"></a>Installation
You can download the package by adding `freshdesk_export` to your list of dependencies in `mix.exs`:
```elixir
def deps do
  [
    {:freshdesk_export, "~> 0.1.0"}
  ]
end
```
Then add the `freshdesk_domain` and the `freshdesk_api_key` to the `:freshdesk_export` application's environment variables in the `deps/freshdesk_export/mix.exs` file:
```elixir
def application do
  [
    applications: [...],
    extra_applications: [...],
    env: [
      freshdesk_domain: "https://yourorganization.freshdesk.com",
      freshdesk_api_key: ""
    ]
  ]
end
```
This step will get your code hooked up to the proper Freshdesk instance. Check out [this short article](https://support.freshdesk.com/support/solutions/articles/225435-where-can-i-find-my-api-key-) if you need help finding your Freshdesk API key.

## <a id="quick-start-examples"></a>Quick-Start Examples
**The default is to pull back 100 tickets per page.** This will be a variable in the future but currently is hard coded.

### Get a single ticket
```elixir
FreshdeskExport.get_ticket(ticket_id)
```
### Get a single page of tickets
```elixir
FreshdeskExport.request_tickets(page_number)
```
### Get all tickets
```elixir
FreshdeskExport.get_tickets
```
### Return a JSON object
```elixir
import Poison, only: [encode!: 1]
FreshdeskExport.request_tickets(page_number) |> encode!
```

```elixir
import Poison, only: [encode!: 1]
FreshdeskExport.get_tickets |> encode!
```
### Save to a JSON file
```elixir
FreshdeskExport.get_tickets |> FreshdeskExport.write_json(file_path)
```

## <a id="documentation"></a>Documentation
Check out the [HexDocs](https://hexdocs.pm/freshdesk_export) page for official documentation.