Sha256: b76d879f2fd1edc4e84f4b06368d97152a2fceda3e80ea371c1f8d346ab77519

Contents?: true

Size: 949 Bytes

Versions: 4

Compression:

Stored size: 949 Bytes

Contents

# frozen_string_literal: true

module Supersaas
  class Promotions < BaseApi
    # REF: https://www.supersaas.com/info/dev/promotion_api
    def list(limit = nil, offset = nil)
      path = '/promotions'
      params = {}
      params.merge!(limit: validate_number(limit)) if limit
      params.merge!(offset: validate_number(offset)) if offset
      res = client.get(path, params)
      res.map { |attributes| Supersaas::Promotion.new(attributes) }
    end

    def promotion(promotion_code)
      path = '/promotions'
      query = { promotion_code: validate_promotion(promotion_code) }
      res = client.get(path, query)
      res.map { |attributes| Supersaas::Promotion.new(attributes) }
    end

    def duplicate_promotion_code(promotion_code, template_code)
      path = '/promotions'
      query = { id: validate_promotion(promotion_code), template_code: validate_promotion(template_code) }
      client.post(path, query)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
supersaas-api-client-2.0.5 lib/supersaas-api-client/api/promotions.rb
supersaas-api-client-2.0.4 lib/supersaas-api-client/api/promotions.rb
supersaas-api-client-2.0.3 lib/supersaas-api-client/api/promotions.rb
supersaas-api-client-2.0.2 lib/supersaas-api-client/api/promotions.rb