Sha256: d483198ccdfc2cc6c22785d781adff8200d5cc4b445044e1a1d9cfbf7e9d2b22
Contents?: true
Size: 1.04 KB
Versions: 10
Compression:
Stored size: 1.04 KB
Contents
module Paddle module Classic class CouponsResource < Resource def list(product_id:) response = post_request("2.0/product/list_coupons", body: {product_id: product_id}) Collection.from_response(response, type: Coupon) end def create(coupon_type:, discount_type:, discount_amount:, **params) attrs = {coupon_type: coupon_type, discount_type: discount_type, discount_amount: discount_amount} response = post_request("2.1/product/create_coupon", body: attrs.merge(params)) coupons = response.body["response"]["coupon_codes"] coupons.map {|c| Paddle::Coupon.new(code: c)} end def delete(coupon_code:, product_id:) attrs = {coupon_code: coupon_code, product_id: product_id} response = post_request("2.0/product/delete_coupon", body: attrs) return true if response.success? end def update(**params) response = post_request("2.1/product/update_coupon", body: params) return true if response.success? end end end end
Version data entries
10 entries across 10 versions & 1 rubygems