rms_web_service 0.1.2 → 0.1.3

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: dd03378f6428937283c1abf606036b9abf6b05f1
4
- data.tar.gz: 6908ae4a258b178e9de8f299c14a46e9deb957d7
3
+ metadata.gz: bea5a6cfaeb3326135eba7ff31a0de5f29db01de
4
+ data.tar.gz: 38abe79fa798d3b18b02557f0bbed6c35ed23543
5
5
  SHA512:
6
- metadata.gz: a244fcf7b47080a365a602e55a0ca661a159f3d171e4db5764b763868e1e3b76dc983361fb4631a645866da6898bfdeb765f54c372d4314d36dd90a0430e5fbd
7
- data.tar.gz: d26ac747de65732ff23bc19e2177f021d8bb8ed0ace736ff563b657a3027cff7af60da56e51534438a7ee9611ee45ef39d79a702aa9848d9f0608bd55ee21a8e
6
+ metadata.gz: eaf09a19cdb735e4ced433208f1a9fdd4874e702849d15ebf165ce9501052c75fac60f37329afcdde0095b98c79fd4a9bfbd9a8573e742a480e267d006e72383
7
+ data.tar.gz: 5d16a89e1bdf89fe84dc3d2e875cfbf0df2707b29245015b8905a93377dba70d65ecfb1490348bf3b0822f110cb49f6f78eb051028cd1e348d8412d1ae8ba3bc
data/README.md CHANGED
@@ -39,18 +39,18 @@ client = RmsWebService::Client::Item.new(service_secret: "dummy_service_secret",
39
39
 
40
40
  ### RmsWebService::Client::Item
41
41
 
42
- RmsWebService::Client::ItemのインスタンスがAPIの各メソッドを持っています。パラメータを渡す場合はハッシュ、複数のItemを渡す場合は配列を使用します。
42
+ RmsWebService::Client::ItemのインスタンスがAPIの各メソッドを持っています。各メソッドへのパラメータの渡し方は下記の通りです。
43
43
 
44
44
  ```ruby
45
- # item.get
46
- item = client.get(:item_url => "ed-60c-w")
45
+ item = client.get("ed-60c-w")
47
46
  # '.item_name'、'.item_price'等のメソッドを持ちます。属性については公式ドキュメントを見てください。
48
47
 
49
- # item.update
48
+ item = client.delete("test001")
49
+ # '.success?'で成功したかどうかを判別できます。'.errors'でエラー内容を確認できます。
50
+
50
51
  item = client.update({:item_url => "ed-60c-w", :item_price => 43800})
51
52
  # '.success?'で成功したかどうかを判別できます。'.errors'でエラー内容を確認できます。
52
53
 
53
- # item.insert
54
54
  item = client.insert({
55
55
  :item_url => "test001",
56
56
  :item_name => "test001",
@@ -59,15 +59,9 @@ item = client.insert({
59
59
  })
60
60
  # '.success?'で成功したかどうかを判別できます。'.errors'でエラー内容を確認できます。
61
61
 
62
- # item.delete
63
- item = client.delete(:item_url => "test001")
64
- # '.success?'で成功したかどうかを判別できます。'.errors'でエラー内容を確認できます。
65
-
66
- # item.search
67
62
  items = client.search(:item_name => "空気清浄機")
68
63
  # item.getと同じ性質のインスタンスを要素として持つ配列を返します
69
64
 
70
- # items.update
71
65
  items = client.items_update([
72
66
  {:item_url => "ed-60c-w", :item_price => 43800},
73
67
  {:item_url => "noexist", :item_price => 10800}
@@ -11,6 +11,7 @@ module RmsWebService
11
11
 
12
12
  def initialize(args={})
13
13
  @configuration = ::RmsWebService::Configuration.new(args)
14
+ @endpoint = args[:endpoint]
14
15
  end
15
16
 
16
17
  def connection(method)
@@ -21,11 +22,11 @@ module RmsWebService
21
22
  end
22
23
 
23
24
  def endpoint(method)
24
- return Endpoint + method
25
+ @endpoint || Endpoint + method
25
26
  end
26
27
 
27
- def get(args)
28
- request = connection('item/get').get {|req| req.params['itemUrl'] = args[:item_url]}
28
+ def get(item_url)
29
+ request = connection('item/get').get {|req| req.params['itemUrl'] = item_url }
29
30
  return ::RmsWebService::Response::Item::Get.new(request.body)
30
31
  end
31
32
 
@@ -59,12 +60,12 @@ module RmsWebService
59
60
  return ::RmsWebService::Response::Item::Update.new(request.body)
60
61
  end
61
62
 
62
- def delete(args)
63
+ def delete(item_url)
63
64
  xml_object = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
64
65
  xml.request do
65
66
  xml.itemDeleteRequest do
66
67
  xml.item do
67
- args.each {|key, value| eval("xml.#{key.to_s.camelize(:lower)} '#{value}'")}
68
+ xml.itemUrl item_url
68
69
  end
69
70
  end
70
71
  end
@@ -1,3 +1,3 @@
1
1
  module RmsWebService
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -5,6 +5,8 @@ describe RmsWebService::Client::Item do
5
5
  subject(:client) {described_class.new(:service_secret => service_secret, :license_key => license_key)}
6
6
  let(:service_secret) {'dummy_service_secret'}
7
7
  let(:license_key) {'dummy_license_key'}
8
+ let(:default_url) {"https://api.rms.rakuten.co.jp/es/1.0/"}
9
+ let(:specified_url) {"https://example.com/"}
8
10
 
9
11
  describe '.new' do
10
12
  it { is_expected.to be_a RmsWebService::Client::Item }
@@ -20,12 +22,24 @@ describe RmsWebService::Client::Item do
20
22
  it { is_expected.to be_a Faraday::Connection }
21
23
  end
22
24
 
25
+ describe '.endpoint' do
26
+ context 'default URL' do
27
+ subject {client.endpoint("item/get")}
28
+ it { is_expected.to eq default_url + "item/get"}
29
+ end
30
+ context 'specify URL' do
31
+ let(:api) {described_class.new(:service_secret => service_secret, :license_key => license_key, :endpoint => specified_url)}
32
+ subject {api.endpoint("item/get")}
33
+ it { is_expected.to eq specified_url}
34
+ end
35
+ end
36
+
23
37
  describe '.get' do
24
38
  before do
25
39
  stub_request(:get, "https://api.rms.rakuten.co.jp/es/1.0/item/get?itemUrl=test001")
26
40
  .to_return(:status => 200, body: fixture('get.xml'))
27
41
  end
28
- subject {client.get(:item_url => 'test001')}
42
+ subject {client.get('test001')}
29
43
  it {is_expected.to be_a RWS::Response::Item::Get}
30
44
  end
31
45
 
@@ -34,7 +48,7 @@ describe RmsWebService::Client::Item do
34
48
  stub_request(:post, "https://api.rms.rakuten.co.jp/es/1.0/item/delete")
35
49
  .to_return(:status => 200, body: fixture('delete.xml'))
36
50
  end
37
- subject {client.delete(:item_url => 'test001')}
51
+ subject {client.delete('test001')}
38
52
  it {is_expected.to be_a RWS::Response::Item::Delete}
39
53
  end
40
54
 
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.2
4
+ version: 0.1.3
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-15 00:00:00.000000000 Z
11
+ date: 2014-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday