Sha256: b2f05caff3b12ab12f5a1515962198799d7ecf73d7ec358e1a3efb46f49504f7
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
require 'uri' module Voucherify module Service class Campaigns attr_reader :client def initialize(client) @client = client end def create(campaign) @client.post('/campaigns', campaign.to_json) end def get(campaign_name) @client.get("/campaigns/#{ERB::Util.url_encode(campaign_name)}") end def delete(campaign_name, params = {}) @client.delete("/campaigns/#{ERB::Util.url_encode(campaign_name)}", {:force => (!!(params['force'] || params[:force])).to_s}) nil end def add_voucher(campaign_name, params = {}) code = params['code'] || params[:code] url = "/campaigns/#{ERB::Util.url_encode(campaign_name)}/vouchers" url += "/#{ERB::Util.url_encode(code)}" if code params.delete 'code' params.delete :code @client.post(url, params.to_json) end def import_vouchers(campaign_name, vouchers) @client.post("/campaigns/#{ERB::Util.url_encode(campaign_name)}/import", vouchers.to_json) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
voucherify-4.1.0 | lib/voucherify/service/campaigns.rb |
voucherify-4.0.0 | lib/voucherify/service/campaigns.rb |