Class: LiffService

Inherits:
Object
  • Object
show all
Defined in:
lib/kamiliff/services/liff_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ LiffService

Returns a new instance of LiffService.



17
18
19
20
21
22
23
24
25
# File 'lib/kamiliff/services/liff_service.rb', line 17

def initialize(options)
  self.path = options[:path] || "/"
  self.size = options[:liff_size] || :compact
  self.size = size.to_s.upcase
  raise "liff_size should be compact, tall or full." unless size.in? %w[COMPACT TALL FULL]
  self.url = ENV["LIFF_#{size}"]
  raise "LIFF_#{size} should be in the env variables" if url.blank?
  self.id = url[(url.rindex('/')+1)..-1]
end

Instance Attribute Details

#idObject

liff id



15
16
17
# File 'lib/kamiliff/services/liff_service.rb', line 15

def id
  @id
end

#pathObject

rails routes path



4
5
6
# File 'lib/kamiliff/services/liff_service.rb', line 4

def path
  @path
end

#sizeObject

size COMPACT TALL FULL



8
9
10
# File 'lib/kamiliff/services/liff_service.rb', line 8

def size
  @size
end

#urlObject

liff app url liff.line.me/app/#liff_id



12
13
14
# File 'lib/kamiliff/services/liff_service.rb', line 12

def url
  @url
end

Instance Method Details

#full_urlObject



27
28
29
30
31
32
33
34
# File 'lib/kamiliff/services/liff_service.rb', line 27

def full_url
  # liff mode is Concatenate
  base64_string = Base64EncodeService.new({
    path: path,
    liff_size: size
  }).run
  "#{url}/#{base64_string}"
end