Class: Paddle::Product

Inherits:
Object
  • Object
show all
Defined in:
lib/paddle/models/product.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(name:, tax_category:, **params) ⇒ Object



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

def create(name:, tax_category:, **params)
  attrs = { name: name, tax_category: tax_category }
  response = Client.post_request("products", body: attrs.merge(params))
  Product.new(response.body["data"])
end

.list(**params) ⇒ Object



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

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

.retrieve(id:) ⇒ Object



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

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

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



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

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