rees46 0.0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/Guardfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +72 -0
- data/Rakefile +8 -0
- data/lib/rees46/configuration.rb +19 -0
- data/lib/rees46/not_configured_error.rb +4 -0
- data/lib/rees46/recommender.rb +38 -0
- data/lib/rees46/requester.rb +43 -0
- data/lib/rees46/tracker.rb +48 -0
- data/lib/rees46/version.rb +3 -0
- data/lib/rees46.rb +28 -0
- data/rees46.gemspec +31 -0
- data/spec/rees46/recommender_spec.rb +29 -0
- data/spec/rees46/tracker_spec.rb +77 -0
- data/spec/rees46_spec.rb +43 -0
- data/spec/spec_helper.rb +39 -0
- data/spec/workflow_spec.rb +18 -0
- metadata +196 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b251633a47ec300432c4e03b4dda9bebf8c09285
|
4
|
+
data.tar.gz: 1b793605c8b0bb8d034cc0530ad460031799b5e8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cc500a2eacd29bf9f72aee4920b79ce2f5daf287d053632800c37160bc9dcf60032cf4f7d8a25e014b8735100de3c416dc3268a3cc0c856a7ac355ec5b0b7053
|
7
|
+
data.tar.gz: 082e61ade5c57fc60d655f11b9459697647fa3e67ce7ffd84f80a1ef3ba8f264932bba7e4354b5c54e75e0343da0376355626212511223b174cf3b9993c8c898
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color --format=doc
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard :rspec, cmd: 'clear && bundle exec rspec' do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
end
|
9
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Anton Zhavoronkov
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# REES46
|
2
|
+
|
3
|
+
Гем для отправки событий и приема рекомедаций
|
4
|
+
|
5
|
+
## Установка
|
6
|
+
|
7
|
+
```
|
8
|
+
gem 'rees46'
|
9
|
+
```
|
10
|
+
```
|
11
|
+
bundle
|
12
|
+
```
|
13
|
+
|
14
|
+
## Инициализация
|
15
|
+
|
16
|
+
В первую очередь необходимо инициализировать модуль:
|
17
|
+
```ruby
|
18
|
+
REES46.configure do |config|
|
19
|
+
config.shop_id = "КОД_ВАШЕГО_МАГАЗИНА"
|
20
|
+
config.user_id = ID_ТЕКУЩЕГО_ПОЛЬЗОВАТЕЛЯ
|
21
|
+
config.session_id = "ID_СЕССИИ_ТЕКУЩЕГО_ПОЛЬЗОВАТЕЛЯ"
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
```shop_id``` - обязательный параметр
|
26
|
+
|
27
|
+
После процесса инициализации необходимо связать пользователя (в том числе анонимного) со сгенерированным ID сессии (например, сохранить в локальное хранилище приложения), а затем передавать его в конфигурацию при последующем использовании:
|
28
|
+
|
29
|
+
```
|
30
|
+
ваш_метод_сохранения_id_сессии(REES46.config.session_id)
|
31
|
+
```
|
32
|
+
|
33
|
+
## Отслеживание событий
|
34
|
+
|
35
|
+
Все действия необходимо производить только после инициализации модуля.
|
36
|
+
|
37
|
+
### Просмотр:
|
38
|
+
```ruby
|
39
|
+
REES46::Tracker.view(item: { item_id: 5, price: 1499.99, is_available: true })
|
40
|
+
```
|
41
|
+
|
42
|
+
### Добавление в корзину
|
43
|
+
```ruby
|
44
|
+
REES46::Tracker.cart(item: { item_id: 5, price: 1499.99, is_available: true })
|
45
|
+
```
|
46
|
+
|
47
|
+
### Удаление из корзины
|
48
|
+
```ruby
|
49
|
+
REES46::Tracker.remove_from_cart(item: { item_id: 5, price: 1499.99, is_available: true })
|
50
|
+
```
|
51
|
+
|
52
|
+
### Покупка
|
53
|
+
```ruby
|
54
|
+
REES46::Tracker.purchase(items: [{ item_id: 5, price: 1499.99, is_available: true, amount: 1 }, { item_id: 1, price: 50, is_available: true, amount: 5}], order_id: 25)
|
55
|
+
```
|
56
|
+
|
57
|
+
### Оценка
|
58
|
+
```ruby
|
59
|
+
REES46::Tracker.rate(item: { item_id: 5, price: 1499.99, is_available: true }, rating: 5)
|
60
|
+
```
|
61
|
+
|
62
|
+
## Запрос рекомендаций
|
63
|
+
|
64
|
+
Все действия необходимо производить только после инициализации модуля.
|
65
|
+
Запросы возвращают массив ID товаров.
|
66
|
+
|
67
|
+
### Вас это заинтересует
|
68
|
+
```ruby
|
69
|
+
REES46::Recommender.interesting(item: 4291, cart: [2,5,6])
|
70
|
+
```
|
71
|
+
```item``` - опциональный параметр, означает текущий просматриваемый товар.
|
72
|
+
```cart``` - опциональный параметр, означает текущее содержимое корзины.
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module REES46
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :shop_id
|
4
|
+
attr_accessor :user_id
|
5
|
+
attr_accessor :session_id
|
6
|
+
|
7
|
+
def configured?
|
8
|
+
shop_id.present? && session_id.present?
|
9
|
+
end
|
10
|
+
|
11
|
+
def finalize
|
12
|
+
assign_session_id if session_id.blank?
|
13
|
+
end
|
14
|
+
|
15
|
+
def assign_session_id
|
16
|
+
@session_id = REES46::Requester.generate_ssid(shop_id: @shop_id)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module REES46
|
2
|
+
class Recommender
|
3
|
+
RECOMMENDER_TYPES = [:interesting, :also_bought, :similar, :popular, :see_also, :recently_viewed, :buying_now]
|
4
|
+
|
5
|
+
class << self
|
6
|
+
RECOMMENDER_TYPES.each do |recommender_type|
|
7
|
+
define_method recommender_type do |params = {}|
|
8
|
+
recommend(recommender_type, params)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def recommend(recommender_type, params)
|
13
|
+
result = REES46::Requester.recommend(normalize(params, recommender_type))
|
14
|
+
|
15
|
+
if result.code == 200
|
16
|
+
return result.to_a
|
17
|
+
else
|
18
|
+
return []
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def normalize(params, recommender_type)
|
23
|
+
result = params.dup
|
24
|
+
result = result.merge(recommender_type: recommender_type)
|
25
|
+
|
26
|
+
if params[:cart].present?
|
27
|
+
params[:cart].each_with_index do |cart_id, i|
|
28
|
+
result["cart[#{i}]"] = cart_id
|
29
|
+
end
|
30
|
+
|
31
|
+
result.delete(:cart)
|
32
|
+
end
|
33
|
+
|
34
|
+
result
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'timeout'
|
3
|
+
|
4
|
+
module REES46
|
5
|
+
class Requester
|
6
|
+
HOST = 'http://api.rees46.com'
|
7
|
+
TIMEOUT = 2
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def recommend(params)
|
11
|
+
request('recommend', :get, params)
|
12
|
+
end
|
13
|
+
|
14
|
+
def push(params)
|
15
|
+
request('push', :post, params)
|
16
|
+
end
|
17
|
+
|
18
|
+
def generate_ssid(params)
|
19
|
+
request('generate_ssid', :get, params)
|
20
|
+
end
|
21
|
+
|
22
|
+
def request(path, method, params)
|
23
|
+
result = nil
|
24
|
+
|
25
|
+
merged_params = params.merge(shop_id: REES46.configuration.shop_id, ssid: REES46.configuration.session_id, user_id: REES46.configuration.user_id)
|
26
|
+
|
27
|
+
begin
|
28
|
+
Timeout::timeout(TIMEOUT) do
|
29
|
+
result = if method == :get
|
30
|
+
HTTParty.get("#{HOST}/#{path}", query: merged_params)
|
31
|
+
else
|
32
|
+
HTTParty.post("#{HOST}/#{path}", body: merged_params)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
rescue Timeout::Error => e
|
36
|
+
puts 'REES46 is currently unavailable'
|
37
|
+
end
|
38
|
+
|
39
|
+
result
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module REES46
|
2
|
+
class Tracker
|
3
|
+
EVENT_TYPES = [:view, :cart, :remove_from_cart, :purchase, :rate]
|
4
|
+
ITEM_ATTRIBUTES = [:item_id, :price, :is_available, :category, :locations, :name, :description, :url, :image_url, :tags]
|
5
|
+
|
6
|
+
class << self
|
7
|
+
EVENT_TYPES.each do |event_type|
|
8
|
+
define_method event_type do |arguments|
|
9
|
+
track(event_type, arguments)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def track(event_type, arguments)
|
14
|
+
raise REES46::NotConfiguredError.new('REES46 should be configured first') unless REES46.configured?
|
15
|
+
|
16
|
+
resp = REES46::Requester.push(normalize(arguments, event_type))
|
17
|
+
if resp.code == 500
|
18
|
+
puts "REES46: Oops, something gone wrong"
|
19
|
+
else
|
20
|
+
resp.parsed_response
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def normalize(arguments, event_type)
|
25
|
+
result = arguments.dup
|
26
|
+
result[:event] = event_type.to_s
|
27
|
+
|
28
|
+
if result[:item].present?
|
29
|
+
result[:item].each do |key, value|
|
30
|
+
result["#{key}[0]"] = value
|
31
|
+
end
|
32
|
+
result.delete(:item)
|
33
|
+
end
|
34
|
+
|
35
|
+
if result[:items].present?
|
36
|
+
result[:items].each_with_index do |item, i|
|
37
|
+
item.each do |key, value|
|
38
|
+
result["#{key}[#{i}]"] = value
|
39
|
+
end
|
40
|
+
end
|
41
|
+
result.delete(:items)
|
42
|
+
end
|
43
|
+
|
44
|
+
result
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/rees46.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'active_support/core_ext/object/blank'
|
2
|
+
require 'rees46/configuration'
|
3
|
+
require 'rees46/tracker'
|
4
|
+
require 'rees46/requester'
|
5
|
+
require 'rees46/recommender'
|
6
|
+
require 'rees46/version'
|
7
|
+
require 'rees46/not_configured_error'
|
8
|
+
|
9
|
+
module REES46
|
10
|
+
HOST = 'http://api.rees46.com'
|
11
|
+
|
12
|
+
class << self
|
13
|
+
attr_writer :configuration
|
14
|
+
|
15
|
+
def configure
|
16
|
+
yield configuration
|
17
|
+
configuration.finalize
|
18
|
+
end
|
19
|
+
|
20
|
+
def configured?
|
21
|
+
configuration.configured?
|
22
|
+
end
|
23
|
+
|
24
|
+
def configuration
|
25
|
+
@configuration ||= Configuration.new
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/rees46.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rees46/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "rees46"
|
8
|
+
s.version = REES46::VERSION
|
9
|
+
s.authors = ["Anton Zhavoronkov"]
|
10
|
+
s.email = ["anton.zhavoronkov@gmail.com"]
|
11
|
+
s.summary = %q{Библиотека для работы с REES46}
|
12
|
+
s.description = %q{Библиотека для работы с REES46: отправка событий и запрос рекомендаций}
|
13
|
+
s.homepage = "https://github.com/rees46/rees46-ruby/"
|
14
|
+
s.license = "MIT"
|
15
|
+
|
16
|
+
s.files = `git ls-files -z`.split("\x0")
|
17
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_dependency 'httparty', '~> 0.13'
|
22
|
+
s.add_dependency 'activesupport', '~> 0'
|
23
|
+
|
24
|
+
s.add_development_dependency 'bundler', '~> 1.6'
|
25
|
+
s.add_development_dependency 'rake', '~> 10.3'
|
26
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
27
|
+
s.add_development_dependency 'webmock', '~> 1.18'
|
28
|
+
s.add_development_dependency 'guard', '~> 2.6'
|
29
|
+
s.add_development_dependency 'guard-rspec', '~> 4.2'
|
30
|
+
s.add_development_dependency 'pry', '~> 0.10'
|
31
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rees46'
|
3
|
+
|
4
|
+
describe REES46::Recommender do
|
5
|
+
it 'has an array of all possible recommenders' do
|
6
|
+
expect(REES46::Recommender::RECOMMENDER_TYPES).to be_an(Array)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'has a method shortcut for each recommender type' do
|
10
|
+
REES46::Recommender::RECOMMENDER_TYPES.each do |recommender_type|
|
11
|
+
expect(REES46::Recommender).to respond_to(recommender_type)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'interesting' do
|
16
|
+
before do
|
17
|
+
REES46.configure do |config|
|
18
|
+
config.shop_id = test_shop_id
|
19
|
+
config.user_id = test_user_id
|
20
|
+
config.session_id = test_session_id
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'sends request' do
|
25
|
+
REES46::Recommender.interesting(item_id: 25, limit: 10, category: 25, locations: '5,123,91', cart: [25, 1, 4])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rees46'
|
3
|
+
|
4
|
+
describe REES46::Tracker do
|
5
|
+
it 'has an array constant of event types' do
|
6
|
+
expect(REES46::Tracker::EVENT_TYPES).to be_an(Array)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'has a method shortcut for each event type' do
|
10
|
+
REES46::Tracker::EVENT_TYPES.each do |event_type|
|
11
|
+
expect(REES46::Tracker).to respond_to(event_type)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'has an array if all possible item attibutes' do
|
16
|
+
expect(REES46::Tracker::ITEM_ATTRIBUTES).to be_an(Array)
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '.track' do
|
20
|
+
it 'raises error if module is not configured' do
|
21
|
+
expect {
|
22
|
+
REES46::Tracker.track(:view, {})
|
23
|
+
}.to raise_error(REES46::NotConfiguredError)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'events' do
|
28
|
+
before do
|
29
|
+
REES46.configure do |config|
|
30
|
+
config.shop_id = test_shop_id
|
31
|
+
config.user_id = test_user_id
|
32
|
+
config.session_id = test_session_id
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '.view' do
|
37
|
+
it 'sends request' do
|
38
|
+
REES46::Tracker.view(item: { item_id: 1, price: 1500.25, available: true, category: 15 })
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '.cart' do
|
43
|
+
it 'sends request' do
|
44
|
+
REES46::Tracker.cart(item: { item_id: 1, price: 1500.25, available: true, category: 15 })
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '.remove_from_cart' do
|
49
|
+
it 'sends request' do
|
50
|
+
REES46::Tracker.remove_from_cart(item: { item_id: 1, price: 1500.25, available: true, category: 15 })
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '.purchase' do
|
55
|
+
it 'sends request' do
|
56
|
+
items_info = [
|
57
|
+
{
|
58
|
+
item_id: 1,
|
59
|
+
price: 1500,
|
60
|
+
available: true,
|
61
|
+
category: 15,
|
62
|
+
amount: 5
|
63
|
+
},
|
64
|
+
{
|
65
|
+
item_id: 2,
|
66
|
+
price: 300,
|
67
|
+
available: true,
|
68
|
+
category: 2,
|
69
|
+
amount: 1
|
70
|
+
}
|
71
|
+
]
|
72
|
+
|
73
|
+
REES46::Tracker.purchase(items: items_info, order_id: 25)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/spec/rees46_spec.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rees46'
|
3
|
+
|
4
|
+
describe REES46 do
|
5
|
+
describe '.configure' do
|
6
|
+
it 'stores shop_id' do
|
7
|
+
REES46.configure do |config|
|
8
|
+
config.shop_id = test_shop_id
|
9
|
+
end
|
10
|
+
|
11
|
+
expect(REES46.configuration.shop_id).to eq(test_shop_id)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'stores user_id' do
|
15
|
+
REES46.configure do |config|
|
16
|
+
config.session_id = test_session_id
|
17
|
+
config.user_id = test_user_id
|
18
|
+
end
|
19
|
+
|
20
|
+
expect(REES46.configuration.user_id).to eq(test_user_id)
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when session_id is provided' do
|
24
|
+
it 'stores session_id' do
|
25
|
+
REES46.configure do |config|
|
26
|
+
config.session_id = test_session_id
|
27
|
+
end
|
28
|
+
|
29
|
+
expect(REES46.configuration.session_id).to eq(test_session_id)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when session_id is not provided' do
|
34
|
+
it 'requests session_id from api' do
|
35
|
+
REES46.configure do |config|
|
36
|
+
config.shop_id = test_shop_id
|
37
|
+
end
|
38
|
+
|
39
|
+
expect(REES46.configuration.session_id).to be_present
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'webmock/rspec'
|
3
|
+
|
4
|
+
def test_shop_id
|
5
|
+
'5bb5e4e023d775b1e6c3206758a206c6'
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_session_id
|
9
|
+
'ea4c1fe1ae6c155195274161d1dcf695'
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_user_id
|
13
|
+
46
|
14
|
+
end
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.raise_errors_for_deprecations!
|
18
|
+
config.order = 'random'
|
19
|
+
|
20
|
+
config.before :each do
|
21
|
+
stub_request(:get, "http://api.rees46.com/generate_ssid?shop_id=#{test_shop_id}&ssid=&user_id=").
|
22
|
+
to_return(:status => 200, :body => "#{test_session_id}", :headers => {})
|
23
|
+
|
24
|
+
['view', 'cart', 'remove_from_cart'].each do |event|
|
25
|
+
stub_request(:post, "http://api.rees46.com/push").
|
26
|
+
with(:body => "event=#{event}&item_id[0]=1&price[0]=1500.25&available[0]=true&category[0]=15&shop_id=5bb5e4e023d775b1e6c3206758a206c6&ssid=ea4c1fe1ae6c155195274161d1dcf695&user_id=46").
|
27
|
+
to_return(:status => 200, :body => "", :headers => {})
|
28
|
+
end
|
29
|
+
|
30
|
+
stub_request(:post, "http://api.rees46.com/push").
|
31
|
+
with(:body => "order_id=25&event=purchase&item_id[0]=1&price[0]=1500&available[0]=true&category[0]=15&amount[0]=5&item_id[1]=2&price[1]=300&available[1]=true&category[1]=2&amount[1]=1&shop_id=5bb5e4e023d775b1e6c3206758a206c6&ssid=ea4c1fe1ae6c155195274161d1dcf695&user_id=46").
|
32
|
+
to_return(:status => 200, :body => "", :headers => {})
|
33
|
+
|
34
|
+
stub_request(:get, "http://api.rees46.com/recommend?cart%5B0%5D=25&cart%5B1%5D=1&cart%5B2%5D=4&category=25&item_id=25&limit=10&locations=5,123,91&recommender_type=interesting&shop_id=5bb5e4e023d775b1e6c3206758a206c6&ssid=ea4c1fe1ae6c155195274161d1dcf695&user_id=46").
|
35
|
+
to_return(:status => 200, :body => "", :headers => {})
|
36
|
+
|
37
|
+
REES46.configuration = nil
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rees46'
|
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
|
10
|
+
end
|
11
|
+
|
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: {})
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rees46
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anton Zhavoronkov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.13'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.18'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.18'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.6'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.6'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '4.2'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '4.2'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.10'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.10'
|
139
|
+
description: "Библиотека для работы с REES46: отправка событий и запрос рекомендаций"
|
140
|
+
email:
|
141
|
+
- anton.zhavoronkov@gmail.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".gitignore"
|
147
|
+
- ".rspec"
|
148
|
+
- Gemfile
|
149
|
+
- Guardfile
|
150
|
+
- LICENSE.txt
|
151
|
+
- README.md
|
152
|
+
- Rakefile
|
153
|
+
- lib/rees46.rb
|
154
|
+
- lib/rees46/configuration.rb
|
155
|
+
- lib/rees46/not_configured_error.rb
|
156
|
+
- lib/rees46/recommender.rb
|
157
|
+
- lib/rees46/requester.rb
|
158
|
+
- lib/rees46/tracker.rb
|
159
|
+
- lib/rees46/version.rb
|
160
|
+
- rees46.gemspec
|
161
|
+
- spec/rees46/recommender_spec.rb
|
162
|
+
- spec/rees46/tracker_spec.rb
|
163
|
+
- spec/rees46_spec.rb
|
164
|
+
- spec/spec_helper.rb
|
165
|
+
- spec/workflow_spec.rb
|
166
|
+
homepage: https://github.com/rees46/rees46-ruby/
|
167
|
+
licenses:
|
168
|
+
- MIT
|
169
|
+
metadata: {}
|
170
|
+
post_install_message:
|
171
|
+
rdoc_options: []
|
172
|
+
require_paths:
|
173
|
+
- lib
|
174
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
|
+
requirements:
|
181
|
+
- - ">="
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: '0'
|
184
|
+
requirements: []
|
185
|
+
rubyforge_project:
|
186
|
+
rubygems_version: 2.2.2
|
187
|
+
signing_key:
|
188
|
+
specification_version: 4
|
189
|
+
summary: "Библиотека для работы с REES46"
|
190
|
+
test_files:
|
191
|
+
- spec/rees46/recommender_spec.rb
|
192
|
+
- spec/rees46/tracker_spec.rb
|
193
|
+
- spec/rees46_spec.rb
|
194
|
+
- spec/spec_helper.rb
|
195
|
+
- spec/workflow_spec.rb
|
196
|
+
has_rdoc:
|