liff_selector 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -2
- data/Gemfile.lock +33 -0
- data/README.md +56 -1
- data/lib/liff_selector/version.rb +1 -1
- data/lib/liff_selector.rb +83 -9
- metadata +4 -9
- data/lib/liff_selector/command/clean.rb +0 -38
- data/lib/liff_selector/command/create.rb +0 -32
- data/lib/liff_selector/command/delete.rb +0 -21
- data/lib/liff_selector/command/show.rb +0 -12
- data/lib.rb +0 -30
- data/uri.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29a33ebd8f6b48ab71794cc22749eeb803cb7041
|
4
|
+
data.tar.gz: b2ae0b6481700f021d5efb2906d7941e41235446
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec4dbd6c1aa48bf288a707906f3cf59d3aebfc0d246bce92961dc02f20cb6173003b8d14271e5508de331c2cd9a1696ee1fcbd40e63d289e41a9bfd1bbd95943
|
7
|
+
data.tar.gz: 64328ee947196ea038031293e2efc4d749272846375d5d674364acc145195665542958e423b4d923c13f1dc7d8aa7dc011b23ea675cd9bf6cba0567a973e263e
|
data/.gitignore
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
domain_name (0.5.20180417)
|
5
|
+
unf (>= 0.0.5, < 1.0.0)
|
6
|
+
dotenv (2.4.0)
|
7
|
+
http-cookie (1.0.3)
|
8
|
+
domain_name (~> 0.5)
|
9
|
+
liff_selector (0.1.0)
|
10
|
+
dotenv
|
11
|
+
rest-client
|
12
|
+
mime-types (3.1)
|
13
|
+
mime-types-data (~> 3.2015)
|
14
|
+
mime-types-data (3.2016.0521)
|
15
|
+
netrc (0.11.0)
|
16
|
+
rest-client (2.0.2)
|
17
|
+
http-cookie (>= 1.0.2, < 2.0)
|
18
|
+
mime-types (>= 1.16, < 4.0)
|
19
|
+
netrc (~> 0.8)
|
20
|
+
unf (0.1.4)
|
21
|
+
unf_ext
|
22
|
+
unf_ext (0.0.7.5)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
dotenv
|
29
|
+
liff_selector
|
30
|
+
rest-client
|
31
|
+
|
32
|
+
BUNDLED WITH
|
33
|
+
1.16.0
|
data/README.md
CHANGED
@@ -22,7 +22,62 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
### show
|
26
|
+
display all liff applications.
|
27
|
+
|
28
|
+
```
|
29
|
+
$ ./exe/liff_select show
|
30
|
+
id liffId type url
|
31
|
+
1. 1578425738-81wbQ6WM full https://example.com
|
32
|
+
2. 1578425738-8AM1APKY tall https://esample.com/1
|
33
|
+
```
|
34
|
+
|
35
|
+
### same
|
36
|
+
display same type and url liff applications.
|
37
|
+
|
38
|
+
```
|
39
|
+
./exe/liff_select same
|
40
|
+
> "type": full, "url": https://example.com
|
41
|
+
- id: 1, liffId: XXXXXXXXXX-XXXXXXXX
|
42
|
+
> "type": tall, "url": https://esample.com/1
|
43
|
+
- id: 2, liffId: XXXXXXXXXX-XXXXXXXX
|
44
|
+
```
|
45
|
+
|
46
|
+
### create
|
47
|
+
create new liff application. give type, url
|
48
|
+
|
49
|
+
```
|
50
|
+
./exe/liff_select create compact https://example.com
|
51
|
+
> make liff app
|
52
|
+
> [SUCESS] make app
|
53
|
+
> app uri : line://app/XXXXXXXXXX-XXXXXXXX
|
54
|
+
```
|
55
|
+
|
56
|
+
### delete
|
57
|
+
|
58
|
+
```
|
59
|
+
./exe/liff_select delete 1
|
60
|
+
1. XXXXXXXXXX-XXXXXXXX compact https://example.com
|
61
|
+
> [SUCESS] delete app
|
62
|
+
```
|
63
|
+
|
64
|
+
### clean
|
65
|
+
delete same type and url applications
|
66
|
+
|
67
|
+
```
|
68
|
+
./exe/liff_select clean
|
69
|
+
> "type": tall, "url": https://liff-a4geru.c9users.io/charge
|
70
|
+
- id: 1, liffId: 1578425738-8AM1APKY
|
71
|
+
> "type": compact, "url": https://liff-a4geru.c9users.io/
|
72
|
+
- id: 2, liffId: 1578425738-GBp65o2R
|
73
|
+
- id: 3, liffId: 1578425738-WeqQXxKp
|
74
|
+
- id: 5, liffId: 1578425738-yLqlrmVE
|
75
|
+
> "type": compact, "url": https://liff-a4geru.c9users.io/charge
|
76
|
+
- id: 4, liffId: 1578425738-YbD5yxAq
|
77
|
+
>> delete "id": 3, "type": compact, "url": https://liff-a4geru.c9users.io/
|
78
|
+
>> delete "id": 5, "type": compact, "url": https://liff-a4geru.c9users.io/
|
79
|
+
> [SUCESS] delete app
|
80
|
+
```
|
26
81
|
|
27
82
|
## Development
|
28
83
|
|
data/lib/liff_selector.rb
CHANGED
@@ -3,22 +3,96 @@ require 'json'
|
|
3
3
|
require 'rest-client'
|
4
4
|
|
5
5
|
module LiffSelector
|
6
|
+
@token = ENV['LINE_TOKEN']
|
7
|
+
@request_url = 'https://api.line.me/liff/v1/apps'
|
6
8
|
def self.run(argv)
|
7
9
|
case argv[0]
|
8
10
|
when 'show'
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
show
|
12
|
+
when 'same'
|
13
|
+
same
|
14
|
+
when 'create'
|
15
|
+
raise ArgumentError, 'give _type_ _url_' if argv.length != 3
|
16
|
+
create(type: argv[1], url: argv[2])
|
17
|
+
when 'clean'
|
18
|
+
clean
|
19
|
+
when 'delete'
|
20
|
+
raise ArgumentError, 'give _liff_id_' if argv.length != 2
|
21
|
+
delete(liff_id: argv[1])
|
14
22
|
else
|
15
23
|
raise NotImplementedError, 'unknow command given'
|
16
24
|
end
|
17
25
|
end
|
18
26
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
27
|
+
private
|
28
|
+
# command
|
29
|
+
def self.show
|
30
|
+
puts "id liffId\t\ttype\turl"
|
31
|
+
all_apps.each_with_index do |app, i|
|
32
|
+
puts "#{i+1}. #{app['liffId']}\t#{app['view']['type']}\t#{app['view']['url']}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.same
|
37
|
+
apps = all_apps
|
38
|
+
uniq_app = apps.map{|app| {type: app['view']['type'], url: app['view']['url'] } }.uniq
|
39
|
+
delete_apps = uniq_app.map{|delete_app|
|
40
|
+
same_apps = apps
|
41
|
+
.map.with_index{|app, i| app.store('id', i + 1); app }
|
42
|
+
.select{|app| delete_app[:type] == app['view']['type'] and delete_app[:url] == app['view']['url']}
|
43
|
+
|
44
|
+
puts "> \"type\": #{delete_app[:type]}, \"url\": #{delete_app[:url]}"
|
45
|
+
same_apps.map{|app| puts " - id: #{app['id']}, liffId: #{app['liffId']}" }
|
46
|
+
same_apps[1..-1]
|
47
|
+
}.flatten!
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.create(type:, url:)
|
51
|
+
raise ArgumentError, 'not correct uri' unless correct_url?(url)
|
52
|
+
raise ArgumentError, 'not correct type please choose [compact, tall, full]' unless ["compact", "tall", "full"].include?(type)
|
53
|
+
puts '> make liff app'
|
54
|
+
|
55
|
+
# api request
|
56
|
+
response = RestClient.post(@request_url, {view: {type: type, url: url } }.to_json, {:Authorization => "bearer #{@token}", :content_type => :json})
|
57
|
+
result = JSON.parse(response)
|
58
|
+
|
59
|
+
puts '> [SUCESS] make app'
|
60
|
+
puts "> app uri : line://app/#{result['liffId']}"
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.clean
|
64
|
+
delete_apps = same
|
65
|
+
|
66
|
+
raise ArgumentError, 'not same app' if delete_apps.empty?
|
67
|
+
|
68
|
+
begin
|
69
|
+
delete_apps.map{|app|
|
70
|
+
# api request
|
71
|
+
RestClient.delete "#{@request_url}/#{app["liffId"]}", { :Authorization => "bearer #{@token}" }
|
72
|
+
puts ">> delete \"id\": #{app["id"]}, \"type\": #{app["view"]["type"]}, \"url\": #{app["view"]["url"]}"
|
73
|
+
}
|
74
|
+
puts '> [SUCESS] delete apps'
|
75
|
+
rescue
|
76
|
+
puts '> [FAILED] cannot delete app'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.delete(liff_id:)
|
81
|
+
app = all_apps[liff_id.to_i-1]
|
82
|
+
puts "#{liff_id}. #{app['liffId']}\t#{app['view']['type']}\t#{app['view']['url']}"
|
83
|
+
|
84
|
+
# api request
|
85
|
+
RestClient.delete "#{@request_url}/#{app['liffId']}", { :Authorization => "bearer #{@token}" }
|
86
|
+
puts '> [SUCESS] delete app'
|
87
|
+
end
|
88
|
+
|
89
|
+
# http request
|
90
|
+
def self.all_apps
|
91
|
+
res = JSON.parse(RestClient.get @request_url, { :Authorization => "bearer #{@token}" })['apps']
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.correct_url?(url)
|
95
|
+
uri = URI.parse(url)
|
96
|
+
status_code = RestClient.get(url)
|
23
97
|
end
|
24
98
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liff_selector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 4geru
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -91,21 +91,16 @@ files:
|
|
91
91
|
- ".gitignore"
|
92
92
|
- CODE_OF_CONDUCT.md
|
93
93
|
- Gemfile
|
94
|
+
- Gemfile.lock
|
94
95
|
- LICENSE.txt
|
95
96
|
- README.md
|
96
97
|
- Rakefile
|
97
98
|
- bin/console
|
98
99
|
- bin/setup
|
99
100
|
- exe/liff_select
|
100
|
-
- lib.rb
|
101
101
|
- lib/liff_selector.rb
|
102
|
-
- lib/liff_selector/command/clean.rb
|
103
|
-
- lib/liff_selector/command/create.rb
|
104
|
-
- lib/liff_selector/command/delete.rb
|
105
|
-
- lib/liff_selector/command/show.rb
|
106
102
|
- lib/liff_selector/version.rb
|
107
103
|
- liff_selector.gemspec
|
108
|
-
- uri.rb
|
109
104
|
homepage: https://github.com/4geru/liff-selector
|
110
105
|
licenses:
|
111
106
|
- MIT
|
@@ -126,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
121
|
version: '0'
|
127
122
|
requirements: []
|
128
123
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.6.
|
124
|
+
rubygems_version: 2.6.8
|
130
125
|
signing_key:
|
131
126
|
specification_version: 4
|
132
127
|
summary: Write a short summary, because RubyGems requires one.
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require './lib'
|
2
|
-
require './show'
|
3
|
-
|
4
|
-
def delete
|
5
|
-
apps = get_all_application
|
6
|
-
uniq_app = apps.map{|app| {type: app['view']['type'], url: app['view']['url'] } }.uniq
|
7
|
-
delete_apps = uniq_app.map{|uapp|
|
8
|
-
same_apps = apps
|
9
|
-
.map.with_index{|app, i| app.store('id', i + 1); app }
|
10
|
-
.select{|app| uapp[:type] == app['view']['type'] and uapp[:url] == app['view']['url']}
|
11
|
-
|
12
|
-
puts ">== same application No.#{same_apps.map{|app| app['id'] }.join(' No.')} =="
|
13
|
-
puts "> \"type\" : #{uapp[:type]}\t \"url\" : #{uapp[:url]}"
|
14
|
-
same_apps[1..-1]
|
15
|
-
}.flatten!
|
16
|
-
|
17
|
-
unless delete_apps.empty?
|
18
|
-
puts ">> delete apps No.#{delete_apps.map{|app| app['id']}.join(' No.')}"
|
19
|
-
puts '> delete this application[Y/N]'
|
20
|
-
return if gets.gsub("\n", '').upcase != 'Y'
|
21
|
-
begin
|
22
|
-
delete_apps.map{|app|
|
23
|
-
raise unless delete_delete_application(app['liffId'])
|
24
|
-
puts ">> delete \"id\" : #{app[:id]}\t\"type\" : #{app[:type]}\t\"url\" : #{app[:url]}"
|
25
|
-
}
|
26
|
-
puts '> [SUCESS] delete application'
|
27
|
-
rescue
|
28
|
-
puts '> [FAILED] cannot delete application'
|
29
|
-
end
|
30
|
-
else
|
31
|
-
puts ">> There is not same application"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
if __FILE__ == $0
|
36
|
-
show
|
37
|
-
delete
|
38
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require './lib'
|
2
|
-
require 'uri'
|
3
|
-
|
4
|
-
def create()
|
5
|
-
puts '> please input url'
|
6
|
-
url = gets.gsub("\n", '')
|
7
|
-
unless correct_url(url)
|
8
|
-
puts 'it is not correct uri'
|
9
|
-
return
|
10
|
-
end
|
11
|
-
puts '> correct uri'
|
12
|
-
|
13
|
-
while true do
|
14
|
-
puts 'please input type[compact/tall/full]'
|
15
|
-
type = gets.gsub("\n", '')
|
16
|
-
break if ["compact", "tall", "full"].include?(type)
|
17
|
-
end
|
18
|
-
puts '> correct type!'
|
19
|
-
puts '>> making liff application >>'
|
20
|
-
status = post_create_application(type, url)
|
21
|
-
puts status
|
22
|
-
case status
|
23
|
-
when 200
|
24
|
-
puts '> [SUCESS] make application'
|
25
|
-
else
|
26
|
-
puts '> [FAILED] make application'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
if __FILE__ == $0
|
31
|
-
create()
|
32
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require './lib'
|
2
|
-
require './show'
|
3
|
-
|
4
|
-
def delete
|
5
|
-
puts '> select delete application id'
|
6
|
-
id = gets.gsub("\n", '').to_i
|
7
|
-
application = get_all_application[id-1]
|
8
|
-
puts "#{id}. #{application['liffId']}\t#{application['view']['type']}\t#{application['view']['url']}"
|
9
|
-
puts '> delete this application[Y/N]'
|
10
|
-
return if gets.gsub("\n", '').upcase != 'Y'
|
11
|
-
if delete_delete_application(application['liffId'])
|
12
|
-
puts '> [SUCESS] delete application'
|
13
|
-
else
|
14
|
-
puts '> [FAILED] cannot delete application'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
if __FILE__ == $0
|
19
|
-
show
|
20
|
-
delete
|
21
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require './lib'
|
2
|
-
|
3
|
-
def show
|
4
|
-
puts "id liffId\t\ttype\turl"
|
5
|
-
get_all_application.each_with_index do |application, i|
|
6
|
-
puts "#{i+1}. #{application['liffId']}\t#{application['view']['type']}\t#{application['view']['url']}"
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
if __FILE__ == $0
|
11
|
-
show
|
12
|
-
end
|
data/lib.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'dotenv/load'
|
2
|
-
require 'rest-client'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
@token = ENV['APPLICATION']
|
6
|
-
def get_all_application
|
7
|
-
droplet_ep = 'https://api.line.me/liff/v1/apps'
|
8
|
-
res = JSON.parse(RestClient.get droplet_ep, { :Authorization => "bearer #{@token}" })['apps']
|
9
|
-
end
|
10
|
-
|
11
|
-
def post_create_application(type, url)
|
12
|
-
droplet_ep = 'https://api.line.me/liff/v1/apps'
|
13
|
-
RestClient.post(droplet_ep, {view: {type: type, url: url } }.to_json, {:Authorization => "bearer #{@token}", :content_type => :json})
|
14
|
-
end
|
15
|
-
|
16
|
-
def delete_delete_application(liff_id)
|
17
|
-
droplet_ep = "https://api.line.me/liff/v1/apps/#{liff_id}"
|
18
|
-
RestClient.delete droplet_ep, { :Authorization => "bearer #{@token}" } { |response, request, result| response.code == 200 }
|
19
|
-
end
|
20
|
-
|
21
|
-
def correct_url(url)
|
22
|
-
begin
|
23
|
-
uri = URI.parse(url)
|
24
|
-
status_code = RestClient.get(url){ |response, request, result| response.code }
|
25
|
-
return true if status_code == 200
|
26
|
-
rescue TypeError, SocketError, URI::InvalidURIError
|
27
|
-
puts 'erroe'
|
28
|
-
end
|
29
|
-
false
|
30
|
-
end
|
data/uri.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require './lib'
|
2
|
-
require './show'
|
3
|
-
|
4
|
-
def uri
|
5
|
-
puts '> select uri application id'
|
6
|
-
id = gets.gsub("\n", '').to_i
|
7
|
-
application = get_all_application[id-1]
|
8
|
-
puts "> [SELECTED] #{id}. #{application['liffId']}\t#{application['view']['type']}\t#{application['view']['url']}"
|
9
|
-
puts "> this application uri : line://app/#{application['liffId']}"
|
10
|
-
end
|
11
|
-
|
12
|
-
if __FILE__ == $0
|
13
|
-
show
|
14
|
-
uri
|
15
|
-
end
|