{"id":19025764,"url":"https://github.com/humphreyja/http_event_client","last_synced_at":"2025-07-11T04:04:52.059Z","repository":{"id":84429825,"uuid":"95340197","full_name":"humphreyja/http_event_client","owner":"humphreyja","description":"Elixir HTTP event client to send events to another server (useful for Heroku messaging between apps","archived":false,"fork":false,"pushed_at":"2017-07-20T03:17:13.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-21T19:15:20.512Z","etag":null,"topics":["elixir","heroku"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/http_event_server/api-reference.html","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/humphreyja.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-25T05:21:08.000Z","updated_at":"2017-07-20T18:21:29.000Z","dependencies_parsed_at":"2023-03-12T22:57:38.250Z","dependency_job_id":null,"html_url":"https://github.com/humphreyja/http_event_client","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/humphreyja/http_event_client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humphreyja%2Fhttp_event_client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humphreyja%2Fhttp_event_client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humphreyja%2Fhttp_event_client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humphreyja%2Fhttp_event_client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/humphreyja","download_url":"https://codeload.github.com/humphreyja/http_event_client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humphreyja%2Fhttp_event_client/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264726769,"owners_count":23654494,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","heroku"],"created_at":"2024-11-08T20:44:32.219Z","updated_at":"2025-07-11T04:04:47.049Z","avatar_url":"https://github.com/humphreyja.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HTTPEventClient\n\n[![Hex.pm version](https://img.shields.io/hexpm/v/http_event_client.svg)](https://hex.pm/packages/http_event_client)\n[![Hex.pm license](https://img.shields.io/hexpm/l/http_event_client.svg)](https://github.com/humphreyja/http_event_client/blob/master/LICENSE.txt)\n\n[Documentation](https://hexdocs.pm/http_event_server/api-reference.html)\n\n## Installation\n\nThe package can be installed by adding `http_event_client` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [{:http_event_client, \"~\u003e 0.2.2\"}]\nend\n```\n\n## Usage\n\n### Config Based\nPros: You can use the package anywhere in your code without needing to set up a connection client.\nCons: You can only connect to a single server for the project.\n\nHere is how you would set up the client\n\n\n```elixir\n# Config\n\nconfig :http_event_client,\n  event_server_url: \"https://example.com/events\",\n  api_token: \"1944ea5a-c924-4a24-9afa-60030e5bc486\"\n```\n\nNow you can use this anywhere by calling either the emit or emit_async methods as shown below.\n\n```elixir\nHTTPEventClient.emit(\"my-event\", data)\n\nHTTPEventClient.emit_async(\"my-event\", data)\n```\n\n### Client Based\nPros: Supports multiple servers/endpoints.\nCons: You have to create a client for every connection.\n\nHere is an example module that properly uses the client method to connect.\n\n```elixir\ndefmodule Messenger do\n  def send_event(data) do\n    HTTPEventClient.emit(client(), \"my-event\", data)\n  end\n\n  def send_async_event(data) do\n    HTTPEventClient.emit_async(client(), \"my-event\", data)\n  end\n\n  defp client do\n    %HTTPEventClient{\n      api_token: Application.get_env(:messenger, :event_server_api_token),\n      event_server_url: Application.get_env(:messenger, :event_server_url)\n    }\n  end\nend\n```\n\n\n### Additional Info\n\n### Event Types\nThere are two event types, normal and async.  The async method will just put the normal method in another process.  Because of that, it will never return anything.  The normal method will wait for a response and return the response.  \n\n### Sending Data\nData is, by default, sent with a POST request with a JSON encoded body and authenticated using an Authorization Bearer token.    \n\n### Event Data\nData being sent is encoded into JSON using Poison.  If you use the [http_event_server](https://hex.pm/packages/http_event_server) package, it will decode the data using Poison.  So any data you send should be able to work with Poison's encode/decode methods (pretty much everything).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumphreyja%2Fhttp_event_client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhumphreyja%2Fhttp_event_client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumphreyja%2Fhttp_event_client/lists"}