From b640dcff1d8f3bae0a64704b9a4ef53f7cdd93ff Mon Sep 17 00:00:00 2001 From: "Kian-Meng, Ang" Date: Sat, 6 Nov 2021 14:36:03 +0800 Subject: [PATCH] Misc doc changes Besides other documentation changes, this commit ensures the generated HTML doc for HexDocs.pm will become the source of truth for this Elixir library and leverage on latest features of ExDoc. --- .formatter.exs | 4 ++++ .gitignore | 29 +++++++++++++++++++++++----- LICENSE | 7 ------- LICENSE.md | 21 ++++++++++++++++++++ README.md | 37 +++++++++++++++++++++++++++++------- lib/mailchimp/config.ex | 24 +++++++++++------------ lib/mailchimp/http_client.ex | 6 +++--- mix.exs | 34 ++++++++++++++++++++------------- mix.lock | 23 ++++++++++++++++++++++ 9 files changed, 138 insertions(+), 47 deletions(-) create mode 100644 .formatter.exs delete mode 100644 LICENSE create mode 100644 LICENSE.md create mode 100644 mix.lock diff --git a/.formatter.exs b/.formatter.exs new file mode 100644 index 0000000..d2cda26 --- /dev/null +++ b/.formatter.exs @@ -0,0 +1,4 @@ +# Used by "mix format" +[ + inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] +] diff --git a/.gitignore b/.gitignore index 3379e72..81c103b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,26 @@ -/_build -/deps +# The directory Mix will write compiled artifacts to. +/_build/ + +# If you run "mix test --cover", coverage assets end up here. +/cover/ + +# The directory Mix downloads your dependencies sources to. +/deps/ + +# Where third-party dependencies like ExDoc output generated docs. +/doc/ + +# Ignore .fetch files in case you like to edit your project deps locally. +/.fetch + +# If the VM crashes, it generates a dump, let's ignore it too. erl_crash.dump + +# Also ignore archive artifacts (built via "mix archive.build"). *.ez -/mix.lock -/doc -/priv/test/dump/* + +# Ignore package tarball (built via "mix hex.build"). +mailchimp-*.tar + +# Temporary files, for example, from tests. +/tmp/ diff --git a/LICENSE b/LICENSE deleted file mode 100644 index c69d8aa..0000000 --- a/LICENSE +++ /dev/null @@ -1,7 +0,0 @@ -Copyright 2017 Jean Duarte - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..dbe4f6f --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +# The MIT License + +Copyright (c) 2017 Jean Duarte + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 3abf654..e2c7896 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,10 @@ -[![Hex Version](http://img.shields.io/hexpm/v/mailchimp.svg)](https://hex.pm/packages/mailchimp) +# MailChimp + +[![Module Version](https://img.shields.io/hexpm/v/mailchimp.svg)](https://hex.pm/packages/mailchimp) +[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/mailchimp/) +[![Total Download](https://img.shields.io/hexpm/dt/mailchimp.svg)](https://hex.pm/packages/mailchimp) +[![License](https://img.shields.io/hexpm/l/mailchimp.svg)](https://github.com/duartejc/mailchimp/blob/master/LICENSE.md) +[![Last Updated](https://img.shields.io/github/last-commit/duartejc/mailchimp.svg)](https://github.com/duartejc/mailchimp/commits/master) This is a basic Elixir wrapper for version 3 of the MailChimp API. @@ -8,7 +14,9 @@ First, add MailChimp lib to your `mix.exs` dependencies: ```elixir def deps do - [{:mailchimp, "~> 0.1.2"}] + [ + {:mailchimp, "~> 0.1.2"} + ] end ``` @@ -26,21 +34,36 @@ config :mailchimp, or ```elixir - Application.put_env(:mailchimp, :api_key, "your apikey-us12") +Application.put_env(:mailchimp, :api_key, "your apikey-us12") ``` ### Getting Account Details - Mailchimp.Account.get!() +```elixir +Mailchimp.Account.get!() +``` ### Getting All Lists - Mailchimp.Account.get! |> Mailchimp.Account.lists! +```elixir +Mailchimp.Account.get! |> Mailchimp.Account.lists! +``` ### Adding a Member to a List - Mailchimp.List.create_member(list, "test@email.com", "subscribed", %{}, %{}) +```elixir +Mailchimp.List.create_member(list, "test@email.com", "subscribed", %{}, %{}) +``` ### Creating a new Campaign - Mailchimp.Campaign.create!(:regular) +```elixir +Mailchimp.Campaign.create!(:regular) +``` + +## Copyright and License + +Copyright (c) 2017 Jean Duarte + +This work is free. You can redistribute it and/or modify it under the +terms of the MIT License. See the [LICENSE.md](./LICENSE.md) file for more details. diff --git a/lib/mailchimp/config.ex b/lib/mailchimp/config.ex index b19d015..c935a63 100644 --- a/lib/mailchimp/config.ex +++ b/lib/mailchimp/config.ex @@ -1,13 +1,13 @@ defmodule Mailchimp.Config do @moduledoc """ - Mailchimp Config Module + Mailchimp Config Module. """ @default_api_version "3.0" @default_api_endpoint "api.mailchimp.com" @doc """ - Return configured API Key + Returns configured API Key. ### Examples @@ -20,7 +20,7 @@ defmodule Mailchimp.Config do def api_key!, do: Application.fetch_env!(:mailchimp, :api_key) @doc """ - Return configured API Version + Returns configured API Version. ### Examples @@ -37,24 +37,24 @@ defmodule Mailchimp.Config do def api_version, do: Application.get_env(:mailchimp, :api_version, @default_api_version) @doc """ - Return configured API endpoint + Returns configured API endpoint. ### Examples - iex> Application.put_env(:mailchimp, :api_endpoint, "api.mc.local") - iex> Mailchimp.Config.api_endpoint() - "api.mc.local" + iex> Application.put_env(:mailchimp, :api_endpoint, "api.mc.local") + iex> Mailchimp.Config.api_endpoint() + "api.mc.local" - iex> Application.delete_env(:mailchimp, :api_endpoint) - iex> Mailchimp.Config.api_endpoint() - "api.mailchimp.com" + iex> Application.delete_env(:mailchimp, :api_endpoint) + iex> Mailchimp.Config.api_endpoint() + "api.mailchimp.com" """ @spec api_endpoint() :: String.t() def api_endpoint, do: Application.get_env(:mailchimp, :api_endpoint, @default_api_endpoint) @doc """ - Return configured API Version + Returns configured API Version. ### Examples @@ -71,7 +71,7 @@ defmodule Mailchimp.Config do end @doc """ - Return configured API Version + Returns configured API Version. ### Examples diff --git a/lib/mailchimp/http_client.ex b/lib/mailchimp/http_client.ex index e25d5e9..3d87566 100644 --- a/lib/mailchimp/http_client.ex +++ b/lib/mailchimp/http_client.ex @@ -1,6 +1,6 @@ defmodule Mailchimp.HTTPClient do @moduledoc """ - Poison HTTP Client for Mailchimp + Poison HTTP Client for Mailchimp. """ use HTTPoison.Base @@ -8,7 +8,7 @@ defmodule Mailchimp.HTTPClient do alias Mailchimp.Config @doc """ - Complete / Filter URL + Complete / Filter URL. ### Examples @@ -49,7 +49,7 @@ defmodule Mailchimp.HTTPClient do end @doc """ - Add Auth Header to every request that has none already + Add Auth Header to every request that has none already. ### Examples diff --git a/mix.exs b/mix.exs index b92b96e..370efa2 100644 --- a/mix.exs +++ b/mix.exs @@ -1,16 +1,17 @@ defmodule Mailchimp.Mixfile do use Mix.Project + @source_url "https://github.com/duartejc/mailchimp" + @version "0.1.2" + def project do [ app: :mailchimp, - version: "0.1.2", + version: @version, elixir: "~> 1.7", - description: description(), package: package(), - source_url: "https://github.com/duartejc/mailchimp", deps: deps(), - docs: [readme: "README.md", main: "README"] + docs: docs() ] end @@ -20,27 +21,34 @@ defmodule Mailchimp.Mixfile do ] end - defp description do - """ - A basic Elixir wrapper for version 3 of the MailChimp API. - """ - end - defp deps do [ {:httpoison, "~> 1.6"}, {:jason, "~> 1.1"}, - {:ex_doc, "~> 0.21", only: :dev, runtime: false}, + {:ex_doc, ">= 0.0.0", only: :dev, runtime: false}, {:exvcr, "~> 0.11", only: :test} ] end defp package do [ - files: ["lib", "mix.exs", "README.md", "LICENSE"], + description: "A basic Elixir wrapper for version 3 of the MailChimp API.", + files: ["lib", "mix.exs", "README.md", "LICENSE.md"], maintainers: ["Jean Duarte", "Eric Froese"], licenses: ["MIT"], - links: %{"GitHub" => "https://github.com/duartejc/mailchimp"} + links: %{"GitHub" => @source_url} + ] + end + + defp docs do + [ + extras: [ + "LICENSE.md": [title: "License"], + "README.md": [title: "Overview"] + ], + main: "readme", + source_url: @source_url, + formatters: ["html"] ] end end diff --git a/mix.lock b/mix.lock new file mode 100644 index 0000000..bc87b39 --- /dev/null +++ b/mix.lock @@ -0,0 +1,23 @@ +%{ + "certifi": {:hex, :certifi, "2.8.0", "d4fb0a6bb20b7c9c3643e22507e42f356ac090a1dcea9ab99e27e0376d695eba", [:rebar3], [], "hexpm", "6ac7efc1c6f8600b08d625292d4bbf584e14847ce1b6b5c44d983d273e1097ea"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.17", "6f3c7e94170377ba45241d394389e800fb15adc5de51d0a3cd52ae766aafd63f", [:mix], [], "hexpm", "f93ac89c9feca61c165b264b5837bf82344d13bebc634cd575cb711e2e342023"}, + "ex_doc": {:hex, :ex_doc, "0.25.5", "ac3c5425a80b4b7c4dfecdf51fa9c23a44877124dd8ca34ee45ff608b1c6deb9", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "688cfa538cdc146bc4291607764a7f1fcfa4cce8009ecd62de03b27197528350"}, + "exactor": {:hex, :exactor, "2.2.4", "5efb4ddeb2c48d9a1d7c9b465a6fffdd82300eb9618ece5d34c3334d5d7245b1", [:mix], [], "hexpm", "1222419f706e01bfa1095aec9acf6421367dcfab798a6f67c54cf784733cd6b5"}, + "exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm", "32e95820a97cffea67830e91514a2ad53b888850442d6d395f53a1ac60c82e07"}, + "exvcr": {:hex, :exvcr, "0.13.2", "e17fd3ee3a341f41a3aa65a3ce73a339759a9d0658f83782492c6e9b6cf9daa4", [:mix], [{:exactor, "~> 2.2", [hex: :exactor, repo: "hexpm", optional: false]}, {:exjsx, "~> 4.0", [hex: :exjsx, repo: "hexpm", optional: false]}, {:finch, "~> 0.8.0", [hex: :finch, repo: "hexpm", optional: true]}, {:httpoison, "~> 1.0", [hex: :httpoison, repo: "hexpm", optional: true]}, {:httpotion, "~> 3.1", [hex: :httpotion, repo: "hexpm", optional: true]}, {:ibrowse, "4.4.0", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:meck, "~> 0.8", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "17f41a533d14f582fe6b5f83214f058cf5ba77c6a7bc15bc53a9ea1827d92d96"}, + "hackney": {:hex, :hackney, "1.18.0", "c4443d960bb9fba6d01161d01cd81173089686717d9490e5d3606644c48d121f", [:rebar3], [{:certifi, "~>2.8.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "9afcda620704d720db8c6a3123e9848d09c87586dc1c10479c42627b905b5c5e"}, + "httpoison": {:hex, :httpoison, "1.8.0", "6b85dea15820b7804ef607ff78406ab449dd78bed923a49c7160e1886e987a3d", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "28089eaa98cf90c66265b6b5ad87c59a3729bea2e74e9d08f9b51eb9729b3c3a"}, + "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, + "jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"}, + "jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [:mix, :rebar3], [], "hexpm", "fc3499fed7a726995aa659143a248534adc754ebd16ccd437cd93b649a95091f"}, + "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.15.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"}, + "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, + "meck": {:hex, :meck, "0.9.2", "85ccbab053f1db86c7ca240e9fc718170ee5bda03810a6292b5306bf31bae5f5", [:rebar3], [], "hexpm", "81344f561357dc40a8344afa53767c32669153355b626ea9fcbc8da6b3045826"}, + "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, + "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, + "parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"}, + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"}, +}