Class: Bakong::OpenApi::Resources::Deeplinks

Inherits:
Base
  • Object
show all
Defined in:
lib/bakong/open_api/resources/deeplinks.rb

Overview

‘POST /v1/generate_deeplink_by_qr` — turn a KHQR string into a short link the user’s wallet app can open directly.

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Bakong::OpenApi::Resources::Base

Instance Method Details

#generate(qr:, source_info: nil) ⇒ Hash

Returns { short_link: “https://…” }.

Parameters:

  • qr (String)

    KHQR payload (typically generated by the bakong-khqr gem)

  • source_info (Bakong::OpenApi::SourceInfo, nil) (defaults to: nil)

    optional; if provided, all three fields must be set

Returns:

  • (Hash)

    { short_link: “https://…” }

Raises:



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/bakong/open_api/resources/deeplinks.rb', line 20

def generate(qr:, source_info: nil)
  if source_info && !source_info.complete?
    raise MissingFieldsError.new(
      "source_info requires app_icon_url, app_name, and app_deep_link_callback",
      error_code: 5
    )
  end

  body = { qr: qr }
  body[:source_info] = source_info.to_payload if source_info

  submit("/v1/generate_deeplink_by_qr", body)
end