rms_web_service 0.1.3 → 0.1.4

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: bea5a6cfaeb3326135eba7ff31a0de5f29db01de
4
- data.tar.gz: 38abe79fa798d3b18b02557f0bbed6c35ed23543
3
+ metadata.gz: 5e4456d8e87be3c43e71ff4c8dcdaa64ae6f0737
4
+ data.tar.gz: bdb5461405ef0f45c0d67d5531079706bb5b5ec3
5
5
  SHA512:
6
- metadata.gz: eaf09a19cdb735e4ced433208f1a9fdd4874e702849d15ebf165ce9501052c75fac60f37329afcdde0095b98c79fd4a9bfbd9a8573e742a480e267d006e72383
7
- data.tar.gz: 5d16a89e1bdf89fe84dc3d2e875cfbf0df2707b29245015b8905a93377dba70d65ecfb1490348bf3b0822f110cb49f6f78eb051028cd1e348d8412d1ae8ba3bc
6
+ metadata.gz: df03d83ad6a75e22409231907ac76793c8da2ebc28137ce7c3bf5db96f103cb2312b3d6307299eef595f32641a921e65e3f1126488b60ed4705cacbdd9fe949d
7
+ data.tar.gz: 37f4d4611fc5f8fb063303c94a08701ae0155d8f0dcbaeb18aa82968ef5a058e513c8231f956e85ccb125ebc239850ccc06f7df403ec4e79f810545070575c01
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.1.2
3
4
  - 2.0.0
4
5
  - 1.9.3
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in rms_web_service.gemspec
4
4
  gemspec
5
+
6
+ gem "coveralls", require: false
data/README.md CHANGED
@@ -4,12 +4,14 @@ RMS Webservice APIのRubyラッパーです。
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/rms_web_service.svg)](http://badge.fury.io/rb/rms_web_service)
6
6
  [![Build Status](https://travis-ci.org/kamiya54/rms_web_service.svg)](https://travis-ci.org/kamiya54/rms_web_service)
7
+ [![Coverage Status](https://coveralls.io/repos/kamiya54/rms_web_service/badge.png)](https://coveralls.io/r/kamiya54/rms_web_service)
8
+ [![Code Climate](https://codeclimate.com/github/kamiya54/rms_web_service/badges/gpa.svg)](https://codeclimate.com/github/kamiya54/rms_web_service)
7
9
 
8
10
  #### ご注意
9
11
 
10
- * 楽天市場出品者用APIです。
12
+ * 楽天市場出店者のみが利用できるAPIです。
11
13
  * 現在一部機能のみサポートしています。
12
- * 公式のものではありません。個人が作っているものですので、ご利用は自己責任でお願いします。
14
+ * 非公式です。
13
15
 
14
16
  ## Installation
15
17
 
@@ -1,9 +1,18 @@
1
+ #encoding: utf-8
1
2
  module RmsWebService
2
3
  module Response
3
4
  module Item
4
- class Error < Parser
5
- def initialize(xml)
6
- set_attributes Nokogiri::XML.parse(xml).xpath("//errorMessage").children
5
+ class Error
6
+ require 'rms_web_service/response/item/error/const'
7
+ def self.parse(xml)
8
+ raise ArgumentError, "Argument must be a String class. but argument is #{xml.class}." unless xml.class == String
9
+ hash = Hash.new
10
+ Nokogiri::XML.parse(xml).xpath("//errorMessage").children.each {|att| hash.store(att.name.underscore, att.content)}
11
+ if hash['field_id'] && ::FIELDID_LIST["#{hash['field_id']}"].present?
12
+ hash.store("field", ::FIELDID_LIST["#{hash['field_id']}"][0].underscore)
13
+ hash.store("field_name", ::FIELDID_LIST["#{hash['field_id']}"][1].underscore)
14
+ end
15
+ return hash
7
16
  end
8
17
  end
9
18
  end
@@ -0,0 +1,64 @@
1
+ #encoding: utf-8
2
+ FIELDID_LIST = {
3
+ "501" => ['itemUrl', '商品管理番号'],
4
+ "502" => ['itemName', '商品名'],
5
+ "503" => ['itemPrice', '販売価格'],
6
+ "504" => ['genreId', '全商品ディレクトリID'],
7
+ "505" => ['itemLayout','商品情報レイアウト'],
8
+ "506" => ['isIncludedTax', '消費税'],
9
+ "507" => ['isIncludedPostage', '送料'],
10
+ "508" => ['isIncludedCashOnDeliveryPostage', '代引き手数料'],
11
+ "509" => ['inventoryType', '在庫タイプ'],
12
+ "510" => ['orderLimit ', '注文受付数'],
13
+ "511" => ['isDepot', '倉庫指定'],
14
+ "512" => ['isSaleButton', '注文ボタン'],
15
+ "513" => ['isDocumentButton', '資料請求ボタン'],
16
+ "514" => ['isInquiryButton', '商品問い合わせボタン'],
17
+ "515" => ['isAvailableForMobile', 'モバイル表示'],
18
+ "516" => ['isNoshiEnable', 'のし対応'],
19
+ "517" => ['pointRate', 'ポイント変倍率'],
20
+ "518" => ['pointRateStart', 'ポイント変倍適応期間(開始)'],
21
+ "518" => ['pointRateEnd', 'ポイント変倍適応期間(終了)'],
22
+ "519" => ['imageAlt', '商品画像名(ALT)'],
23
+ "520" => ['itemNumber', '商品番号'],
24
+ "521" => ['descriptionForPC', 'PC用商品説明文'],
25
+ "522" => ['descriptionForMobile', 'モバイル用商品説明文'],
26
+ "523" => ['displayPrice', '表示価格'],
27
+ "524" => ['imageUrl', '商品画像URL'],
28
+ "525" => ['movieUrl', '動画URL'],
29
+ "526" => ['catchCopyForPC', 'PC用キャッチコピー'],
30
+ "527" => ['catchCopyForMobile', 'モバイル用キャッチコピー'],
31
+ "528" => ['descriptionBySalesMethod', 'PC用販売説明文'],
32
+ "529" => ['postage', '個別送料'],
33
+ "530" => ['postageSegment1', '送料区分1'],
34
+ "531" => ['postageSegment2', '送料区分2'],
35
+ "532" => ['isTimeSale', '期間限定販売フラグ'],
36
+ "532" => ['timeSaleStartDateTime', '期間限定販売開始日'],
37
+ "532" => ['timeSaleEndDateTime', '期間限定販売終了日'],
38
+ "534" => ['inventoryQuantityFlag', '在庫数表示'],
39
+ "535" => ['horizontalName', '項目選択肢別在庫用縦軸選択肢項目名'],
40
+ "536" => ['verticalName', '項目選択肢別在庫用横軸選択肢項目名'],
41
+ "537" => ['inventoryDisplayFlag', '項目選択肢別在庫用残り表示閾値'],
42
+ "540" => ['catalogId', 'カタログID'],
43
+ "542" => ['isBackorder', '在庫切れ時の注文受付'],
44
+ "543" => ['normalDeliveryDateId', '在庫あり時納期管理番号'],
45
+ "544" => ['backorderDeliveryDateId', '在庫切れ時納期管理番号'],
46
+ "552" => ['tagId', 'タグID'],
47
+ "553" => ['reviewDisp', 'レビュー表示'],
48
+ "554" => ['asurakuDeliveryId', 'あす楽配送管理番号'],
49
+ "556" => ['sizeChartLinkCode', 'サイズ表リンクコード'],
50
+ "557" => ['isStockNoticeButton', '再入荷のお知らせボタン'],
51
+ "565" => ['isUnavailableForSearch', 'サーチ非表示'],
52
+ "568" => ['displayPriceId ', '二重価格文言ID'],
53
+ "570" => ['descriptionForSmartPhone', 'スマートフォン用商品説明文'],
54
+ "702" => ['optionStyle', '選択肢スタイル'],
55
+ "703" => ['optionName', 'Select/Checkbox用項目名'],
56
+ "704" => ['value', 'Select/Checkbox用選択肢'],
57
+ "705" => ['optionNameHorizontal', '項目選択肢別在庫用横軸選択肢'],
58
+ "706" => ['childNoHorizontal', '項目選択肢別在庫用横軸選択肢子番号'],
59
+ "707" => ['optionNameVertical', '項目選択肢別在庫用縦軸選択肢'],
60
+ "708" => ['childNoVertical', '項目選択肢別在庫用縦軸選択肢子番号'],
61
+ "709" => ['isBackorderAvailable', '項目選択肢別在庫用取り寄せ可能表示'],
62
+ "710" => ['inventoryCount', '在庫数'],
63
+ "711" => ['isRestoreInventoryFlag', '在庫戻し設定']
64
+ }
@@ -8,7 +8,7 @@ module RmsWebService
8
8
  @status = Item::Status.new(xml)
9
9
  @code = @parsed_xml.xpath("//code").first.content if @parsed_xml.xpath("//code").present?
10
10
  @errors = []
11
- @parsed_xml.xpath("//errorMessages").each {|error| @errors << Error.new(error)} if @parsed_xml.xpath("//errorMessages").present?
11
+ @parsed_xml.xpath("//errorMessages").children.each {|error| @errors << Error.parse(error.to_s)} if @parsed_xml.xpath("//errorMessages").present?
12
12
  end
13
13
 
14
14
  def set_attributes(args)
@@ -16,8 +16,7 @@ module RmsWebService
16
16
  end
17
17
 
18
18
  def set_attribute(name, content)
19
- att = name.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').tr("-", "_").downcase
20
- self.define_singleton_method(att) {content}
19
+ self.define_singleton_method(name.underscore) {content}
21
20
  end
22
21
  end
23
22
  end
@@ -1,3 +1,3 @@
1
1
  module RmsWebService
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -9,7 +9,7 @@
9
9
  </status>
10
10
  <itemUpdateResult>
11
11
  <code>code</code>
12
- <errorMessages><errorMessage><errorId>errorId</errorId><fieldId>fieldId</fieldId><msg>error message</msg><listIndex>1</listIndex><listIndex2>2</listIndex2></errorMessage></errorMessages>
12
+ <errorMessages><errorMessage><errorId>errorId</errorId><fieldId>503</fieldId><msg>error message</msg><listIndex>1</listIndex><listIndex2>2</listIndex2></errorMessage></errorMessages>
13
13
  <item>
14
14
  <itemUrl>yyy</itemUrl>
15
15
  </item>
@@ -2,6 +2,24 @@ require 'spec_helper'
2
2
  require 'rms_web_service'
3
3
 
4
4
  describe RmsWebService::Response::Item::Delete do
5
- subject {described_class.new(fixture('delete.xml'))}
6
- it {is_expected.to respond_to(:status, :code, :success?, :errors, :item_url)}
5
+ let(:api) {described_class.new(fixture('delete.xml'))}
6
+
7
+ describe 'attributes' do
8
+ it 'should respond to SystemResult' do
9
+ expect(api).to respond_to :status
10
+ end
11
+
12
+ it 'should respond to ItemDeleteResult' do
13
+ expect(api).to respond_to :code
14
+ expect(api).to respond_to :success?
15
+ end
16
+
17
+ it 'should respond to Item' do
18
+ expect(api).to respond_to :item_url
19
+ end
20
+
21
+ it 'should respond to ErrorMessage' do
22
+ expect(api).to respond_to :errors
23
+ end
24
+ end
7
25
  end
@@ -1,8 +1,20 @@
1
+ #encoding: utf-8
1
2
  require 'spec_helper'
2
3
  require 'rms_web_service'
3
4
 
4
5
  describe RWS::Response::Item::Error do
5
- subject(:error) {described_class.new(fixture('update.xml'))}
6
- it {is_expected.to be_a RWS::Response::Item::Error}
7
- it {is_expected.to respond_to(:field_id)}
6
+ let(:res) {{"error_id"=>"errorId", "field_id"=>"503", "msg"=>"error message", "list_index"=>"1", "list_index2"=>"2", "field"=>"item_price", "field_name"=>"販売価格"}}
7
+ subject {described_class.parse(fixture('update.xml').read)}
8
+ it("should return formatted error") {is_expected.to eq res}
9
+
10
+ describe 'optional attributes' do
11
+ it {is_expected.to include("field")}
12
+ it {is_expected.to include("field_name")}
13
+ end
14
+
15
+ describe 'invalid argument' do
16
+ it "" do
17
+ expect{described_class.parse(Array.new)}.to raise_error ArgumentError
18
+ end
19
+ end
8
20
  end
@@ -2,7 +2,26 @@ require 'spec_helper'
2
2
  require 'rms_web_service'
3
3
 
4
4
  describe RmsWebService::Response::Item::Get do
5
- subject {described_class.new(fixture('get.xml'))}
6
- it {is_expected.to respond_to(:status, :code, :success?, :item_url, :item_name, :item_price)}
7
- it {is_expected.not_to respond_to(:errors)}
5
+ let(:api) {described_class.new(fixture('get.xml'))}
6
+
7
+ describe 'attributes' do
8
+ it 'should respond to SystemResult' do
9
+ expect(api).to respond_to :status
10
+ end
11
+
12
+ it 'should respond to ItemGetResult' do
13
+ expect(api).to respond_to :code
14
+ expect(api).to respond_to :success?
15
+ end
16
+
17
+ it 'should respond to Item' do
18
+ expect(api).to respond_to :item_url
19
+ expect(api).to respond_to :item_name
20
+ expect(api).to respond_to :item_price
21
+ end
22
+
23
+ it 'should not respond to ErrorMessage' do
24
+ expect(api).not_to respond_to :errors
25
+ end
26
+ end
8
27
  end
@@ -2,6 +2,24 @@ require 'spec_helper'
2
2
  require 'rms_web_service'
3
3
 
4
4
  describe RmsWebService::Response::Item::Insert do
5
- subject {described_class.new(fixture('insert.xml'))}
6
- it {is_expected.to respond_to(:status, :code, :success?, :errors, :item_url)}
5
+ let(:api) {described_class.new(fixture('insert.xml'))}
6
+
7
+ describe 'attributes' do
8
+ it 'should respond to SystemResult' do
9
+ expect(api).to respond_to :status
10
+ end
11
+
12
+ it 'should respond to ItemDeleteResult' do
13
+ expect(api).to respond_to :code
14
+ expect(api).to respond_to :success?
15
+ end
16
+
17
+ it 'should respond to Item' do
18
+ expect(api).to respond_to :item_url
19
+ end
20
+
21
+ it 'should respond to ErrorMessage' do
22
+ expect(api).to respond_to :errors
23
+ end
24
+ end
7
25
  end
@@ -2,10 +2,27 @@ require 'spec_helper'
2
2
  require 'rms_web_service'
3
3
 
4
4
  describe RmsWebService::Response::Item::ItemsUpdate do
5
- subject(:res) {described_class.new(fixture('items_update.xml'))}
6
- it {is_expected.to respond_to(:status)}
7
- it {is_expected.to_not respond_to(:code, :success?, :errors, :item_url)}
5
+ subject(:api) {described_class.new(fixture('items_update.xml'))}
8
6
  it 'should be an array of RWS::Response::Item::Update' do
9
- expect(res[0]).to be_a RWS::Response::Item::Update
7
+ expect(api[0]).to be_a RWS::Response::Item::Update
8
+ end
9
+
10
+ describe 'attributes' do
11
+ it 'should respond to SystemResult' do
12
+ expect(api).to respond_to :status
13
+ end
14
+
15
+ it 'should not respond to ItemsUpdateResult' do
16
+ expect(api).not_to respond_to :code
17
+ expect(api).not_to respond_to :success?
18
+ end
19
+
20
+ it 'should not respond to Item' do
21
+ expect(api).not_to respond_to :item_url
22
+ end
23
+
24
+ it 'should not respond to ErrorMessage' do
25
+ expect(api).not_to respond_to :errors
26
+ end
10
27
  end
11
28
  end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe RmsWebService::Response::Item::Parser do
4
+ describe "initialize" do
5
+ subject {::RWS::Response::Item::Update.new(fixture('update.xml'))}
6
+ it {is_expected.to be_a ::RWS::Response::Item::Parser}
7
+ end
8
+
9
+ describe "#errors" do
10
+ let(:api) {::RWS::Response::Item::Update.new(fixture('update.xml'))}
11
+ it "" do
12
+ expect(api.errors).to be_a Array
13
+ end
14
+ end
15
+ end
@@ -2,10 +2,27 @@ require 'spec_helper'
2
2
  require 'rms_web_service'
3
3
 
4
4
  describe RmsWebService::Response::Item::Search do
5
- subject(:res) {described_class.new(fixture('search.xml'))}
6
- it {is_expected.to respond_to(:status, :success?, :code)}
7
- it {is_expected.to_not respond_to(:item_url, :errors)}
5
+ subject(:api) {described_class.new(fixture('search.xml'))}
8
6
  it 'should be an array of RWS::Response::Item::Get' do
9
- expect(res[0]).to be_a RWS::Response::Item::Get
7
+ expect(api[0]).to be_a RWS::Response::Item::Get
8
+ end
9
+
10
+ describe 'attributes' do
11
+ it 'should respond to SystemResult' do
12
+ expect(api).to respond_to :status
13
+ end
14
+
15
+ it 'should respond to ItemSearchResult' do
16
+ expect(api).to respond_to :code
17
+ expect(api).to respond_to :success?
18
+ end
19
+
20
+ it 'should not respond to Item' do
21
+ expect(api).not_to respond_to :item_url
22
+ end
23
+
24
+ it 'should not respond to ErrorMessage' do
25
+ expect(api).not_to respond_to :errors
26
+ end
10
27
  end
11
28
  end
@@ -2,6 +2,24 @@ require 'spec_helper'
2
2
  require 'rms_web_service'
3
3
 
4
4
  describe RmsWebService::Response::Item::Update do
5
- subject {described_class.new(fixture('update.xml'))}
6
- it {is_expected.to respond_to(:status, :code, :success?, :errors, :item_url)}
5
+ let(:api) {described_class.new(fixture('update.xml'))}
6
+
7
+ describe 'attributes' do
8
+ it 'should respond to SystemResult' do
9
+ expect(api).to respond_to :status
10
+ end
11
+
12
+ it 'should respond to ItemDeleteResult' do
13
+ expect(api).to respond_to :code
14
+ expect(api).to respond_to :success?
15
+ end
16
+
17
+ it 'should respond to Item' do
18
+ expect(api).to respond_to :item_url
19
+ end
20
+
21
+ it 'should respond to ErrorMessage' do
22
+ expect(api).to respond_to :errors
23
+ end
24
+ end
7
25
  end
data/spec/spec_helper.rb CHANGED
@@ -9,3 +9,6 @@ end
9
9
  def fixture(file)
10
10
  File.new(File.join(fixture_path, file))
11
11
  end
12
+
13
+ require 'coveralls'
14
+ Coveralls.wear!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rms_web_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - kamiya54
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-16 00:00:00.000000000 Z
11
+ date: 2014-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -129,6 +129,7 @@ executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
+ - .coveralls.yml
132
133
  - .gitignore
133
134
  - .rspec
134
135
  - .travis.yml
@@ -145,6 +146,7 @@ files:
145
146
  - lib/rms_web_service/response/item.rb
146
147
  - lib/rms_web_service/response/item/delete.rb
147
148
  - lib/rms_web_service/response/item/error.rb
149
+ - lib/rms_web_service/response/item/error/const.rb
148
150
  - lib/rms_web_service/response/item/get.rb
149
151
  - lib/rms_web_service/response/item/insert.rb
150
152
  - lib/rms_web_service/response/item/items_update.rb
@@ -168,6 +170,7 @@ files:
168
170
  - spec/rms_web_service/response/item/get_spec.rb
169
171
  - spec/rms_web_service/response/item/insert_spec.rb
170
172
  - spec/rms_web_service/response/item/items_update_spec.rb
173
+ - spec/rms_web_service/response/item/parser_spec.rb
171
174
  - spec/rms_web_service/response/item/search_spec.rb
172
175
  - spec/rms_web_service/response/item/status_spec.rb
173
176
  - spec/rms_web_service/response/item/update_spec.rb
@@ -212,6 +215,7 @@ test_files:
212
215
  - spec/rms_web_service/response/item/get_spec.rb
213
216
  - spec/rms_web_service/response/item/insert_spec.rb
214
217
  - spec/rms_web_service/response/item/items_update_spec.rb
218
+ - spec/rms_web_service/response/item/parser_spec.rb
215
219
  - spec/rms_web_service/response/item/search_spec.rb
216
220
  - spec/rms_web_service/response/item/status_spec.rb
217
221
  - spec/rms_web_service/response/item/update_spec.rb