GithubHelp home page GithubHelp logo

tubbz-alt / zen_ex Goto Github PK

View Code? Open in Web Editor NEW

This project forked from system76/zen_ex

0.0 0.0 0.0 120 KB

Zendesk REST API client for Elixir

License: Creative Commons Zero v1.0 Universal

Elixir 100.00%

zen_ex's Introduction

zen_ex Build Status

Zendesk REST API client for Elixir

zen_ex is composed of Models and Entities. See Usage.

Installation

Add zen_ex to your list of dependencies in mix.exs:

def deps do
  [{:zen_ex, "~> 0.4"}]
end

Update your dependencies:

% mix deps.get

Add your Zendesk settings to your config:

config :zen_ex,
  subdomain: "your-zendesk-subdomain",
  user: "[email protected]",
  api_token: "xxxx"

See also: Generating a new API token

Usage

# List users
users = ZenEx.Model.User.list.entities

# Show user
user = ZenEx.Model.User.show(1)

# Create user
user = ZenEx.Model.User.create(%ZenEx.Entity.User{name: "otoyo", email: "[email protected]"})

# List tickets
collection = ZenEx.Model.Ticket.list(per_page: 100, sort_order: "desc")
tickets = collection.entities
next_tickets = collection |> ZenEx.Collection.next

# Show ticket
ticket = ZenEx.Model.Ticket.show(1)

# Create ticket
ticket = ZenEx.Model.Ticket.create(%ZenEx.Entity.Ticket{subject: "My printer is on fire!", description: "But no problem."})

See also under ZenEx.Model.

Supporting multiple Zendesk configs

You may need to interact with more than one instance of Zendesk. In order to facilitate that there is a small override that can be put into the Process dictionary that will tell it to look for config settings keyed against a class name.

For example:

config/config.exs

config :zen_ex,
  subdomain: System.get_env("ZENDESK_SUBDOMAIN"),
  user: System.get_env("ZENDESK_USER_EMAIL"),
  api_token: System.get_env("ZENDESK_API_TOKEN")

config :zen_ex, ZendeskAlt,
  subdomain: System.get_env("ZENDESK_ALT_SUBDOMAIN"),
  user: System.get_env("ZENDESK_ALT_USER_EMAIL"),
  api_token: System.get_env("ZENDESK_ALT_API_TOKEN")

Then whenever you want to use the alternate config, before using anything in the zen_ex library make sure to add a line of code like the following:

Process.put(:zendesk_config_module, ZendeskAlt)

Anytime you use the zendesk library after that it will use the alternate config until you remove that process dictionary entry. It is good practice to put it back when you are done.

Process.put(:zendesk_config_module, nil)

If you do not add a :zendesk_config_module key to the Process dictionary then it will continue to use the default zen_ex config settings.

Supported API

Core API

  • Users
    • list
    • show
    • create
    • update
    • create_or_update
    • destroy
    • create_many
    • update_many
    • create_or_update_many
    • destroy_many
    • search
  • Tickets
    • list
    • show
    • create
    • update
    • destroy
    • create_many
    • update_many
    • destroy_many
  • Dynamic contents
    • list
    • show
    • create
    • update
    • destroy
  • Variants of dynamic contents
    • list
    • show
    • create
    • create_many
    • update
    • update_many
    • destroy
  • Locales
    • show
  • Job statuses
    • list
    • show
    • show_many

Help Center API

  • Categories
    • list
    • show
    • create
    • update
    • destroy
  • Sections
    • list
    • show
    • create
    • update
    • destroy
  • Articles
    • list
    • show
    • create
    • update
    • search
    • destroy
  • Translations
    • list
    • list_missing
    • show
    • create
    • update
    • destroy

Contributing

Contributions are welcome ;)

LICENSE

ZenEx is released under CC0-1.0 (see LICENSE).

zen_ex's People

Contributors

btkostner avatar dereksweet avatar otoyo avatar poops avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.