Module: MixinBot::UrlScheme
- Defined in:
- lib/mixin_bot/url_scheme.rb
Overview
Deep link URL schemes (parity with Go url_scheme.go).
Constant Summary collapse
- SCHEME =
'mixin'
Class Method Summary collapse
- .scheme_apps(app_id:, action: nil, params: {}) ⇒ Object
- .scheme_codes(code_id) ⇒ Object
- .scheme_conversations(conversation_id: nil, user_id: nil) ⇒ Object
- .scheme_pay(asset_id:, trace_id:, recipient_id:, memo:, amount:) ⇒ Object
- .scheme_send(category:, data: nil, conversation_id: nil) ⇒ Object
- .scheme_snapshots(snapshot_id: nil, trace_id: nil) ⇒ Object
- .scheme_transfer(user_id) ⇒ Object
- .scheme_users(user_id) ⇒ Object
Class Method Details
.scheme_apps(app_id:, action: nil, params: {}) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/mixin_bot/url_scheme.rb', line 49 def scheme_apps(app_id:, action: nil, params: {}) u = URI("#{SCHEME}://apps/#{app_id}") q = { action: action.presence || 'open' }.merge(params || {}) u.query = URI.encode_www_form(q) u.to_s end |
.scheme_codes(code_id) ⇒ Object
31 32 33 |
# File 'lib/mixin_bot/url_scheme.rb', line 31 def scheme_codes(code_id) URI("#{SCHEME}://codes/#{code_id}").to_s end |
.scheme_conversations(conversation_id: nil, user_id: nil) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/mixin_bot/url_scheme.rb', line 42 def scheme_conversations(conversation_id: nil, user_id: nil) u = URI("#{SCHEME}://conversations") u.path = "/#{conversation_id}" if conversation_id.present? u.query = URI.encode_www_form(user: user_id) if user_id.present? u.to_s end |
.scheme_pay(asset_id:, trace_id:, recipient_id:, memo:, amount:) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mixin_bot/url_scheme.rb', line 20 def scheme_pay(asset_id:, trace_id:, recipient_id:, memo:, amount:) q = URI.encode_www_form( asset: asset_id, trace: trace_id, amount: amount.to_s, recipient: recipient_id, memo: memo.to_s ) "#{SCHEME}://pay?#{q}" end |
.scheme_send(category:, data: nil, conversation_id: nil) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/mixin_bot/url_scheme.rb', line 56 def scheme_send(category:, data: nil, conversation_id: nil) q = { category: category.to_s } q[:data] = URI.encode_www_form_component(Base64.strict_encode64(data)) if data.present? q[:conversation] = conversation_id if conversation_id.present? "#{SCHEME}://send?#{URI.encode_www_form(q)}" end |
.scheme_snapshots(snapshot_id: nil, trace_id: nil) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/mixin_bot/url_scheme.rb', line 35 def scheme_snapshots(snapshot_id: nil, trace_id: nil) u = URI("#{SCHEME}://snapshots") u.path = "/#{snapshot_id}" if snapshot_id.present? u.query = URI.encode_www_form(trace: trace_id) if trace_id.present? u.to_s end |
.scheme_transfer(user_id) ⇒ Object
16 17 18 |
# File 'lib/mixin_bot/url_scheme.rb', line 16 def scheme_transfer(user_id) URI("#{SCHEME}://transfer/#{user_id}").to_s end |
.scheme_users(user_id) ⇒ Object
12 13 14 |
# File 'lib/mixin_bot/url_scheme.rb', line 12 def scheme_users(user_id) URI("#{SCHEME}://users/#{user_id}").to_s end |