Skip to content

Commit

Permalink
Added segments endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanhornby committed May 6, 2019
1 parent 00b28fd commit e9605e4
Show file tree
Hide file tree
Showing 10 changed files with 561 additions and 98 deletions.
9 changes: 8 additions & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
engines:
duplication:
enabled: false
structure:
enabled: false
credo:
enabled: true
strict: true
strict: false
all: true
#only: "warning"
#ignore: "readability"
198 changes: 143 additions & 55 deletions .credo.exs
Original file line number Diff line number Diff line change
@@ -1,71 +1,159 @@
# This file contains the configuration for Credo and you are probably reading
# this after creating it with `mix credo.gen.config`.
#
# If you find anything wrong or unclear in this file, please report an
# issue on GitHub: https://github.com/rrrene/credo/issues
#
%{
#
# You can have as many configs as you like in the `configs:` field.
configs: [
%{
#
# Run any exec using `mix credo -C <name>`. If no exec name is given
# "default" is used.
#
name: "default",
#
# These are the files included in the analysis:
files: %{
included: ["lib/"]
#
# You can give explicit globs or simply directories.
# In the latter case `**/*.{ex,exs}` will be used.
#
included: ["lib/", "src/", "test/", "web/", "apps/"],
excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"]
},
check_for_updates: true,
strict: true,
#
# If you create your own checks, you must specify the source files for
# them here, so they can be loaded by Credo before running the analysis.
#
requires: [],
#
# If you want to enforce a style guide and need a more traditional linting
# experience, you can change `strict` to `true` below:
#
strict: false,
#
# If you want to use uncolored output by default, you can change `color`
# to `false` below:
#
color: true,
#
# You can customize the parameters of any check by adding a second element
# to the tuple.
#
# To disable a check put `false` as second element:
#
# {Credo.Check.Design.DuplicatedCode, false}
#
checks: [
{Credo.Check.Consistency.ExceptionNames},
{Credo.Check.Consistency.LineEndings},
{Credo.Check.Consistency.MultiAliasImportRequireUse},
{Credo.Check.Consistency.ParameterPatternMatching},
{Credo.Check.Consistency.SpaceAroundOperators},
{Credo.Check.Consistency.SpaceInParentheses},
{Credo.Check.Consistency.TabsOrSpaces},
{Credo.Check.Design.AliasUsage},
{Credo.Check.Design.DuplicatedCode, excluded_macros: [:test]},
{Credo.Check.Design.TagTODO},
{Credo.Check.Design.TagFIXME},
{Credo.Check.Readability.FunctionNames},
{Credo.Check.Readability.LargeNumbers},
{Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 80},
{Credo.Check.Readability.ModuleAttributeNames},
{Credo.Check.Readability.ModuleDoc},
{Credo.Check.Readability.ModuleNames},
{Credo.Check.Readability.ParenthesesOnZeroArityDefs},
{Credo.Check.Readability.ParenthesesInCondition},
{Credo.Check.Readability.PredicateFunctionNames},
{Credo.Check.Readability.PreferImplicitTry},
{Credo.Check.Readability.RedundantBlankLines},
{Credo.Check.Readability.StringSigils},
{Credo.Check.Readability.TrailingBlankLine},
{Credo.Check.Readability.TrailingWhiteSpace},
{Credo.Check.Readability.VariableNames},
{Credo.Check.Readability.Semicolons},
{Credo.Check.Readability.SpaceAfterCommas},
{Credo.Check.Refactor.DoubleBooleanNegation},
{Credo.Check.Refactor.CondStatements},
{Credo.Check.Refactor.CyclomaticComplexity},
{Credo.Check.Refactor.FunctionArity},
{Credo.Check.Refactor.MatchInCondition},
{Credo.Check.Refactor.NegatedConditionsInUnless},
{Credo.Check.Refactor.NegatedConditionsWithElse},
{Credo.Check.Refactor.Nesting},
{Credo.Check.Refactor.PipeChainStart},
{Credo.Check.Refactor.UnlessWithElse},
{Credo.Check.Warning.BoolOperationOnSameValues},
{Credo.Check.Warning.IExPry},
{Credo.Check.Warning.IoInspect},
{Credo.Check.Warning.OperationOnSameValues},
{Credo.Check.Warning.OperationWithConstantResult},
{Credo.Check.Warning.UnusedEnumOperation},
{Credo.Check.Warning.UnusedFileOperation},
{Credo.Check.Warning.UnusedKeywordOperation},
{Credo.Check.Warning.UnusedListOperation},
{Credo.Check.Warning.UnusedPathOperation},
{Credo.Check.Warning.UnusedRegexOperation},
{Credo.Check.Warning.UnusedStringOperation},
{Credo.Check.Warning.UnusedTupleOperation},
#
## Consistency Checks
#
{Credo.Check.Consistency.ExceptionNames, []},
{Credo.Check.Consistency.LineEndings, []},
{Credo.Check.Consistency.ParameterPatternMatching, []},
{Credo.Check.Consistency.SpaceAroundOperators, []},
{Credo.Check.Consistency.SpaceInParentheses, []},
{Credo.Check.Consistency.TabsOrSpaces, []},

# Controversial and experimental checks
#
## Design Checks
#
# You can customize the priority of any check
# Priority values are: `low, normal, high, higher`
#
{Credo.Check.Design.AliasUsage,
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
# You can also customize the exit_status of each check.
# If you don't want TODO comments to cause `mix credo` to fail, just
# set this value to 0 (zero).
#
{Credo.Check.Design.TagTODO, [exit_status: 2]},
{Credo.Check.Design.TagFIXME, []},

#
## Readability Checks
#
{Credo.Check.Readability.AliasOrder, []},
{Credo.Check.Readability.FunctionNames, []},
{Credo.Check.Readability.LargeNumbers, []},
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]},
{Credo.Check.Readability.ModuleAttributeNames, []},
{Credo.Check.Readability.ModuleDoc, []},
{Credo.Check.Readability.ModuleNames, []},
{Credo.Check.Readability.ParenthesesInCondition, []},
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []},
{Credo.Check.Readability.PredicateFunctionNames, []},
{Credo.Check.Readability.PreferImplicitTry, []},
{Credo.Check.Readability.RedundantBlankLines, []},
{Credo.Check.Readability.Semicolons, []},
{Credo.Check.Readability.SpaceAfterCommas, []},
{Credo.Check.Readability.StringSigils, []},
{Credo.Check.Readability.TrailingBlankLine, []},
{Credo.Check.Readability.TrailingWhiteSpace, []},
# TODO: enable by default in Credo 1.1
{Credo.Check.Readability.UnnecessaryAliasExpansion, false},
{Credo.Check.Readability.VariableNames, []},

#
## Refactoring Opportunities
#
{Credo.Check.Refactor.CondStatements, []},
{Credo.Check.Refactor.CyclomaticComplexity, []},
{Credo.Check.Refactor.FunctionArity, []},
{Credo.Check.Refactor.LongQuoteBlocks, []},
{Credo.Check.Refactor.MapInto, false},
{Credo.Check.Refactor.MatchInCondition, []},
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
{Credo.Check.Refactor.Nesting, []},
{Credo.Check.Refactor.PipeChainStart,
[
excluded_argument_types: [:atom, :binary, :fn, :keyword, :number],
excluded_functions: []
]},
{Credo.Check.Refactor.UnlessWithElse, []},

#
## Warnings
#
{Credo.Check.Warning.BoolOperationOnSameValues, []},
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
{Credo.Check.Warning.IExPry, []},
{Credo.Check.Warning.IoInspect, []},
{Credo.Check.Warning.LazyLogging, false},
{Credo.Check.Warning.OperationOnSameValues, []},
{Credo.Check.Warning.OperationWithConstantResult, []},
{Credo.Check.Warning.RaiseInsideRescue, []},
{Credo.Check.Warning.UnusedEnumOperation, []},
{Credo.Check.Warning.UnusedFileOperation, []},
{Credo.Check.Warning.UnusedKeywordOperation, []},
{Credo.Check.Warning.UnusedListOperation, []},
{Credo.Check.Warning.UnusedPathOperation, []},
{Credo.Check.Warning.UnusedRegexOperation, []},
{Credo.Check.Warning.UnusedStringOperation, []},
{Credo.Check.Warning.UnusedTupleOperation, []},

#
# Controversial and experimental checks (opt-in, just replace `false` with `[]`)
#
{Credo.Check.Consistency.MultiAliasImportRequireUse, false},
{Credo.Check.Design.DuplicatedCode, false},
{Credo.Check.Readability.MultiAlias, false},
{Credo.Check.Readability.Specs, false},
{Credo.Check.Refactor.ABCSize, false},
{Credo.Check.Refactor.AppendSingleItem, false},
{Credo.Check.Refactor.DoubleBooleanNegation, false},
{Credo.Check.Refactor.ModuleDependencies, false},
{Credo.Check.Refactor.VariableRebinding, false},
{Credo.Check.Warning.MapGetUnsafePass, false},
{Credo.Check.Warning.UnsafeToAtom, false}

#
# Custom checks can be created using `mix credo.gen.check`.
#
]
}
]
Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ elixir:
- 1.8.1
env:
matrix:
- secure: VPEgRpn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Z6XsLArQ2ImE5SEW6b4t3Rs7SLVWdQfE1j2iYmzNCosd84DvkTM8tHhaXw3QLr95GpmyAIithrvy6b2c0tCFHN2fgmFuh7XnR4VcKWxGPp76UziM3GjAh/zGnxVTlFQ1i3kUzf4zm64fhrF7pJ3Vws2+Dv/clHLhxm5DLeE2uBuditNiGWfgHMCZxzui0Vvnwc/h1ac9WXNo6jlfa38mMV2IVOUWk+lTA5P/BTssGjwO1EpWPZT3h7IoZowuhqCxMLygD1RCVd90OzhX3OTe+B5VwCgM7C+oE43mY=
13 changes: 10 additions & 3 deletions lib/campaigns.ex
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ defmodule MailerLite.Campaigns do
iex> type: 2}
iex> MailerLite.Campaigns.send(campaign_id, send_options)
iex> {:ok, response} = MailerLite.Campaigns.cancel(campaign_id)
iex> MailerLite.Campaigns.delete(campaign_id)
iex> is_map(response)
true
Expand Down Expand Up @@ -136,16 +137,18 @@ defmodule MailerLite.Campaigns do
## Example response
{:ok}
{:ok, %{"success" => true}}
## Test
iex> new_campaign = %{groups: [24992054],
iex> subject: "A regular email campaign",
iex> type: "regular"}
iex> {:ok, response} = MailerLite.Campaigns.new(new_campaign)
iex> MailerLite.Campaigns.delete(Map.get(response, "id"))
iex> campaign_id = Map.get(response, "id")
iex> MailerLite.Campaigns.delete(campaign_id)
{:ok, %{"success" => true}}
"""
@spec delete(MailerLite.id) :: {:ok, map} | {:error, atom}
def delete(campaign) when is_integer(campaign) do
Expand Down Expand Up @@ -273,6 +276,8 @@ defmodule MailerLite.Campaigns do
iex> subject: "A regular email campaign",
iex> type: "regular"}
iex> {:ok, response} = MailerLite.Campaigns.new(new_campaign)
iex> campaign_id = Map.get(response, "id")
iex> MailerLite.Campaigns.delete(campaign_id)
iex> is_map(response)
true
Expand All @@ -296,7 +301,7 @@ defmodule MailerLite.Campaigns do
def send(_campaign), do: {:error, :invalid_argument}

@doc ~S"""
Schedule and send a campaign that has `draft`status and has `step` value equal to `3`.
Schedule and send a campaign that has `draft` status and has `step` value equal to `3`.
TODO Use Elixir native Date for input/output
Expand Down Expand Up @@ -371,6 +376,8 @@ defmodule MailerLite.Campaigns do
iex> send_options = %{date: "2020-12-25 09:31",
iex> type: 2}
iex> {:ok, response} = MailerLite.Campaigns.send(Map.get(new_response, "id"), send_options)
iex> MailerLite.Campaigns.cancel(campaign_id)
iex> MailerLite.Campaigns.delete(campaign_id)
iex> is_map(response)
true
Expand Down
Loading

0 comments on commit e9605e4

Please sign in to comment.