aboutyou-sdk 0.0.9 → 0.0.10

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjEwNWU3MTUxOGVmMWM4OGU1NmI3N2EzODUxZDQxNDc4MTYwMDg1ZA==
4
+ MDdiN2JjYmMwYTVkOGY2MTUwYmQ0MzdlZGNjODRiMDdkNTlmNDA0ZA==
5
5
  data.tar.gz: !binary |-
6
- ZjJhZTViOGQzOTNmNGQzN2RmNjY2YjE5ZjMyNWJlNWZmZjczNjQ4Yg==
6
+ NGI0M2JmOTg4MjI2ODk0YzA2NGNmOGE1ODJhNmMwM2ZiOTAzNDBiZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- N2IyNDAyNTE1OGY2MjY3YmRkZjQ4ZjY5ZWY0NWY3OTBjNmY5YjRhYzAxYmRl
10
- YmI1YWNhOTE1YzllNDAwMGQ1MjIyNTIyMjdhMTJhMmQ5ZWE3Y2IyZThiNzlh
11
- ZmZmZDhiZjg0ZWE4MGFiZGJjZThlZjQ1YjlmNzYwZTJmYjYxMzY=
9
+ ZTVmODJjYjM2YTI0NTg1ODk3OWU3NWU4ODc2ZjI5ZjIxZGZhY2E4N2M4ZmFk
10
+ MzkwNmQ4ZjY3NTFhOTNkYTJiNzJhZDExNjkxNzgxOTE4NDkxODM4MmMxOTVm
11
+ YmRhZDczYjE1ZTQ4ODc4MTE1ZWVlYWM4NWMwNTYwNTlhNzVhNDQ=
12
12
  data.tar.gz: !binary |-
13
- NjExZDYwM2U1YTdiZWNmY2EyZDdiYmEwYjAwZDJiZjkzOWE1NmRlZDA1Y2Nm
14
- NTVlYjRmMzhjMmZmNjBjNDU1ZDQ3MjE0OTBjMzVkOTIzNThjNmEyNThkMmU3
15
- NjIwYjk1MDg0NTQ3N2NiNDgzNWFlYzhiM2I0NjFhZTE0MWFiNDI=
13
+ YjI3Zjk2MGVkNTQxMzRlYzJjZWY0NjVkYmRmYzQyYzM2ODJlZTQ4MDg0MWJh
14
+ NGU1NWRlNDk4NmZkYTdmNjE2Nzk0MmQyNDAxYmViYTFlMjU0MDdmMTY1M2U3
15
+ MmYxMTM3ZWVmMTIwNmRiMTA5YTE0MzAzNjRlOGM5MGVlMDRmYWM=
data/lib/aboutyou-sdk.rb CHANGED
@@ -2,44 +2,57 @@ require 'httparty'
2
2
  require 'json'
3
3
  require 'require_all'
4
4
 
5
- require_rel "aboutyou-sdk"
6
-
7
- ###
8
- # Provides access to the Collins Frontend Platform.
9
- # All the public methods cover a single API query.
10
- #
11
- # author:: Collins GmbH & Co KG
12
- ###
5
+ require_rel 'aboutyou-sdk'
6
+
7
+ ###
8
+ # Provides access to the Collins Frontend Platform.
9
+ # All the public methods cover a single API query.
10
+ #
11
+ # author:: Collins GmbH & Co KG
12
+ ###
13
13
  class AY
14
+
15
+ # url for staging
14
16
  IMAGE_URL_STAGE = 'http://mndb.staging.aboutyou.de/mmdb/file'
17
+ # url for the sandbox
15
18
  IMAGE_URL_SANDBOX = 'http://mndb.sandbox.aboutyou.de/mmdb/file'
19
+ # url for live
16
20
  IMAGE_URL_LIVE = 'http://cdn.aboutyou.de/file'
17
21
 
22
+ # the client which performs the api calls
18
23
  attr_accessor :aboutYouClient
24
+ # the app id of the app which should be represented by an instance of AY
19
25
  attr_accessor :appId
26
+ # the authentifaction token from dev-center for the app id
20
27
  attr_accessor :appPassword
28
+ # the endpoint used for api calls
21
29
  attr_accessor :apiEndPoint
30
+ # the environment which should be used by the app
22
31
  attr_accessor :environment
32
+ # a logger template
23
33
  attr_accessor :logger
34
+ # the model factory builds model objects based on the api response
24
35
  attr_accessor :modelFactoryInstance
36
+ # the url for getting images
25
37
  attr_accessor :baseImageUrl
38
+ # the session id from a user using this app
26
39
  attr_accessor :sessionId
27
40
 
28
- ###
29
- # the Constructor for the AY class
30
- #
31
- # * *Args* :
32
- # - +appId+ -> The App-Id of the App
33
- # - +appPassword+ -> The Auth-Token of the App
34
- # - +sessionId+ -> A String containing the sessionId of the User
35
- # - +apiEndPoint+ -> Can be either live or staging
36
- # - +resultFactory+ -> If nil it will use the DefaultModelFactory with the DefaultFacetManager
37
- # - +logger+ -> Logger-Template
38
- # - +facetManagerCache+ -> The prefered Caching-Strategy
39
- #
40
- # * *Returns* :
41
- # - Instance of AY
42
- ###
41
+ ###
42
+ # the Constructor for the AY class
43
+ #
44
+ # * *Args* :
45
+ # - +appId+ -> The App-Id of the App
46
+ # - +appPassword+ -> The Auth-Token of the App
47
+ # - +sessionId+ -> A String containing the sessionId of the User
48
+ # - +apiEndPoint+ -> Can be either live or staging
49
+ # - +resultFactory+ -> If nil it will use the DefaultModelFactory with the DefaultFacetManager
50
+ # - +logger+ -> Logger-Template
51
+ # - +facetManagerCache+ -> The prefered Caching-Strategy
52
+ #
53
+ # * *Returns* :
54
+ # - Instance of AY
55
+ ###
43
56
  def initialize(
44
57
  appId,
45
58
  appPassword,
@@ -53,34 +66,40 @@ class AY
53
66
  self.sessionId = sessionId
54
67
  self.appId = appId
55
68
  self.appPassword = appPassword
56
- self.aboutYouClient = AboutYou::SDK::Client.new(appId, appPassword, apiEndPoint, logger)
69
+ self.aboutYouClient = AboutYou::SDK::Client.new(
70
+ appId,
71
+ appPassword,
72
+ apiEndPoint,
73
+ logger
74
+ )
57
75
  resultFactory ? self.modelFactoryInstance = resultFactory : initDefaultFactory(facetManagerCache)
58
76
 
59
77
  if apiEndPoint == AboutYou::SDK::Constants::API_ENVIRONMENT_STAGE
60
- self.baseImageUrl=(IMAGE_URL_STAGE)
78
+ self.baseImageUrl = (IMAGE_URL_STAGE)
61
79
  self.environment = AboutYou::SDK::Constants::API_ENVIRONMENT_STAGE
62
80
  elsif apiEndPoint == AboutYou::SDK::Constants::API_ENVIRONMENT_SANDBOX
63
- self.baseImageUrl=(IMAGE_URL_SANDBOX)
81
+ self.baseImageUrl = (IMAGE_URL_SANDBOX)
64
82
  self.environment = AboutYou::SDK::Constants::API_ENVIRONMENT_SANDBOX
65
- else
66
- self.baseImageUrl=(IMAGE_URL_LIVE)
83
+ else
84
+ self.baseImageUrl = (IMAGE_URL_LIVE)
67
85
  end
68
86
  end
69
87
 
70
-
71
- ###
72
- # Adds a single item into the basket.
73
- # You can specify an amount. Please mind, that an amount > 1 will result in #amount basket positions.
74
- # So if you read out the basket again later, it's your job to merge the positions again.
75
- #
76
- # * *Args* :
77
- # - +sessionId+ -> A String containing the sessionId of the User
78
- # - +variantId+ -> The Id of the Variant which should be added to the basket
79
- # - +amount+ -> The Amount of the Item which should be added to the basket
80
- #
81
- # * *Returns* :
82
- # - Instance of AboutYou::SDK::Model::Basket
83
- ###
88
+ ###
89
+ # Adds a single item into the basket.
90
+ # You can specify an amount. Please mind, that an amount > 1 will result
91
+ # in #amount basket positions.
92
+ # So if you read out the basket again later, it's your job to
93
+ # merge the positions again.
94
+ #
95
+ # * *Args* :
96
+ # - +sessionId+ -> A String containing the sessionId of the User
97
+ # - +variantId+ -> Id of the Variant which should be added to the basket
98
+ # - +amount+ -> The Amount of the Item which should be added to the basket
99
+ #
100
+ # * *Returns* :
101
+ # - Instance of AboutYou::SDK::Model::Basket
102
+ ###
84
103
  def addItemToBasket(sessionId, variantId, amount = 1)
85
104
 
86
105
  basket = AboutYou::SDK::Model::Basket.new
@@ -471,7 +490,7 @@ class AY
471
490
 
472
491
  ###
473
492
  # Returns the URL to the Collins JavaScript file for helper functions
474
- # to add product variants into the basket of Mary & Paul or auto-resizing
493
+ # to add product variants into the basket of AboutYou or auto-resizing
475
494
  # the Iframe. This URL may be changed in future, so please use this method instead
476
495
  # of hardcoding the URL into your HTML template.
477
496
  #
@@ -520,9 +539,7 @@ class AY
520
539
  # Setter-Method for the api endpoint
521
540
  #
522
541
  # * *Args* :
523
- # - +apiEndPoint+ -> the endpoint can be the string 'stage' or 'live',
524
- # then the default endpoints will be used or
525
- # an absolute url
542
+ # - +apiEndPoint+ -> the endpoint can be the string 'stage' or 'live', then the default endpoints will be used or an absolute url
526
543
  ###
527
544
  def apiEndpoint=(apiEndPoint)
528
545
 
@@ -7,13 +7,20 @@ module AboutYou
7
7
  ###
8
8
  class Client
9
9
 
10
+ # url for staging-api-requests
10
11
  API_END_POINT_STAGE = 'http://shop-api.staging.aboutyou.de/api'
12
+ # url for sandbox-api-requests
11
13
  API_END_POINT_SANDBOX = 'http://shop-api.sandbox.aboutyou.de/api'
14
+ # url for live-api-requests
12
15
  API_END_POINT_LIVE = 'https://shop-api.aboutyou.de/api'
13
16
 
17
+ # the app id of the app which should be represented by an instance of AY
14
18
  attr_accessor :appId
19
+ # the authentifaction token from dev-center for the app id
15
20
  attr_accessor :appPassword
21
+ # the url used for api calls
16
22
  attr_accessor :apiEndPoint
23
+ # the page id of the current page visited by an user
17
24
  attr_accessor :pageId
18
25
 
19
26
 
@@ -6,43 +6,78 @@ module AboutYou
6
6
  # Author:: Collins GmbH & Co KG
7
7
  ###
8
8
  module Constants
9
- SDK_VERSION = 0.1
10
- FACET_BRAND = 0
11
- FACET_COLOR = 1
12
- FACET_SIZE = 2
13
- FACET_GENDERAGE = 3
14
- FACET_CUPSIZE = 4
15
- FACET_LENGTH = 5
16
- FACET_DIMENSION3 = 6
17
- FACET_SIZE_CODE = 206
18
- FACET_SIZE_RUN = 172
19
- FACET_CLOTHING_UNISEX_INT = 173
20
- FACET_CLOTHING_UNISEX_INCH = 174
21
- FACET_SHOES_UNISEX_EUR = 194
22
- FACET_CLOTHING_WOMEN_DE = 175
23
- FACET_CLOTHING_UNISEX_ONESIZE = 204
24
- FACET_SHOES_UNISEX_ADIDAS_EUR = 195
25
- FACET_CLOTHING_WOMEN_BELTS_CM = 181
26
- FACET_CLOTHING_WOMEN_INCH = 180
27
- FACET_CLOTHING_MEN_BELTS_CM = 190
28
- FACET_CLOTHING_MEN_INCH = 189
29
- FACET_CLOTHING_MEN_DE = 187
30
- FACET_CONDITION = 234
31
- FACET_QUANTITY_PER_PACK = 263
32
- FACET_SEASON_CODE = 289
9
+
10
+ # Version of the SDK
11
+ SDK_VERSION = 0.1
12
+ # Group Id for Brands
13
+ FACET_BRAND = 0
14
+ # Group Id for Color
15
+ FACET_COLOR = 1
16
+ # Group Id for Size
17
+ FACET_SIZE = 2
18
+ # Group Id for Gender/Age
19
+ FACET_GENDERAGE = 3
20
+ # Group Id for Cupsize
21
+ FACET_CUPSIZE = 4
22
+ # Group Id for Length
23
+ FACET_LENGTH = 5
24
+ # Group Id for Dimensions
25
+ FACET_DIMENSION3 = 6
26
+ # Group Id for Size-Codes
27
+ FACET_SIZE_CODE = 206
28
+ # Group Id for Size_Run
29
+ FACET_SIZE_RUN = 172
30
+ # Group Id for Clothing_Unisex_Int
31
+ FACET_CLOTHING_UNISEX_INT = 173
32
+ # Group Id for Clothing_Unisex_Inch
33
+ FACET_CLOTHING_UNISEX_INCH = 174
34
+ # Group Id for Clothing_Unisex_Eur
35
+ FACET_SHOES_UNISEX_EUR = 194
36
+ # Group Id for Clothing_Women_DE
37
+ FACET_CLOTHING_WOMEN_DE = 175
38
+ # Group Id for Clothing_Unisex_Onesize
39
+ FACET_CLOTHING_UNISEX_ONESIZE = 204
40
+ # Group Id for Shoes_Unisex_Adidas_Eur
41
+ FACET_SHOES_UNISEX_ADIDAS_EUR = 195
42
+ # Group Id for Clothing_Women_Belts_Cm
43
+ FACET_CLOTHING_WOMEN_BELTS_CM = 181
44
+ # Group Id for Clothing_Women_Inch
45
+ FACET_CLOTHING_WOMEN_INCH = 180
46
+ # Group Id for Clothing_Men_Belts_Cm
47
+ FACET_CLOTHING_MEN_BELTS_CM = 190
48
+ # Group Id for Clothing_Men_Inch
49
+ FACET_CLOTHING_MEN_INCH = 189
50
+ # Group Id for Clothing_Men_De
51
+ FACET_CLOTHING_MEN_DE = 187
52
+ # Group Id for Condition
53
+ FACET_CONDITION = 234
54
+ # Group Id for Quantity_Per_Pack
55
+ FACET_QUANTITY_PER_PACK = 263
56
+ # Group Id for Season Code
57
+ FACET_SEASON_CODE = 289
58
+
59
+ # Sort-argument passed to api for relevance
60
+ SORT_RELEVANCE = 'relevance'
61
+ # Sort-argument passed to api for last updated
62
+ SORT_UPDATED = 'updated_date'
63
+ # Sort-argument passed to api for creation date
64
+ SORT_CREATED = 'created_date'
65
+ # Sort-argument passed to api for most viewed
66
+ SORT_MOST_VIEWED = 'most_viewed'
67
+ # Sort-argument passed to api for price
68
+ SORT_PRICE = 'price'
33
69
 
34
- SORT_RELEVANCE = 'relevance'
35
- SORT_UPDATED = 'updated_date'
36
- SORT_CREATED = 'created_date'
37
- SORT_MOST_VIEWED = 'most_viewed'
38
- SORT_PRICE = 'price'
70
+ # argument for api when requiring products
71
+ TYPE_PRODUCTS = 'products'
72
+ # argument for api when requiring categories
73
+ TYPE_CATEGORIES = 'categories'
39
74
 
40
- TYPE_PRODUCTS = 'products'
41
- TYPE_CATEGORIES = 'categories'
42
-
43
- API_ENVIRONMENT_STAGE = 'stage'
44
- API_ENVIRONMENT_SANDBOX = 'sandbox'
45
- API_ENVIRONMENT_LIVE = 'live'
75
+ # environment-named for api-staging
76
+ API_ENVIRONMENT_STAGE = 'stage'
77
+ # environment-named for api-sandbox
78
+ API_ENVIRONMENT_SANDBOX = 'sandbox'
79
+ # environment-named for api-live
80
+ API_ENVIRONMENT_LIVE = 'live'
46
81
  end
47
82
  end
48
83
  end
@@ -1,54 +1,101 @@
1
1
  module AboutYou
2
2
  module SDK
3
3
  module Criteria
4
+ ###
5
+ # This class is used for the selection of certain product fields
6
+ # which should be fetched in addition when making an api call
7
+ #
8
+ # author:: Collins GmbH & Co KG
9
+ ###
4
10
  class ProductFields
5
- ###
6
- # id and name is set per default
7
- ###
8
- IS_ACTIVE = "active"
9
- BRAND = "brand_id"
10
- DESCRIPTION_LONG = "description_long"
11
- DESCRIPTION_SHORT = "description_short"
12
- DEFAULT_VARIANT = "default_variant"
13
- VARIANTS = "variants"
14
- MIN_PRICE = "min_price"
15
- MAX_PRICE = "max_price"
16
- IS_SALE = "sale"
17
- DEFAULT_IMAGE = "default_image"
18
- ATTRIBUTES_MERGED = "attributes_merged"
19
- CATEGORIES = "categories"
20
- INACTIVE_VARIANTS = "inactive_variants"
21
- MAX_SAVINGS = "max_savings"
22
- MAX_SAVINGS_PERCENTAGE = "max_savings_percentage"
23
- tags = "tags"
11
+ # id and name is set per default
12
+
13
+ #product field "is_active"
14
+ IS_ACTIVE = 'active'
15
+ #product field "brand_id"
16
+ BRAND = 'brand_id'
17
+ #product field "description_long"
18
+ DESCRIPTION_LONG = 'description_long'
19
+ #product field "description_short"
20
+ DESCRIPTION_SHORT = 'description_short'
21
+ #product field "default_variant"
22
+ DEFAULT_VARIANT = 'default_variant'
23
+ #product field "variants"
24
+ VARIANTS = 'variants'
25
+ #product field "min_price"
26
+ MIN_PRICE = 'min_price'
27
+ #product field "max_price"
28
+ MAX_PRICE = 'max_price'
29
+ #product field "sale"
30
+ IS_SALE = 'sale'
31
+ #product field "default_image"
32
+ DEFAULT_IMAGE = 'default_image'
33
+ #product field "attributes_merged"
34
+ ATTRIBUTES_MERGED = 'attributes_merged'
35
+ #product field "categories"
36
+ CATEGORIES = 'categories'
37
+ #product field "inactive_variants"
38
+ INACTIVE_VARIANTS = 'inactive_variants'
39
+ #product field "max_savings"
40
+ MAX_SAVINGS = 'max_savings'
41
+ #product field "max_savings_percentage"
42
+ MAX_SAVINGS_PERCENTAGE = 'max_savings_percentage'
43
+ #product field "tags"
44
+ TAGS = 'tags'
24
45
 
46
+ ###
47
+ # filters a given set of fields
48
+ #
49
+ # * *Args* :
50
+ # - +fields+ -> an Array of product fields which should be filtered
51
+ #
52
+ # * *Returns* :
53
+ # - a filtered Array of product fields
54
+ ###
25
55
  def self.filterFields(fields)
26
56
  fields = fields.uniq
27
57
 
28
58
  # this simplifies parsing on (pre)fetching facets
29
- if (
30
- fields.include? ATTRIBUTES_MERGED && (
59
+ if (fields.include? ATTRIBUTES_MERGED) && (
31
60
  fields.include?(BRAND) ||
32
61
  fields.include?(VARIANTS) ||
33
62
  fields.include?(DEFAULT_VARIANT)
34
63
  )
35
- )
36
64
  fields.push(ATTRIBUTES_MERGED)
37
65
  end
38
-
39
- return fields;
66
+ fields
40
67
  end
41
-
68
+
69
+ ###
70
+ # determines whether the api call has to require Facets or not
71
+ #
72
+ # * *Args* :
73
+ # - +fields+ -> an Array of product fields which should be filtered
74
+ #
75
+ # * *Returns* :
76
+ # - a boolean which is true when ap call has to require facets
77
+ ###
42
78
  def self.requiresFacets(fields)
43
- requiredFacetFields = [BRAND,VARIANTS,DEFAULT_VARIANT,ATTRIBUTES_MERGED] & fields
44
- return (requiredFacetFields.count > 0);
79
+ ([BRAND,
80
+ VARIANTS,
81
+ DEFAULT_VARIANT,
82
+ ATTRIBUTES_MERGED
83
+ ] & fields).count > 0
45
84
  end
46
85
 
86
+ ###
87
+ # determines whether the api call has to require Categories or not
88
+ #
89
+ # * *Args* :
90
+ # - +fields+ -> an Array of product fields which should be filtered
91
+ #
92
+ # * *Returns* :
93
+ # - a boolean which is true when ap call has to require categories
94
+ ###
47
95
  def self.requiresCategories(fields)
48
-
49
- return fields.include?(CATEGORIES)
96
+ fields.include?(CATEGORIES)
50
97
  end
51
98
  end
52
99
  end
53
100
  end
54
- end
101
+ end