rees46 0.0.1.2 → 0.0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b251633a47ec300432c4e03b4dda9bebf8c09285
4
- data.tar.gz: 1b793605c8b0bb8d034cc0530ad460031799b5e8
3
+ metadata.gz: 36e3efd1ab3953c01cd2d2ea9f82fce9035ef679
4
+ data.tar.gz: c0158a1f2f3f5a5f68faa45fa8c89144d3c2c577
5
5
  SHA512:
6
- metadata.gz: cc500a2eacd29bf9f72aee4920b79ce2f5daf287d053632800c37160bc9dcf60032cf4f7d8a25e014b8735100de3c416dc3268a3cc0c856a7ac355ec5b0b7053
7
- data.tar.gz: 082e61ade5c57fc60d655f11b9459697647fa3e67ce7ffd84f80a1ef3ba8f264932bba7e4354b5c54e75e0343da0376355626212511223b174cf3b9993c8c898
6
+ metadata.gz: 5c23f50acb6324d8ba68be37bd08ee4ecdddcde78c3824c2cffc53f9a585f1c59b203fdfa9de1aa7d9074365739580c10643603c3daa7cf8f3383f1fb74f95bd
7
+ data.tar.gz: fa6f00152dc4306ada8c4ac1b71a9cde9b968327933501cbc34318848bb3d4a1b11e57bda92ae1da08924976e46aa45349ad1640560110894680a17ec0f5b906
data/README.md CHANGED
@@ -17,7 +17,7 @@ bundle
17
17
  ```ruby
18
18
  REES46.configure do |config|
19
19
  config.shop_id = "КОД_ВАШЕГО_МАГАЗИНА"
20
- config.user_id = ID_ТЕКУЩЕГО_ПОЛЬЗОВАТЕЛЯ
20
+ config.user_id = "ID_ТЕКУЩЕГО_ПОЛЬЗОВАТЕЛЯ"
21
21
  config.session_id = "ID_СЕССИИ_ТЕКУЩЕГО_ПОЛЬЗОВАТЕЛЯ"
22
22
  end
23
23
  ```
@@ -64,9 +64,47 @@ REES46::Tracker.rate(item: { item_id: 5, price: 1499.99, is_available: true }, r
64
64
  Все действия необходимо производить только после инициализации модуля.
65
65
  Запросы возвращают массив ID товаров.
66
66
 
67
+ Все рекомендеры принимают опциональные параметры:
68
+ ```item``` - означает текущий просматриваемый товар.
69
+
70
+ ```cart``` - означает текущее содержимое корзины.
71
+
72
+ Лучше всего их передавать всегда, это повысит качество рекомендаций.
73
+
74
+
67
75
  ### Вас это заинтересует
68
76
  ```ruby
69
77
  REES46::Recommender.interesting(item: 4291, cart: [2,5,6])
70
78
  ```
71
- ```item``` - опциональный параметр, означает текущий просматриваемый товар.
72
- ```cart``` - опциональный параметр, означает текущее содержимое корзины.
79
+
80
+ ### Популярные
81
+ ```ruby
82
+ REES46::Recommender.popular(category: 256)
83
+ ```
84
+ Здесь передается ID просматриваемой категории. Если не передать этот параметр - будут рекомендации по всем категориям.
85
+
86
+
87
+ ### С этим товаром покупают
88
+ ```ruby
89
+ REES46::Recommender.also_bought(item: 23)
90
+ ```
91
+ В данном случае item - обязательный параметр.
92
+
93
+ ### Посмотрите также
94
+ ```ruby
95
+ REES46::Recommender.see_also(cart: [5, 23])
96
+ ```
97
+ В данном случае cart - обязательный параметр.
98
+
99
+ ### Вы недавно смотрели
100
+ ```ruby
101
+ REES46::Recommender.recently_viewed
102
+ ```
103
+ Не требует дополнительных параметров
104
+
105
+ ### Прямо сейчас покупают
106
+ ```ruby
107
+ REES46::Recommender.buying_now
108
+ ```
109
+
110
+ [Дополнительная информация](http://rees46.com/integration)
@@ -10,6 +10,8 @@ module REES46
10
10
  end
11
11
 
12
12
  def recommend(recommender_type, params)
13
+ raise REES46::NotConfiguredError.new('REES46 should be configured first') unless REES46.configured?
14
+
13
15
  result = REES46::Requester.recommend(normalize(params, recommender_type))
14
16
 
15
17
  if result.code == 200
@@ -1,3 +1,3 @@
1
1
  module REES46
2
- VERSION = "0.0.1.2"
2
+ VERSION = "0.0.2.0"
3
3
  end
data/rees46.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_dependency 'httparty', '~> 0.13'
22
- s.add_dependency 'activesupport', '~> 0'
22
+ s.add_dependency 'activesupport', '> 3'
23
23
 
24
24
  s.add_development_dependency 'bundler', '~> 1.6'
25
25
  s.add_development_dependency 'rake', '~> 10.3'
@@ -1,18 +1,142 @@
1
1
  require 'spec_helper'
2
2
  require 'rees46'
3
3
 
4
- describe 'workflow' do
5
- it 'pushes the event' do
6
- REES46.configure do |c|
7
- c.shop_id = test_shop_id
8
- c.user_id = test_user_id
9
- c.session_id = test_session_id
4
+ describe 'Примеры использования' do
5
+ let(:shop_id) { 'b6ef5e0003904ba8245eb7aac0c286' }
6
+ let(:session_id) { '7b710da8-9b32-4a7b-ba2c-a8f14e635c98' }
7
+ let(:user_id) { 46 }
8
+ before(:each) { WebMock.allow_net_connect! }
9
+
10
+ describe 'Инициализация' do
11
+ context 'ID магазина' do
12
+ it 'Необходимо передавать всегда' do
13
+ REES46.configure do |c|
14
+ c.shop_id = shop_id
15
+ end
16
+
17
+ expect(REES46.configuration.shop_id).to be_present
18
+ end
19
+ end
20
+
21
+ context 'ID сессии' do
22
+ context 'Когда нет' do
23
+ it 'Модуль генерирует ID сессии' do
24
+ REES46.configure do |c|
25
+ c.shop_id = shop_id
26
+ end
27
+
28
+ expect(REES46.configuration.session_id).to be_a(String)
29
+ end
30
+ end
31
+
32
+ context 'Когда есть' do
33
+ it 'Необходимо передать ее в модуль' do
34
+ REES46.configure do |c|
35
+ c.shop_id = shop_id
36
+ c.session_id = session_id
37
+ c.user_id = user_id
38
+ end
39
+
40
+ expect(REES46.configuration.user_id).to be_present
41
+ end
42
+ end
43
+ end
44
+
45
+ context 'ID пользователя' do
46
+ it 'Необходимо передавать в модуль' do
47
+ REES46.configure do |c|
48
+ c.shop_id = shop_id
49
+ c.session_id = session_id
50
+ c.user_id = user_id
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ describe 'Отслеживание событий' do
57
+ it 'Возможно только после инициализации модуля' do
58
+ expect{
59
+ REES46::Tracker.view(item: { item_id: 15 })
60
+ }.to raise_error(REES46::NotConfiguredError)
10
61
  end
11
62
 
12
- # REES46::Tracker.view(item: {})
13
- # REES46::Tracker.cart(item: {})
14
- # REES46::Tracker.cart(item: {})
15
- # REES46::Tracker.remove_from_cart(item: {})
16
- # REES46::Tracker.purchase(items: {})
63
+ context 'Типы событий' do
64
+ before(:each) do
65
+ REES46.configure do |c|
66
+ c.shop_id = shop_id
67
+ c.session_id = session_id
68
+ c.user_id = user_id
69
+ end
70
+ end
71
+
72
+ let(:item1) { { item_id: 5, price: 10_999.99, is_available: true, category: 15 } }
73
+ let(:item2) { { item_id: 39, price: 458.10, is_available: true, category: 4 } }
74
+
75
+ it 'Просмотр товара' do
76
+ expect(REES46::Tracker.view(item: item1)).to eq({'status' => 'success'})
77
+ end
78
+
79
+ it 'Добавление товара в корзину' do
80
+ expect(REES46::Tracker.cart(item: item1)).to eq({'status' => 'success'})
81
+ end
82
+
83
+ it 'Удаление товара из корзины' do
84
+ expect(REES46::Tracker.remove_from_cart(item: item1)).to eq({'status' => 'success'})
85
+ end
86
+
87
+ it 'Покупка' do
88
+ expect(REES46::Tracker.purchase(items: [item1.merge(amount: 2), item2.merge(amount: 5)], order_id: 91)).to eq({'status' => 'success'})
89
+ end
90
+
91
+ it 'Оценка' do
92
+ expect(REES46::Tracker.rate(item: item1, rating: 3)).to eq({'status' => 'success'})
93
+ end
94
+ end
95
+ end
96
+
97
+ describe 'Запрос рекомендаций' do
98
+ it 'Возможен только после инициализации модуля' do
99
+ expect{
100
+ REES46::Recommender.interesting
101
+ }.to raise_error(REES46::NotConfiguredError)
102
+ end
103
+
104
+ context 'Виды рекомендаций' do
105
+ before(:each) do
106
+ REES46.configure do |c|
107
+ c.shop_id = shop_id
108
+ c.session_id = session_id
109
+ c.user_id = user_id
110
+ end
111
+ end
112
+
113
+ it 'Возможно, вас это заинтересует' do
114
+ expect(REES46::Recommender.interesting).to be_an(Array)
115
+ end
116
+
117
+ it 'Популярные товары' do
118
+ expect(REES46::Recommender.popular(category: 4)).to be_an(Array)
119
+ end
120
+
121
+ it 'Вы недавно смотрели' do
122
+ expect(REES46::Recommender.recently_viewed).to be_an(Array)
123
+ end
124
+
125
+ it 'Похожие товары' do
126
+ expect(REES46::Recommender.similar(item: 5)).to be_an(Array)
127
+ end
128
+
129
+ it 'С этим также покупают' do
130
+ expect(REES46::Recommender.also_bought(item: 5)).to be_an(Array)
131
+ end
132
+
133
+ it 'Посмотрите также' do
134
+ expect(REES46::Recommender.see_also(cart: [5, 39])).to be_an(Array)
135
+ end
136
+
137
+ it 'Прямо сейчас покупают' do
138
+ expect(REES46::Recommender.buying_now).to be_an(Array)
139
+ end
140
+ end
17
141
  end
18
142
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rees46
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.2
4
+ version: 0.0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Zhavoronkov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-07 00:00:00.000000000 Z
11
+ date: 2014-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement