Sha256: d3ddfd7029a31c71bd1909a32483a5d1ae71409b2dd41c759282cd5506a6fca9

Contents?: true

Size: 791 Bytes

Versions: 2

Compression:

Stored size: 791 Bytes

Contents

module Paddle
  class Adjustment < Object
    class << self
      def list(**params)
        response = Client.get_request("adjustments", params: params)
        Collection.from_response(response, type: Adjustment)
      end

      def create(transaction_id:, action:, reason:, items:, **params)
        attrs = { transaction_id: transaction_id, action: action, reason: reason, items: items }
        response = Client.post_request("adjustments", body: attrs.merge(params))
        Adjustment.new(response.body["data"])
      end

      def credit_note(id:, disposition: "attachment")
        response = Client.get_request("adjustments/#{id}/credit-note?disposition=#{disposition}")
        if response.success?
          response.body["data"]["url"]
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
paddle-2.7.0 lib/paddle/models/adjustment.rb
paddle-2.6.0 lib/paddle/models/adjustment.rb