kiji 0.1.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a872976a91ecf3d493cdeb0d8c5d8e39bee5c4e1
4
+ data.tar.gz: 8c815743a03b7443e884c860115dd7b11333df99
5
+ SHA512:
6
+ metadata.gz: b2f7275dbb91271fa8275f586fef099b202f24e582ee9e6b83dabb9499009ce710fc1e297fadc5639eb81fd9791fd6de761c50381e622b51d25b549724bbea4f
7
+ data.tar.gz: d36173406f6e597a9491e1531c4d99cf99d4b970b172315e2a7f74653b6368fb0db0a7e79600315ad33fc8a4617a041fb44738341a19f9cd1b0e09328cc4e5fd
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .env
11
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,7 @@
1
+ inherit_from: '.rubocop_todo.yml'
2
+
3
+ Style/Blocks:
4
+ Enabled: false
5
+
6
+ Style/AsciiComments:
7
+ Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,48 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2015-04-02 16:13:11 +0900 using RuboCop version 0.29.1.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 5
9
+ Metrics/AbcSize:
10
+ Max: 47
11
+
12
+ # Offense count: 1
13
+ # Configuration parameters: CountComments.
14
+ Metrics/ClassLength:
15
+ Max: 170
16
+
17
+ # Offense count: 1
18
+ Metrics/CyclomaticComplexity:
19
+ Max: 7
20
+
21
+ # Offense count: 54
22
+ # Configuration parameters: AllowURI, URISchemes.
23
+ Metrics/LineLength:
24
+ Max: 245
25
+
26
+ # Offense count: 5
27
+ # Configuration parameters: CountComments.
28
+ Metrics/MethodLength:
29
+ Max: 30
30
+
31
+ # Offense count: 1
32
+ Metrics/PerceivedComplexity:
33
+ Max: 8
34
+
35
+ # Offense count: 4
36
+ Style/Documentation:
37
+ Enabled: false
38
+
39
+ # Offense count: 4
40
+ Style/RegexpLiteral:
41
+ MaxSlashes: 0
42
+
43
+ Metrics/ClassLength:
44
+ Exclude:
45
+ - 'lib/kiji/signer.rb'
46
+
47
+ Metrics/AbcSize:
48
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in egov.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,48 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(lib spec)
6
+
7
+ ## Uncomment to clear the screen before every task
8
+ # clearing :on
9
+
10
+ ## Guard internally checks for changes in the Guardfile and exits.
11
+ ## If you want Guard to automatically start up again, run guard in a
12
+ ## shell loop, e.g.:
13
+ ##
14
+ ## $ while bundle exec guard; do echo "Restarting Guard..."; done
15
+ ##
16
+ ## Note: if you are using the `directories` clause above and you are not
17
+ ## watching the project directory ('.'), then you will want to move
18
+ ## the Guardfile to a watched dir and symlink it back, e.g.
19
+ #
20
+ # $ mkdir config
21
+ # $ mv Guardfile config/
22
+ # $ ln -s config/Guardfile .
23
+ #
24
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
25
+
26
+ # Note: The cmd option is now required due to the increasing number of ways
27
+ # rspec may be run, below are examples of the most common uses.
28
+ # * bundler: 'bundle exec rspec'
29
+ # * bundler binstubs: 'bin/rspec'
30
+ # * spring: 'bin/rspec' (This will use spring if running and you have
31
+ # installed the spring binstubs per the docs)
32
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
33
+ # * 'just' rspec: 'rspec'
34
+
35
+ guard :rspec, cmd: 'bundle exec rspec', failed_mode: :focus do
36
+ watch(%r{^spec/.+_spec\.rb$})
37
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
38
+ watch('spec/spec_helper.rb') { 'spec' }
39
+ end
40
+
41
+ guard :bundler do
42
+ watch('Gemfile')
43
+ watch(/^.+\.gemspec/)
44
+ end
45
+
46
+ guard :rubocop, all_on_start: true, cli: ['-D', '--format', 'clang'] do
47
+ watch(/.+\.rb$/)
48
+ end
data/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2015 Kensuke NAITO and KUFU, Inc.
2
+
3
+ 以下に定める条件に従い、本ソフトウェアおよび関連文書のファイル(以下「ソフトウェア」)の複製を取得するすべての人に対し、ソフトウェアを無制限に扱うことを無償で許可します。これには、ソフトウェアの複製を使用、複写、変更、結合、掲載、頒布、サブライセンス、および/または販売する権利、およびソフトウェアを提供する相手に同じことを許可する権利も無制限に含まれます。
4
+
5
+ 上記の著作権表示および本許諾表示を、ソフトウェアのすべての複製または重要な部分に記載するものとします。
6
+
7
+ ソフトウェアは「現状のまま」で、明示であるか暗黙であるかを問わず、何らの保証もなく提供されます。ここでいう保証とは、商品性、特定の目的への適合性、および権利非侵害についての保証も含みますが、それに限定されるものではありません。 作者または著作権者は、契約行為、不法行為、またはそれ以外であろうと、ソフトウェアに起因または関連し、あるいはソフトウェアの使用またはその他の扱いによって生じる一切の請求、損害、その他の義務について何らの責任も負わないものとします。
data/README.md ADDED
@@ -0,0 +1,217 @@
1
+ ![kiji logo](https://raw.githubusercontent.com/wiki/kufu/kiji/images/logo_kiji.png)
2
+
3
+ by [KUFU, Inc.](http://kufuinc.com/)
4
+
5
+ # kiji
6
+
7
+ A Ruby interface to the e-Gov API.
8
+
9
+ ## 理念
10
+
11
+ 2008 年より[電子政府(e-Gov)のウェブサイト](http://www.e-gov.go.jp/shinsei/index.html)上で社会保険・労働保険関連手続きの電子申請の受付が開始されました。
12
+ 2010 年には e-Gov の使い勝手の向上を図り、一括申請機能の提供が開始されました。
13
+ そして 2014 年 10 月、さらなる利便性の向上を目的に、外部連携 API 仕様が公開されました。
14
+
15
+ これまで様々な取組が行われてきた一方で、確定申告などで利用される国税の電子申告(e-Tax)と比べるとまだまだ普及度が低いのが実情です。
16
+
17
+ わたしたちは kiji の開発・公開によって e-Gov 外部連携 API に対応したソフトウェアが増えることを期待します。
18
+ そして、電子政府の認知度の向上、利用率の向上、及び利用の拡大に貢献し、もってユーザの利便性の向上を目指します。
19
+
20
+
21
+ ## インストール
22
+
23
+ Gemfile に追記して:
24
+
25
+ ```ruby
26
+ gem 'kiji'
27
+ ```
28
+
29
+ bundle コマンドを実行します:
30
+
31
+ ```bash
32
+ $ bundle
33
+ ```
34
+
35
+ もしくは、直接インストール:
36
+
37
+ ```bash
38
+ $ gem install kiji
39
+ ```
40
+
41
+ ## 使い方
42
+
43
+ ### 利用者 ID 登録
44
+
45
+ ```ruby
46
+ client = Kiji::Client.new do |c|
47
+ c.software_id = ENV['EGOV_SOFTWARE_ID']
48
+ c.api_end_point = ENV['EGOV_API_END_POINT']
49
+ c.cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
50
+ c.private_key = OpenSSL::PKey::RSA.new(File.read(private_key_file))
51
+ end
52
+
53
+ response = client.register("NEW_USER_ID") # => Faraday::Response
54
+ xml = Nokogiri::XML(response.body) # => Nokogiri::XML::Document
55
+ xml.at_xpath('//Code').text # => 0(正常終了)
56
+ ```
57
+
58
+ ### 利用者認証
59
+
60
+ ```ruby
61
+ client = Kiji::Client.new do |c|
62
+ c.software_id = ENV['EGOV_SOFTWARE_ID']
63
+ c.api_end_point = ENV['EGOV_API_END_POINT']
64
+ c.cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
65
+ c.private_key = OpenSSL::PKey::RSA.new(File.read(private_key_file))
66
+ end
67
+
68
+ # 利用者認証(Access Key の取得 & 設定)
69
+ response = client.login("REGISTERED_USER_ID")
70
+ xml = Nokogiri::XML(response.body)
71
+ client.access_key = xml.at_xpath('//AccessKey').text
72
+ ```
73
+
74
+ ### 一括申請
75
+
76
+ ```ruby
77
+ client = Kiji::Client.new do |c|
78
+ c.software_id = ENV['EGOV_SOFTWARE_ID']
79
+ c.api_end_point = ENV['EGOV_API_END_POINT']
80
+ c.cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
81
+ c.private_key = OpenSSL::PKey::RSA.new(File.read(private_key_file))
82
+ end
83
+
84
+ # 利用者認証(Access Key の取得 & 設定)
85
+ response = client.login("REGISTERED_USER_ID")
86
+ xml = Nokogiri::XML(response.body)
87
+ client.access_key = xml.at_xpath('//AccessKey').text
88
+
89
+ # 一括申請
90
+ file_name = 'apply.zip'
91
+ encoded_data = Base64.encode64(File.new("data/#{file_name}").read)
92
+ client.apply(file_name, encoded_data)
93
+ ```
94
+
95
+
96
+ ## 事前準備
97
+
98
+ e-Gov API を利用するには外部連携 API 利用ソフトウェア開発の申込みを行い、ソフトウェア ID を入手する必要があります。
99
+ 詳しくは [利用にあたっての留意事項](http://www.e-gov.go.jp/shinsei/interface_api/attention.html) をご参照ください。
100
+
101
+
102
+ ## 検証環境での利用
103
+
104
+ 検証環境には BASIC 認証が設定されています。
105
+ `Kiji::Client` の `basic_auth_id` および `basic_auth_password` に ID と Password をそれぞれ設定しましょう。
106
+
107
+ ```ruby
108
+ client = Kiji::Client.new do |c|
109
+ ...
110
+ c.basic_auth_id = ENV['EGOV_BASIC_AUTH_ID']
111
+ c.basic_auth_password = ENV['EGOV_BASIC_AUTH_PASSWORD']
112
+ end
113
+ ```
114
+
115
+ また、署名に利用する証明書については e-Gov にて配布されているものを利用します。
116
+
117
+ [仕様書ダウンロード|電子政府の総合窓口e-Gov イーガブ](http://www.e-gov.go.jp/shinsei/interface_api/download.html) > 検証環境テスト用電子証明書
118
+
119
+ **TIPS**
120
+
121
+ pfx から *.pem と *.cer を取り出す
122
+
123
+ __*.cer__
124
+
125
+ ```bash
126
+ $ openssl pkcs12 -in e-GovEE02_sha2.pfx -nokeys -out ~/Desktop/egov.cer
127
+ Enter Import Password:(gpkitestと入力)
128
+ MAC verified OK
129
+ ```
130
+
131
+ __*.pem__
132
+
133
+ ```bash
134
+ $ openssl pkcs12 -in e-GovEE02_sha2.pfx -nocerts -out ~/Desktop/egov.pem
135
+ Enter Import Password:(gpkitestと入力)
136
+ MAC verified OK
137
+ Enter PEM pass phrase:(適当なパスワード入力)
138
+ Verifying - Enter PEM pass phrase:(適当なパスワード入力)
139
+ ```
140
+
141
+
142
+ ## API と メソッドの対応
143
+
144
+ | API | メソッド | 実装状況 |
145
+ | --- | --- | :---: |
146
+ | 利用者 ID 登録 | register | ○ |
147
+ | 利用者認証 | login | ○ |
148
+ | 一括申請 | apply | ○ |
149
+ | 送信案件一覧情報取得 (ID 指定) | sended_applications_by_id | ○ |
150
+ | 送信案件一覧情報取得 (日付 指定) | sended_applications_by_date | ○ |
151
+ | 申請案件一覧情報取得 | arrived_applications | ○ |
152
+ | 状況照会 | reference | ○ |
153
+ | 取下げ | withdraw | ○ |
154
+ | 補正通知一覧取得 | amends | ○ |
155
+ | 補正(再提出) | reamend | △ |
156
+ | 補正(部分補正) | partamend | △ |
157
+ | 補正(補正申請) | amend_apply | △ |
158
+ | 公文書・コメント一覧取得 | notices | ○ |
159
+ | 公文書取得 | officialdocument | ○ |
160
+ | 公文書取得完了 | done_officialdocument | ○ |
161
+ | 公文書署名検証 | verify_officialdocument | ○ |
162
+ | コメント通知取得 | comment | ○ |
163
+ | コメント通知取得完了 | done_comment | ○ |
164
+ | 電子納付対応金融機関一覧取得 | banks | ○ |
165
+ | 電子納付情報一覧取得 | payments | ○ |
166
+ | 電子納付金融機関サイト表示 | - | ☓ |
167
+ | 証明書識別情報追加 | append_certificate | ○ |
168
+ | 証明書識別情報更新 | update_certificate | ○ |
169
+ | 証明書識別情報削除 | delete_certificate | ○ |
170
+
171
+ ※実装状況について
172
+
173
+ - ○: 実装、テスト済み
174
+ - △: 実装予定
175
+ - ☓: 実装予定無し
176
+
177
+ ## 参考リンク
178
+
179
+ - [e-Gov電子申請システム|電子政府の総合窓口e-Gov イーガブ](http://www.e-gov.go.jp/shinsei/index.html)
180
+ e-Gov に関する最新情報
181
+ - [外部連携API仕様公開(ソフトウェア開発事業者の方へ)|電子政府の総合窓口e-Gov イーガブ](http://www.e-gov.go.jp/shinsei/interface_api/index.html)
182
+ (公式)API の仕様について
183
+ - [一括申請仕様公開(ソフトウェア開発事業者の方へ)|電子政府の総合窓口e-Gov イーガブ](http://www.e-gov.go.jp/shinsei/interface/index.html)
184
+ (公式)申請データの構造仕様について
185
+
186
+ ## 注意事項
187
+
188
+ - kiji を利用する場合、必ず検証環境にて検証を行ってください。
189
+ - すでに最終試験に合格したソフトウェアに kiji を組み込む場合、新たにソフトウェア ID を取得し、再度最終試験に合格する必要があります。(API 利用ガイド p. 20)
190
+ - 最終確認試験にて合格していない API 機能を利用すると当該ソフトウェアからの e-Gov 電子申請システムへの接続が制限されます。ご注意ください。(API 利用ガイド p. 20)
191
+
192
+ ## Contributing
193
+
194
+ 1. Fork it ( https://github.com/[my-github-username]/kiji/fork )
195
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
196
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
197
+ 4. Push to the branch (`git push origin my-new-feature`)
198
+ 5. Create a new Pull Request
199
+
200
+
201
+ ## Copyright
202
+
203
+ Copyright (c) 2015 Kensuke NAITO and KUFU, Inc.
204
+ ライセンスはこちら: [kiji/LICENSE.md](https://github.com/kufu/kiji/blob/master/LICENSE.md)
205
+
206
+
207
+ ## KUFU について
208
+
209
+ ![KUFU logo](https://raw.githubusercontent.com/wiki/kufu/kiji/images/logo_kufu.png)
210
+
211
+ kiji は株式会社 KUFU によってメンテナンス、開発が行われています。
212
+ わたしたちは OSS の力を信じています。
213
+
214
+ KUFU では OSS 活動に積極的なエンジニアを募集しています!
215
+
216
+ [「雇用」×「国のAPI」をハックする Ruby エンジニア募集!](https://www.wantedly.com/projects/3788)
217
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'kiji'
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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/egov.gemspec ADDED
@@ -0,0 +1,42 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kiji/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'kiji'
8
+ spec.version = Kiji::VERSION
9
+ spec.authors = ['kakipo']
10
+ spec.email = ['kakipo@gmail.com']
11
+
12
+ # if spec.respond_to?(:metadata)
13
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
14
+ # end
15
+
16
+ spec.summary = 'API toolkits for Japanese e-Gov system'
17
+ spec.homepage = 'https://github.com/kufu/kiji'
18
+ spec.license = 'MIT'
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.8'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rubocop'
27
+ spec.add_development_dependency 'guard'
28
+ spec.add_development_dependency 'guard-rspec'
29
+ spec.add_development_dependency 'guard-bundler'
30
+ spec.add_development_dependency 'guard-rubocop'
31
+ spec.add_development_dependency 'pry'
32
+ spec.add_development_dependency 'pry-byebug'
33
+ spec.add_development_dependency 'dotenv'
34
+ spec.add_development_dependency 'webmock'
35
+ spec.add_development_dependency 'vcr'
36
+ spec.add_development_dependency 'rubyzip'
37
+
38
+ # spec.add_runtime_dependency 'signer'
39
+ spec.add_runtime_dependency 'faraday'
40
+ spec.add_runtime_dependency 'nokogiri'
41
+ spec.add_runtime_dependency 'activesupport'
42
+ end
data/lib/kiji.rb ADDED
@@ -0,0 +1,3 @@
1
+ require 'kiji/version'
2
+ require 'kiji/client'
3
+ require 'kiji/zipper'