Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bang-methods): add bang methods to resource base module #18

Merged
merged 5 commits into from
Oct 11, 2018

Conversation

mpiercy827
Copy link
Contributor

What

Adds list!/2, retrieve!/2, create!/2 and delete!/2 methods to resource base.

Why

To follow the Elixir package conventions of having methods with a trailing bang.

Note

I haven't thought of the best way to add tests for these new methods. Adding tests to every resource might be a bit cumbersome, but I'm open to doing that.

@coveralls
Copy link

coveralls commented Oct 8, 2018

Pull Request Test Coverage Report for Build 349

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 90.323%

Totals Coverage Status
Change from base Build 256: 0.0%
Covered Lines: 28
Relevant Lines: 31

💛 - Coveralls

def list!(params \\ %{}, headers \\ %{}) do
case list(params, headers) do
{:ok, body, headers} -> {body, headers}
error -> raise to_string(error)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you want to raise the error message not the whole tuple? Something like this?

{:error, error} -> raise(error)

Copy link

@mgartner mgartner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a comment.

@mpiercy827
Copy link
Contributor Author

@mgartner ready for another look!

@@ -18,27 +18,59 @@ defmodule Lob.ResourceBase do
def list(params \\ %{}, headers \\ %{}) do
Client.get_request("#{base_url()}?#{Util.build_query_string(params)}" , Util.build_headers(headers))
end

@spec list!(map, map) :: {map, list}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Do we need to update the typespecs to reflect that it can raise an error?

Copy link
Contributor

@itsachen itsachen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@itsachen itsachen removed their assignment Oct 9, 2018
@itsachen itsachen requested a review from a team October 9, 2018 21:56
@mgartner mgartner assigned kylekwong and unassigned mgartner Oct 10, 2018
@mpiercy827 mpiercy827 merged commit 6fa3db4 into master Oct 11, 2018
@mpiercy827 mpiercy827 deleted the bang-methods branch October 11, 2018 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

5 participants