Sha256: 2c7fd77f17fc564ec12f4925014001bbe93511a0011f1a99f34dee422ffeb472

Contents?: true

Size: 913 Bytes

Versions: 3

Compression:

Stored size: 913 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/#{URI.encode(id)}")
      end

      def delete_export(id)
        @client.delete("/exports/#{URI.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

3 entries across 3 versions & 1 rubygems

Version Path
voucherify-3.0.0 lib/voucherify/service/distributions.rb
voucherify-2.4.0 lib/voucherify/service/distributions.rb
voucherify-2.3.0 lib/voucherify/service/distributions.rb