Class: Paddle::Adjustment

Inherits:
Object
  • Object
show all
Defined in:
lib/paddle/models/adjustment.rb

Class Method Summary collapse

Methods inherited from Object

#initialize, #to_ostruct, #update

Constructor Details

This class inherits a constructor from Paddle::Object

Class Method Details

.create(transaction_id:, action:, reason:, items:, **params) ⇒ Object



9
10
11
12
13
# File 'lib/paddle/models/adjustment.rb', line 9

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

.credit_note(id:, disposition: "attachment") ⇒ Object



15
16
17
18
19
20
# File 'lib/paddle/models/adjustment.rb', line 15

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

.list(**params) ⇒ Object



4
5
6
7
# File 'lib/paddle/models/adjustment.rb', line 4

def list(**params)
  response = Client.get_request("adjustments", params: params)
  Collection.from_response(response, type: Adjustment)
end