rakuten_web_service 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjUzYzEwODZhZmIwNGNhODVjNTE0NWEwZjk5ZGEwMGU5OGRjYWYwOA==
4
+ MTQ4NTc2ZGU1NWYxM2EzYjdhYmY0ZmRkMzE3YTQzMDQ2MDY1MmM5ZQ==
5
5
  data.tar.gz: !binary |-
6
- MzlkMjI0MGM3MzU4NTQ4NWQ1Y2VkN2EyMjdjMzVlNzA1NTM4YWVlYQ==
6
+ MjM5N2E1NThiNGZlMTViNTUwMTg5NDE3ZjE3YjRkNGZjOGViYmQxZQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MjliYzdiZGJiYjBkOTA2M2I0ZjNmN2FkNDYwZmYyY2E5ZmQ2MmY4OTIzN2Nh
10
- MGQzMDUxMjQ0NGZhMDAxYmVjMzlmM2JhODE1OWU5NWQ4NmI4ZWJlNTkxZDI0
11
- MjE1MDUwYzRmOGY2YzUyNjg5ZGYzMWZjMjk5NWFmNGZiNGZkMWQ=
9
+ Y2YxNmMyNzBlZWNlNWY3ZTk1ODQxMjNiN2I2ZjliMTBmYmM5NTJiOGM0ZTAx
10
+ ZmViYzJlNDc4MWQ4M2MyODM4N2NiYzczMTJiYTc4Y2JmOWE3YmU4YjVjZWYy
11
+ NGMxNWFiMDdmNjhjMzNiYWEzMDAyNjM5YTY5ZWY0Yjc4M2VkYTU=
12
12
  data.tar.gz: !binary |-
13
- MzQzOTM1MDY4NDM3ZmRiYzI2ZTRkYzcxOWQ1ZWUwZGNjMzRhNzUyYmI4MDQ4
14
- ODc4MDRmNmJiMDFhMzliMWUyNTgyZDNmNDFkYzYxNTFiZTVmODIxYzAyOWU1
15
- YWE1MGZlYTZlNWM5MGQzOTM3ZDEwMWMzYmVlNDFlZWRjNzNkMzM=
13
+ YjI1ZmU1YzIzMWVhNDFlYTAyMzAwMjA5MTQ1N2U2NjNmNjU3ODUxNjExOTc3
14
+ ZjE3OWIyN2FjOTg3NmYzZTI1OTY1ZDA5MWU0Y2FiN2I2YzEyNDExZDc2ZDJh
15
+ YWYxNmZkNDFjYjdkNjM2N2M5NDY2YjMyMzRiZmY2YzIzOGEzYjg=
@@ -5,7 +5,18 @@ module RakutenWebService
5
5
 
6
6
  class << self
7
7
  def parse_response(response)
8
- [Genre.new(response['current'])]
8
+ current = response['current']
9
+ if children = response['children']
10
+ children = children.map { |child| Genre.new(child['child']) }
11
+ current.merge!('children' => children)
12
+ end
13
+ if parents = response['parents']
14
+ parents = parents.map { |parent| Genre.new(parent['parent']) }
15
+ current.merge!('parents' => parents)
16
+ end
17
+
18
+ genre = Genre.new(current)
19
+ [genre]
9
20
  end
10
21
 
11
22
  def new(params)
@@ -41,6 +52,11 @@ module RakutenWebService
41
52
  def ranking(options={})
42
53
  RakutenWebService::Ichiba::RankingItem.search(:genre_id => self.id)
43
54
  end
55
+
56
+ def children
57
+ return @params['children'] if @params['children']
58
+ Genre.search(:genre_id => self.id).first.children
59
+ end
44
60
  end
45
61
  end
46
62
  end
@@ -1,3 +1,3 @@
1
1
  module RakutenWebService
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -79,9 +79,11 @@ describe RakutenWebService::Ichiba::Genre do
79
79
  :affiliateId => affiliate_id,
80
80
  :applicationId => application_id,
81
81
  :genreId => new_genre_id }).
82
- to_return(:body => { :genreId => new_genre_id,
83
- :genreName => 'DummyGenre',
84
- :genreLevel => 3 }.to_json)
82
+ to_return(:body => {:current =>
83
+ { :genreId => new_genre_id,
84
+ :genreName => 'DummyGenre',
85
+ :genreLevel => 3 }
86
+ }.to_json)
85
87
 
86
88
  @genre = RakutenWebService::Ichiba::Genre.new(new_genre_id)
87
89
  end
@@ -104,6 +106,40 @@ describe RakutenWebService::Ichiba::Genre do
104
106
  end
105
107
  end
106
108
 
109
+ describe '#children' do
110
+ let(:root_genre) { RakutenWebService::Ichiba::Genre.new(genre_id) }
111
+
112
+ subject { root_genre.children }
113
+
114
+ specify 'children respond genres under the specified genre' do
115
+ expect(root_genre.children.size).to eq(expected_json['children'].size)
116
+ end
117
+
118
+ context 'when children of the genre have not been fetched' do
119
+ let(:target_genre) { expected_json['children'].first['child'] }
120
+
121
+ before do
122
+ @additional_request = stub_request(:get, endpoint).
123
+ with(:query => {
124
+ :affiliateId => affiliate_id,
125
+ :applicationId => application_id,
126
+ :genreId => target_genre['genreId']
127
+ }).to_return(:body => {
128
+ :current => target_genre,
129
+ :children => []
130
+ }.to_json)
131
+ end
132
+
133
+ subject { root_genre.children.first }
134
+
135
+ specify 'should call ' do
136
+ expect(subject.children.size).to eq(0)
137
+ expect(@additional_request).to have_been_made
138
+ end
139
+
140
+ end
141
+ end
142
+
107
143
  describe '#ranking' do
108
144
  let(:genre) { RakutenWebService::Ichiba::Genre.new(genre_id) }
109
145
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rakuten_web_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tatsuya Sato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-22 00:00:00.000000000 Z
11
+ date: 2013-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday