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



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

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



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

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

Instance Method Details

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



85
86
87
88
89
90
91
92
93
94
# File 'lib/line_liff.rb', line 85

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

#delete_liff(liff_id) ⇒ Object



104
105
106
# File 'lib/line_liff.rb', line 104

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

#endpointObject



77
78
79
# File 'lib/line_liff.rb', line 77

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

#get_liffsObject



80
81
82
83
# File 'lib/line_liff.rb', line 80

def get_liffs
    endpoint_path  = ""
    get endpoint_path,credentials
end

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



95
96
97
98
99
100
101
102
# File 'lib/line_liff.rb', line 95

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,credentials
end