Sha256: d08559382791c4a7829e1b75948e93b7b7e9f9304032c1736bb2942e0c190524

Contents?: true

Size: 927 Bytes

Versions: 2

Compression:

Stored size: 927 Bytes

Contents

require 'uri'

module Voucherify
  module Service
    class Distributions
      attr_reader :client

      def initialize(client)
        @client = client
      end

      def publish(params)
        payload = {}
        if params.is_a? String
          payload = {:campaign => params}
        elsif params.is_a? Hash
          payload = params
        end

        @client.post('/vouchers/publish', payload.to_json)
      end

      def create_export(export)
        @client.post('/exports', export)
      end

      def get_export(id)
        @client.get("/exports/#{ERB::Util.url_encode(id)}")
      end

      def delete_export(id)
        @client.delete("/exports/#{ERB::Util.url_encode(id)}")
      end

      def list_publications(params = {})
        @client.get('/publications', params)
      end

      def create_publication(params)
        @client.post('/publications', params.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/distributions.rb
voucherify-4.0.0 lib/voucherify/service/distributions.rb