Skip to content

Conversation

@asgoel
Copy link

@asgoel asgoel commented Mar 26, 2017

@ewandennis added ability to insert/update or delete a single suppression list entry.

Also had to add one more error check to the endpoint response parser to handle normal HTTPoison errors (such as request timeouts).

@coveralls
Copy link

coveralls commented Mar 26, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 9035124 on asgoel:suppression_list_delete_insert into e20f6da on SparkPost:master.

Copy link
Contributor

@ewandennis ewandennis left a comment

Choose a reason for hiding this comment

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

More great work @asgoel. Thanks as always!

Insert or update a single entry in the suppression list.
Returns a single string with the success message if the entry
was updated or inserted. Returns a %SparkPost.Endpoint.Error{} with a 400
if the type is invalid.
Copy link
Contributor

Choose a reason for hiding this comment

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

"...if there was an issue with the request format" ?

Copy link
Author

Choose a reason for hiding this comment

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

sure

- type: one of "transactional" or "non_transactional"
- description (optional): optional description of this entry in the suppression list
"""
def update_one(recipient, type, description \\ nil) do
Copy link
Contributor

Choose a reason for hiding this comment

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

Think we should call it insert_or_update_one/3 or upsert_one/3?

Copy link
Author

Choose a reason for hiding this comment

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

upsert_one sounds good

else
%{type: type, description: description}
end
response = Endpoint.request(:put, "suppression-list/#{recipient}", body)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should adopt the usual {:ok, %Sparkpost.Endpoint.Response{}} or {:error, %SparkPost.Endpoint.Error{}} here.

Copy link
Author

Choose a reason for hiding this comment

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

I'd like to adopt this. Unfortunately I'm not sure I have enough time to go through and update the library everywhere to make sure everything still works. Might make sense to have this in a different PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup. I wasn't suggesting you retrofit the whole library with this. These are the first endpoints with simple good/bad responses though so I thought we'd start here.

Parameters:
recipient: the entry to delete from the suppression list.
"""
def delete(recipient) do
Copy link
Contributor

Choose a reason for hiding this comment

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

The same comment about idiomatic {:ok, ...} return values applies here.

decoded_body = decode_response_body(body)
if decode_results do
%SparkPost.Endpoint.Response{status_code: 200, results: decoded_body.results}
%SparkPost.Endpoint.Response{status_code: code, results: decoded_body.results}
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Will have to check which other modules either make assumptions about the status code or pass it on to client code. This could produce a (good) breaking change in those cases.

Copy link
Author

Choose a reason for hiding this comment

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

didn't see anything on a cursory glance. Let me know if I missed anything though.

@asgoel
Copy link
Author

asgoel commented Mar 28, 2017

@ewandennis started the migration over to the idiomatic {:ok | :error, resp} tuples. let me know thoughts

@coveralls
Copy link

coveralls commented Mar 28, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling d8efa11 on asgoel:suppression_list_delete_insert into e20f6da on SparkPost:master.

@ewandennis
Copy link
Contributor

Sorry for the delay on this. I'm going to merge, do a little cleanup elsewhere and cut a release. Thanks as ever @asgoel !

@ewandennis ewandennis merged commit 9e09202 into SparkPost:master Apr 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants