affilinet 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 +4 -4
- data/.rspec +1 -0
- data/README.md +54 -2
- data/lib/affilinet.rb +6 -0
- data/lib/affilinet/category.rb +6 -0
- data/lib/affilinet/client.rb +10 -39
- data/lib/affilinet/fluent_interface.rb +62 -0
- data/lib/affilinet/middleware/mash.rb +24 -2
- data/lib/affilinet/product.rb +6 -0
- data/lib/affilinet/property.rb +6 -0
- data/lib/affilinet/search.rb +16 -0
- data/lib/affilinet/shop.rb +6 -0
- data/lib/affilinet/version.rb +1 -1
- data/spec/cassettes/Affilinet_Client/initialized_with_credentials/_categories/returns_a_Affilinet_Middleware_Mash.yml +2 -2
- data/spec/cassettes/Affilinet_Client/initialized_with_credentials/_products/returns_a_Affilinet_Middleware_Mash.yml +14 -10
- data/spec/cassettes/Affilinet_Client/initialized_with_credentials/_properties/returns_a_Affilinet_Middleware_Mash.yml +11 -7
- data/spec/cassettes/Affilinet_Client/initialized_with_credentials/_search/returns_a_Affilinet_Middleware_Mash.yml +34 -30
- data/spec/cassettes/Affilinet_Client/initialized_with_credentials/_shops/returns_a_Affilinet_Middleware_Mash.yml +10 -14
- data/spec/cassettes/Affilinet_Client/initialized_with_credentials/raises_Faraday_Error_ParsingError_on_wrong_API_requests.yml +12 -8
- data/spec/lib/affilinet/category_spec.rb +12 -0
- data/spec/lib/affilinet/client_spec.rb +65 -0
- data/spec/lib/affilinet/middleware/mash.rb +31 -0
- data/spec/lib/affilinet/product_spec.rb +19 -0
- data/spec/lib/affilinet/property_spec.rb +12 -0
- data/spec/lib/affilinet/search_spec.rb +12 -0
- data/spec/lib/affilinet/shop_spec.rb +63 -0
- metadata +23 -10
- data/spec/cassettes/Affilinet_Client/initialized_with_credentials/_categories/performs_the_GET_request_to_the_correct_endpoint.yml +0 -46
- data/spec/cassettes/Affilinet_Client/initialized_with_credentials/categories/performs_the_GET_request_to_the_correct_endpoint.yml +0 -50
- data/spec/cassettes/Affilinet_Client/initialized_with_credentials/raises_Error_on_wrong_API_requests.yml +0 -37
- data/spec/lib/client_spec.rb +0 -98
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7046a31b5e99b7642286a9dbbb0c55f3575aa7a
|
4
|
+
data.tar.gz: dfcd4458b152850d17edd06fd9530c6fa597e9ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bdb7204a9ed7dc55f59fe4abada90b64bbef31dfa60a7d3d901f87e98d1a309755be4b055949805fb5609f2af6786eeaa7631dac3c4fc97f4bc307e30edfc4d
|
7
|
+
data.tar.gz: 785a715cb561e45d1ccc799c45633527e7049386e9a0761b3568a80398cf453844e9db2cf8adce2830489819905d99f9fc50779a9b4bf790d931151b438fc049
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Affilinet
|
2
2
|
|
3
|
-
|
3
|
+
Alpha version of a gem to access the [Affilinet](http://affili.net) JSON API.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,7 +18,59 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
Examples replicating the instructions on the [API Description](http://developer.affili.net/desktopdefault.aspx/tabid-110/178_read-845)
|
22
|
+
|
23
|
+
### Basic setup
|
24
|
+
|
25
|
+
````ruby
|
26
|
+
require 'affilinet'
|
27
|
+
|
28
|
+
client = Affilinet::Client.new publisher_id: 580442, password: '1TuKEGkOJJ24dN07ByOy'
|
29
|
+
````
|
30
|
+
|
31
|
+
### Search products
|
32
|
+
|
33
|
+
````ruby
|
34
|
+
result = client.search.query('jeans').all
|
35
|
+
|
36
|
+
# > result.products.first.brand
|
37
|
+
# => "Meat of the Room"
|
38
|
+
````
|
39
|
+
|
40
|
+
### Get Products
|
41
|
+
|
42
|
+
````ruby
|
43
|
+
result = client.products.product_ids([580858761,580858759]).all
|
44
|
+
|
45
|
+
# > result.products.first.price_information.display_price
|
46
|
+
# => "starting from 90.99 GBP "
|
47
|
+
````
|
48
|
+
### Get Shop List
|
49
|
+
|
50
|
+
````ruby
|
51
|
+
result = client.shops.all
|
52
|
+
|
53
|
+
# > result.shops.first.shop_title
|
54
|
+
# => "affilinet ShowCase"
|
55
|
+
````
|
56
|
+
|
57
|
+
### Get Category List
|
58
|
+
|
59
|
+
````ruby
|
60
|
+
result = client.categories.shop_id(0).all
|
61
|
+
|
62
|
+
# > result.categories.first.title
|
63
|
+
# => "Clothes & Accessories "
|
64
|
+
````
|
65
|
+
|
66
|
+
### Get Property List
|
67
|
+
|
68
|
+
````ruby
|
69
|
+
result = client.properties.shop_id(1748).all
|
70
|
+
|
71
|
+
# result.property_counts.first.property_name
|
72
|
+
# => "Colour"
|
73
|
+
````
|
22
74
|
|
23
75
|
## Contributing
|
24
76
|
|
data/lib/affilinet.rb
CHANGED
@@ -5,7 +5,13 @@ require "affilinet/version"
|
|
5
5
|
require "affilinet/middleware/mash"
|
6
6
|
require "affilinet/middleware/mashify"
|
7
7
|
require "affilinet/middleware/parse_json"
|
8
|
+
require "affilinet/fluent_interface"
|
8
9
|
require "affilinet/client"
|
10
|
+
require "affilinet/shop"
|
11
|
+
require "affilinet/product"
|
12
|
+
require "affilinet/search"
|
13
|
+
require "affilinet/category"
|
14
|
+
require "affilinet/property"
|
9
15
|
|
10
16
|
module Affilinet
|
11
17
|
end
|
data/lib/affilinet/client.rb
CHANGED
@@ -34,53 +34,24 @@ module Affilinet
|
|
34
34
|
connection.get(endpoint, args).body
|
35
35
|
end
|
36
36
|
|
37
|
-
def categories
|
38
|
-
|
37
|
+
def categories
|
38
|
+
Affilinet::Category.new self
|
39
39
|
end
|
40
40
|
|
41
|
-
def properties
|
42
|
-
|
41
|
+
def properties
|
42
|
+
Affilinet::Property.new self
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
46
|
-
|
47
|
-
get 'GetShopList',
|
48
|
-
'LogoScale' => options[:logo_scale],
|
49
|
-
'CurrentPage' => options[:page],
|
50
|
-
'PageSize' => options[:page_size],
|
51
|
-
'Query' => options[:query],
|
52
|
-
'UpdatedAfter' => options[:updated_after]
|
45
|
+
def products
|
46
|
+
Affilinet::Product.new self
|
53
47
|
end
|
54
48
|
|
55
|
-
def
|
56
|
-
|
57
|
-
get 'GetProducts',
|
58
|
-
'ProductIds' => ids.take(50).join(','),
|
59
|
-
'ImageScales' => options[:image_scales].join(','),
|
60
|
-
'LogoScales' => options[:logo_scales].join(',')
|
49
|
+
def shops
|
50
|
+
Affilinet::Shop.new self
|
61
51
|
end
|
62
52
|
|
63
|
-
def search
|
64
|
-
|
65
|
-
get 'SearchProducts',
|
66
|
-
'ShopIds' => options[:shop_ids].join(','),
|
67
|
-
'ShopIdMode' => options[:shop_id_exclude] ? 'Exclude' : 'Include',
|
68
|
-
'Query' => options[:query],
|
69
|
-
'CategoryIds' => options[:category_ids].join(','),
|
70
|
-
'UseAffilinetCategories' => options[:affilinet_categories],
|
71
|
-
'ExcludeSubCategories' => options[:categories_exclude],
|
72
|
-
'WithImageOnly' => options[:image_only],
|
73
|
-
'ImageScales' => options[:image_scales].join(','),
|
74
|
-
'LogoScales' => options[:logo_scales].join(','),
|
75
|
-
'CurrentPage' => options[:page],
|
76
|
-
'PageSize' => options[:page_size],
|
77
|
-
'MinimumPrice' => options[:price_min],
|
78
|
-
'MaximumPrice' => options[:price_max],
|
79
|
-
'SortBy' => options[:sort_by],
|
80
|
-
'SortOrder' => options[:sort_asc] ? 'ascending' : 'descending',
|
81
|
-
'FacetFields' => options[:facets].take(4).join(','),
|
82
|
-
'FacetValueLimit' => options[:facet_limit],
|
83
|
-
'FQ' => options[:filter_query]
|
53
|
+
def search
|
54
|
+
Affilinet::Search.new self
|
84
55
|
end
|
85
56
|
end
|
86
57
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Affilinet
|
2
|
+
module FluentInterface
|
3
|
+
module ClassMethods
|
4
|
+
def add_attributes(attributes)
|
5
|
+
attributes.each do |attr|
|
6
|
+
add_attribute attr
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_attribute(attr)
|
11
|
+
define_method attr do |value|
|
12
|
+
spawn.send("#{attr}!", value)
|
13
|
+
end
|
14
|
+
|
15
|
+
define_method "#{attr}!" do |value|
|
16
|
+
@criteria[attr] = value
|
17
|
+
self
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def set_endpoint endpoint
|
22
|
+
define_method :endpoint do
|
23
|
+
endpoint
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
module InstanceMethods
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class FluentInterfaceBase
|
33
|
+
extend Affilinet::FluentInterface::ClassMethods
|
34
|
+
include Affilinet::FluentInterface::InstanceMethods
|
35
|
+
attr_accessor :criteria, :client, :endpoint
|
36
|
+
|
37
|
+
def initialize(client)
|
38
|
+
@client = client
|
39
|
+
@criteria = {}
|
40
|
+
end
|
41
|
+
|
42
|
+
def all
|
43
|
+
@client.get endpoint, to_query
|
44
|
+
end
|
45
|
+
|
46
|
+
def first
|
47
|
+
if (@criteria[:current_page] && @criteria[:page_size])
|
48
|
+
new_current_page = (@criteria[:current_page] - 1) * @criteria[:page_size] + 1
|
49
|
+
return current_page(new_current_page).page_size(1).all
|
50
|
+
end
|
51
|
+
all
|
52
|
+
end
|
53
|
+
|
54
|
+
def spawn
|
55
|
+
clone
|
56
|
+
end
|
57
|
+
|
58
|
+
def to_query
|
59
|
+
Affilinet::Middleware::Mash.join_arrays Affilinet::Middleware::Mash.camelize_keys @criteria
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -1,7 +1,29 @@
|
|
1
1
|
module Affilinet
|
2
2
|
module Middleware
|
3
3
|
class Mash < Hashie::Mash
|
4
|
-
def
|
4
|
+
def self.join_arrays(hash)
|
5
|
+
hash.each_pair do |key,value|
|
6
|
+
hash[key] = value.join(',') if value.is_a? Array
|
7
|
+
end
|
8
|
+
hash
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.camelize_keys(hash)
|
12
|
+
hash.keys.each do |key|
|
13
|
+
hash[self.camelize(key)] = hash.delete key
|
14
|
+
end
|
15
|
+
hash
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.camelize(term)
|
19
|
+
string = term.to_s
|
20
|
+
string = string.sub(/^[a-z\d]*/) { $&.capitalize }
|
21
|
+
string.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{$2.capitalize}" }
|
22
|
+
string.gsub!('/', '::')
|
23
|
+
string
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.underscore(camel_cased_word)
|
5
27
|
word = camel_cased_word.to_s.dup
|
6
28
|
word.gsub!('::', '/')
|
7
29
|
word.gsub!(/(?:([A-Za-z\d])|^)(#{/(?=a)b/})(?=\b|[^a-z])/) { "#{$1}#{$1 && '_'}#{$2.downcase}" }
|
@@ -14,7 +36,7 @@ module Affilinet
|
|
14
36
|
|
15
37
|
protected
|
16
38
|
def convert_key(key)
|
17
|
-
underscore key.to_s
|
39
|
+
Affilinet::Middleware::Mash.underscore key.to_s
|
18
40
|
end
|
19
41
|
end
|
20
42
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Affilinet
|
2
|
+
class Search < Affilinet::FluentInterfaceBase
|
3
|
+
add_attributes [:shop_ids, :shop_id_mode, :query, :category_ids, :f_q,
|
4
|
+
:use_affilinet_categories, :exclude_sub_categories,
|
5
|
+
:with_image_only, :image_scales, :logo_scales, :sort_by,
|
6
|
+
:current_page, :page_size, :minimum_price, :maximum_price,
|
7
|
+
:sort_order, :facet_fields, :facet_value_limit]
|
8
|
+
set_endpoint 'SearchProducts'
|
9
|
+
|
10
|
+
def to_query
|
11
|
+
query = @criteria.delete :query
|
12
|
+
@criteria = Affilinet::Middleware::Mash.join_arrays Affilinet::Middleware::Mash.camelize_keys @criteria
|
13
|
+
@criteria.merge({'query' => query})
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/affilinet/version.rb
CHANGED
@@ -19,7 +19,7 @@ http_interactions:
|
|
19
19
|
message: OK
|
20
20
|
headers:
|
21
21
|
Date:
|
22
|
-
-
|
22
|
+
- Sun, 23 Feb 2014 16:02:59 GMT
|
23
23
|
Server:
|
24
24
|
- Microsoft-IIS/6.0
|
25
25
|
X-Powered-By:
|
@@ -46,5 +46,5 @@ http_interactions:
|
|
46
46
|
ICJDbG90aGVzICYgQWNjZXNzb3JpZXMgIiwNCiAgICAgICJQcm9kdWN0Q291
|
47
47
|
bnQiOiAzMTMNCiAgICB9DQogIF0NCn0=
|
48
48
|
http_version:
|
49
|
-
recorded_at:
|
49
|
+
recorded_at: Sun, 23 Feb 2014 16:02:59 GMT
|
50
50
|
recorded_with: VCR 2.8.0
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://product-api.affili.net/V3/productservice.svc/JSON/GetProducts?
|
5
|
+
uri: https://product-api.affili.net/V3/productservice.svc/JSON/GetProducts?Password=1TuKEGkOJJ24dN07ByOy&ProductIds=580858761,580858759&publisherId=580442
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -18,16 +18,20 @@ http_interactions:
|
|
18
18
|
code: 200
|
19
19
|
message: OK
|
20
20
|
headers:
|
21
|
+
Date:
|
22
|
+
- Sun, 23 Feb 2014 16:02:59 GMT
|
23
|
+
Server:
|
24
|
+
- Microsoft-IIS/6.0
|
25
|
+
X-Powered-By:
|
26
|
+
- ASP.NET
|
27
|
+
X-Aspnet-Version:
|
28
|
+
- 4.0.30319
|
21
29
|
Content-Length:
|
22
30
|
- '5372'
|
31
|
+
Cache-Control:
|
32
|
+
- private
|
23
33
|
Content-Type:
|
24
34
|
- application/json
|
25
|
-
Server:
|
26
|
-
- Microsoft-IIS/7.5
|
27
|
-
X-Powered-By:
|
28
|
-
- ASP.NET
|
29
|
-
Date:
|
30
|
-
- Sat, 15 Feb 2014 18:02:54 GMT
|
31
35
|
body:
|
32
36
|
encoding: ASCII-8BIT
|
33
37
|
string: !binary |-
|
@@ -35,7 +39,7 @@ http_interactions:
|
|
35
39
|
MiwNCiAgICAiVG90YWxSZWNvcmRzIjogMiwNCiAgICAiVG90YWxQYWdlcyI6
|
36
40
|
IDEsDQogICAgIkN1cnJlbnRQYWdlIjogMQ0KICB9LA0KICAiUHJvZHVjdHMi
|
37
41
|
OiBbDQogICAgew0KICAgICAgIkxhc3RTaG9wVXBkYXRlIjogIlwvRGF0ZSgx
|
38
|
-
|
42
|
+
MzkzMDk2NjgwMDAwKzAxMDApXC8iLA0KICAgICAgIkxhc3RQcm9kdWN0Q2hh
|
39
43
|
bmdlIjogIlwvRGF0ZSgxMzgyNDMyNDAwMDAwKzAyMDApXC8iLA0KICAgICAg
|
40
44
|
IlNjb3JlIjogMC4wLA0KICAgICAgIlByb2R1Y3RJZCI6IDU4MDg1ODc1OSwN
|
41
45
|
CiAgICAgICJBcnRpY2xlTnVtYmVyIjogIkFCQ0RfMDAwMTY1IiwNCiAgICAg
|
@@ -93,7 +97,7 @@ http_interactions:
|
|
93
97
|
ICAgIlNob3BDYXRlZ29yeUlkUGF0aCI6ICIzNDc1ODc1NCA+IDM0NzU4Nzc4
|
94
98
|
ID4gMzQ3NTg3ODEiLA0KICAgICAgIkFmZmlsaW5ldENhdGVnb3J5SWRQYXRo
|
95
99
|
IjogIjE0Ig0KICAgIH0sDQogICAgew0KICAgICAgIkxhc3RTaG9wVXBkYXRl
|
96
|
-
|
100
|
+
IjogIlwvRGF0ZSgxMzkzMDk2NjgwMDAwKzAxMDApXC8iLA0KICAgICAgIkxh
|
97
101
|
c3RQcm9kdWN0Q2hhbmdlIjogIlwvRGF0ZSgxMzgyNDMyNDAwMDAwKzAyMDAp
|
98
102
|
XC8iLA0KICAgICAgIlNjb3JlIjogMC4wLA0KICAgICAgIlByb2R1Y3RJZCI6
|
99
103
|
IDU4MDg1ODc2MSwNCiAgICAgICJBcnRpY2xlTnVtYmVyIjogIkFCQ0RfMDAw
|
@@ -152,5 +156,5 @@ http_interactions:
|
|
152
156
|
NzU4NzgxIiwNCiAgICAgICJBZmZpbGluZXRDYXRlZ29yeUlkUGF0aCI6ICIx
|
153
157
|
NCINCiAgICB9DQogIF0NCn0=
|
154
158
|
http_version:
|
155
|
-
recorded_at:
|
159
|
+
recorded_at: Sun, 23 Feb 2014 16:03:00 GMT
|
156
160
|
recorded_with: VCR 2.8.0
|
@@ -18,16 +18,20 @@ http_interactions:
|
|
18
18
|
code: 200
|
19
19
|
message: OK
|
20
20
|
headers:
|
21
|
+
Date:
|
22
|
+
- Sun, 23 Feb 2014 16:02:58 GMT
|
23
|
+
Server:
|
24
|
+
- Microsoft-IIS/6.0
|
25
|
+
X-Powered-By:
|
26
|
+
- ASP.NET
|
27
|
+
X-Aspnet-Version:
|
28
|
+
- 4.0.30319
|
21
29
|
Content-Length:
|
22
30
|
- '410'
|
31
|
+
Cache-Control:
|
32
|
+
- private
|
23
33
|
Content-Type:
|
24
34
|
- application/json
|
25
|
-
Server:
|
26
|
-
- Microsoft-IIS/7.5
|
27
|
-
X-Powered-By:
|
28
|
-
- ASP.NET
|
29
|
-
Date:
|
30
|
-
- Sat, 15 Feb 2014 18:00:48 GMT
|
31
35
|
body:
|
32
36
|
encoding: ASCII-8BIT
|
33
37
|
string: !binary |-
|
@@ -42,5 +46,5 @@ http_interactions:
|
|
42
46
|
ICJPcmlnaW4iLA0KICAgICAgIlRvdGFsQ291bnQiOiAzMTMNCiAgICB9DQog
|
43
47
|
IF0NCn0=
|
44
48
|
http_version:
|
45
|
-
recorded_at:
|
49
|
+
recorded_at: Sun, 23 Feb 2014 16:02:59 GMT
|
46
50
|
recorded_with: VCR 2.8.0
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://product-api.affili.net/V3/productservice.svc/JSON/SearchProducts?
|
5
|
+
uri: https://product-api.affili.net/V3/productservice.svc/JSON/SearchProducts?Password=1TuKEGkOJJ24dN07ByOy&publisherId=580442&query=jeans
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -18,16 +18,20 @@ http_interactions:
|
|
18
18
|
code: 200
|
19
19
|
message: OK
|
20
20
|
headers:
|
21
|
+
Date:
|
22
|
+
- Sun, 23 Feb 2014 16:03:00 GMT
|
23
|
+
Server:
|
24
|
+
- Microsoft-IIS/6.0
|
25
|
+
X-Powered-By:
|
26
|
+
- ASP.NET
|
27
|
+
X-Aspnet-Version:
|
28
|
+
- 4.0.30319
|
21
29
|
Content-Length:
|
22
30
|
- '26570'
|
31
|
+
Cache-Control:
|
32
|
+
- private
|
23
33
|
Content-Type:
|
24
34
|
- application/json
|
25
|
-
Server:
|
26
|
-
- Microsoft-IIS/7.5
|
27
|
-
X-Powered-By:
|
28
|
-
- ASP.NET
|
29
|
-
Date:
|
30
|
-
- Sat, 15 Feb 2014 18:03:48 GMT
|
31
35
|
body:
|
32
36
|
encoding: ASCII-8BIT
|
33
37
|
string: !binary |-
|
@@ -35,9 +39,9 @@ http_interactions:
|
|
35
39
|
MTAsDQogICAgIlRvdGFsUmVjb3JkcyI6IDQzLA0KICAgICJUb3RhbFBhZ2Vz
|
36
40
|
IjogNSwNCiAgICAiQ3VycmVudFBhZ2UiOiAxDQogIH0sDQogICJQcm9kdWN0
|
37
41
|
cyI6IFsNCiAgICB7DQogICAgICAiTGFzdFNob3BVcGRhdGUiOiAiXC9EYXRl
|
38
|
-
|
42
|
+
KDEzOTMwOTY2ODAwMDArMDEwMClcLyIsDQogICAgICAiTGFzdFByb2R1Y3RD
|
39
43
|
aGFuZ2UiOiAiXC9EYXRlKDEzODI0MzI0MDAwMDArMDIwMClcLyIsDQogICAg
|
40
|
-
|
44
|
+
ICAiU2NvcmUiOiAxLjI3MDMwOTQsDQogICAgICAiUHJvZHVjdElkIjogNTgw
|
41
45
|
ODU4NzY2LA0KICAgICAgIkFydGljbGVOdW1iZXIiOiAiQUJDRF8wMDAxNzIi
|
42
46
|
LA0KICAgICAgIlNob3BJZCI6IDE3NDgsDQogICAgICAiU2hvcFRpdGxlIjog
|
43
47
|
ImFmZmlsaW5ldCBTaG93Q2FzZSIsDQogICAgICAiUHJvZHVjdE5hbWUiOiAi
|
@@ -94,9 +98,9 @@ http_interactions:
|
|
94
98
|
cnlJZFBhdGgiOiAiMzQ3NTg3NTQgPiAzNDc1ODc3OCA+IDM0NzU4NzgxIiwN
|
95
99
|
CiAgICAgICJBZmZpbGluZXRDYXRlZ29yeUlkUGF0aCI6ICIxNCINCiAgICB9
|
96
100
|
LA0KICAgIHsNCiAgICAgICJMYXN0U2hvcFVwZGF0ZSI6ICJcL0RhdGUoMTM5
|
97
|
-
|
101
|
+
MzA5NjY4MDAwMCswMTAwKVwvIiwNCiAgICAgICJMYXN0UHJvZHVjdENoYW5n
|
98
102
|
ZSI6ICJcL0RhdGUoMTM4MjQzMjQwMDAwMCswMjAwKVwvIiwNCiAgICAgICJT
|
99
|
-
|
103
|
+
Y29yZSI6IDEuMjcwMzA5NCwNCiAgICAgICJQcm9kdWN0SWQiOiA1ODA4NTg3
|
100
104
|
NDksDQogICAgICAiQXJ0aWNsZU51bWJlciI6ICJBQkNEXzAwMDE1NSIsDQog
|
101
105
|
ICAgICAiU2hvcElkIjogMTc0OCwNCiAgICAgICJTaG9wVGl0bGUiOiAiYWZm
|
102
106
|
aWxpbmV0IFNob3dDYXNlIiwNCiAgICAgICJQcm9kdWN0TmFtZSI6ICJKZWFu
|
@@ -151,10 +155,10 @@ http_interactions:
|
|
151
155
|
CiAgICAgICJQcm9ncmFtSWQiOiA4OTkxLA0KICAgICAgIlNob3BDYXRlZ29y
|
152
156
|
eUlkUGF0aCI6ICIzNDc1ODc1NCA+IDM0NzU4Nzc4ID4gMzQ3NTg3ODEiLA0K
|
153
157
|
ICAgICAgIkFmZmlsaW5ldENhdGVnb3J5SWRQYXRoIjogIjE0Ig0KICAgIH0s
|
154
|
-
|
155
|
-
|
158
|
+
DQogICAgew0KICAgICAgIkxhc3RTaG9wVXBkYXRlIjogIlwvRGF0ZSgxMzkz
|
159
|
+
MDk2NjgwMDAwKzAxMDApXC8iLA0KICAgICAgIkxhc3RQcm9kdWN0Q2hhbmdl
|
156
160
|
IjogIlwvRGF0ZSgxMzgyNDMyNDAwMDAwKzAyMDApXC8iLA0KICAgICAgIlNj
|
157
|
-
|
161
|
+
b3JlIjogMS4yNzAzMDk0LA0KICAgICAgIlByb2R1Y3RJZCI6IDU4MDg1ODc1
|
158
162
|
NSwNCiAgICAgICJBcnRpY2xlTnVtYmVyIjogIkFCQ0RfMDAwMTYxIiwNCiAg
|
159
163
|
ICAgICJTaG9wSWQiOiAxNzQ4LA0KICAgICAgIlNob3BUaXRsZSI6ICJhZmZp
|
160
164
|
bGluZXQgU2hvd0Nhc2UiLA0KICAgICAgIlByb2R1Y3ROYW1lIjogIkplYW5z
|
@@ -211,9 +215,9 @@ http_interactions:
|
|
211
215
|
ODk5MSwNCiAgICAgICJTaG9wQ2F0ZWdvcnlJZFBhdGgiOiAiMzQ3NTg3NTQg
|
212
216
|
PiAzNDc1ODc3OCA+IDM0NzU4NzgxIiwNCiAgICAgICJBZmZpbGluZXRDYXRl
|
213
217
|
Z29yeUlkUGF0aCI6ICIxNCINCiAgICB9LA0KICAgIHsNCiAgICAgICJMYXN0
|
214
|
-
|
218
|
+
U2hvcFVwZGF0ZSI6ICJcL0RhdGUoMTM5MzA5NjY4MDAwMCswMTAwKVwvIiwN
|
215
219
|
CiAgICAgICJMYXN0UHJvZHVjdENoYW5nZSI6ICJcL0RhdGUoMTM4MjQzMjQw
|
216
|
-
|
220
|
+
MDAwMCswMjAwKVwvIiwNCiAgICAgICJTY29yZSI6IDEuMjcwMzA5NCwNCiAg
|
217
221
|
ICAgICJQcm9kdWN0SWQiOiA1ODA4NTg3NTAsDQogICAgICAiQXJ0aWNsZU51
|
218
222
|
bWJlciI6ICJBQkNEXzAwMDE1NiIsDQogICAgICAiU2hvcElkIjogMTc0OCwN
|
219
223
|
CiAgICAgICJTaG9wVGl0bGUiOiAiYWZmaWxpbmV0IFNob3dDYXNlIiwNCiAg
|
@@ -270,10 +274,10 @@ http_interactions:
|
|
270
274
|
bUlkIjogODk5MSwNCiAgICAgICJTaG9wQ2F0ZWdvcnlJZFBhdGgiOiAiMzQ3
|
271
275
|
NTg3NTQgPiAzNDc1ODc3OCA+IDM0NzU4NzgxIiwNCiAgICAgICJBZmZpbGlu
|
272
276
|
ZXRDYXRlZ29yeUlkUGF0aCI6ICIxNCINCiAgICB9LA0KICAgIHsNCiAgICAg
|
273
|
-
|
277
|
+
ICJMYXN0U2hvcFVwZGF0ZSI6ICJcL0RhdGUoMTM5MzA5NjY4MDAwMCswMTAw
|
274
278
|
KVwvIiwNCiAgICAgICJMYXN0UHJvZHVjdENoYW5nZSI6ICJcL0RhdGUoMTM4
|
275
|
-
|
276
|
-
|
279
|
+
MjQzMjQwMDAwMCswMjAwKVwvIiwNCiAgICAgICJTY29yZSI6IDEuMjcwMzA5
|
280
|
+
NCwNCiAgICAgICJQcm9kdWN0SWQiOiA1ODA4NTg3NTksDQogICAgICAiQXJ0
|
277
281
|
aWNsZU51bWJlciI6ICJBQkNEXzAwMDE2NSIsDQogICAgICAiU2hvcElkIjog
|
278
282
|
MTc0OCwNCiAgICAgICJTaG9wVGl0bGUiOiAiYWZmaWxpbmV0IFNob3dDYXNl
|
279
283
|
IiwNCiAgICAgICJQcm9kdWN0TmFtZSI6ICJKZWFucyDCtE1pbGFub8K0LCBE
|
@@ -329,9 +333,9 @@ http_interactions:
|
|
329
333
|
ZWdvcnlJZFBhdGgiOiAiMzQ3NTg3NTQgPiAzNDc1ODc3OCA+IDM0NzU4Nzgx
|
330
334
|
IiwNCiAgICAgICJBZmZpbGluZXRDYXRlZ29yeUlkUGF0aCI6ICIxNCINCiAg
|
331
335
|
ICB9LA0KICAgIHsNCiAgICAgICJMYXN0U2hvcFVwZGF0ZSI6ICJcL0RhdGUo
|
332
|
-
|
336
|
+
MTM5MzA5NjY4MDAwMCswMTAwKVwvIiwNCiAgICAgICJMYXN0UHJvZHVjdENo
|
333
337
|
YW5nZSI6ICJcL0RhdGUoMTM4MjQzMjQwMDAwMCswMjAwKVwvIiwNCiAgICAg
|
334
|
-
|
338
|
+
ICJTY29yZSI6IDEuMjcwMzA5NCwNCiAgICAgICJQcm9kdWN0SWQiOiA1ODA4
|
335
339
|
NTg3NjAsDQogICAgICAiQXJ0aWNsZU51bWJlciI6ICJBQkNEXzAwMDE2NiIs
|
336
340
|
DQogICAgICAiU2hvcElkIjogMTc0OCwNCiAgICAgICJTaG9wVGl0bGUiOiAi
|
337
341
|
YWZmaWxpbmV0IFNob3dDYXNlIiwNCiAgICAgICJQcm9kdWN0TmFtZSI6ICJK
|
@@ -389,9 +393,9 @@ http_interactions:
|
|
389
393
|
ODk5MSwNCiAgICAgICJTaG9wQ2F0ZWdvcnlJZFBhdGgiOiAiMzQ3NTg3NTQg
|
390
394
|
PiAzNDc1ODc3OCA+IDM0NzU4NzgxIiwNCiAgICAgICJBZmZpbGluZXRDYXRl
|
391
395
|
Z29yeUlkUGF0aCI6ICIxNCINCiAgICB9LA0KICAgIHsNCiAgICAgICJMYXN0
|
392
|
-
|
396
|
+
U2hvcFVwZGF0ZSI6ICJcL0RhdGUoMTM5MzA5NjY4MDAwMCswMTAwKVwvIiwN
|
393
397
|
CiAgICAgICJMYXN0UHJvZHVjdENoYW5nZSI6ICJcL0RhdGUoMTM4MjQzMjQw
|
394
|
-
|
398
|
+
MDAwMCswMjAwKVwvIiwNCiAgICAgICJTY29yZSI6IDEuMjcwMzA5NCwNCiAg
|
395
399
|
ICAgICJQcm9kdWN0SWQiOiA1ODA4NTg4ODMsDQogICAgICAiQXJ0aWNsZU51
|
396
400
|
bWJlciI6ICJBQkNEXzAwMDI4OSIsDQogICAgICAiU2hvcElkIjogMTc0OCwN
|
397
401
|
CiAgICAgICJTaG9wVGl0bGUiOiAiYWZmaWxpbmV0IFNob3dDYXNlIiwNCiAg
|
@@ -447,10 +451,10 @@ http_interactions:
|
|
447
451
|
ICAiUHJvZ3JhbUlkIjogODk5MSwNCiAgICAgICJTaG9wQ2F0ZWdvcnlJZFBh
|
448
452
|
dGgiOiAiMzQ3NTg3ODQgPiAzNDc1ODgwMCA+IDM0NzU4ODAzIiwNCiAgICAg
|
449
453
|
ICJBZmZpbGluZXRDYXRlZ29yeUlkUGF0aCI6ICIxNCINCiAgICB9LA0KICAg
|
450
|
-
|
454
|
+
IHsNCiAgICAgICJMYXN0U2hvcFVwZGF0ZSI6ICJcL0RhdGUoMTM5MzA5NjY4
|
451
455
|
MDAwMCswMTAwKVwvIiwNCiAgICAgICJMYXN0UHJvZHVjdENoYW5nZSI6ICJc
|
452
456
|
L0RhdGUoMTM4MjQzMjQwMDAwMCswMjAwKVwvIiwNCiAgICAgICJTY29yZSI6
|
453
|
-
|
457
|
+
IDEuMjcwMzA5NCwNCiAgICAgICJQcm9kdWN0SWQiOiA1ODA4NTg4ODUsDQog
|
454
458
|
ICAgICAiQXJ0aWNsZU51bWJlciI6ICJBQkNEXzAwMDI5MSIsDQogICAgICAi
|
455
459
|
U2hvcElkIjogMTc0OCwNCiAgICAgICJTaG9wVGl0bGUiOiAiYWZmaWxpbmV0
|
456
460
|
IFNob3dDYXNlIiwNCiAgICAgICJQcm9kdWN0TmFtZSI6ICJKZWFucyB0cm91
|
@@ -505,9 +509,9 @@ http_interactions:
|
|
505
509
|
MSwNCiAgICAgICJTaG9wQ2F0ZWdvcnlJZFBhdGgiOiAiMzQ3NTg3ODQgPiAz
|
506
510
|
NDc1ODgwMCA+IDM0NzU4ODAzIiwNCiAgICAgICJBZmZpbGluZXRDYXRlZ29y
|
507
511
|
eUlkUGF0aCI6ICIxNCINCiAgICB9LA0KICAgIHsNCiAgICAgICJMYXN0U2hv
|
508
|
-
|
512
|
+
cFVwZGF0ZSI6ICJcL0RhdGUoMTM5MzA5NjY4MDAwMCswMTAwKVwvIiwNCiAg
|
509
513
|
ICAgICJMYXN0UHJvZHVjdENoYW5nZSI6ICJcL0RhdGUoMTM4MjQzMjQwMDAw
|
510
|
-
|
514
|
+
MCswMjAwKVwvIiwNCiAgICAgICJTY29yZSI6IDEuMjcwMzA5NCwNCiAgICAg
|
511
515
|
ICJQcm9kdWN0SWQiOiA1ODA4NTg4ODYsDQogICAgICAiQXJ0aWNsZU51bWJl
|
512
516
|
ciI6ICJBQkNEXzAwMDI5MiIsDQogICAgICAiU2hvcElkIjogMTc0OCwNCiAg
|
513
517
|
ICAgICJTaG9wVGl0bGUiOiAiYWZmaWxpbmV0IFNob3dDYXNlIiwNCiAgICAg
|
@@ -563,9 +567,9 @@ http_interactions:
|
|
563
567
|
OTkxLA0KICAgICAgIlNob3BDYXRlZ29yeUlkUGF0aCI6ICIzNDc1ODc4NCA+
|
564
568
|
IDM0NzU4ODAwID4gMzQ3NTg4MDMiLA0KICAgICAgIkFmZmlsaW5ldENhdGVn
|
565
569
|
b3J5SWRQYXRoIjogIjE0Ig0KICAgIH0sDQogICAgew0KICAgICAgIkxhc3RT
|
566
|
-
|
570
|
+
aG9wVXBkYXRlIjogIlwvRGF0ZSgxMzkzMDk2NjgwMDAwKzAxMDApXC8iLA0K
|
567
571
|
ICAgICAgIkxhc3RQcm9kdWN0Q2hhbmdlIjogIlwvRGF0ZSgxMzgyNDMyNDAw
|
568
|
-
|
572
|
+
MDAwKzAyMDApXC8iLA0KICAgICAgIlNjb3JlIjogMS4yNzAzMDk0LA0KICAg
|
569
573
|
ICAgIlByb2R1Y3RJZCI6IDU4MDg1ODg3OCwNCiAgICAgICJBcnRpY2xlTnVt
|
570
574
|
YmVyIjogIkFCQ0RfMDAwMjg0IiwNCiAgICAgICJTaG9wSWQiOiAxNzQ4LA0K
|
571
575
|
ICAgICAgIlNob3BUaXRsZSI6ICJhZmZpbGluZXQgU2hvd0Nhc2UiLA0KICAg
|
@@ -623,5 +627,5 @@ http_interactions:
|
|
623
627
|
ICAiQWZmaWxpbmV0Q2F0ZWdvcnlJZFBhdGgiOiAiMTQiDQogICAgfQ0KICBd
|
624
628
|
LA0KICAiRmFjZXRzIjogW10NCn0=
|
625
629
|
http_version:
|
626
|
-
recorded_at:
|
630
|
+
recorded_at: Sun, 23 Feb 2014 16:03:00 GMT
|
627
631
|
recorded_with: VCR 2.8.0
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://product-api.affili.net/V3/productservice.svc/JSON/GetShopList?
|
5
|
+
uri: https://product-api.affili.net/V3/productservice.svc/JSON/GetShopList?Password=1TuKEGkOJJ24dN07ByOy&publisherId=580442
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -18,20 +18,16 @@ http_interactions:
|
|
18
18
|
code: 200
|
19
19
|
message: OK
|
20
20
|
headers:
|
21
|
-
Date:
|
22
|
-
- Sat, 15 Feb 2014 18:02:11 GMT
|
23
|
-
Server:
|
24
|
-
- Microsoft-IIS/6.0
|
25
|
-
X-Powered-By:
|
26
|
-
- ASP.NET
|
27
|
-
X-Aspnet-Version:
|
28
|
-
- 4.0.30319
|
29
21
|
Content-Length:
|
30
22
|
- '485'
|
31
|
-
Cache-Control:
|
32
|
-
- private
|
33
23
|
Content-Type:
|
34
24
|
- application/json
|
25
|
+
Server:
|
26
|
+
- Microsoft-IIS/7.5
|
27
|
+
X-Powered-By:
|
28
|
+
- ASP.NET
|
29
|
+
Date:
|
30
|
+
- Sun, 23 Feb 2014 16:02:59 GMT
|
35
31
|
body:
|
36
32
|
encoding: ASCII-8BIT
|
37
33
|
string: !binary |-
|
@@ -40,12 +36,12 @@ http_interactions:
|
|
40
36
|
cyI6IDEsDQogICAgIkN1cnJlbnRQYWdlIjogMQ0KICB9LA0KICAiU2hvcHMi
|
41
37
|
OiBbDQogICAgew0KICAgICAgIlNob3BJZCI6IDE3NDgsDQogICAgICAiUHJv
|
42
38
|
Z3JhbUlkIjogODk5MSwNCiAgICAgICJTaG9wVGl0bGUiOiAiYWZmaWxpbmV0
|
43
|
-
|
44
|
-
|
39
|
+
IFNob3dDYXNlIiwNCiAgICAgICJMYXN0VXBkYXRlIjogIlwvRGF0ZSgxMzkz
|
40
|
+
MDk2NjgwMDAwKzAxMDApXC8iLA0KICAgICAgIlNob3BMaW5rIjogImFmZmls
|
45
41
|
aS5uZXQiLA0KICAgICAgIlByb2R1Y3RDb3VudCI6IDMxMywNCiAgICAgICJM
|
46
42
|
b2dvIjogew0KICAgICAgICAiTG9nb1NjYWxlIjogIk5vTG9nbyIsDQogICAg
|
47
43
|
ICAgICJVUkwiOiAiIiwNCiAgICAgICAgIldpZHRoIjogMCwNCiAgICAgICAg
|
48
44
|
IkhlaWdodCI6IDANCiAgICAgIH0NCiAgICB9DQogIF0NCn0=
|
49
45
|
http_version:
|
50
|
-
recorded_at:
|
46
|
+
recorded_at: Sun, 23 Feb 2014 16:02:59 GMT
|
51
47
|
recorded_with: VCR 2.8.0
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://product-api.affili.net/V3/productservice.svc/JSON/SearchProducts?
|
5
|
+
uri: https://product-api.affili.net/V3/productservice.svc/JSON/SearchProducts?Password=1TuKEGkOJJ24dN07ByOy&publisherId=580442&query
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -18,20 +18,24 @@ http_interactions:
|
|
18
18
|
code: 400
|
19
19
|
message: Bad Request
|
20
20
|
headers:
|
21
|
+
Date:
|
22
|
+
- Sun, 23 Feb 2014 16:04:35 GMT
|
23
|
+
Server:
|
24
|
+
- Microsoft-IIS/6.0
|
25
|
+
X-Powered-By:
|
26
|
+
- ASP.NET
|
27
|
+
X-Aspnet-Version:
|
28
|
+
- 4.0.30319
|
21
29
|
Content-Length:
|
22
30
|
- '112'
|
31
|
+
Cache-Control:
|
32
|
+
- private
|
23
33
|
Content-Type:
|
24
34
|
- application/json; charset=utf-8
|
25
|
-
Server:
|
26
|
-
- Microsoft-IIS/7.5
|
27
|
-
X-Powered-By:
|
28
|
-
- ASP.NET
|
29
|
-
Date:
|
30
|
-
- Sat, 15 Feb 2014 18:21:46 GMT
|
31
35
|
body:
|
32
36
|
encoding: UTF-8
|
33
37
|
string: '{"ErrorMessages":[{"Key":"2021950074","Value":"FilterQueries, CategoryIds
|
34
38
|
or Query should be set in request."}]}'
|
35
39
|
http_version:
|
36
|
-
recorded_at:
|
40
|
+
recorded_at: Sun, 23 Feb 2014 16:04:36 GMT
|
37
41
|
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Affilinet::Category do
|
4
|
+
subject { Affilinet::Category.new double('Affilinet::Client') }
|
5
|
+
|
6
|
+
describe '#all' do
|
7
|
+
it 'correctly queries the client' do
|
8
|
+
expect(subject.client).to receive(:get).with('GetCategoryList', {'ShopId' => 0})
|
9
|
+
subject.shop_id(0).all
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Affilinet::Client, :vcr do
|
4
|
+
it 'raises ArgumentError if initialized with no options' do
|
5
|
+
expect do
|
6
|
+
Affilinet::Client.new
|
7
|
+
end.to raise_error ArgumentError
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'initialized with credentials' do
|
11
|
+
subject { Affilinet::Client.new publisher_id: 580442, password: '1TuKEGkOJJ24dN07ByOy' }
|
12
|
+
|
13
|
+
it 'raises Faraday::Error::ParsingError on wrong API requests' do
|
14
|
+
expect do
|
15
|
+
subject.search.all
|
16
|
+
end.to raise_error Faraday::Error::ParsingError
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#connection' do
|
20
|
+
it 'is an instance of Faraday::Connection' do
|
21
|
+
expect(subject.connection).to be_an_instance_of Faraday::Connection
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#options' do
|
26
|
+
it 'includes publisher_id' do
|
27
|
+
expect(subject.options).to include(:publisher_id)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'includes password' do
|
31
|
+
expect(subject.options).to include(:password)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#categories' do
|
36
|
+
it 'returns a Affilinet::Middleware::Mash' do
|
37
|
+
expect(subject.categories.shop_id(0).all).to be_an_instance_of Affilinet::Middleware::Mash
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#properties' do
|
42
|
+
it 'returns a Affilinet::Middleware::Mash' do
|
43
|
+
expect(subject.properties.shop_id(1748).all).to be_an_instance_of Affilinet::Middleware::Mash
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#shops' do
|
48
|
+
it 'returns a Affilinet::Middleware::Mash' do
|
49
|
+
expect(subject.shops.all).to be_an_instance_of Affilinet::Middleware::Mash
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#products' do
|
54
|
+
it 'returns a Affilinet::Middleware::Mash' do
|
55
|
+
expect(subject.products.product_ids([580858761,580858759]).all).to be_an_instance_of Affilinet::Middleware::Mash
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#search' do
|
60
|
+
it 'returns a Affilinet::Middleware::Mash' do
|
61
|
+
expect(subject.search.query('jeans').all).to be_an_instance_of Affilinet::Middleware::Mash
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Affilinet::Middleware::Mash do
|
4
|
+
subject { Affilinet::Middleware::Mash }
|
5
|
+
|
6
|
+
describe '::join_arrays' do
|
7
|
+
it 'joins array values using a comma' do
|
8
|
+
foo = {bar: ['baz', 'fubar']}
|
9
|
+
expect(subject.join_arrays foo).to eq({bar: 'baz,fubar'})
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '::camelize_keys' do
|
14
|
+
it 'camelizes all the keys' do
|
15
|
+
foo = {foo_bar: 'foo', f_q: 'bar'}
|
16
|
+
expect(subject.camelize_keys foo).to eq({'FooBar' => 'foo', 'FQ' => 'bar'})
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '::camelize' do
|
21
|
+
it 'camelizes words' do
|
22
|
+
expect(subject.camelize :foo_bar_baz).to eq('FooBarBaz')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '::underscore' do
|
27
|
+
it 'underscores words' do
|
28
|
+
expect(subject.underscore 'FooBarBaz').to eq('foo_bar_baz')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Affilinet::Product do
|
4
|
+
subject { Affilinet::Product.new double('Affilinet::Client') }
|
5
|
+
|
6
|
+
describe '#to_query' do
|
7
|
+
it 'generates the correct Hash' do
|
8
|
+
shop = subject.logo_scales(['10x2', '3x4'])
|
9
|
+
expect(shop.to_query).to eq({'LogoScales' => '10x2,3x4'})
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#all' do
|
14
|
+
it 'correctly queries the client' do
|
15
|
+
expect(subject.client).to receive(:get).with('GetProducts', {'ProductIds' => '1,2,3', 'LogoScales' => '3x4'})
|
16
|
+
subject.logo_scales('3x4').product_ids([1, 2, 3]).all
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Affilinet::Property do
|
4
|
+
subject { Affilinet::Property.new double('Affilinet::Client') }
|
5
|
+
|
6
|
+
describe '#all' do
|
7
|
+
it 'correctly queries the client' do
|
8
|
+
expect(subject.client).to receive(:get).with('GetPropertyList', {'ShopId' => 0})
|
9
|
+
subject.shop_id(0).all
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Affilinet::Search do
|
4
|
+
subject { Affilinet::Search.new double('Affilinet::Client') }
|
5
|
+
|
6
|
+
describe '#all' do
|
7
|
+
it 'correctly queries the client' do
|
8
|
+
expect(subject.client).to receive(:get).with('SearchProducts', {'query' => 'jeans'})
|
9
|
+
subject.query('jeans').all
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Affilinet::Shop do
|
4
|
+
subject { Affilinet::Shop.new double('Affilinet::Client') }
|
5
|
+
|
6
|
+
[:logo_scale, :current_page, :page_size, :updated_after, :query].each do |attr|
|
7
|
+
describe "##{attr}" do
|
8
|
+
it "sets the #{attr}" do
|
9
|
+
shop = subject.send(attr, 'foo')
|
10
|
+
expect(shop.criteria[attr]).to eq('foo')
|
11
|
+
end
|
12
|
+
|
13
|
+
it "replaces the #{attr}" do
|
14
|
+
shop = subject.send(attr, 'bar')
|
15
|
+
expect(shop.criteria[attr]).to eq('bar')
|
16
|
+
shop = subject.send(attr, 'baz')
|
17
|
+
expect(shop.criteria[attr]).to eq('baz')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'fluent interface basics' do
|
23
|
+
it 'successfully chains methods' do
|
24
|
+
shop = subject.current_page(4).page_size(50)
|
25
|
+
expect(shop.criteria[:current_page]).to eq(4)
|
26
|
+
expect(shop.criteria[:page_size]).to eq(50)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'spawns new instances for every chained method' do
|
30
|
+
shop = subject.current_page(2)
|
31
|
+
shop_first = shop.page_size(50)
|
32
|
+
shop_second = shop.page_size(50)
|
33
|
+
expect(shop_first).not_to equal(shop_second)
|
34
|
+
expect(shop_first.criteria[:current_page]).to eq(shop_second.criteria[:current_page])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#to_query' do
|
39
|
+
it 'generates the correct Hash' do
|
40
|
+
shop = subject.current_page(1).page_size(100)
|
41
|
+
expect(shop.to_query).to eq({'PageSize' => 100, 'CurrentPage' => 1})
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#all' do
|
46
|
+
it 'correctly queries the client' do
|
47
|
+
expect(subject.client).to receive(:get).with('GetShopList', {'CurrentPage' => 2})
|
48
|
+
subject.current_page(2).all
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#first' do
|
53
|
+
it 'only requests one element, correctly recalculating pagination' do
|
54
|
+
expect(subject.client).to receive(:get).with('GetShopList', {'CurrentPage' => 71, 'PageSize' => 1})
|
55
|
+
subject.current_page(3).page_size(35).first
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'returns all if no page or size is provided' do
|
59
|
+
expect(subject.client).to receive(:get).with('GetShopList', {})
|
60
|
+
subject.first
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: affilinet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo Sampaio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -144,6 +144,7 @@ extensions: []
|
|
144
144
|
extra_rdoc_files: []
|
145
145
|
files:
|
146
146
|
- .gitignore
|
147
|
+
- .rspec
|
147
148
|
- .ruby-gemset
|
148
149
|
- .ruby-version
|
149
150
|
- Gemfile
|
@@ -152,21 +153,30 @@ files:
|
|
152
153
|
- Rakefile
|
153
154
|
- affilinet.gemspec
|
154
155
|
- lib/affilinet.rb
|
156
|
+
- lib/affilinet/category.rb
|
155
157
|
- lib/affilinet/client.rb
|
158
|
+
- lib/affilinet/fluent_interface.rb
|
156
159
|
- lib/affilinet/middleware/mash.rb
|
157
160
|
- lib/affilinet/middleware/mashify.rb
|
158
161
|
- lib/affilinet/middleware/parse_json.rb
|
162
|
+
- lib/affilinet/product.rb
|
163
|
+
- lib/affilinet/property.rb
|
164
|
+
- lib/affilinet/search.rb
|
165
|
+
- lib/affilinet/shop.rb
|
159
166
|
- lib/affilinet/version.rb
|
160
|
-
- spec/cassettes/Affilinet_Client/initialized_with_credentials/_categories/performs_the_GET_request_to_the_correct_endpoint.yml
|
161
167
|
- spec/cassettes/Affilinet_Client/initialized_with_credentials/_categories/returns_a_Affilinet_Middleware_Mash.yml
|
162
168
|
- spec/cassettes/Affilinet_Client/initialized_with_credentials/_products/returns_a_Affilinet_Middleware_Mash.yml
|
163
169
|
- spec/cassettes/Affilinet_Client/initialized_with_credentials/_properties/returns_a_Affilinet_Middleware_Mash.yml
|
164
170
|
- spec/cassettes/Affilinet_Client/initialized_with_credentials/_search/returns_a_Affilinet_Middleware_Mash.yml
|
165
171
|
- spec/cassettes/Affilinet_Client/initialized_with_credentials/_shops/returns_a_Affilinet_Middleware_Mash.yml
|
166
|
-
- spec/cassettes/Affilinet_Client/initialized_with_credentials/categories/performs_the_GET_request_to_the_correct_endpoint.yml
|
167
|
-
- spec/cassettes/Affilinet_Client/initialized_with_credentials/raises_Error_on_wrong_API_requests.yml
|
168
172
|
- spec/cassettes/Affilinet_Client/initialized_with_credentials/raises_Faraday_Error_ParsingError_on_wrong_API_requests.yml
|
169
|
-
- spec/lib/
|
173
|
+
- spec/lib/affilinet/category_spec.rb
|
174
|
+
- spec/lib/affilinet/client_spec.rb
|
175
|
+
- spec/lib/affilinet/middleware/mash.rb
|
176
|
+
- spec/lib/affilinet/product_spec.rb
|
177
|
+
- spec/lib/affilinet/property_spec.rb
|
178
|
+
- spec/lib/affilinet/search_spec.rb
|
179
|
+
- spec/lib/affilinet/shop_spec.rb
|
170
180
|
- spec/spec_helper.rb
|
171
181
|
homepage: http://github.com/esampaio/affilinet
|
172
182
|
licenses:
|
@@ -193,14 +203,17 @@ signing_key:
|
|
193
203
|
specification_version: 4
|
194
204
|
summary: Gem to access the rest (actually only get but...) API of affilinet
|
195
205
|
test_files:
|
196
|
-
- spec/cassettes/Affilinet_Client/initialized_with_credentials/_categories/performs_the_GET_request_to_the_correct_endpoint.yml
|
197
206
|
- spec/cassettes/Affilinet_Client/initialized_with_credentials/_categories/returns_a_Affilinet_Middleware_Mash.yml
|
198
207
|
- spec/cassettes/Affilinet_Client/initialized_with_credentials/_products/returns_a_Affilinet_Middleware_Mash.yml
|
199
208
|
- spec/cassettes/Affilinet_Client/initialized_with_credentials/_properties/returns_a_Affilinet_Middleware_Mash.yml
|
200
209
|
- spec/cassettes/Affilinet_Client/initialized_with_credentials/_search/returns_a_Affilinet_Middleware_Mash.yml
|
201
210
|
- spec/cassettes/Affilinet_Client/initialized_with_credentials/_shops/returns_a_Affilinet_Middleware_Mash.yml
|
202
|
-
- spec/cassettes/Affilinet_Client/initialized_with_credentials/categories/performs_the_GET_request_to_the_correct_endpoint.yml
|
203
|
-
- spec/cassettes/Affilinet_Client/initialized_with_credentials/raises_Error_on_wrong_API_requests.yml
|
204
211
|
- spec/cassettes/Affilinet_Client/initialized_with_credentials/raises_Faraday_Error_ParsingError_on_wrong_API_requests.yml
|
205
|
-
- spec/lib/
|
212
|
+
- spec/lib/affilinet/category_spec.rb
|
213
|
+
- spec/lib/affilinet/client_spec.rb
|
214
|
+
- spec/lib/affilinet/middleware/mash.rb
|
215
|
+
- spec/lib/affilinet/product_spec.rb
|
216
|
+
- spec/lib/affilinet/property_spec.rb
|
217
|
+
- spec/lib/affilinet/search_spec.rb
|
218
|
+
- spec/lib/affilinet/shop_spec.rb
|
206
219
|
- spec/spec_helper.rb
|
@@ -1,46 +0,0 @@
|
|
1
|
-
---
|
2
|
-
http_interactions:
|
3
|
-
- request:
|
4
|
-
method: get
|
5
|
-
uri: https://product-api.affili.net/V3/productservice.svc/JSON/GetCategoryList?Password=1TuKEGkOJJ24dN07ByOy&ShopId=0&publisherId=580442
|
6
|
-
body:
|
7
|
-
encoding: US-ASCII
|
8
|
-
string: ''
|
9
|
-
headers:
|
10
|
-
User-Agent:
|
11
|
-
- Faraday v0.8.9
|
12
|
-
Accept-Encoding:
|
13
|
-
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
-
Accept:
|
15
|
-
- '*/*'
|
16
|
-
response:
|
17
|
-
status:
|
18
|
-
code: 200
|
19
|
-
message: OK
|
20
|
-
headers:
|
21
|
-
Content-Length:
|
22
|
-
- '428'
|
23
|
-
Content-Type:
|
24
|
-
- application/json
|
25
|
-
Server:
|
26
|
-
- Microsoft-IIS/7.5
|
27
|
-
X-Powered-By:
|
28
|
-
- ASP.NET
|
29
|
-
Date:
|
30
|
-
- Sat, 15 Feb 2014 17:41:51 GMT
|
31
|
-
body:
|
32
|
-
encoding: ASCII-8BIT
|
33
|
-
string: !binary |-
|
34
|
-
77u/ew0KICAiR2V0Q2F0ZWdvcnlMaXN0U3VtbWFyeSI6IHsNCiAgICAiUmVj
|
35
|
-
b3JkcyI6IDEsDQogICAgIlRvdGFsUmVjb3JkcyI6IDEsDQogICAgIlRvdGFs
|
36
|
-
UGFnZXMiOiAxLA0KICAgICJDdXJyZW50UGFnZSI6IDEsDQogICAgIlByb2dy
|
37
|
-
YW1JZCI6IDAsDQogICAgIlByb2dyYW1UaXRsZSI6ICJhZmZpbGluZXQiLA0K
|
38
|
-
ICAgICJTaG9wVGl0bGUiOiAiYWZmaWxpbmV0IiwNCiAgICAiU2hvcElkIjog
|
39
|
-
MA0KICB9LA0KICAiQ2F0ZWdvcmllcyI6IFsNCiAgICB7DQogICAgICAiSWQi
|
40
|
-
OiAxNCwNCiAgICAgICJJZFBhdGgiOiAiMTQiLA0KICAgICAgIlRpdGxlIjog
|
41
|
-
IkNsb3RoZXMgJiBBY2Nlc3NvcmllcyAiLA0KICAgICAgIlRpdGxlUGF0aCI6
|
42
|
-
ICJDbG90aGVzICYgQWNjZXNzb3JpZXMgIiwNCiAgICAgICJQcm9kdWN0Q291
|
43
|
-
bnQiOiAzMTMNCiAgICB9DQogIF0NCn0=
|
44
|
-
http_version:
|
45
|
-
recorded_at: Sat, 15 Feb 2014 17:41:51 GMT
|
46
|
-
recorded_with: VCR 2.8.0
|
@@ -1,50 +0,0 @@
|
|
1
|
-
---
|
2
|
-
http_interactions:
|
3
|
-
- request:
|
4
|
-
method: get
|
5
|
-
uri: https://product-api.affili.net/V3/productservice.svc/JSON/GetCategoryList?Password=1TuKEGkOJJ24dN07ByOy&ShopId=0&publisherId=580442
|
6
|
-
body:
|
7
|
-
encoding: US-ASCII
|
8
|
-
string: ''
|
9
|
-
headers:
|
10
|
-
User-Agent:
|
11
|
-
- Faraday v0.8.9
|
12
|
-
Accept-Encoding:
|
13
|
-
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
-
Accept:
|
15
|
-
- '*/*'
|
16
|
-
response:
|
17
|
-
status:
|
18
|
-
code: 200
|
19
|
-
message: OK
|
20
|
-
headers:
|
21
|
-
Date:
|
22
|
-
- Sat, 15 Feb 2014 17:40:35 GMT
|
23
|
-
Server:
|
24
|
-
- Microsoft-IIS/6.0
|
25
|
-
X-Powered-By:
|
26
|
-
- ASP.NET
|
27
|
-
X-Aspnet-Version:
|
28
|
-
- 4.0.30319
|
29
|
-
Content-Length:
|
30
|
-
- '428'
|
31
|
-
Cache-Control:
|
32
|
-
- private
|
33
|
-
Content-Type:
|
34
|
-
- application/json
|
35
|
-
body:
|
36
|
-
encoding: ASCII-8BIT
|
37
|
-
string: !binary |-
|
38
|
-
77u/ew0KICAiR2V0Q2F0ZWdvcnlMaXN0U3VtbWFyeSI6IHsNCiAgICAiUmVj
|
39
|
-
b3JkcyI6IDEsDQogICAgIlRvdGFsUmVjb3JkcyI6IDEsDQogICAgIlRvdGFs
|
40
|
-
UGFnZXMiOiAxLA0KICAgICJDdXJyZW50UGFnZSI6IDEsDQogICAgIlByb2dy
|
41
|
-
YW1JZCI6IDAsDQogICAgIlByb2dyYW1UaXRsZSI6ICJhZmZpbGluZXQiLA0K
|
42
|
-
ICAgICJTaG9wVGl0bGUiOiAiYWZmaWxpbmV0IiwNCiAgICAiU2hvcElkIjog
|
43
|
-
MA0KICB9LA0KICAiQ2F0ZWdvcmllcyI6IFsNCiAgICB7DQogICAgICAiSWQi
|
44
|
-
OiAxNCwNCiAgICAgICJJZFBhdGgiOiAiMTQiLA0KICAgICAgIlRpdGxlIjog
|
45
|
-
IkNsb3RoZXMgJiBBY2Nlc3NvcmllcyAiLA0KICAgICAgIlRpdGxlUGF0aCI6
|
46
|
-
ICJDbG90aGVzICYgQWNjZXNzb3JpZXMgIiwNCiAgICAgICJQcm9kdWN0Q291
|
47
|
-
bnQiOiAzMTMNCiAgICB9DQogIF0NCn0=
|
48
|
-
http_version:
|
49
|
-
recorded_at: Sat, 15 Feb 2014 17:40:35 GMT
|
50
|
-
recorded_with: VCR 2.8.0
|
@@ -1,37 +0,0 @@
|
|
1
|
-
---
|
2
|
-
http_interactions:
|
3
|
-
- request:
|
4
|
-
method: get
|
5
|
-
uri: https://product-api.affili.net/V3/productservice.svc/JSON/SearchProducts?CategoryIds=&CurrentPage&ExcludeSubCategories&FQ&FacetFields=&FacetValueLimit&ImageScales=&LogoScales=&MaximumPrice&MinimumPrice&PageSize&Password=1TuKEGkOJJ24dN07ByOy&Query&ShopIdMode=Include&ShopIds=&SortBy&SortOrder=descending&UseAffilinetCategories&WithImageOnly&publisherId=580442
|
6
|
-
body:
|
7
|
-
encoding: US-ASCII
|
8
|
-
string: ''
|
9
|
-
headers:
|
10
|
-
User-Agent:
|
11
|
-
- Faraday v0.8.9
|
12
|
-
Accept-Encoding:
|
13
|
-
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
-
Accept:
|
15
|
-
- '*/*'
|
16
|
-
response:
|
17
|
-
status:
|
18
|
-
code: 400
|
19
|
-
message: Bad Request
|
20
|
-
headers:
|
21
|
-
Content-Length:
|
22
|
-
- '112'
|
23
|
-
Content-Type:
|
24
|
-
- application/json; charset=utf-8
|
25
|
-
Server:
|
26
|
-
- Microsoft-IIS/7.5
|
27
|
-
X-Powered-By:
|
28
|
-
- ASP.NET
|
29
|
-
Date:
|
30
|
-
- Sat, 15 Feb 2014 18:21:17 GMT
|
31
|
-
body:
|
32
|
-
encoding: UTF-8
|
33
|
-
string: '{"ErrorMessages":[{"Key":"2021950074","Value":"FilterQueries, CategoryIds
|
34
|
-
or Query should be set in request."}]}'
|
35
|
-
http_version:
|
36
|
-
recorded_at: Sat, 15 Feb 2014 18:21:18 GMT
|
37
|
-
recorded_with: VCR 2.8.0
|
data/spec/lib/client_spec.rb
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Affilinet::Client, :vcr do
|
4
|
-
it 'raises ArgumentError if initialized with no options' do
|
5
|
-
expect do
|
6
|
-
Affilinet::Client.new
|
7
|
-
end.to raise_error ArgumentError
|
8
|
-
end
|
9
|
-
|
10
|
-
context 'initialized with credentials' do
|
11
|
-
subject { Affilinet::Client.new publisher_id: 580442, password: '1TuKEGkOJJ24dN07ByOy' }
|
12
|
-
|
13
|
-
it 'raises Faraday::Error::ParsingError on wrong API requests' do
|
14
|
-
expect do
|
15
|
-
subject.search
|
16
|
-
end.to raise_error Faraday::Error::ParsingError
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#connection' do
|
20
|
-
it 'is an instance of Faraday::Connection' do
|
21
|
-
expect(subject.connection).to be_an_instance_of Faraday::Connection
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '#options' do
|
26
|
-
it 'includes publisher_id' do
|
27
|
-
expect(subject.options).to include(:publisher_id)
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'includes password' do
|
31
|
-
expect(subject.options).to include(:password)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe '#categories' do
|
36
|
-
it 'performs the GET request to the correct endpoint' do
|
37
|
-
expect(subject).to receive(:get).with('GetCategoryList', {'ShopId'=>0})
|
38
|
-
subject.categories
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'returns a Affilinet::Middleware::Mash' do
|
42
|
-
expect(subject.categories).to be_an_instance_of Affilinet::Middleware::Mash
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '#properties' do
|
47
|
-
it 'performs the GET request to the correct endpoint' do
|
48
|
-
expect(subject).to receive(:get).with('GetPropertyList', {'ShopId'=>1})
|
49
|
-
subject.properties 1
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'returns a Affilinet::Middleware::Mash' do
|
53
|
-
expect(subject.properties 1748).to be_an_instance_of Affilinet::Middleware::Mash
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe '#shops' do
|
58
|
-
it 'performs the GET request to the correct endpoint' do
|
59
|
-
expect(subject).to receive(:get).with('GetShopList', {"LogoScale"=>nil,
|
60
|
-
"CurrentPage"=>nil, "PageSize"=>nil, "Query"=>nil, "UpdatedAfter"=>nil})
|
61
|
-
subject.shops
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'returns a Affilinet::Middleware::Mash' do
|
65
|
-
expect(subject.shops).to be_an_instance_of Affilinet::Middleware::Mash
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe '#products' do
|
70
|
-
it 'performs the GET request to the correct endpoint' do
|
71
|
-
expect(subject).to receive(:get).with('GetProducts', {"ProductIds"=>"",
|
72
|
-
"ImageScales"=>"", "LogoScales"=>""})
|
73
|
-
subject.products
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'returns a Affilinet::Middleware::Mash' do
|
77
|
-
expect(subject.products [580858761,580858759]).to be_an_instance_of Affilinet::Middleware::Mash
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
describe '#search' do
|
82
|
-
it 'performs the GET request to the correct endpoint' do
|
83
|
-
expect(subject).to receive(:get).with('SearchProducts', {"ShopIds"=>"",
|
84
|
-
"ShopIdMode"=>"Include", "Query"=>nil, "CategoryIds"=>"",
|
85
|
-
"UseAffilinetCategories"=>nil, "ExcludeSubCategories"=>nil,
|
86
|
-
"WithImageOnly"=>nil, "ImageScales"=>"", "LogoScales"=>"",
|
87
|
-
"CurrentPage"=>nil, "PageSize"=>nil, "MinimumPrice"=>nil,
|
88
|
-
"MaximumPrice"=>nil, "SortBy"=>nil, "SortOrder"=>"descending",
|
89
|
-
"FacetFields"=>"", "FacetValueLimit"=>nil, "FQ"=>nil})
|
90
|
-
subject.search
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'returns a Affilinet::Middleware::Mash' do
|
94
|
-
expect(subject.search query: 'jeans').to be_an_instance_of Affilinet::Middleware::Mash
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|