rms_item_api 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e166418c4d289ab8ad9ed1845a4cf091bc8ab8cd
4
- data.tar.gz: c2eda935303a79796363f9bec9e22e767c794575
3
+ metadata.gz: 4adb298a103b9b2ccbe1ae7c56c63b12a6f183be
4
+ data.tar.gz: d5abe7537db0e8dcc1a603a157a17945333fb165
5
5
  SHA512:
6
- metadata.gz: 3940333e003e6c2bdcd638a942bd8c4cedf0c625357b0fc6c01eba334c65bb87a212f46c559ca64a2724bafbffdf23de9c2ab29fd4331f52c59d45614fbca54c
7
- data.tar.gz: bf5b03f8f43b64f74ab29c8079c2190dd22895ba195760d3b445eca2c0ec3ab8407ec7cf48078f018c51e7136db9c0a52c602d20f0b98434989508fc5ec6f341
6
+ metadata.gz: 3b84634e3399f42d05279bb717ee45f4518986bf8c0b1aba4fc602dba481a3991f0c0042b3c08405074421ac99db0166535be92c6b0a7162e933fc1af738f8d1
7
+ data.tar.gz: a678c7a2f2f7fcd50b59fe643473e0629fcdac717dbd1c05e2b3d27e124e36ea02e74c5f90183c19d4564a87c4af46f43a841d3c7325319b4ad5b82592a48b64
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
data/.rbenv-gemsets ADDED
@@ -0,0 +1 @@
1
+ rms_item_api
data/Gemfile.lock ADDED
@@ -0,0 +1,75 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rms_item_api (0.1.2)
5
+ activemodel
6
+ activesupport
7
+ builder
8
+ faraday
9
+ hashie
10
+ oga
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ activemodel (5.0.2)
16
+ activesupport (= 5.0.2)
17
+ activesupport (5.0.2)
18
+ concurrent-ruby (~> 1.0, >= 1.0.2)
19
+ i18n (~> 0.7)
20
+ minitest (~> 5.1)
21
+ tzinfo (~> 1.1)
22
+ ansi (1.5.0)
23
+ ast (2.3.0)
24
+ builder (3.2.3)
25
+ coderay (1.1.1)
26
+ concurrent-ruby (1.0.5)
27
+ diff-lcs (1.3)
28
+ faraday (0.11.0)
29
+ multipart-post (>= 1.2, < 3)
30
+ hashie (3.5.5)
31
+ i18n (0.8.1)
32
+ method_source (0.8.2)
33
+ minitest (5.10.1)
34
+ multipart-post (2.0.0)
35
+ oga (2.9)
36
+ ast
37
+ ruby-ll (~> 2.1)
38
+ pry (0.10.4)
39
+ coderay (~> 1.1.0)
40
+ method_source (~> 0.8.1)
41
+ slop (~> 3.4)
42
+ rake (10.5.0)
43
+ rspec (3.5.0)
44
+ rspec-core (~> 3.5.0)
45
+ rspec-expectations (~> 3.5.0)
46
+ rspec-mocks (~> 3.5.0)
47
+ rspec-core (3.5.4)
48
+ rspec-support (~> 3.5.0)
49
+ rspec-expectations (3.5.0)
50
+ diff-lcs (>= 1.2.0, < 2.0)
51
+ rspec-support (~> 3.5.0)
52
+ rspec-mocks (3.5.0)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.5.0)
55
+ rspec-support (3.5.0)
56
+ ruby-ll (2.1.2)
57
+ ansi
58
+ ast
59
+ slop (3.6.0)
60
+ thread_safe (0.3.6)
61
+ tzinfo (1.2.2)
62
+ thread_safe (~> 0.1)
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ bundler (~> 1.10)
69
+ pry
70
+ rake (~> 10.0)
71
+ rms_item_api!
72
+ rspec
73
+
74
+ BUNDLED WITH
75
+ 1.14.5
data/README.md CHANGED
@@ -78,7 +78,7 @@ item = client.update({
78
78
  この機能を利用すると、RMSに登録されている商品情報を削除することができます。
79
79
 
80
80
  ```ruby
81
- item = client.update({
81
+ item = client.delete({
82
82
  item_url: 'test123',
83
83
  })
84
84
  ```
@@ -1,3 +1,3 @@
1
1
  module RmsItemApi
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/rms_item_api.rb CHANGED
@@ -19,28 +19,28 @@ module RmsItemApi
19
19
 
20
20
  def get(item_data)
21
21
  result = connection('get').get {|r| r.params['itemUrl'] = item_data}
22
- parse_response(result.body, "Get")
22
+ check_system_status(result.body, "Get")
23
23
  end
24
24
 
25
25
  def update(item_data)
26
26
  request_xml = {itemUpdateRequest: {item: item_data}}.to_xml(
27
27
  root: 'request', camelize: :lower, skip_types: true)
28
28
  result = connection('update').post {|r| r.body = request_xml}
29
- parse_response(result.body, "Update")
29
+ check_system_status(result.body, "Update")
30
30
  end
31
31
 
32
32
  def insert(item_data)
33
33
  request_xml = {itemInsertRequest: {item: item_data}}.to_xml(
34
34
  root: 'request', camelize: :lower, skip_types: true)
35
35
  result = connection('insert').post {|r| r.body = request_xml}
36
- parse_response(result.body, "Insert")
36
+ check_system_status(result.body, "Insert")
37
37
  end
38
38
 
39
39
  def delete(item_data)
40
40
  request_xml = {itemDeleteRequest: {item: item_data}}.to_xml(
41
41
  root: 'request', camelize: :lower, skip_types: true)
42
42
  result = connection('delete').post {|r| r.body = request_xml}
43
- parse_response(result.body, "Delete")
43
+ check_system_status(result.body, "Delete")
44
44
  end
45
45
 
46
46
  private
@@ -61,8 +61,17 @@ module RmsItemApi
61
61
  end
62
62
  end
63
63
 
64
- def parse_response(result, method)
64
+ def check_system_status(result, method)
65
65
  parsed_xml = Oga.parse_xml(result)
66
+ system_status = Oga.parse_xml(result).xpath("result/status/systemStatus").text
67
+ if system_status == 'NG'
68
+ raise Oga.parse_xml(result).xpath("result/status/message").text
69
+ else
70
+ parse_response(parsed_xml, method)
71
+ end
72
+ end
73
+
74
+ def parse_response(parsed_xml, method)
66
75
  result_code = parsed_xml.xpath("result/item#{method}Result/code").text
67
76
  case method
68
77
  when 'Get'
@@ -109,11 +118,12 @@ module RmsItemApi
109
118
  xml.children.each do |x|
110
119
  error_field = x.xpath('fieldId').text
111
120
  error_description = x.xpath('msg').text.force_encoding('utf-8')
112
- puts error_msg = "#{field_name[error_field]}:#{error_description}"
121
+ puts "#{field_name[error_field]}:#{error_description}"
113
122
  end
114
123
  end
115
124
  end
116
- end # case method
117
- end # def parse_response
125
+ end # case
126
+ end # parse_response
127
+
118
128
  end # class rms_item_api
119
129
  end # module rms_item_api
data/rms_item_api.gemspec CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency "faraday"
22
22
  spec.add_dependency "activesupport"
23
23
  spec.add_dependency "activemodel"
24
+ spec.add_dependency "builder"
24
25
  spec.add_dependency "oga"
25
26
  spec.add_dependency "hashie"
26
27
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rms_item_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - t4traw
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-10 00:00:00.000000000 Z
11
+ date: 2017-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: builder
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'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: oga
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -144,9 +158,11 @@ extensions: []
144
158
  extra_rdoc_files: []
145
159
  files:
146
160
  - ".gitignore"
161
+ - ".rbenv-gemsets"
147
162
  - ".rspec"
148
163
  - ".travis.yml"
149
164
  - Gemfile
165
+ - Gemfile.lock
150
166
  - LICENSE
151
167
  - README.md
152
168
  - Rakefile
@@ -175,9 +191,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
191
  version: '0'
176
192
  requirements: []
177
193
  rubyforge_project:
178
- rubygems_version: 2.4.5
194
+ rubygems_version: 2.5.2
179
195
  signing_key:
180
196
  specification_version: 4
181
197
  summary: RMSの商品APIを簡単に叩けるrubyラッパー
182
198
  test_files: []
183
- has_rdoc: