Class: Paddle::Price

Inherits:
Object
  • Object
show all
Defined in:
lib/paddle/models/price.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(product_id:, description:, amount:, currency:, **params) ⇒ Object



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

def create(product_id:, description:, amount:, currency:, **params)
  attrs = { product_id: product_id, description: description, unit_price: { amount: amount, currency_code: currency } }
  response = Client.post_request("prices", body: attrs.merge(params))
  Price.new(response.body["data"])
end

.list(**params) ⇒ Object



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

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

.retrieve(id:) ⇒ Object



15
16
17
18
# File 'lib/paddle/models/price.rb', line 15

def retrieve(id:)
  response = Client.get_request("prices/#{id}")
  Price.new(response.body["data"])
end

.update(id:, **params) ⇒ Object



20
21
22
23
# File 'lib/paddle/models/price.rb', line 20

def update(id:, **params)
  response = Client.patch_request("prices/#{id}", body: params)
  Price.new(response.body["data"])
end