From 1198e297283e3ad9d2231ec3bff70f8897e490dd Mon Sep 17 00:00:00 2001 From: hazimj <42558497+hazimj@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:13:08 +1000 Subject: [PATCH] Add helper method for returns Since there is already a helper method for `purchase` could we also get one for the `return` api? This would help make our codebase a bit more consistent instead of having to rely on the lower level `api_post` function. --- lib/sailthru/client.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/sailthru/client.rb b/lib/sailthru/client.rb index 5290cf2..bdca552 100644 --- a/lib/sailthru/client.rb +++ b/lib/sailthru/client.rb @@ -388,6 +388,31 @@ def purchase(email, items, incomplete = nil, message_id = nil, options = {}) end api_post(:purchase, data) end + + # params: + # email, String + # items, Array of Hashes + # incomplete, Integer + # message_id, String + # options, Hash + # returns: + # hash, response from server + # + # Record that a user has made a return or refund. + def return(email, items, incomplete = nil, message_id = nil, options = {}) + data = options + data[:email] = email + data[:items] = items + + if incomplete != nil + data[:incomplete] = incomplete.to_i + end + + if message_id != nil + data[:message_id] = message_id + end + api_post(:return, data) + end # DEPRECATED: Please use either stats_list or stats_blast # params: