plenty_client 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.rspec +2 -0
- data/.rubocop.yml +43 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +154 -0
- data/Rakefile +6 -0
- data/lib/plenty_client/config.rb +15 -0
- data/lib/plenty_client/constants.rb +362 -0
- data/lib/plenty_client/endpoint.rb +73 -0
- data/lib/plenty_client/item/attribute/name.rb +52 -0
- data/lib/plenty_client/item/attribute/value.rb +52 -0
- data/lib/plenty_client/item/attribute/value_name.rb +52 -0
- data/lib/plenty_client/item/attribute.rb +36 -0
- data/lib/plenty_client/item/barcode.rb +56 -0
- data/lib/plenty_client/item/cross_selling.rb +26 -0
- data/lib/plenty_client/item/image/availability.rb +37 -0
- data/lib/plenty_client/item/image/name.rb +57 -0
- data/lib/plenty_client/item/image.rb +53 -0
- data/lib/plenty_client/item/manufacturer/commission.rb +52 -0
- data/lib/plenty_client/item/manufacturer.rb +36 -0
- data/lib/plenty_client/item/property/market_reference.rb +52 -0
- data/lib/plenty_client/item/property/name.rb +52 -0
- data/lib/plenty_client/item/property.rb +36 -0
- data/lib/plenty_client/item/property_group.rb +36 -0
- data/lib/plenty_client/item/property_group_name.rb +44 -0
- data/lib/plenty_client/item/sales_price.rb +37 -0
- data/lib/plenty_client/item/shipping_profile.rb +26 -0
- data/lib/plenty_client/item/unit.rb +35 -0
- data/lib/plenty_client/item/unit_name.rb +38 -0
- data/lib/plenty_client/item/variation/barcode.rb +53 -0
- data/lib/plenty_client/item/variation/bundle.rb +52 -0
- data/lib/plenty_client/item/variation/category.rb +52 -0
- data/lib/plenty_client/item/variation/client.rb +37 -0
- data/lib/plenty_client/item/variation/default_category.rb +45 -0
- data/lib/plenty_client/item/variation/description.rb +53 -0
- data/lib/plenty_client/item/variation/image.rb +49 -0
- data/lib/plenty_client/item/variation/market.rb +37 -0
- data/lib/plenty_client/item/variation/market_ident_number.rb +53 -0
- data/lib/plenty_client/item/variation/sales_price.rb +53 -0
- data/lib/plenty_client/item/variation/sku.rb +52 -0
- data/lib/plenty_client/item/variation/stock.rb +57 -0
- data/lib/plenty_client/item/variation/supplier.rb +52 -0
- data/lib/plenty_client/item/variation/warehouse.rb +52 -0
- data/lib/plenty_client/item/variation.rb +35 -0
- data/lib/plenty_client/item/variation_property.rb +36 -0
- data/lib/plenty_client/item/variation_property_value.rb +48 -0
- data/lib/plenty_client/item.rb +24 -0
- data/lib/plenty_client/item_set/component.rb +54 -0
- data/lib/plenty_client/item_set/config.rb +20 -0
- data/lib/plenty_client/item_set.rb +44 -0
- data/lib/plenty_client/order/contact_wish.rb +17 -0
- data/lib/plenty_client/order/coupon_code/contact.rb +20 -0
- data/lib/plenty_client/order/coupon_code/validation.rb +20 -0
- data/lib/plenty_client/order/coupon_code.rb +19 -0
- data/lib/plenty_client/order/currency.rb +32 -0
- data/lib/plenty_client/order/date.rb +32 -0
- data/lib/plenty_client/order/item/date.rb +20 -0
- data/lib/plenty_client/order/item/property.rb +20 -0
- data/lib/plenty_client/order/item/serial_number.rb +25 -0
- data/lib/plenty_client/order/item.rb +18 -0
- data/lib/plenty_client/order/property.rb +21 -0
- data/lib/plenty_client/order/referrer.rb +22 -0
- data/lib/plenty_client/order/shipping/country.rb +18 -0
- data/lib/plenty_client/order/shipping/information.rb +45 -0
- data/lib/plenty_client/order/shipping/package.rb +54 -0
- data/lib/plenty_client/order/shipping/profile.rb +23 -0
- data/lib/plenty_client/order/shipping/service_provider.rb +27 -0
- data/lib/plenty_client/order/shipping.rb +12 -0
- data/lib/plenty_client/order.rb +43 -0
- data/lib/plenty_client/request.rb +128 -0
- data/lib/plenty_client/sales_price/account.rb +30 -0
- data/lib/plenty_client/sales_price/country.rb +26 -0
- data/lib/plenty_client/sales_price/currency.rb +26 -0
- data/lib/plenty_client/sales_price/customer_class.rb +31 -0
- data/lib/plenty_client/sales_price/name.rb +36 -0
- data/lib/plenty_client/sales_price/online_store.rb +29 -0
- data/lib/plenty_client/sales_price/referrer.rb +25 -0
- data/lib/plenty_client/version.rb +3 -0
- data/lib/plenty_client.rb +108 -0
- data/plenty_client.gemspec +29 -0
- metadata +204 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
module PlentyClient
|
2
|
+
module Order
|
3
|
+
module Shipping
|
4
|
+
class Package
|
5
|
+
extend PlentyClient::Endpoint
|
6
|
+
extend PlentyClient::Request
|
7
|
+
|
8
|
+
BASE_ORDERS_SHIPPING_PATH = '/orders/{orderId}/shipping'.freeze
|
9
|
+
|
10
|
+
FIND_ORDERS_SHIPPING_PACKAGE = '/packages/{orderShippingPackageId}'.freeze
|
11
|
+
LIST_ORDERS_SHIPPING_PACKAGE = '/packages'.freeze
|
12
|
+
CREATE_ORDER_SHIPPING_PACKAGE = '/packages'.freeze
|
13
|
+
UPDATE_ORDER_SHIPPING_PACKAGE = '/packages/{orderShippingPackageId}'.freeze
|
14
|
+
DELETE_ORDER_SHIPPING_PACKAGE = '/packages/{orderShippingPackageId}'.freeze
|
15
|
+
DELETE_ORDER_SHIPPING_PACKAGES = '/packages'.freeze
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def list(order_id, headers = {}, &block)
|
19
|
+
get(build_endpoint("#{BASE_ORDERS_SHIPPING_PATH}#{LIST_ORDERS_SHIPPING_PACKAGE}",
|
20
|
+
order: order_id), headers, &block)
|
21
|
+
end
|
22
|
+
|
23
|
+
def find(order_id, package_id, headers = {}, &block)
|
24
|
+
get(build_endpoint("#{BASE_ORDERS_SHIPPING_PATH}#{FIND_ORDERS_SHIPPING_PACKAGE}",
|
25
|
+
order: order_id,
|
26
|
+
shipping_package: package_id), headers, &block)
|
27
|
+
end
|
28
|
+
|
29
|
+
def create(order_id, body = {})
|
30
|
+
post(build_endpoint("#{BASE_ORDERS_SHIPPING_PATH}#{CREATE_ORDER_SHIPPING_PACKAGE}",
|
31
|
+
order: order_id), body)
|
32
|
+
end
|
33
|
+
|
34
|
+
def update(order_id, package_id, body = {})
|
35
|
+
put(build_endpoint("#{BASE_ORDERS_SHIPPING_PATH}#{CREATE_ORDER_SHIPPING_PACKAGE}",
|
36
|
+
order: order_id,
|
37
|
+
shipping_package: package_id), body)
|
38
|
+
end
|
39
|
+
|
40
|
+
def delete(order_id, package_id, body = {})
|
41
|
+
delete(build_endpoint("#{BASE_ORDERS_SHIPPING_PATH}#{DELETE_ORDER_SHIPPING_PACKAGE}",
|
42
|
+
order: order_id,
|
43
|
+
shipping_package: package_id), body)
|
44
|
+
end
|
45
|
+
|
46
|
+
def delete_all(order_id, body = {})
|
47
|
+
delete(build_endpoint("#{BASE_ORDERS_SHIPPING_PATH}#{DELETE_ORDER_SHIPPING_PACKAGES}",
|
48
|
+
order: order_id), body)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module PlentyClient
|
2
|
+
module Order
|
3
|
+
module Shipping
|
4
|
+
class Profile
|
5
|
+
extend PlentyClient::Endpoint
|
6
|
+
extend PlentyClient::Request
|
7
|
+
|
8
|
+
LIST_SHIPPING_PRESET = '/orders/shipping/presets'.freeze
|
9
|
+
FIND_SHIPPING_PRESETS = '/orders/shipping/presets/{presetId}'.freeze
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def list(headers = {}, &block)
|
13
|
+
get(build_endpoint(LIST_SHIPPING_PRESET), headers, &block)
|
14
|
+
end
|
15
|
+
|
16
|
+
def find(preset_id, headers = {}, &block)
|
17
|
+
get(build_endpoint(FIND_SHIPPING_PRESETS, preset: preset_id), headers, &block)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module PlentyClient
|
2
|
+
module Order
|
3
|
+
module Shipping
|
4
|
+
class ServiceProvider
|
5
|
+
extend PlentyClient::Endpoint
|
6
|
+
extend PlentyClient::Request
|
7
|
+
|
8
|
+
BASE_ORDERS_SHIPPING_SERVICE_PROVIDER_PATH = '/orders/shipping'.freeze
|
9
|
+
|
10
|
+
LIST_ORDERS_SHIPPING_SERVICE_PROVIDER = '/shipping_service_providers'.freeze
|
11
|
+
FIND_ORDER_SHIPPING_SERVICE_PROVIDER = '/shipping_service_providers/{shippingServiceProviderID}'.freeze
|
12
|
+
|
13
|
+
class << self
|
14
|
+
def list(headers = {}, &block)
|
15
|
+
get(build_endpoint("#{BASE_ORDERS_SHIPPING_SERVICE_PROVIDER_PATH}#{LIST_ORDERS_SHIPPING_SERVICE_PROVIDER}"),
|
16
|
+
headers, &block)
|
17
|
+
end
|
18
|
+
|
19
|
+
def find(service_provider_id, headers = {}, &block)
|
20
|
+
get(build_endpoint("#{BASE_ORDERS_SHIPPING_SERVICE_PROVIDER_PATH}#{FIND_ORDER_SHIPPING_SERVICE_PROVIDER}",
|
21
|
+
shipping_service_provider: service_provider_id), headers, &block)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module PlentyClient
|
2
|
+
module Order
|
3
|
+
extend PlentyClient::Endpoint
|
4
|
+
extend PlentyClient::Request
|
5
|
+
|
6
|
+
CREATE_ORDER = '/orders'.freeze
|
7
|
+
LIST_ORDERS = '/orders'.freeze
|
8
|
+
FIND_ORDER = '/orders/{orderId}'.freeze
|
9
|
+
LIST_CONTACTS_ORDERS = '/orders/contacts/{contactId}'.freeze
|
10
|
+
UPDATE_ORDER = '/orders/{orderId}'.freeze
|
11
|
+
LIST_ORDERS_PACKAGE_NUMBERS = '/orders/{orderId}/packagenumbers'.freeze
|
12
|
+
DELETE_ORDER = '/orders/{orderId}'.freeze
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def create(body = {})
|
16
|
+
post(build_endpoint(CREATE_ORDER), body)
|
17
|
+
end
|
18
|
+
|
19
|
+
def list(headers = {}, &block)
|
20
|
+
get(build_endpoint(LIST_ORDERS), headers, &block)
|
21
|
+
end
|
22
|
+
|
23
|
+
def list_contacts_orders(contact_id, headers = {}, &block)
|
24
|
+
get(build_endpoint(LIST_CONTACTS_ORDERS, contact: contact_id), headers, &block)
|
25
|
+
end
|
26
|
+
def list_contacts_orders(order_id, headers = {}, &block)
|
27
|
+
get(build_endpoint(LIST_ORDERS_PACKAGE_NUMBERS, order: order_id), headers, &block)
|
28
|
+
end
|
29
|
+
|
30
|
+
def find(order_id = nil, headers = {}, &block)
|
31
|
+
get(build_endpoint(FIND_ORDER, order: order_id), headers, &block)
|
32
|
+
end
|
33
|
+
|
34
|
+
def update(order_id, body = {})
|
35
|
+
put(build_endpoint(UPDATE_ORDER, order: order_id), body)
|
36
|
+
end
|
37
|
+
|
38
|
+
def delete(order_id, body = {})
|
39
|
+
delete(build_endpoint(DELETE_ORDER, order: order_id), body)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'curl'
|
2
|
+
module PlentyClient
|
3
|
+
module Request
|
4
|
+
def request(http_method, path, params = {})
|
5
|
+
return false if http_method.nil? || path.nil?
|
6
|
+
return false unless %w(post put patch delete get).include?(http_method.to_s)
|
7
|
+
|
8
|
+
login if PlentyClient::Config.access_token.nil?
|
9
|
+
start_time = Time.now
|
10
|
+
response = perform(http_method, path, params)
|
11
|
+
body = parse_body(response, http_method, path, params)
|
12
|
+
if PlentyClient::Config.log
|
13
|
+
log_output(http_method, base_url(path), params, time_diff_ms(start_time, Time.now))
|
14
|
+
end
|
15
|
+
body
|
16
|
+
end
|
17
|
+
|
18
|
+
def post(path, body = {})
|
19
|
+
request(:post, path, body)
|
20
|
+
end
|
21
|
+
|
22
|
+
def put(path, body = {})
|
23
|
+
request(:put, path, body)
|
24
|
+
end
|
25
|
+
|
26
|
+
def patch(path, body = {})
|
27
|
+
request(:patch, path, body)
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete(path, body = {})
|
31
|
+
request(:delete, path, body)
|
32
|
+
end
|
33
|
+
|
34
|
+
def get(path, params = {}, &block)
|
35
|
+
page = 1
|
36
|
+
rval_array = []
|
37
|
+
if block_given?
|
38
|
+
loop do
|
39
|
+
response = request(:get, path, params.merge(page: page))
|
40
|
+
yield response['entries'] if block_given?
|
41
|
+
page += 1
|
42
|
+
break if response['isLastPage'] == true
|
43
|
+
end
|
44
|
+
else
|
45
|
+
response = request(:get, path, params.merge(page: page))
|
46
|
+
rval_array << rval
|
47
|
+
end
|
48
|
+
rval_array.flatten
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def login
|
54
|
+
response = perform(:post, "/login?username=#{PlentyClient::Config.api_user}" \
|
55
|
+
"&password=#{PlentyClient::Config.api_password}")
|
56
|
+
result = parse_body(response, :post, 'login')
|
57
|
+
PlentyClient::Config.access_token = result['accessToken']
|
58
|
+
PlentyClient::Config.refresh_token = result['refreshToken']
|
59
|
+
end
|
60
|
+
|
61
|
+
def perform(http_method, path, params = {})
|
62
|
+
case http_method.to_s.downcase
|
63
|
+
when 'get'
|
64
|
+
Curl.get(base_url(path), params) do |curl|
|
65
|
+
curl_options(curl)
|
66
|
+
end
|
67
|
+
when 'post'
|
68
|
+
Curl.post(base_url(path), params) do |curl|
|
69
|
+
curl_options(curl)
|
70
|
+
end
|
71
|
+
when 'put'
|
72
|
+
Curl.put(base_url(path), params) do |curl|
|
73
|
+
curl_options(curl)
|
74
|
+
end
|
75
|
+
when 'delete'
|
76
|
+
Curl.delete(base_url(path), params) do |curl|
|
77
|
+
curl_options(curl)
|
78
|
+
end
|
79
|
+
when 'patch'
|
80
|
+
Curl.patch(base_url(path), params) do |curl|
|
81
|
+
curl_options(curl)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def curl_options(curl)
|
87
|
+
curl.headers['Content-type'] = 'application/json'
|
88
|
+
unless PlentyClient::Config.access_token.nil?
|
89
|
+
curl.headers['Authorization'] = "Bearer #{PlentyClient::Config.access_token}"
|
90
|
+
end
|
91
|
+
curl.headers['Accept'] = 'application/x.plentymarkets.v1+json'
|
92
|
+
curl
|
93
|
+
end
|
94
|
+
|
95
|
+
def base_url(path)
|
96
|
+
uri = URI(PlentyClient::Config.site_url)
|
97
|
+
url = "#{uri.scheme}://#{uri.host}/rest"
|
98
|
+
url += path.start_with?('/') ? path : "/#{path}"
|
99
|
+
url
|
100
|
+
end
|
101
|
+
|
102
|
+
def login_required?(path)
|
103
|
+
return false if defined?(Rails) && Rails.env == 'testing'
|
104
|
+
return true unless path.include?('login')
|
105
|
+
false
|
106
|
+
end
|
107
|
+
|
108
|
+
def parse_body(response, http_method, rest_path, params = {})
|
109
|
+
result = JSON.parse(response.body)
|
110
|
+
raise InvalidResponseException.new(http_method, rest_path, params) if result.nil?
|
111
|
+
result
|
112
|
+
end
|
113
|
+
|
114
|
+
def log_output(http_method, path, params, duration)
|
115
|
+
puts [Time.now, "#{duration} ms", http_method.upcase, path, params].join(' # ')
|
116
|
+
end
|
117
|
+
|
118
|
+
def time_diff_ms(start, finish)
|
119
|
+
((finish - start) * 1000.0).round(2)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
class InvalidResponseException < StandardError
|
125
|
+
def initialize(http_method, rest_path, params)
|
126
|
+
super("The response was null. http_Method: #{http_method}, Path: #{rest_path}, options: #{params}")
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module PlentyClient
|
2
|
+
module SalesPrice
|
3
|
+
class Account
|
4
|
+
extend PlentyClient::Endpoint
|
5
|
+
extend PlentyClient::Request
|
6
|
+
|
7
|
+
|
8
|
+
LIST_REFERRER_ACCOUNTS = '/items/sales_prices/{salesPriceId}/accounts'.freeze
|
9
|
+
ACTIVATE_REFERRER_ACCOUNT = '/items/sales_prices/{salesPriceId}/accounts'.freeze
|
10
|
+
DEACTIVATE_REFERRER_ACCOUNT = '/items/sales_prices/{salesPriceId}/accounts/{accountType}/{accountId}'.freeze
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def list(sales_price_id, headers = {}, &block)
|
14
|
+
get(build_endpoint(LIST_REFERRER_ACCOUNTS, sales_price: sales_price_id), headers, &block)
|
15
|
+
end
|
16
|
+
|
17
|
+
def activate(sales_price_id, headers = {})
|
18
|
+
post(build_endpoint(ACTIVATE_REFERRER_ACCOUNT, sales_price: sales_price_id), headers)
|
19
|
+
end
|
20
|
+
|
21
|
+
def deactivate(sales_price_id, account_type_id, account_id)
|
22
|
+
delete(build_endpoint(DEACTIVATE_REFERRER_ACCOUNT,
|
23
|
+
sales_price: sales_price_id,
|
24
|
+
account_type: account_type_id,
|
25
|
+
account: account_id))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module PlentyClient
|
2
|
+
module SalesPrice
|
3
|
+
class Country
|
4
|
+
extend PlentyClient::Endpoint
|
5
|
+
extend PlentyClient::Request
|
6
|
+
|
7
|
+
LIST_SALES_PRICE_COUNTRIES = '/items/sales_prices/{salesPriceId}/countries'.freeze
|
8
|
+
ACTIVATE_SALES_PRICE_COUNTRY = '/items/sales_prices/{salesPriceId}/countries'.freeze
|
9
|
+
DEACTIVATE_SALES_PRICE_COUNTRY = '/items/sales_prices/{salesPriceId}/countries/{countryId}'.freeze
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def list(sales_price_id, headers = {}, &block)
|
13
|
+
get(build_endpoint(LIST_SALES_PRICE_COUNTRIES, sales_price: sales_price_id), headers, &block)
|
14
|
+
end
|
15
|
+
|
16
|
+
def activate(sales_price_id, headers = {})
|
17
|
+
post(build_endpoint(ACTIVATE_SALES_PRICE_COUNTRY, sales_price: sales_price_id), headers)
|
18
|
+
end
|
19
|
+
|
20
|
+
def deactivate(sales_price_id, country_id)
|
21
|
+
delete(build_endpoint(DEACTIVATE_SALES_PRICE_COUNTRY, sales_price: sales_price_id, country: country_id))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module PlentyClient
|
2
|
+
module SalesPrice
|
3
|
+
class Currency
|
4
|
+
extend PlentyClient::Endpoint
|
5
|
+
extend PlentyClient::Request
|
6
|
+
|
7
|
+
LIST_SALES_PRICE_CURRENCIES = '/items/sales_prices/{salesPriceId}/currencies'.freeze
|
8
|
+
ACTIVATE_SALES_PRICE_CURRENCY = '/items/sales_prices/{salesPriceId}/currencies'.freeze
|
9
|
+
DEACTIVATE_SALES_PRICE_CURRENCY = '/items/sales_prices/{salesPriceId}/currencies/{currencyIso}'.freeze
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def list(sales_price_id, headers = {}, &block)
|
13
|
+
get(build_endpoint(LIST_SALES_PRICE_CURRENCIES, sales_price: sales_price_id), headers, &block)
|
14
|
+
end
|
15
|
+
|
16
|
+
def activate(sales_price_id, headers = {})
|
17
|
+
post(build_endpoint(ACTIVATE_SALES_PRICE_CURRENCY, sales_price: sales_price_id), headers)
|
18
|
+
end
|
19
|
+
|
20
|
+
def deactivate(sales_price_id, currency_iso)
|
21
|
+
delete(build_endpoint(DEACTIVATE_SALES_PRICE_CURRENCY, sales_price: sales_price_id, currency: currency_iso))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module PlentyClient
|
2
|
+
module SalesPrice
|
3
|
+
class CustomerClass
|
4
|
+
extend PlentyClient::Endpoint
|
5
|
+
extend PlentyClient::Request
|
6
|
+
|
7
|
+
SALES_PRICE_PATH = '/items/sales_prices/{salesPriceId}'.freeze
|
8
|
+
LIST_SALES_PRICE_CUSTOMER_CLASSES = '/customer_classes'.freeze
|
9
|
+
ACTIVATE_SALES_PRICE_CUSTOMER_CLASSES = '/customer_classes'.freeze
|
10
|
+
DEACTIVATE_SALES_PRICE_CUSTOMER_CLASSES = '/customer_classes/{customerClassId}'.freeze
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def list(sales_price_id, headers = {}, &block)
|
14
|
+
get(build_endpoint("#{SALES_PRICE_PATH}#{LIST_SALES_PRICE_CUSTOMER_CLASSES}",
|
15
|
+
sales_price: sales_price_id), headers, &block)
|
16
|
+
end
|
17
|
+
|
18
|
+
def activate(sales_price_id, headers = {})
|
19
|
+
post(build_endpoint("#{SALES_PRICE_PATH}#{ACTIVATE_SALES_PRICE_CUSTOMER_CLASSES}",
|
20
|
+
sales_price: sales_price_id), headers)
|
21
|
+
end
|
22
|
+
|
23
|
+
def deactivate(sales_price_id, customer_class_id)
|
24
|
+
delete(build_endpoint("#{SALES_PRICE_PATH}#{DEACTIVATE_SALES_PRICE_CUSTOMER_CLASSES}",
|
25
|
+
sales_price: sales_price_id,
|
26
|
+
customer_class: customer_class_id))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module PlentyClient
|
2
|
+
module SalesPrice
|
3
|
+
class Name
|
4
|
+
extend PlentyClient::Endpoint
|
5
|
+
extend PlentyClient::Request
|
6
|
+
|
7
|
+
LIST_SALES_PRICE_NAMES = '/items/sales_prices/{salesPriceId}/names'.freeze
|
8
|
+
GET_SALES_PRICE_NAMES_BY_LANG = '/items/sales_prices/{salesPriceId}/names/{lang}'.freeze
|
9
|
+
CREATE_SALES_PRICE_NAME = '/items/sales_prices/{salesPriceId}/names'.freeze
|
10
|
+
UPDATE_SALES_PRICE_NAME = '/items/sales_prices/{salesPriceId}/names/{lang}'.freeze
|
11
|
+
DELETE_SALES_PRICE_NAME = '/items/sales_prices/{salesPriceId}/names/{lang}'.freeze
|
12
|
+
|
13
|
+
class << self
|
14
|
+
def list(sales_price_id, headers = {}, &block)
|
15
|
+
get(build_endpoint(LIST_SALES_PRICE_NAMES, sales_price: sales_price_id), headers, &block)
|
16
|
+
end
|
17
|
+
|
18
|
+
def list_by_lang(sales_price_id, lang, headers = {}, &block)
|
19
|
+
get(build_endpoint(GET_SALES_PRICE_NAMES_BY_LANG, sales_price: sales_price_id, lang: lang), headers, &block)
|
20
|
+
end
|
21
|
+
|
22
|
+
def create(sales_price_id, headers = {})
|
23
|
+
post(build_endpoint(CREATE_SALES_PRICE_NAME, sales_price: sales_price_id), headers)
|
24
|
+
end
|
25
|
+
|
26
|
+
def update(sales_price_id, lang, headers = {})
|
27
|
+
post(build_endpoint(UPDATE_SALES_PRICE_NAME, sales_price: sales_price_id, lang: lang), headers)
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete(sales_price_id, lang, cross_sales_price_id)
|
31
|
+
delete(build_endpoint(DELETE_SALES_PRICE_NAME, sales_price: sales_price_id, lang: lang))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module PlentyClient
|
2
|
+
module SalesPrice
|
3
|
+
class OnlineStore
|
4
|
+
extend PlentyClient::Endpoint
|
5
|
+
extend PlentyClient::Request
|
6
|
+
|
7
|
+
LIST_SALES_PRICE_ONLINE_STORES = '/items/sales_prices/{salesPriceId}/online_stores'.freeze
|
8
|
+
ACTIVATE_SALES_PRICE_ONLINE_STORE = '/items/sales_prices/{salesPriceId}/online_stores'.freeze
|
9
|
+
DEACTIVATE_SALES_PRICE_ONLINE_STORE = '/items/sales_prices/{salesPriceId}/online_stores/{webstoreId}'.freeze
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def list(sales_price_id, headers = {}, &block)
|
13
|
+
get(build_endpoint(LIST_SALES_PRICE_ONLINE_STORES, sales_price: sales_price_id), headers, &block)
|
14
|
+
end
|
15
|
+
|
16
|
+
def activate(sales_price_id, headers = {})
|
17
|
+
post(build_endpoint(ACTIVATE_SALES_PRICE_ONLINE_STORE, sales_price: sales_price_id), headers)
|
18
|
+
end
|
19
|
+
|
20
|
+
def deactivate(sales_price_id, webstore_id)
|
21
|
+
delete(build_endpoint(DEACTIVATE_SALES_PRICE_ONLINE_STORE,
|
22
|
+
sales_price: sales_price_id,
|
23
|
+
webstore: webstore_id))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module PlentyClient
|
2
|
+
module SalesPrice
|
3
|
+
class Referrer
|
4
|
+
include Endpoint
|
5
|
+
LIST_SALES_PRICE_REFERRER = '/items/sales_prices/{salesPriceId}/referrers'.freeze
|
6
|
+
ACTIVATE_SALES_PRICE_REFERRER = '/items/sales_prices/{salesPriceId}/referrers'.freeze
|
7
|
+
DEACTIVATE_SALES_PRICE_REFERRER = '/items/sales_prices/{salesPriceId}/referrers/{referrerId}'.freeze
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def list(sales_price_id, headers = {}, &block)
|
11
|
+
get(build_endpoint(LIST_SALES_PRICE_REFERRER, sales_price: sales_price_id), headers, &block)
|
12
|
+
end
|
13
|
+
|
14
|
+
def activate(sales_price_id, headers = {})
|
15
|
+
post(build_endpoint(ACTIVATE_SALES_PRICE_REFERRER, sales_price: sales_price_id), headers)
|
16
|
+
end
|
17
|
+
|
18
|
+
def deactivate(sales_price_id, country_id)
|
19
|
+
delete(build_endpoint(DEACTIVATE_SALES_PRICE_REFERRER, sales_price: sales_price_id, country: country_id))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'curl'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module PlentyClient
|
5
|
+
autoload :Version, 'plenty_client/version'
|
6
|
+
autoload :Config, 'plenty_client/config'
|
7
|
+
autoload :Endpoint, 'plenty_client/endpoint'
|
8
|
+
autoload :Request, 'plenty_client/request'
|
9
|
+
autoload :Constants, 'plenty_client/constants'
|
10
|
+
|
11
|
+
autoload :Item, 'plenty_client/item'
|
12
|
+
autoload :Order, 'plenty_client/order'
|
13
|
+
autoload :ItemSet, 'plenty_client/item_set'
|
14
|
+
|
15
|
+
module Item
|
16
|
+
autoload :Attribute, 'plenty_client/item/attribute'
|
17
|
+
autoload :Barcode, 'plenty_client/item/barcode'
|
18
|
+
autoload :CrossSelling, 'plenty_client/item/cross_selling'
|
19
|
+
autoload :Image, 'plenty_client/item/image'
|
20
|
+
autoload :Manufacturer, 'plenty_client/item/manufacturer'
|
21
|
+
autoload :Property, 'plenty_client/item/property'
|
22
|
+
autoload :PropertyGroup, 'plenty_client/item/property_group'
|
23
|
+
autoload :PropertyGroupName, 'plenty_client/item/property_group_name'
|
24
|
+
autoload :SalesPrice, 'plenty_client/item/sales_price'
|
25
|
+
autoload :SalesPriceShippingProfile, 'plenty_client/item/sales_price_shipping_profile'
|
26
|
+
autoload :Unit, 'plenty_client/item/unit'
|
27
|
+
autoload :UnitName, 'plenty_client/item/unit_name'
|
28
|
+
autoload :Variation, 'plenty_client/item/variation'
|
29
|
+
autoload :VariationProperty, 'plenty_client/item/variation_property'
|
30
|
+
autoload :VariationPropertyValue, 'plenty_client/item/variation_property_value'
|
31
|
+
|
32
|
+
module Attribute
|
33
|
+
autoload :Name, 'plenty_client/item/attribute/name'
|
34
|
+
autoload :Value, 'plenty_client/item/attribute/value'
|
35
|
+
autoload :ValueName, 'plenty_client/item/attribute/value_name'
|
36
|
+
end
|
37
|
+
|
38
|
+
module Image
|
39
|
+
autoload :Availability, 'plenty_client/item/image/availability'
|
40
|
+
autoload :Name, 'plenty_client/item/attribute/name'
|
41
|
+
end
|
42
|
+
|
43
|
+
module Manufacturer
|
44
|
+
autoload :Commission, 'plenty_client/item/image/commission'
|
45
|
+
end
|
46
|
+
|
47
|
+
module Property
|
48
|
+
autoload :MarketReference, 'plenty_client/item/property/market_reference'
|
49
|
+
autoload :Name, 'plenty_client/item/property/name'
|
50
|
+
end
|
51
|
+
|
52
|
+
module Variation
|
53
|
+
autoload :Barcode, 'plenty_client/item/variation/barcode'
|
54
|
+
autoload :Bundle, 'plenty_client/item/variation/bundle'
|
55
|
+
autoload :Category, 'plenty_client/item/variation/category'
|
56
|
+
autoload :Client, 'plenty_client/item/variation/client'
|
57
|
+
autoload :DefaultCategory, 'plenty_client/item/variation/default_category'
|
58
|
+
autoload :Description, 'plenty_client/item/variation/description'
|
59
|
+
autoload :Image, 'plenty_client/item/variation/image'
|
60
|
+
autoload :Market, 'plenty_client/item/variation/market'
|
61
|
+
autoload :MarketIdentNumber, 'plenty_client/item/variation/market_ident_number'
|
62
|
+
autoload :SalesPrice, 'plenty_client/item/variation/sales_price'
|
63
|
+
autoload :Sku, 'plenty_client/item/variation/sku'
|
64
|
+
autoload :Stock, 'plenty_client/item/variation/stock'
|
65
|
+
autoload :Supplier, 'plenty_client/item/variation/supplier'
|
66
|
+
autoload :Warehouse, 'plenty_client/item/variation/warehouse'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
module ItemSet
|
71
|
+
autoload :Component, 'plenty_client/item_set/component'
|
72
|
+
autoload :Config, 'plenty_client/item_set/config'
|
73
|
+
end
|
74
|
+
|
75
|
+
module Order
|
76
|
+
autoload :CouponCode, 'plenty_client/order/coupon_code'
|
77
|
+
autoload :Currency, 'plenty_client/order/currency'
|
78
|
+
autoload :Date, 'plenty_client/order/date'
|
79
|
+
autoload :Item, 'plenty_client/order/item'
|
80
|
+
autoload :Property, 'plenty_client/order/property'
|
81
|
+
autoload :Referrer, 'plenty_client/order/referrer'
|
82
|
+
autoload :Shipping, 'plenty_client/order/shipping'
|
83
|
+
|
84
|
+
module Item
|
85
|
+
autoload :Date, 'plenty_client/order/item/date'
|
86
|
+
autoload :Property, 'plenty_client/order/item/property'
|
87
|
+
autoload :SerialNumber, 'plenty_client/order/item/serial_number'
|
88
|
+
end
|
89
|
+
|
90
|
+
module Shipping
|
91
|
+
autoload :Country, 'plenty_client/order/shipping/country'
|
92
|
+
autoload :Information, 'plenty_client/order/shipping/information'
|
93
|
+
autoload :Package, 'plenty_client/order/shipping/package'
|
94
|
+
autoload :Profile, 'plenty_client/order/shipping/profile'
|
95
|
+
autoload :ServiceProvider, 'plenty_client/order/shipping/service_provider'
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
module SalesPrice
|
100
|
+
autoload :Account, 'plenty_client/sales_price/account'
|
101
|
+
autoload :Country, 'plenty_client/sales_price/country'
|
102
|
+
autoload :Currency, 'plenty_client/sales_price/currency'
|
103
|
+
autoload :CustomerClass, 'plenty_client/sales_price/customer_class'
|
104
|
+
autoload :Name, 'plenty_client/sales_price/name'
|
105
|
+
autoload :OnlineStore, 'plenty_client/sales_price/online_store'
|
106
|
+
autoload :Referrer, 'plenty_client/sales_price/referrer'
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'plenty_client/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'plenty_client'
|
7
|
+
spec.version = PlentyClient::VERSION
|
8
|
+
spec.authors = ['Dariusch Ochlast']
|
9
|
+
spec.email = ['dariusch.ochlast@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'This is Version 1 of the PlentyMarkets Rest Client for Ruby.'
|
12
|
+
spec.description = 'This Client is a wrapper arount the PlentyMarkets REST API providing simple classes to interact.'
|
13
|
+
spec.homepage = 'https://github.com/Dariusch/plenty_client'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = 'exe'
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
26
|
+
|
27
|
+
spec.add_dependency 'json', '~> 1.8', '>= 1.8.0'
|
28
|
+
spec.add_dependency 'curb', '~> 0.9.3'
|
29
|
+
end
|