iijmio-cli 0.0.1
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 +7 -0
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +75 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/iijmio +4 -0
- data/iijmio-cli.gemspec +32 -0
- data/lib/iijmio/cli.rb +349 -0
- data/lib/iijmio/cli/version.rb +15 -0
- metadata +183 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 957f8d19bf7f31aae9d158026862dfc97c187494
|
4
|
+
data.tar.gz: 995adabe98ca4ccbd173b34362d0fc4860617853
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9baab4e178443eaf37e3069258915ac3716561ad88159f760366cedfd45703b318e5f649c6d7ea8f3c3725d1930f53ef52124cdb608106d992379d6bd0229937
|
7
|
+
data.tar.gz: 1498b64fa58ce030e4e2d1bf6150fc2ad59bbb58961d67c9e01c88e803dc26da5a97e0eae351a16386bb2d7010d7656110c72124e1908358c01759fbc981dc24
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Takahiro INOUE
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# Iijmio::CLI
|
2
|
+
|
3
|
+
CLI tools for [iijmio API](https://api.iijmio.jp).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```
|
8
|
+
$ gem install "iijmio-cli"
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
設定
|
14
|
+
|
15
|
+
```
|
16
|
+
$ iijmio config
|
17
|
+
|
18
|
+
--------------------------------------------------------------------------------
|
19
|
+
- iijmio-cli configuration setup
|
20
|
+
--------------------------------------------------------------------------------
|
21
|
+
Please input your IIJmio developer ID (default: '5XKr784JyAXAAfAWCbI').
|
22
|
+
[ENTER]
|
23
|
+
Please input your IIJmio username (default: '').
|
24
|
+
xxxx # NOTE: NOT mail address.
|
25
|
+
Please input your IIJmio password (default: '').
|
26
|
+
[ENTER]
|
27
|
+
|
28
|
+
... Completed !!
|
29
|
+
```
|
30
|
+
|
31
|
+
認証
|
32
|
+
|
33
|
+
```
|
34
|
+
$ iijmio auth
|
35
|
+
|
36
|
+
Please input your IIJmio password.
|
37
|
+
|
38
|
+
... Completed !!
|
39
|
+
```
|
40
|
+
|
41
|
+
クーポン切り替え(1分間に1回まで)
|
42
|
+
|
43
|
+
```
|
44
|
+
$ iijmio ls
|
45
|
+
+ Family Share (ServiceCode: hddxxxxxxxx)
|
46
|
+
- クーポン残量: xx.xx [GB]
|
47
|
+
+ SIMs
|
48
|
+
+ ID: hdoxxxxxxxx
|
49
|
+
- TEL: xxx-xxxx-xxxx
|
50
|
+
- クーポン: 無効
|
51
|
+
|
52
|
+
$ iijmio switch lte hdoxxxxxxxx # NOTE: クーポンを有効にする
|
53
|
+
|
54
|
+
$ iijmio ls
|
55
|
+
+ Family Share (ServiceCode: hddxxxxxxxx)
|
56
|
+
- クーポン残量: xx.xx [GB]
|
57
|
+
+ SIMs
|
58
|
+
+ ID: hdo24188760
|
59
|
+
- TEL: xxx-xxxx-xxxx
|
60
|
+
- クーポン: 有効
|
61
|
+
|
62
|
+
$ iijmio switch low hdoxxxxxxxx # NOTE: クーポンを無効にする
|
63
|
+
|
64
|
+
$ iijmio ls
|
65
|
+
+ Family Share (ServiceCode: hddxxxxxxxx)
|
66
|
+
- クーポン残量: xx.xx [GB]
|
67
|
+
+ SIMs
|
68
|
+
+ ID: hdoxxxxxxxx
|
69
|
+
- TEL: xxx-xxxx-xxxx
|
70
|
+
- クーポン: 無効
|
71
|
+
```
|
72
|
+
|
73
|
+
## License
|
74
|
+
|
75
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "iijmio/cli"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/exe/iijmio
ADDED
data/iijmio-cli.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
lib = ::File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'iijmio/cli/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "iijmio-cli"
|
8
|
+
spec.version = ::Iijmio::CLI::VERSION
|
9
|
+
spec.authors = ["Takahiro INOUE"]
|
10
|
+
spec.email = ["takahiro.inoue@mail.3dcg-arts.net"]
|
11
|
+
|
12
|
+
spec.summary = %q{CLI tools for iijmio API.}
|
13
|
+
spec.description = %q{CLI tools for iijmio API.}
|
14
|
+
spec.homepage = "https://github.com/hinata/iijmio-cli"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "capybara"
|
23
|
+
spec.add_dependency "faraday"
|
24
|
+
spec.add_dependency "nokogiri"
|
25
|
+
spec.add_dependency "phantomjs"
|
26
|
+
spec.add_dependency "poltergeist"
|
27
|
+
spec.add_dependency "thor"
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler"
|
30
|
+
spec.add_development_dependency "rake"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
32
|
+
end
|
data/lib/iijmio/cli.rb
ADDED
@@ -0,0 +1,349 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require "iijmio/cli/version"
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
module ::Iijmio
|
6
|
+
module CLI
|
7
|
+
class ImplementedCLI < ::Thor
|
8
|
+
=begin
|
9
|
+
@function
|
10
|
+
=end
|
11
|
+
desc %{config [[developer_id|username|password|default_sim] [configuration]]}, %{No description.}
|
12
|
+
def config *args
|
13
|
+
case args.length
|
14
|
+
when 0
|
15
|
+
require "pp"
|
16
|
+
pp ::Iijmio::CLI.get_config
|
17
|
+
when 2
|
18
|
+
case args[ 0 ]
|
19
|
+
when %{developer_id}
|
20
|
+
::Iijmio::CLI.set_config({
|
21
|
+
developer_id: args[ 1 ]
|
22
|
+
})
|
23
|
+
when %{username}
|
24
|
+
::Iijmio::CLI.set_config({
|
25
|
+
username: args[ 1 ]
|
26
|
+
})
|
27
|
+
when %{password}
|
28
|
+
::Iijmio::CLI.set_config({
|
29
|
+
password: args[ 1 ]
|
30
|
+
})
|
31
|
+
when %{default_sim}
|
32
|
+
::Iijmio::CLI.set_config({
|
33
|
+
default_sim: args[ 1 ]
|
34
|
+
})
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
=begin
|
40
|
+
@function
|
41
|
+
=end
|
42
|
+
desc %{auth [IIJmio developer ID (option)] [IIJmio username (option)] [IIJmio password (option)]}, %{No description.}
|
43
|
+
def auth *args
|
44
|
+
developer_id = args[ 0 ] || ::Iijmio::CLI.get_config[ :developer_id ]
|
45
|
+
username = args[ 1 ] || ::Iijmio::CLI.get_config[ :username ]
|
46
|
+
password = args[ 2 ] || ::Iijmio::CLI.get_config[ :password ]
|
47
|
+
|
48
|
+
if developer_id == %{}
|
49
|
+
puts %{Please input your IIJmio developer ID.}
|
50
|
+
|
51
|
+
developer_id = STDIN.gets
|
52
|
+
end
|
53
|
+
|
54
|
+
if username == %{}
|
55
|
+
puts %{Please input your IIJmio username.}
|
56
|
+
|
57
|
+
username = STDIN.gets
|
58
|
+
end
|
59
|
+
|
60
|
+
if password == %{}
|
61
|
+
puts %{Please input your IIJmio password.}
|
62
|
+
|
63
|
+
password = STDIN.noecho(&:gets)
|
64
|
+
end
|
65
|
+
|
66
|
+
developer_id.strip!
|
67
|
+
username.strip!
|
68
|
+
password.strip!
|
69
|
+
|
70
|
+
::Capybara.register_driver :poltergeist do | application |
|
71
|
+
::Capybara::Poltergeist::Driver.new(application, js_errors: true, phantomjs: ::Phantomjs.path, timeout: 3000)
|
72
|
+
end
|
73
|
+
|
74
|
+
# NOTE: This Webrick is slient HTTP server.
|
75
|
+
web_server_thread =
|
76
|
+
::Thread.start {
|
77
|
+
server =
|
78
|
+
::WEBrick::HTTPServer.new(
|
79
|
+
BindAddress: %{127.0.0.1},
|
80
|
+
Port: %{8888},
|
81
|
+
AccessLog: [],
|
82
|
+
Logger: ::WEBrick::Log.new(%{/dev/null})
|
83
|
+
)
|
84
|
+
|
85
|
+
server.mount_proc("/") { | request, response |
|
86
|
+
response.body = %{}
|
87
|
+
}
|
88
|
+
|
89
|
+
server.start
|
90
|
+
}
|
91
|
+
|
92
|
+
session = ::Capybara::Session.new(:poltergeist)
|
93
|
+
session.driver.headers = {
|
94
|
+
"User-Agent": ::Iijmio::CLI.user_agent
|
95
|
+
}
|
96
|
+
|
97
|
+
session.visit(%{https://api.iijmio.jp/mobile/d/v1/authorization/?response_type=token&client_id=#{ developer_id }&state=#{ ::SecureRandom.hex(16) }&redirect_uri=http%3A%2F%2F127.0.0.1%3A8888})
|
98
|
+
|
99
|
+
username_element = session.find(%{input[id=username]})
|
100
|
+
username_element.native.send_key(username) if username_element.value == %{}
|
101
|
+
|
102
|
+
password_element = session.find(%{input[id=password]})
|
103
|
+
password_element.native.send_key(password) if password_element.value == %{}
|
104
|
+
|
105
|
+
link_element = session.find(%{a[id*=submit]})
|
106
|
+
link_element.click
|
107
|
+
|
108
|
+
sleep 1
|
109
|
+
|
110
|
+
link_element = session.find(%{a[id*=confir]})
|
111
|
+
link_element.click
|
112
|
+
|
113
|
+
sleep 1
|
114
|
+
|
115
|
+
if session.current_url =~ /access_token=(\w+)/
|
116
|
+
::Iijmio::CLI.set_config({
|
117
|
+
token: $1
|
118
|
+
})
|
119
|
+
end
|
120
|
+
|
121
|
+
web_server_thread.kill
|
122
|
+
|
123
|
+
puts %{}
|
124
|
+
puts %{... Completed !!}
|
125
|
+
puts %{}
|
126
|
+
end
|
127
|
+
|
128
|
+
=begin
|
129
|
+
@function
|
130
|
+
=end
|
131
|
+
desc %{ls}, %{No description.}
|
132
|
+
def ls *args
|
133
|
+
response =
|
134
|
+
::Iijmio::CLI.get_iijmio_rest_api
|
135
|
+
|
136
|
+
=begin
|
137
|
+
+ Family Share (ServiceCode: xxxx)
|
138
|
+
- クーポン残量: 10.00 [GB]
|
139
|
+
=end
|
140
|
+
|
141
|
+
response[ %{couponInfo} ].each do | hdd_info |
|
142
|
+
plan = hdd_info[ %{plan} ]
|
143
|
+
hdd_service_code = hdd_info[ %{hddServiceCode} ]
|
144
|
+
coupon = hdd_info[ %{coupon} ]
|
145
|
+
|
146
|
+
puts %{+ #{ plan } (ServiceCode: #{ hdd_service_code })}
|
147
|
+
puts %{ - クーポン残量: #{ sprintf(%{%.2f}, coupon.map { | v | v[ %{volume} ] }.reduce(:+) / 1000.0) } [GB]}
|
148
|
+
|
149
|
+
=begin
|
150
|
+
+ SIMs
|
151
|
+
+ ID: xxxx
|
152
|
+
- TEL: 000-0000-0000
|
153
|
+
- クーポン: 無効
|
154
|
+
+ ID: xxxx
|
155
|
+
- TEL: 000-0000-0000
|
156
|
+
- クーポン: 無効
|
157
|
+
+ ID: xxxx
|
158
|
+
- TEL: 000-0000-0000
|
159
|
+
- クーポン: 無効
|
160
|
+
=end
|
161
|
+
|
162
|
+
puts %{+ SIMs}
|
163
|
+
|
164
|
+
hdd_info[ %{hdoInfo} ].each do | hdo_info |
|
165
|
+
hdo_service_code = hdo_info[ %{hdoServiceCode} ]
|
166
|
+
tel = hdo_info[ %{number} ]
|
167
|
+
coupon_use = hdo_info[ %{couponUse} ]
|
168
|
+
|
169
|
+
puts %{ + ID: #{ hdo_service_code }}
|
170
|
+
puts %{ - TEL: #{ %{#{$1}-#{$2}-#{$3}} if tel =~ /([0-9]{3})([0-9]{4})([0-9]{4})/ }}
|
171
|
+
puts %{ - クーポン: #{ coupon_use ? %{有効} : %{無効} }}
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
=begin
|
177
|
+
@function
|
178
|
+
=end
|
179
|
+
desc %{switch [low|lte (requirement)] [SIM ID (option)]}, %{No description.}
|
180
|
+
def switch *args
|
181
|
+
if args.length < 1 ||
|
182
|
+
args.length > 2
|
183
|
+
STDERR.puts %{Invalid args.}
|
184
|
+
exit 1
|
185
|
+
end
|
186
|
+
|
187
|
+
coupon_use = args[ 0 ].downcase != %{low}
|
188
|
+
hdo_service_code = args[ 1 ] || ::Iijmio::CLI.get_config[ :default_sim ]
|
189
|
+
|
190
|
+
if hdo_service_code !~ /[a-z]{1,3}[0-9]{1,9}/ # FIXME: It's vague validation.
|
191
|
+
STDERR.puts %{Invalid SIM ID (#{ hdoServiceCode }).}
|
192
|
+
exit 1
|
193
|
+
end
|
194
|
+
|
195
|
+
::Iijmio::CLI.put_iijmio_rest_api({
|
196
|
+
couponInfo: [ { hdoInfo: [ { couponUse: coupon_use, hdoServiceCode: hdo_service_code } ] } ]
|
197
|
+
})
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
=begin
|
202
|
+
@function
|
203
|
+
@private
|
204
|
+
@static
|
205
|
+
=end
|
206
|
+
private
|
207
|
+
def self.config_path
|
208
|
+
return ::File.join(::Dir.home, %{.iijmio-cli})
|
209
|
+
end
|
210
|
+
|
211
|
+
=begin
|
212
|
+
@function
|
213
|
+
@private
|
214
|
+
@static
|
215
|
+
=end
|
216
|
+
private
|
217
|
+
def self.get_config
|
218
|
+
if !::File.exists?(::Iijmio::CLI.config_path)
|
219
|
+
puts %{-} * 80
|
220
|
+
puts %{- iijmio-cli configuration setup}
|
221
|
+
puts %{-} * 80
|
222
|
+
|
223
|
+
puts %{Please input your IIJmio developer ID (default: '5XKr784JyAXAAfAWCbI').}
|
224
|
+
|
225
|
+
developer_id = STDIN.gets
|
226
|
+
developer_id.strip!
|
227
|
+
|
228
|
+
puts %{Please input your IIJmio username (default: '').}
|
229
|
+
|
230
|
+
username = STDIN.gets
|
231
|
+
username.strip!
|
232
|
+
|
233
|
+
puts %{Please input your IIJmio password (default: '').}
|
234
|
+
|
235
|
+
password = STDIN.noecho(&:gets)
|
236
|
+
password.strip!
|
237
|
+
|
238
|
+
if developer_id == %{}
|
239
|
+
developer_id = %{5XKr784JyAXAAfAWCbI}
|
240
|
+
end
|
241
|
+
|
242
|
+
if username == %{}
|
243
|
+
username = %{}
|
244
|
+
end
|
245
|
+
|
246
|
+
if password == %{}
|
247
|
+
password = %{}
|
248
|
+
end
|
249
|
+
|
250
|
+
::File.open ::Iijmio::CLI.config_path, %{wb} do | config_file |
|
251
|
+
config_file.write({
|
252
|
+
developer_id: developer_id,
|
253
|
+
username: username,
|
254
|
+
password: password
|
255
|
+
}.to_yaml)
|
256
|
+
end
|
257
|
+
|
258
|
+
puts %{}
|
259
|
+
puts %{... Completed !!}
|
260
|
+
puts %{}
|
261
|
+
end
|
262
|
+
|
263
|
+
return ::YAML.load_file(::Iijmio::CLI.config_path)
|
264
|
+
end
|
265
|
+
|
266
|
+
=begin
|
267
|
+
@function
|
268
|
+
@private
|
269
|
+
@static
|
270
|
+
=end
|
271
|
+
private
|
272
|
+
def self.set_config options = {}
|
273
|
+
config = {}
|
274
|
+
config[ :developer_id ] = options[ :developer_id ] || ::Iijmio::CLI.get_config[ :developer_id ]
|
275
|
+
config[ :username ] = options[ :username ] || ::Iijmio::CLI.get_config[ :username ]
|
276
|
+
config[ :password ] = options[ :password ] || ::Iijmio::CLI.get_config[ :password ]
|
277
|
+
config[ :token ] = options[ :token ] || ::Iijmio::CLI.get_config[ :token ]
|
278
|
+
config[ :default_sim ] = options[ :default_sim ] || ::Iijmio::CLI.get_config[ :default_sim ]
|
279
|
+
|
280
|
+
::File.open ::Iijmio::CLI.config_path, %{wb} do | config_file |
|
281
|
+
config_file.write(config.to_yaml)
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
=begin
|
286
|
+
@function
|
287
|
+
@private
|
288
|
+
@static
|
289
|
+
=end
|
290
|
+
private
|
291
|
+
def self.user_agent
|
292
|
+
return %{iijmio-cli (#{ ::Iijmio::CLI::VERSION })}
|
293
|
+
end
|
294
|
+
|
295
|
+
=begin
|
296
|
+
@function
|
297
|
+
@private
|
298
|
+
@static
|
299
|
+
=end
|
300
|
+
private
|
301
|
+
def self.get_iijmio_rest_api
|
302
|
+
http_client = ::Faraday.new(url: %{https://api.iijmio.jp})
|
303
|
+
http_client.headers[ :user_agent ] = ::Iijmio::CLI.user_agent
|
304
|
+
|
305
|
+
response =
|
306
|
+
http_client.get do | request |
|
307
|
+
request.url(%{/mobile/d/v1/coupon/})
|
308
|
+
request.headers[ %{X-IIJmio-Developer} ] = ::Iijmio::CLI.get_config[ :developer_id ]
|
309
|
+
request.headers[ %{X-IIJmio-Authorization} ] = ::Iijmio::CLI.get_config[ :token ]
|
310
|
+
request.headers[ %{Content-Type} ] = %{application/json}
|
311
|
+
end
|
312
|
+
|
313
|
+
if response.status != 200
|
314
|
+
STDERR.puts %{Could NOT get correct response (HTTP STATUS: #{ response.status }).}
|
315
|
+
exit 1
|
316
|
+
end
|
317
|
+
|
318
|
+
return ::JSON.parse(response.body)
|
319
|
+
end
|
320
|
+
|
321
|
+
=begin
|
322
|
+
@function
|
323
|
+
@private
|
324
|
+
@static
|
325
|
+
=end
|
326
|
+
private
|
327
|
+
def self.put_iijmio_rest_api data = {}
|
328
|
+
http_client = ::Faraday.new(url: %{https://api.iijmio.jp})
|
329
|
+
http_client.headers[ :user_agent ] = ::Iijmio::CLI.user_agent
|
330
|
+
|
331
|
+
response =
|
332
|
+
http_client.put do | request |
|
333
|
+
request.url(%{/mobile/d/v1/coupon/})
|
334
|
+
request.headers[ %{X-IIJmio-Developer} ] = ::Iijmio::CLI.get_config[ :developer_id ]
|
335
|
+
request.headers[ %{X-IIJmio-Authorization} ] = ::Iijmio::CLI.get_config[ :token ]
|
336
|
+
request.headers[ %{Content-Type} ] = %{application/json}
|
337
|
+
|
338
|
+
request.body = data.to_json # NOTE: See https://api.iijmio.jp
|
339
|
+
end
|
340
|
+
|
341
|
+
if response.status != 200
|
342
|
+
STDERR.puts %{Could NOT get correct response (HTTP STATUS: #{ response.status }).}
|
343
|
+
exit 1
|
344
|
+
end
|
345
|
+
|
346
|
+
return ::JSON.parse(response.body)
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require "capybara"
|
3
|
+
require "capybara/poltergeist"
|
4
|
+
require "faraday"
|
5
|
+
require "json"
|
6
|
+
require "phantomjs"
|
7
|
+
require "securerandom"
|
8
|
+
require "webrick"
|
9
|
+
require "yaml"
|
10
|
+
|
11
|
+
module ::Iijmio
|
12
|
+
module CLI
|
13
|
+
VERSION = %{0.0.1}
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: iijmio-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Takahiro INOUE
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capybara
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: phantomjs
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: poltergeist
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: thor
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: bundler
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '3.0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '3.0'
|
139
|
+
description: CLI tools for iijmio API.
|
140
|
+
email:
|
141
|
+
- takahiro.inoue@mail.3dcg-arts.net
|
142
|
+
executables:
|
143
|
+
- iijmio
|
144
|
+
extensions: []
|
145
|
+
extra_rdoc_files: []
|
146
|
+
files:
|
147
|
+
- ".gitignore"
|
148
|
+
- ".rspec"
|
149
|
+
- Gemfile
|
150
|
+
- LICENSE.txt
|
151
|
+
- README.md
|
152
|
+
- Rakefile
|
153
|
+
- bin/console
|
154
|
+
- bin/setup
|
155
|
+
- exe/iijmio
|
156
|
+
- iijmio-cli.gemspec
|
157
|
+
- lib/iijmio/cli.rb
|
158
|
+
- lib/iijmio/cli/version.rb
|
159
|
+
homepage: https://github.com/hinata/iijmio-cli
|
160
|
+
licenses:
|
161
|
+
- MIT
|
162
|
+
metadata: {}
|
163
|
+
post_install_message:
|
164
|
+
rdoc_options: []
|
165
|
+
require_paths:
|
166
|
+
- lib
|
167
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
168
|
+
requirements:
|
169
|
+
- - ">="
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '0'
|
172
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
|
+
requirements:
|
174
|
+
- - ">="
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: '0'
|
177
|
+
requirements: []
|
178
|
+
rubyforge_project:
|
179
|
+
rubygems_version: 2.5.1
|
180
|
+
signing_key:
|
181
|
+
specification_version: 4
|
182
|
+
summary: CLI tools for iijmio API.
|
183
|
+
test_files: []
|