Class: Bootpay::Commerce::ProductModule

Inherits:
Object
  • Object
show all
Defined in:
lib/bootpay/commerce/product.rb

Instance Method Summary collapse

Constructor Details

#initialize(bootpay) ⇒ ProductModule

Returns a new instance of ProductModule.



8
9
10
# File 'lib/bootpay/commerce/product.rb', line 8

def initialize(bootpay)
  @bootpay = bootpay
end

Instance Method Details

#create(product, image_paths = nil) ⇒ Object

상품 생성 (이미지 포함)



29
30
31
# File 'lib/bootpay/commerce/product.rb', line 29

def create(product, image_paths = nil)
  @bootpay.post_multipart('products', product, image_paths)
end

#delete(product_id) ⇒ Object

상품 삭제



51
52
53
# File 'lib/bootpay/commerce/product.rb', line 51

def delete(product_id)
  @bootpay.delete("products/#{product_id}")
end

#detail(product_id) ⇒ Object

상품 상세 조회



34
35
36
# File 'lib/bootpay/commerce/product.rb', line 34

def detail(product_id)
  @bootpay.get("products/#{product_id}")
end

#list(params = {}) ⇒ Object

상품 목록 조회



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bootpay/commerce/product.rb', line 13

def list(params = {})
  query_params = {}
  query_params[:page]          = params[:page]          unless params[:page].nil?
  query_params[:limit]         = params[:limit]         unless params[:limit].nil?
  query_params[:keyword]       = params[:keyword]       if params[:keyword]
  query_params[:type]          = params[:type]          unless params[:type].nil?
  query_params[:period_type]   = params[:period_type]   if params[:period_type]
  query_params[:s_at]          = params[:s_at]          if params[:s_at]
  query_params[:e_at]          = params[:e_at]          if params[:e_at]
  query_params[:category_code] = params[:category_code] if params[:category_code]

  query = build_query(query_params)
  @bootpay.get("products#{query}")
end

#status(params) ⇒ Object

상품 상태 변경

Raises:

  • (ArgumentError)


45
46
47
48
# File 'lib/bootpay/commerce/product.rb', line 45

def status(params)
  raise ArgumentError, 'product_id is required' unless params[:product_id]
  @bootpay.put("products/#{params[:product_id]}/status", params)
end

#update(product) ⇒ Object

상품 수정

Raises:

  • (ArgumentError)


39
40
41
42
# File 'lib/bootpay/commerce/product.rb', line 39

def update(product)
  raise ArgumentError, 'product_id is required' unless product[:product_id]
  @bootpay.put("products/#{product[:product_id]}", product)
end