Sha256: f921c2f1fc9a62796350940425fa344160cf4b350db8161e208bd427e8bea664
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
require 'uri' module Voucherify module Service class Redemptions attr_reader :client def initialize(client) @client = client end def redeem(code, params = {}) if code.is_a? Hash endpoint = "/promotions/tiers/#{ERB::Util.url_encode(code[:id] || code['id'])}/redemption" else endpoint = "/vouchers/#{ERB::Util.url_encode(code)}/redemption" end @client.post(endpoint, params.to_json) end def list(query = {}) @client.get('/redemptions', query) end def get_for_voucher(code) @client.get("/vouchers/#{ERB::Util.url_encode(code)}/redemption") end def rollback(redemption_id, payload = {}) reason = payload['reason'] || payload[:reason] params = reason ? {:reason => reason} : {} payload.delete 'reason' payload.delete :reason @client.post("/redemptions/#{ERB::Util.url_encode(redemption_id)}/rollback", payload.to_json, params) end def get_redemption(redemption_id) @client.get("/redemptions/#{ERB::Util.url_encode(redemption_id)}") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
voucherify-4.1.0 | lib/voucherify/service/redemptions.rb |
voucherify-4.0.0 | lib/voucherify/service/redemptions.rb |