Class: Line::Bot::LiffClient

Inherits:
Client
  • Object
show all
Defined in:
lib/line_liff.rb

Constant Summary collapse

@@api_version =
"v1"

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Client

#put

Class Method Details

.create_by_line_bot_client(line_bot_client) ⇒ Object



59
60
61
62
63
64
# File 'lib/line_liff.rb', line 59

def self. line_bot_client
    self.new{|config|
        config.channel_secret = line_bot_client.channel_secret
        config.channel_token = line_bot_client.channel_token
    }
end

.default_endpointObject

def self.api_version

@@api_version

end



68
69
70
# File 'lib/line_liff.rb', line 68

def self.default_endpoint
  "https://api.line.me/liff/#{@@api_version}/apps"
end

Instance Method Details

#create_liff(type, url, description = nil, features = {}) ⇒ Object



79
80
81
82
83
84
85
86
87
88
# File 'lib/line_liff.rb', line 79

def create_liff type,url,description = nil,features = {}
    payload = {
        view:{
            type:type,url:url
        },
        description:description,
        features:features
    }
    post "", payload.to_json
end

#delete_liff(liff_id) ⇒ Object



98
99
100
# File 'lib/line_liff.rb', line 98

def delete_liff liff_id
    delete "/#{liff_id}"
end

#endpointObject



71
72
73
# File 'lib/line_liff.rb', line 71

def endpoint
    @endpoint ||= self.class.default_endpoint
end

#get_liffsObject



74
75
76
77
# File 'lib/line_liff.rb', line 74

def get_liffs
    endpoint_path  = ""
    get endpoint_path
end

#update_liff(liff_id, type = nil, url = nil, description = nil, features = {}) ⇒ Object



89
90
91
92
93
94
95
96
# File 'lib/line_liff.rb', line 89

def update_liff liff_id,type=nil,url=nil,description = nil,features = {}
    payload = {}
    payload[:view] = {type:type,url:url}.reject { |k,v| v.nil? }
    payload[:description] = description
    payload[:features] = features
    payload.reject!{|k,v| v.nil? or v.length == 0}
    put "/#{liff_id}", payload.to_json
end