epages-rest 1.0.5 → 1.0.6
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 +4 -4
- data/lib/epages/newsletter.rb +17 -0
- data/lib/epages/product.rb +2 -14
- data/lib/epages/rest/api.rb +2 -0
- data/lib/epages/rest/carts.rb +8 -2
- data/lib/epages/rest/customers.rb +8 -0
- data/lib/epages/rest/newsletters.rb +21 -0
- data/lib/epages/rest/orders.rb +0 -8
- data/lib/epages/rest/products.rb +17 -19
- data/lib/epages/subscriber.rb +15 -0
- data/lib/epages/utils.rb +11 -3
- data/lib/epages/version.rb +1 -1
- data/lib/epages-rest.rb +3 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90f0916b52d7493d5a4e551e896a5087f691880e
|
4
|
+
data.tar.gz: 24c8d720fda0a80806c383455cd2025b05627504
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e101a31f432ef803fc953c9ef0d12bfd35f046b1cf7771bf04cc61ac4cd941046c99c556b4f272aaa100d00817a1321c057ffb6f0f2a613bd2ff29ccb5743b9
|
7
|
+
data.tar.gz: ae871cbb63b7e786782616f1e8270d17b98e5d4d17d1e77935eda3d94307831f19642ee6e70f4f2c7ccf94821290ada1dd4dfd69052fe97425ee9e17fa006d95
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'epages/utils'
|
2
|
+
|
3
|
+
module Epages
|
4
|
+
class Newsletter
|
5
|
+
include Epages::Utils
|
6
|
+
|
7
|
+
KEYS = %w(campaign_id language identifier name description number_of_subscribers subject).collect(&:to_sym).freeze
|
8
|
+
|
9
|
+
attr_reader *KEYS
|
10
|
+
|
11
|
+
def initialize(data)
|
12
|
+
parse_attributes(data)
|
13
|
+
end
|
14
|
+
|
15
|
+
alias_method :id, :campaign_id
|
16
|
+
end
|
17
|
+
end
|
data/lib/epages/product.rb
CHANGED
@@ -8,7 +8,8 @@ module Epages
|
|
8
8
|
|
9
9
|
KEYS = %w(product_id name short_description description product_image images price_info for_sale special_offer delivery_weight
|
10
10
|
shipping_methods_restricted_to availability_text availability energy_labels_string energy_label_source_file
|
11
|
-
product_data_sheet sf_url product_number manufacturer upc ean essential_features search_keywords links
|
11
|
+
product_data_sheet sf_url product_number manufacturer upc ean essential_features search_keywords links tax_class
|
12
|
+
stocklevel watchers).collect(&:to_sym).freeze
|
12
13
|
|
13
14
|
attr_reader *KEYS
|
14
15
|
|
@@ -97,19 +98,6 @@ module Epages
|
|
97
98
|
product_lowest_price(self) if link?('lowest-price')
|
98
99
|
end
|
99
100
|
|
100
|
-
# returns the stock level of the product
|
101
|
-
def stock_level
|
102
|
-
product_stock_level(self)[:stocklevel]
|
103
|
-
end
|
104
|
-
|
105
|
-
# modify the current stock level in [units]
|
106
|
-
#
|
107
|
-
# @param units [Fixnum]. Number of units to change. Can be negative
|
108
|
-
# @param shop [Epages::Shop]. The shop that contains the authorization to do the call
|
109
|
-
def change_stock_level(units, shop)
|
110
|
-
shop.product_change_stock_level(self, units)[:stocklevel]
|
111
|
-
end
|
112
|
-
|
113
101
|
# return a hash with productId and quantity. This format is used for the line_items of Cart
|
114
102
|
def to_line_item(quantity = 1)
|
115
103
|
{productId: product_id, quantity: quantity}
|
data/lib/epages/rest/api.rb
CHANGED
@@ -3,6 +3,7 @@ require 'epages/rest/categories'
|
|
3
3
|
require 'epages/rest/customers'
|
4
4
|
require 'epages/rest/legal'
|
5
5
|
require 'epages/rest/miscellaneous'
|
6
|
+
require 'epages/rest/newsletters'
|
6
7
|
require 'epages/rest/orders'
|
7
8
|
require 'epages/rest/products'
|
8
9
|
require 'epages/rest/sales'
|
@@ -16,6 +17,7 @@ module Epages
|
|
16
17
|
include REST::Customers
|
17
18
|
include REST::Legal
|
18
19
|
include REST::Miscellaneous
|
20
|
+
include REST::Newsletters
|
19
21
|
include REST::Orders
|
20
22
|
include REST::Products
|
21
23
|
include REST::Sales
|
data/lib/epages/rest/carts.rb
CHANGED
@@ -49,7 +49,7 @@ module Epages
|
|
49
49
|
end
|
50
50
|
|
51
51
|
# implements the call https://developer.epages.com/apps/api-reference/delete-shops-shopid-carts-cartid-billing-address.html
|
52
|
-
def
|
52
|
+
def delete_cart_billing_address(cart)
|
53
53
|
id = epages_id(cart)
|
54
54
|
perform_delete_with_object("/carts/#{id}/billing-address", {}, Epages::Cart)
|
55
55
|
end
|
@@ -62,10 +62,16 @@ module Epages
|
|
62
62
|
end
|
63
63
|
|
64
64
|
# implements the call https://developer.epages.com/apps/api-reference/delete-shops-shopid-carts-cartid-shipping-address.html
|
65
|
-
def
|
65
|
+
def delete_cart_shipping_address(cart)
|
66
66
|
id = epages_id(cart)
|
67
67
|
perform_delete_with_object("/carts/#{id}/shipping-address", {}, Epages::Cart)
|
68
68
|
end
|
69
|
+
|
70
|
+
# implements the call https://developer.epages.com/apps/api-reference/post-shops-shopid-carts-cartid-order.html
|
71
|
+
def order_cart(cart)
|
72
|
+
id = epages_id(cart)
|
73
|
+
perform_post_with_object("/carts/#{id}/order", {}, Epages::Order)
|
74
|
+
end
|
69
75
|
end
|
70
76
|
end
|
71
77
|
end
|
@@ -6,6 +6,14 @@ module Epages
|
|
6
6
|
module Customers
|
7
7
|
include REST::Utils
|
8
8
|
|
9
|
+
# call the API and return an array of Epages::Customer
|
10
|
+
# implements the call https://developer.epages.com/apps/api-reference/get-shops-shopid-customers.html
|
11
|
+
#
|
12
|
+
# @param options [Hash]
|
13
|
+
def customers(options = {})
|
14
|
+
perform_get_with_key_and_objects('/customers', options, :items, Epages::Customer)
|
15
|
+
end
|
16
|
+
|
9
17
|
# call the API to creates a customer. If customer_number is not provided in the request, it will be generated automatically.
|
10
18
|
# implements the call https://developer.epages.com/apps/api-reference/post-shops-shopid-customers.html
|
11
19
|
#
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'epages/rest/utils'
|
2
|
+
|
3
|
+
module Epages
|
4
|
+
module REST
|
5
|
+
# implements the calls in https://developer.epages.com/apps/api-reference/resource-newsletter-campaigns.html
|
6
|
+
module Newsletters
|
7
|
+
include REST::Utils
|
8
|
+
|
9
|
+
# implements the call https://developer.epages.com/apps/api-reference/get-shops-shopid-newsletter-campaigns.html
|
10
|
+
def newsletters(options = {})
|
11
|
+
perform_get_with_key_and_objects('/newsletter-campaigns', options, :items, Epages::Newsletter)
|
12
|
+
end
|
13
|
+
|
14
|
+
# implements the call https://developer.epages.com/apps/api-reference/get-shops-shopid-newsletter-campaigns-campaignid-subscribers.html
|
15
|
+
def newsletter_subscribers(newsletter, options = {})
|
16
|
+
id = epages_id(newsletter)
|
17
|
+
perform_get_with_key_and_objects("/newsletter-campaigns/#{id}/subscribers", options, :items, Epages::Subscriber)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/epages/rest/orders.rb
CHANGED
@@ -17,14 +17,6 @@ module Epages
|
|
17
17
|
perform_get_with_object("/orders/#{id}", options, Epages::Order)
|
18
18
|
end
|
19
19
|
|
20
|
-
# implements the calls in https://developer.epages.com/apps/api-reference/put-shops-shopid-orders-orderid.html
|
21
|
-
def modify_order(order, options, locale = 'en_GB')
|
22
|
-
options.each { |k, v| options[k] = v.to_json if v.class.name.deconstantize == 'Epages' }
|
23
|
-
id = epages_id(order)
|
24
|
-
old_order = perform_get_request("/orders/#{id}", locale: locale)
|
25
|
-
perform_put_with_object("/orders/#{id}?locale=#{locale}", old_order.merge(options), Epages::Order)
|
26
|
-
end
|
27
|
-
|
28
20
|
# implements the calls in https://developer.epages.com/apps/api-reference/patch-shops-shopid-orders-orderid.html
|
29
21
|
def update_order(order, options = {}, locale = 'en_GB')
|
30
22
|
id = epages_id(order)
|
data/lib/epages/rest/products.rb
CHANGED
@@ -24,6 +24,15 @@ module Epages
|
|
24
24
|
perform_get_with_object("/products/#{id}", options, Epages::Product)
|
25
25
|
end
|
26
26
|
|
27
|
+
# call the API to create a new product wit hte data provided and return the product created as Epages::Product
|
28
|
+
# implements the call https://developer.epages.com/apps/api-reference/post-shops-shopid-products.html
|
29
|
+
#
|
30
|
+
# @param data [Hash]
|
31
|
+
# @param options [Hash]
|
32
|
+
def create_product(data, options = {})
|
33
|
+
perform_post_with_object("/products#{to_query_options(options)}", data, Epages::Product)
|
34
|
+
end
|
35
|
+
|
27
36
|
# call the API and return a Epages::Product
|
28
37
|
# implements the call https://developer.epages.com/apps/api-reference/patch-shops-shopid-products-productid.html
|
29
38
|
#
|
@@ -124,25 +133,6 @@ module Epages
|
|
124
133
|
perform_get_with_key_and_objects("/products/#{id}/categories", options, :links, Epages::Link)
|
125
134
|
end
|
126
135
|
|
127
|
-
# call the API and return a hash that contains the stock-level
|
128
|
-
# implements the call https://developer.epages.com/apps/api-reference/get-shops-shopid-products-productid-stock-level.html
|
129
|
-
#
|
130
|
-
# @param product [String], [Epages::Product]
|
131
|
-
def product_stock_level(product)
|
132
|
-
id = epages_id(product)
|
133
|
-
perform_get_request("/products/#{id}/stock-level", {})[:stocklevel]
|
134
|
-
end
|
135
|
-
|
136
|
-
# call the API to modify the current stock level of the product
|
137
|
-
# implements the call https://developer.epages.com/apps/api-reference/get-shops-shopid-products-productid-stock-level.html
|
138
|
-
#
|
139
|
-
# @param product [String], [Epages::Product]
|
140
|
-
# @param units [Fixnum]
|
141
|
-
def product_change_stock_level(product, units)
|
142
|
-
id = epages_id(product)
|
143
|
-
perform_put_request("/products/#{id}/stock-level", changeStocklevel: units)[:stocklevel]
|
144
|
-
end
|
145
|
-
|
146
136
|
# call the API and return an array of Epages::Product with updated attribute
|
147
137
|
# implements the call https://developer.epages.com/apps/api-reference/get-shops-shopid-products-updated-productproperty.html
|
148
138
|
#
|
@@ -160,6 +150,14 @@ module Epages
|
|
160
150
|
def export_products(options = {})
|
161
151
|
perform_get_request('/products/export', options)
|
162
152
|
end
|
153
|
+
|
154
|
+
# call the API and returns the list of all watched products. Watched products refers to items currently out of stock and therefore can be watched by online shop customers.
|
155
|
+
# implements the call https://developer.epages.com/apps/api-reference/get-shops-shopid-watched-products.html
|
156
|
+
#
|
157
|
+
# @param options [Hash]
|
158
|
+
def watched_products(options = {})
|
159
|
+
perform_get_with_key_and_objects('/watched-products', options, :items, Epages::Product)
|
160
|
+
end
|
163
161
|
end
|
164
162
|
end
|
165
163
|
end
|
data/lib/epages/utils.rb
CHANGED
@@ -52,12 +52,12 @@ module Epages
|
|
52
52
|
# @param hash [Hash]
|
53
53
|
def camelize_keys(hash)
|
54
54
|
return unless hash.is_a?(Hash)
|
55
|
+
other = {}
|
55
56
|
hash.keys.each do |k|
|
56
57
|
key = k.to_s.camelize(:lower).to_sym
|
57
|
-
|
58
|
-
hash.delete(k) if key != k
|
58
|
+
other[key] = hash[k]
|
59
59
|
end
|
60
|
-
|
60
|
+
other
|
61
61
|
end
|
62
62
|
|
63
63
|
# return the hash with the keys converted to underscore
|
@@ -116,5 +116,13 @@ module Epages
|
|
116
116
|
def camelize_words(string)
|
117
117
|
string.to_s.gsub(/(\w+)/) { |s| s.camelize(:lower) }
|
118
118
|
end
|
119
|
+
|
120
|
+
# return a string that acts as a query parameters (for POST calls)
|
121
|
+
#
|
122
|
+
# @param options [Hash]
|
123
|
+
def to_query_options(options)
|
124
|
+
return '' if !options.is_a?(Hash) || options.empty?
|
125
|
+
"?#{options.map{ |k,v| "#{k}=#{v}" }.join('&')}"
|
126
|
+
end
|
119
127
|
end
|
120
128
|
end
|
data/lib/epages/version.rb
CHANGED
data/lib/epages-rest.rb
CHANGED
@@ -10,6 +10,7 @@ require 'epages/image'
|
|
10
10
|
require 'epages/image_size'
|
11
11
|
require 'epages/line_item_container'
|
12
12
|
require 'epages/link'
|
13
|
+
require 'epages/newsletter'
|
13
14
|
require 'epages/order'
|
14
15
|
require 'epages/payment_data'
|
15
16
|
require 'epages/payment_method_info'
|
@@ -22,6 +23,7 @@ require 'epages/shipping_data'
|
|
22
23
|
require 'epages/shipping_method'
|
23
24
|
require 'epages/shipping_method_info'
|
24
25
|
require 'epages/shop'
|
26
|
+
require 'epages/subscriber'
|
25
27
|
require 'epages/utils'
|
26
28
|
require 'epages/variation'
|
27
29
|
require 'epages/variation_attribute'
|
@@ -32,6 +34,7 @@ require 'epages/rest/carts'
|
|
32
34
|
require 'epages/rest/categories'
|
33
35
|
require 'epages/rest/customers'
|
34
36
|
require 'epages/rest/legal'
|
37
|
+
require 'epages/rest/newsletters'
|
35
38
|
require 'epages/rest/orders'
|
36
39
|
require 'epages/rest/products'
|
37
40
|
require 'epages/rest/request'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epages-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Domingo Cividanes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- lib/epages/image_size.rb
|
78
78
|
- lib/epages/line_item_container.rb
|
79
79
|
- lib/epages/link.rb
|
80
|
+
- lib/epages/newsletter.rb
|
80
81
|
- lib/epages/order.rb
|
81
82
|
- lib/epages/payment_data.rb
|
82
83
|
- lib/epages/payment_method_info.rb
|
@@ -90,6 +91,7 @@ files:
|
|
90
91
|
- lib/epages/rest/customers.rb
|
91
92
|
- lib/epages/rest/legal.rb
|
92
93
|
- lib/epages/rest/miscellaneous.rb
|
94
|
+
- lib/epages/rest/newsletters.rb
|
93
95
|
- lib/epages/rest/orders.rb
|
94
96
|
- lib/epages/rest/products.rb
|
95
97
|
- lib/epages/rest/request.rb
|
@@ -102,6 +104,7 @@ files:
|
|
102
104
|
- lib/epages/shipping_method.rb
|
103
105
|
- lib/epages/shipping_method_info.rb
|
104
106
|
- lib/epages/shop.rb
|
107
|
+
- lib/epages/subscriber.rb
|
105
108
|
- lib/epages/utils.rb
|
106
109
|
- lib/epages/variation.rb
|
107
110
|
- lib/epages/variation_attribute.rb
|