Class: Malipopay::Resources::Products

Inherits:
Object
  • Object
show all
Defined in:
lib/malipopay/resources/products.rb

Instance Method Summary collapse

Constructor Details

#initialize(http_client) ⇒ Products

Returns a new instance of Products.



6
7
8
# File 'lib/malipopay/resources/products.rb', line 6

def initialize(http_client)
  @http = http_client
end

Instance Method Details

#create(params) ⇒ Hash

Create a new product

Parameters:

  • params (Hash)

    Product parameters (name, price, description, etc.)

Returns:

  • (Hash)

    Created product



13
14
15
# File 'lib/malipopay/resources/products.rb', line 13

def create(params)
  @http.post("/api/v1/product", body: params)
end

#get(id) ⇒ Hash

Get a product by ID

Parameters:

  • id (String)

    Product ID

Returns:

  • (Hash)

    Product details



27
28
29
# File 'lib/malipopay/resources/products.rb', line 27

def get(id)
  @http.get("/api/v1/product/#{id}")
end

#get_by_number(number) ⇒ Hash

Get a product by product number

Parameters:

  • number (String)

    Product number

Returns:

  • (Hash)

    Product details



34
35
36
# File 'lib/malipopay/resources/products.rb', line 34

def get_by_number(number)
  @http.get("/api/v1/product", params: { productNumber: number })
end

#list(params = {}) ⇒ Hash

List all products

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters (page, limit, etc.)

Returns:

  • (Hash)

    Paginated list of products



20
21
22
# File 'lib/malipopay/resources/products.rb', line 20

def list(params = {})
  @http.get("/api/v1/product", params: params)
end

#update(id, params) ⇒ Hash

Update an existing product

Parameters:

  • id (String)

    Product ID

  • params (Hash)

    Updated product parameters

Returns:

  • (Hash)

    Updated product



42
43
44
# File 'lib/malipopay/resources/products.rb', line 42

def update(id, params)
  @http.put("/api/v1/product/#{id}", body: params)
end