Skip to content

Commit

Permalink
- Updating readme md
Browse files Browse the repository at this point in the history
- Rename `id` every where to type_id
  • Loading branch information
nsomar committed Jan 18, 2016
1 parent 40744a4 commit 2baae84
Show file tree
Hide file tree
Showing 22 changed files with 574 additions and 131 deletions.
476 changes: 452 additions & 24 deletions README.md

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions lib/api/attachments_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ defmodule Zendesk.AttachmentApi do
@doc """
Show an attachment
`id` the attachment id
`attachment_id` the attachment id
"""
def show_attachment(account, id: id) do
def show_attachment(account, attachment_id: attachment_id) do
perform_request(&parse_attachment/1, account: account, verb: :get,
endpoint: ExPrintf.sprintf(@show_attachment, [id]))
endpoint: ExPrintf.sprintf(@show_attachment, [attachment_id]))
end

@doc """
Delete an attachment
`id` the attachment id
`attachment_id` the attachment id
"""
def delete_attachment(account, id: id) do
def delete_attachment(account, attachment_id: attachment_id) do
perform_request(&parse_delete/1, account: account, verb: :delete,
endpoint: ExPrintf.sprintf(@delete_attachment, [id]))
endpoint: ExPrintf.sprintf(@delete_attachment, [attachment_id]))
end

# Private
Expand Down
2 changes: 1 addition & 1 deletion lib/api/comment_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ defmodule Zendesk.CommentApi do
`comment_id` the comment id
"""
def comment_for_request(account, request_id: request_id, comment_id: comment_id) do
def show_comment(account, request_id: request_id, comment_id: comment_id) do
perform_request(&parse_get_comment/1, account: account, verb: :get,
endpoint: ExPrintf.sprintf(@comment_for_request, [request_id, comment_id]))
end
Expand Down
8 changes: 4 additions & 4 deletions lib/api/group_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ defmodule Zendesk.GroupApi do
`user_id` the user id
"""
def user_groups(account, user_id: user_id) do
def all_groups(account, user_id: user_id) do
perform_request(&parse_get_groups/1, account: account, verb: :get,
endpoint: ExPrintf.sprintf(@user_groups, [user_id]))
end

@doc """
Get group by id
`id` the group id
`group_id` the group id
"""
def group_with_id(account, id: id) do
def show_group(account, group_id: group_id) do
perform_request(&parse_get_group/1, account: account, verb: :get,
endpoint: ExPrintf.sprintf(@group_with_id, [id]))
endpoint: ExPrintf.sprintf(@group_with_id, [group_id]))
end

# Private
Expand Down
4 changes: 2 additions & 2 deletions lib/api/group_membership_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ defmodule Zendesk.GroupMembershipApi do
`membership_id` group membership id
"""
def group_membership(account, membership_id: membership_id) do
def show_group_membership(account, membership_id: membership_id) do
perform_request(&parse_single_membership/1, account: account, verb: :get,
endpoint: ExPrintf.sprintf(@group_membership_with_id, [membership_id]))
end
Expand All @@ -57,7 +57,7 @@ defmodule Zendesk.GroupMembershipApi do
`user_id` the user id
"""
def group_membership(account, membership_id: membership_id, user_id: user_id) do
def show_group_membership(account, membership_id: membership_id, user_id: user_id) do
perform_request(&parse_single_membership/1, account: account, verb: :get,
endpoint: ExPrintf.sprintf(@group_membership_for_user_with_id, [user_id, membership_id]))
end
Expand Down
28 changes: 22 additions & 6 deletions lib/api/request_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,39 @@ defmodule Zendesk.RequestApi do

@doc """
Get requests with multiple statues
`statuses` request statuses to fetch
"""
def request_with_statuses(account, statuses: statuses) do
def all_requests(account, statuses: statuses) do
st = Enum.join(statuses, ",")
perform_request(&parse_requests/1, account: account, verb: :get,
endpoint: ExPrintf.sprintf(@request_status, [st]))
end

@doc """
Get requests for a user
`user_id` user id
"""
def requests_for_user(account, user_id: user_id) do
def all_requests(account, user_id: user_id) do
perform_request(&parse_requests/1, account: account, verb: :get,
endpoint: ExPrintf.sprintf(@request_for_user, [user_id]))
end

@doc """
Get requests for an organization
`organization_id` organization id to return requests for
"""
def requests_for_organization(account, organization_id: organization_id) do
def all_requests(account, organization_id: organization_id) do
perform_request(&parse_requests/1, account: account, verb: :get,
endpoint: ExPrintf.sprintf(@request_for_organization, [organization_id]))
end

@doc """
Searches for a request
`query` query to perform
"""
def search_requests(account, query: query) do
perform_request(&parse_requests/1, account: account, verb: :get,
Expand All @@ -55,14 +63,18 @@ defmodule Zendesk.RequestApi do

@doc """
Gets a request
`request_id` request id to show
"""
def request_with_id(account, id: request_id) do
def show_request(account, request_id: request_id) do
perform_request(&parse_request/1, account: account, verb: :get,
endpoint: ExPrintf.sprintf(@single_request, [request_id]))
end

@doc """
Create a request
`request` request to create
"""
def create_request(account, request: request) do
json = Zendesk.Request.to_json(%{request: request})
Expand All @@ -72,11 +84,15 @@ defmodule Zendesk.RequestApi do

@doc """
Update a request
`request_id` request id to update
`request` request to update
"""
def update_request(account, id: id, request: request) do
def update_request(account, request_id: request_id, request: request) do
json = Zendesk.Request.to_json(%{request: request})
perform_request(&parse_request/1, account: account, verb: :put,
endpoint: ExPrintf.sprintf(@single_request, [id]),
endpoint: ExPrintf.sprintf(@single_request, [request_id]),
body: json, headers: headers)
end

Expand Down
56 changes: 26 additions & 30 deletions lib/api/ticket_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,20 @@ defmodule Zendesk.TicketApi do
`ticket`: The ticket object.
`id`: the ticket id to update.
`ticket_id`: the ticket id to update.
"""
def update_ticket(account, ticket: ticket, id: id) do
def update_ticket(account, ticket: ticket, ticket_id: ticket_id) do
json = Ticket.to_json(%{ticket: ticket})
perform_request(&parse_single_ticket/1, account: account,
verb: :put,
endpoint: ExPrintf.sprintf(@ticket_with_id, [id]),
endpoint: ExPrintf.sprintf(@ticket_with_id, [ticket_id]),
body: json, headers: headers)
end

@doc """
Get All Tickets.
`account`: The Zendesk.Account to use
`ticket`: The ticket object.
`id`: the ticket id to update.
"""
def all_tickets(account) do
perform_request(&parse_multiple_tickets/1, account: account, verb: :get, endpoint: @all_endpoint)
Expand All @@ -77,22 +73,22 @@ defmodule Zendesk.TicketApi do
`account`: The Zendesk.Account to use
`id`: Thec ticket ID to delete
`ticket_id`: Thec ticket ID to delete
"""
def delete_ticket(account, id: id) do
perform_request(&parse_delete_ticket/1, account: account, verb: :delete, endpoint: ticket_url(id))
def delete_ticket(account, ticket_id: ticket_id) do
perform_request(&parse_delete_ticket/1, account: account, verb: :delete, endpoint: ticket_url(ticket_id))
end

@doc """
Fetch a ticket with ID
`account`: The Zendesk.Account to use
`id`: Thec ticket ID to fetch
`ticket_id`: Thec ticket ID to fetch
"""
def ticket_with_id(account, id: id) do
def show_ticket(account, ticket_id: ticket_id) do
perform_request(&parse_single_ticket/1, account: account, verb: :get,
endpoint: ticket_url(id))
endpoint: ticket_url(ticket_id))
end

@doc """
Expand All @@ -102,7 +98,7 @@ defmodule Zendesk.TicketApi do
`ids`: A list of tickets ids to fetch
"""
def tickets_with_ids(account, ids: ids) do
def show_tickets(account, ids: ids) do
ids_strings = Enum.join(ids, ",")
url = ExPrintf.sprintf(@many_tickets, [ids_strings])

Expand All @@ -115,9 +111,9 @@ defmodule Zendesk.TicketApi do
`account`: The Zendesk.Account to use
`requester`: The requester ID to get the ticket for
`requester_id`: The requester ID to get the ticket for
"""
def tickets_with_user(account, requester: requeser_id) do
def show_ticket(account, requester_id: requeser_id) do
perform_request(&parse_multiple_tickets/1, account: account, verb: :get,
endpoint: ExPrintf.sprintf(@by_requester, [requeser_id]))
end
Expand All @@ -127,9 +123,9 @@ defmodule Zendesk.TicketApi do
`account`: The Zendesk.Account to use
`assignee`: The assignee ID to get the ticket for
`assignee_id`: The assignee ID to get the ticket for
"""
def tickets_with_user(account, assignee: assignee_id) do
def show_ticket(account, assignee_id: assignee_id) do
perform_request(&parse_multiple_tickets/1, account: account, verb: :get,
endpoint: ExPrintf.sprintf(@by_assignee, [assignee_id]))
end
Expand All @@ -139,9 +135,9 @@ defmodule Zendesk.TicketApi do
`account`: The Zendesk.Account to use
`cc`: The cc id of the user to get the ticket for
`cc_id`: The cc id of the user to get the ticket for
"""
def tickets_with_user(account, cc: cc_id) do
def show_ticket(account, cc_id: cc_id) do
perform_request(&parse_multiple_tickets/1, account: account, verb: :get,
endpoint: ExPrintf.sprintf(@by_cc, [cc_id]))
end
Expand All @@ -153,7 +149,7 @@ defmodule Zendesk.TicketApi do
`organization_id`: The organization_id to get the tickets for
"""
def ticket_for_organization(account, organization_id: organization_id) do
def show_ticket(account, organization_id: organization_id) do
perform_request(&parse_multiple_tickets/1, account: account, verb: :get,
endpoint: ExPrintf.sprintf(@for_organization, [organization_id]))
end
Expand All @@ -163,35 +159,35 @@ defmodule Zendesk.TicketApi do
`account`: The Zendesk.Account to use
`id`: The ticket ID to get related tickets for
`ticket_id`: The ticket ID to get related tickets for
"""
def ticket_related(account, id: id) do
def ticket_related(account, ticket_id: ticket_id) do
perform_request(&parse_related_tickets_info/1, account: account, verb: :get,
endpoint: ExPrintf.sprintf(@related_tickets, [id]))
endpoint: ExPrintf.sprintf(@related_tickets, [ticket_id]))
end

@doc """
Get the ticket collaborators
`account`: The Zendesk.Account to use
`id`: The ticket ID to get collaborators for
`ticket_id`: The ticket ID to get collaborators for
"""
def ticket_collaborators(account, id: id) do
def ticket_collaborators(account, ticket_id: ticket_id) do
perform_request(&parse_collaborators/1, account: account, verb: :get,
endpoint: ExPrintf.sprintf(@ticket_collaborators, [id]))
endpoint: ExPrintf.sprintf(@ticket_collaborators, [ticket_id]))
end

@doc """
Get the ticket incidents
`account`: The Zendesk.Account to use
`id`: The ticket ID to get the incidents for
`ticket_id`: The ticket ID to get the incidents for
"""
def ticket_incidents(account, id: id) do
def ticket_incidents(account, ticket_id: ticket_id) do
perform_request(&parse_multiple_tickets/1, account: account, verb: :get,
endpoint: ExPrintf.sprintf(@ticket_incidents, [id]))
endpoint: ExPrintf.sprintf(@ticket_incidents, [ticket_id]))
end

@doc """
Expand Down
22 changes: 16 additions & 6 deletions lib/api/ticket_fields_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ defmodule Zendesk.TicketFieldsApi do

@doc """
Get a single ticket field
`ticket_id` ticked id to return fields for
"""
def ticket_field_with_id(account, id: id) do
def all_ticket_fields(account, ticket_id: ticket_id) do
perform_request(&parse_ticket_field/1, account: account, verb: :get,
endpoint: ExPrintf.sprintf(@get_field, [id]))
endpoint: ExPrintf.sprintf(@get_field, [ticket_id]))
end

@doc """
Create a ticket field
`ticket_field` ticket field to create
"""
def create_ticket_field(account, ticket_field: ticket_field) do
json = TicketField.to_json(%{ticket_field: ticket_field})
Expand All @@ -40,22 +44,28 @@ defmodule Zendesk.TicketFieldsApi do

@doc """
Update a ticket field
`ticket_field` ticket field to update
`field_id` the ticket field id to update
"""
def update_ticket_field(account, id: id, ticket_field: ticket_field) do
def update_ticket_field(account, field_id: field_id, ticket_field: ticket_field) do
json = TicketField.to_json(%{ticket_field: ticket_field})

perform_request(&parse_ticket_field/1, account: account, verb: :put,
body: json,
endpoint: ExPrintf.sprintf(@update_field, [id]),
endpoint: ExPrintf.sprintf(@update_field, [field_id]),
headers: headers)
end

@doc """
Delete a ticket field
`field_id` field id to delelte
"""
def delete_ticket_field(account, id: id) do
def delete_ticket_field(account, field_id: field_id) do
perform_request(&parse_ticket_delete/1, account: account, verb: :delete,
endpoint: ExPrintf.sprintf(@get_field, [id]))
endpoint: ExPrintf.sprintf(@get_field, [field_id]))
end

# Private
Expand Down
8 changes: 6 additions & 2 deletions lib/api/ticket_metrics_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@ defmodule Zendesk.TicketMetricsApi do

@doc """
Get metrics for ticket id
`ticket_id` ticket id to get metrics for
"""
def metrics_for_ticket(account, ticket_id: ticket_id) do
def all_metrics(account, ticket_id: ticket_id) do
perform_request(&parse_metric/1, account: account, verb: :get,
endpoint: ExPrintf.sprintf(@ticket_metrics, [ticket_id]))
end

@doc """
Get metrics with id
`metric_id` metric id to show
"""
def metrics_with_id(account, id: metric_id) do
def show_metric(account, metric_id: metric_id) do
perform_request(&parse_metric/1, account: account, verb: :get,
endpoint: ExPrintf.sprintf(@metric_for_id, [metric_id]))
end
Expand Down
Loading

0 comments on commit 2baae84

Please sign in to comment.