nissen-collect 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NjdhYTg5NmUyZjhmM2FkYTk2ZjZmYjkzNjY5YTVmNGRhYTVjMTdjMA==
5
+ data.tar.gz: !binary |-
6
+ Njg0Njk1ZDk0MTU2NDQwNmEwMWEzMmNjZTgwM2I3N2MxOTc2NzNjZA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ OWY1MjY4ZjZhMTBmYWVkZGRiMDBmZWM2Zjc3MWRhNDJkNWI3YWZkYjlkZWE2
10
+ YzNlYzVmYmE0NjQ5Y2YxODM4OTdjNjI4MTc1ZWFjZTE0MjEzNjhkMWFmN2Jk
11
+ ZjMzMGVhMGQ5MGIxYjA5NDMzMGY5NGUxOTBiYmI2N2VmNTE4MjU=
12
+ data.tar.gz: !binary |-
13
+ ZmEzMDM5OTcyY2ExZDM4NTRjMGZjZDY3NjU0Nzc1ODc3Y2U2ZGE5Njg3MDk5
14
+ YjZhZGE5ZTFlZjhlNTBlYTljMDU4ZjcyYzFiZTBiMzdjMjZhNmU2MjczZjJh
15
+ MDNlNmQyMDgyNzI4OTc5MjI0MGJiMjFhNmEzODdjYWQ4ZTQyNzU=
data/.document ADDED
@@ -0,0 +1,3 @@
1
+ -
2
+ ChangeLog.rdoc
3
+ LICENSE.txt
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour --format documentation
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup rdoc --title "nissen-collect Documentation" --protected
data/ChangeLog.rdoc ADDED
@@ -0,0 +1,4 @@
1
+ === 0.1.0 / 2013-07-18
2
+
3
+ * Initial release:
4
+
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Yuichi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 yu1ch1
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ nissen-collect
2
+ ==============
3
+
4
+ nissenスマート接続APIwrapper
data/README.rdoc ADDED
@@ -0,0 +1,27 @@
1
+ = nissen-collect
2
+
3
+ * {Homepage}[https://rubygems.org/gems/nissen-collect]
4
+ * {Documentation}[http://rubydoc.info/gems/nissen-collect/frames]
5
+ * {Email}[mailto:s.yuichi227 at gmail.com]
6
+
7
+ == Description
8
+
9
+ TODO: Description
10
+
11
+ == Features
12
+
13
+ == Examples
14
+
15
+ require 'nissen-collect'
16
+
17
+ == Requirements
18
+
19
+ == Install
20
+
21
+ $ gem install nissen-collect
22
+
23
+ == Copyright
24
+
25
+ Copyright (c) 2013 yu1ch1
26
+
27
+ See LICENSE.txt for details.
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'rake'
5
+
6
+ begin
7
+ gem 'rubygems-tasks', '~> 0.2'
8
+ require 'rubygems/tasks'
9
+
10
+ Gem::Tasks.new
11
+ rescue LoadError => e
12
+ warn e.message
13
+ warn "Run `gem install rubygems-tasks` to install Gem::Tasks."
14
+ end
15
+
16
+ begin
17
+ gem 'rspec', '~> 2.4'
18
+ require 'rspec/core/rake_task'
19
+
20
+ RSpec::Core::RakeTask.new
21
+ rescue LoadError => e
22
+ task :spec do
23
+ abort "Please run `gem install rspec` to install RSpec."
24
+ end
25
+ end
26
+
27
+ task :test => :spec
28
+ task :default => :spec
29
+
30
+ begin
31
+ gem 'yard', '~> 0.8'
32
+ require 'yard'
33
+
34
+ YARD::Rake::YardocTask.new
35
+ rescue LoadError => e
36
+ task :yard do
37
+ abort "Please run `gem install yard` to install YARD."
38
+ end
39
+ end
40
+ task :doc => :yard
@@ -0,0 +1,6 @@
1
+ PdRequest:
2
+ pdcompanycode:
3
+ slipno:
4
+ address1:
5
+ address2:
6
+ address3:
@@ -0,0 +1,21 @@
1
+ buyer:
2
+ shopTransactionId:
3
+ shopOrderDate:
4
+ fullName:
5
+ firstName:
6
+ lastName:
7
+ fullKanaName:
8
+ firstKanaName:
9
+ lastKanaName:
10
+ tel:
11
+ mobile:
12
+ email:
13
+ mobileEmail:
14
+ zipCode:
15
+ address1:
16
+ address2:
17
+ address3:
18
+ companyName:
19
+ departmentName:
20
+ billedAmount:
21
+ paymentType:
@@ -0,0 +1,24 @@
1
+ #注文情報登録API リクエストパラメータ
2
+ deliveries:
3
+ delivery:
4
+ deliveryCustomer:
5
+ fullName:
6
+ firstName:
7
+ lastName:
8
+ fullKanaName:
9
+ firstKanaName:
10
+ lastKanaName:
11
+ zipCode:
12
+ address1:
13
+ address2:
14
+ address3:
15
+ companyName:
16
+ departmentName:
17
+ tel:
18
+ email:
19
+ details:
20
+ detail:
21
+ detailId:
22
+ detailName:
23
+ detailName:
24
+ detailQuantity:
@@ -0,0 +1,4 @@
1
+ #注文情報登録API リクエストパラメータ
2
+ httpInfo:
3
+ httpHeader:
4
+ deviceInfo:
@@ -0,0 +1,5 @@
1
+ #注文情報登録API リクエストパラメータ
2
+ shopInfo:
3
+ shopCode: <%= ENV['NISSEN_COLLECT_SHOPCODE'] %>
4
+ shopPassword: <%= ENV['NISSEN_COLLECT_PASSWORD'] %>
5
+ terminalId: <%= ENV['NISSEN_COLLECT_TERMINALID'] %>
@@ -0,0 +1,4 @@
1
+ transaction:
2
+ nissenTransactionId:
3
+ shopTransactionId:
4
+ billedAmount:
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ module NissenCollect
3
+
4
+ class Cancel
5
+ attr_accessor :body
6
+ @@transaction_path = 'direct/autocancel.do'
7
+
8
+ # @bodyを初期化する
9
+ # @param [Hash] body 生成時引数
10
+ def initialize body=nil
11
+ @body = body ? body : [SHOPINFO,TRANSACTION].inject {|union,hash| union.merge hash}
12
+ end
13
+
14
+ # APIコールを行う
15
+ def call
16
+ connect = NissenCollect::Client.new
17
+ connect.request('get',@@transaction_path,@body)
18
+ end
19
+
20
+ end
21
+
22
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ module NissenCollect
3
+
4
+ class Getauthor
5
+ attr_accessor :body
6
+ @@transaction_path = 'direct/autogetauthor.do'
7
+
8
+ # @bodyを初期化する
9
+ # @param [Hash] body 生成時引数
10
+ def initialize body=nil
11
+ @body = body ? body : [SHOPINFO,BUYER].inject {|union,hash| union.merge hash}
12
+ end
13
+
14
+ # APIコールを行う
15
+ def call
16
+ connect = NissenCollect::Client.new
17
+ connect.request('get',@@transaction_path,@body)
18
+ end
19
+
20
+ end
21
+
22
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ module NissenCollect
3
+
4
+ class Modifytransaction
5
+ attr_accessor :body
6
+ @@transaction_path = 'direct/automodifytransaction.do'
7
+
8
+ # @bodyを初期化する
9
+ # @param [Hash] body 生成時引数
10
+ def initialize body=nil
11
+ @body = body ? body : [SHOPINFO,BUYER,DELIVERIES].inject {|union,hash| union.merge hash}
12
+ end
13
+
14
+ # APIコールを行う
15
+ def call
16
+ connect = NissenCollect::Client.new
17
+ connect.request('get',@@transaction_path,@body)
18
+ end
19
+
20
+ end
21
+
22
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ module NissenCollect
3
+
4
+ class Pdrequest
5
+ attr_accessor :body
6
+ @@transaction_path = 'direct/autotransaction.do'
7
+
8
+ # @bodyを初期化する
9
+ # @param [Hash] body 生成時引数
10
+ def initialize body=nil
11
+ @body = body ? body : [SHOPINFO,TRANSACTION,PDREQUEST].inject {|union,hash| union.merge hash}
12
+ end
13
+
14
+ # APIコールを行う
15
+ def call
16
+ connect = NissenCollect::Client.new
17
+ connect.request('get',@@transaction_path,@body)
18
+ end
19
+
20
+ end
21
+
22
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ module NissenCollect
3
+
4
+ class Transaction
5
+ attr_accessor :body
6
+ @@transaction_path = 'direct/autotransaction.do'
7
+
8
+ # @bodyを初期化する
9
+ # @param [Hash] body 生成時引数
10
+ def initialize body=nil
11
+ @body = body ? body : [SHOPINFO,HTTPINFO,BUYER,DELIVERIES].inject {|union,hash| union.merge hash}
12
+ end
13
+
14
+ # APIコールを行う
15
+ def call
16
+ connect = NissenCollect::Client.new
17
+ connect.request('get',@@transaction_path,@body)
18
+ end
19
+
20
+ end
21
+
22
+ end
@@ -0,0 +1,4 @@
1
+ module NissenCollect
2
+ # nissen-collect version
3
+ VERSION = "0.1.1"
4
+ end
@@ -0,0 +1,62 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'yaml'
3
+ require 'faraday'
4
+ require 'active_support/core_ext'
5
+ require 'erb'
6
+ require 'nissen-collect/version'
7
+ require 'nissen-collect/transaction.rb'
8
+ require 'nissen-collect/getauthor.rb'
9
+ require 'nissen-collect/modifytransaction.rb'
10
+ require 'nissen-collect/pdrequest.rb'
11
+ require 'nissen-collect/cancel.rb'
12
+
13
+ # nissen collect APIwrapper
14
+ module NissenCollect
15
+ $:.unshift(File.dirname(File.expand_path(__FILE__)))
16
+ ROOT_HOST = 'https://collect-operation.nissen.co.jp/'
17
+ SHOPINFO = HashWithIndifferentAccess.new(YAML.load(ERB.new(File.read('lib/nissen-collect/body/shopInfo.yml')).result))
18
+ HTTPINFO = HashWithIndifferentAccess.new(YAML.load_file('lib/nissen-collect/body/httpInfo.yml'))
19
+ BUYER = HashWithIndifferentAccess.new(YAML.load_file('lib/nissen-collect/body/buyer.yml'))
20
+ DELIVERIES = HashWithIndifferentAccess.new(YAML.load_file('lib/nissen-collect/body/deliveries.yml'))
21
+ PDREQUEST = HashWithIndifferentAccess.new(YAML.load_file('lib/nissen-collect/body/PdRequest.yml'))
22
+ TRANSACTION = HashWithIndifferentAccess.new(YAML.load_file('lib/nissen-collect/body/transaction.yml'))
23
+
24
+ class Client
25
+
26
+ # リクエストの作成
27
+ # @param [String] target_host リクエスト先ホスト
28
+ # @param [Xml] params リクエストボディ
29
+ # @return [Proc] request_setup リクエスト
30
+ def request_setup target_path, params
31
+ Proc.new do |req|
32
+ req.body = params
33
+ req.url target_path
34
+ end
35
+ end
36
+
37
+ # httpsコネクションの作成
38
+ # @return [object] connection Faraday::Connection
39
+ def connection
40
+ @connection = Faraday::Connection.new(ROOT_HOST,ssl:{verify:true}) do |builder|
41
+ builder.use Faraday::Request::UrlEncoded # リクエストパラメータを URL エンコードする
42
+ builder.use Faraday::Response::Logger # リクエストを標準出力に出力する
43
+ builder.use Faraday::Adapter::NetHttp # Net/HTTP をアダプターに使う
44
+ end
45
+ end
46
+
47
+ # httpsリクエスト送信
48
+ # @param [String] method 実行するhttpメソッド
49
+ # @param [String] target_path リクエスト送信先パス
50
+ # @params [Hash] params リクエストのbody
51
+ # @return [Hash] httpレスポンス
52
+ def request method, target_path, params
53
+ request_setup = request_setup(target_path, params.to_xml(root:'request'))
54
+ connection.send(method.to_sym, &request_setup).env
55
+ rescue Faraday::Error::ClientError
56
+ raise Twitter::Error::ClientError
57
+ rescue JSON::ParserError
58
+ raise Twitter::Error::ParserError
59
+ end
60
+ end
61
+
62
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path('../lib/nissen-collect/version', __FILE__)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "nissen-collect"
7
+ gem.version = NissenCollect::VERSION
8
+ gem.summary = %q{nissen-collect API wrapper}
9
+ gem.description = %q{transaction,getauthor,modifytransaction,pdrequest,cancel}
10
+ gem.license = "MIT"
11
+ gem.authors = ["yu1ch1"]
12
+ gem.email = "s.yuichi227@gmail.com"
13
+ gem.homepage = "https://rubygems.org/gems/nissen-collect"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ['lib']
19
+
20
+ gem.add_development_dependency 'rspec', '~> 2.4'
21
+ gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
22
+ gem.add_development_dependency 'yard', '~> 0.8'
23
+ end
@@ -0,0 +1,18 @@
1
+ require 'nissen-collect'
2
+ require 'spec_helper'
3
+
4
+ describe NissenCollect do
5
+
6
+ it "should have a VERSION constant" do
7
+ subject.const_get('VERSION').should_not be_empty
8
+ end
9
+
10
+ it "should have Hash constants" do
11
+ ['SHOPINFO','HTTPINFO','BUYER','DELIVERIES','PDREQUEST','TRANSACTION'].map{ |constant|
12
+ subject.const_get(constant).should_not be_empty}
13
+ end
14
+
15
+
16
+
17
+
18
+ end
@@ -0,0 +1,5 @@
1
+ gem 'rspec', '~> 2.4'
2
+ require 'rspec'
3
+ require 'nissen-collect/version'
4
+
5
+ include NissenCollect
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nissen-collect
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - yu1ch1
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '2.4'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '2.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubygems-tasks
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '0.2'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '0.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: yard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '0.8'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '0.8'
55
+ description: transaction,getauthor,modifytransaction,pdrequest,cancel
56
+ email: s.yuichi227@gmail.com
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - .document
62
+ - .gitignore
63
+ - .rspec
64
+ - .yardopts
65
+ - ChangeLog.rdoc
66
+ - LICENSE
67
+ - LICENSE.txt
68
+ - README.md
69
+ - README.rdoc
70
+ - Rakefile
71
+ - lib/nissen-collect.rb
72
+ - lib/nissen-collect/body/PdRequest.yml
73
+ - lib/nissen-collect/body/buyer.yml
74
+ - lib/nissen-collect/body/deliveries.yml
75
+ - lib/nissen-collect/body/httpInfo.yml
76
+ - lib/nissen-collect/body/shopInfo.yml
77
+ - lib/nissen-collect/body/transaction.yml
78
+ - lib/nissen-collect/cancel.rb
79
+ - lib/nissen-collect/getauthor.rb
80
+ - lib/nissen-collect/modifytransaction.rb
81
+ - lib/nissen-collect/pdrequest.rb
82
+ - lib/nissen-collect/transaction.rb
83
+ - lib/nissen-collect/version.rb
84
+ - nissen-collect.gemspec
85
+ - spec/nissen-collect_spec.rb
86
+ - spec/spec_helper.rb
87
+ homepage: https://rubygems.org/gems/nissen-collect
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.0.6
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: nissen-collect API wrapper
111
+ test_files:
112
+ - spec/nissen-collect_spec.rb
113
+ - spec/spec_helper.rb
114
+ has_rdoc: