Class: Item::SupportQrCode
- Inherits:
-
BaseService
- Object
- BaseService
- Item::SupportQrCode
- Defined in:
- app/services/item/support_qr_code.rb
Overview
This will generate a QR code that brings you to the support page
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
Methods inherited from BaseService
#initialize, #log_debug, #log_error, #log_info, #log_warning, #logger, #options, #tagged_logger
Constructor Details
This class inherits a constructor from BaseService
Instance Method Details
#process(sku, serial_number: nil, file_path: nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/item/support_qr_code.rb', line 11 def process(sku, serial_number: nil, file_path: nil) # First see if we have a support page item = Item.goods_visible_for_support.where(sku: sku).first return Result.new(output: nil, status: :not_public) unless item ub = Web::UrlBuilder.new(default_host: 'www.warmlyyours.com', #WEB_HOSTNAME_WITHOUT_PORT default_port: 443, #APP_PORT_NUMBER default_scheme: 'https', default_locale: :delocalized) # Support location params = { sn: serial_number } if serial_number url = ub.process("/#{item.canonical_path}/support", parameters: params) qrcode = RQRCode::QRCode.new(url) image = qrcode.as_png.resize(150,150).crop(20,20,110,110) output = if file_path image.save(file_path) file_path else image end Result.new(output: output, status: :ok, url: url) end |