diff --git a/lib/ex_twilio/resource.ex b/lib/ex_twilio/resource.ex index 77ee8eb..ab56364 100644 --- a/lib/ex_twilio/resource.ex +++ b/lib/ex_twilio/resource.ex @@ -17,9 +17,7 @@ defmodule ExTwilio.Resource do The `import` option specifies which methods you want to be able to use. """ - @doc """ - Provide a `use` macro for use extending. - """ + @doc false defmacro __using__(options) do import_functions = options[:import] || [] quote bind_quoted: [import_functions: import_functions] do @@ -28,20 +26,6 @@ defmodule ExTwilio.Resource do alias ExTwilio.UrlGenerator, as: Url alias ExTwilio.ResultStream - module = String.replace(to_string(__MODULE__), ~r/Elixir\./, "") - resource = String.replace(module, ~r/ExTwilio\./, "") - variable = String.downcase(resource) |> Inflex.pluralize - variable_singular = Inflex.singularize(variable) - - @doc """ - Creates a new #{module} struct. Optionally, you can pass in attributes to - set their initial value in the struct. - - ## Example - - %#{module}{} = #{module}.new - %#{module}{sid: "sid"} = #{module}.new(sid: "sid") - """ @spec new :: %__MODULE__{} def new, do: %__MODULE__{} @@ -57,76 +41,30 @@ defmodule ExTwilio.Resource do end if :stream in import_functions do - @doc """ - Create an `ExTwilio.ResultStream` of all #{resource} records from the - Twilio API. - """ def stream(options \\ []), do: ResultStream.new(__MODULE__, options) end if :all in import_functions do - @doc """ - Retrieve _all_ of the #{resource} records from the Twilio API, paging - through all the API response pages. - - Delegates to `ExTwilio.Api.all/2`. - - ## Examples - - #{variable} = #{module}.all - """ @spec all(list) :: [map] def all(options \\ []), do: stream(options) |> Enum.into([]) end if :find in import_functions do - @doc """ - Find any #{resource} by its Twilio SID. - - Delegates to `ExTwilio.Api.find/3`. - - ## Examples - - {:ok, #{variable_singular}} = #{module}.find("...") - {:error, msg, http_status} = #{module}.find("...") - """ @spec find(String.t | nil, list) :: Parser.parsed_list_response def find(sid, options \\ []), do: Api.find(__MODULE__, sid, options) end if :create in import_functions do - @doc """ - Create a new #{resource} in the Twilio API. Any field supported by - Twilio's #{resource} API can be passed in the 'data' keyword list. - - Delegates to `ExTwilio.Api.create/3`. - """ @spec create(list, list) :: Parser.parsed_response def create(data, options \\ []), do: Api.create(__MODULE__, data, options) end if :update in import_functions do - @doc """ - Update an #{resource} in the Twilio API. You can pass it a binary SID as - the identifier, or a whole %#{module}{} struct. - - Delegates to `ExTwilio.Api.update/4`. - - ## Examples - - {:ok, #{variable_singular}} = #{module}.update(%#{module}{...}, field: "new_value") - {:ok, #{variable_singular}} = #{module}.update("", field: "new_value") - """ @spec update(String.t, list, list) :: Parser.parsed_response def update(sid, data, options \\ []), do: Api.update(__MODULE__, sid, data, options) end if :destroy in import_functions do - @doc """ - Delete any #{resource} from your Twilio account, using its SID. - - Delegates to `ExTwilio.Api.destroy/3`. - """ @spec destroy(String.t, list) :: Parser.success_delete | Parser.error def destroy(sid, options \\ []), do: Api.destroy(__MODULE__, sid, options) end diff --git a/mix.exs b/mix.exs index 060ec44..06ef954 100644 --- a/mix.exs +++ b/mix.exs @@ -40,7 +40,7 @@ defmodule ExTwilio.Mixfile do {:poison, "~> 1.4"}, {:inflex, "~> 1.0.0"}, {:mock, "~> 0.1.0", only: :test}, - {:ex_doc, "~> 0.7", only: :docs}, + {:ex_doc, only: :docs}, {:inch_ex, only: :docs} ] end diff --git a/mix.lock b/mix.lock index 9e768b5..194034e 100644 --- a/mix.lock +++ b/mix.lock @@ -1,5 +1,5 @@ %{"dotenv": {:hex, :dotenv, "0.0.4"}, - "ex_doc": {:hex, :ex_doc, "0.7.2"}, + "ex_doc": {:hex, :ex_doc, "0.9.0"}, "hackney": {:hex, :hackney, "1.0.6"}, "httpoison": {:hex, :httpoison, "0.6.2"}, "httpotion": {:hex, :httpotion, "2.1.0"},