ozon_api 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ozon_api/address_service.rb +1 -2
- data/lib/ozon_api/client.rb +8 -18
- data/lib/ozon_api/configuration.rb +39 -0
- data/lib/ozon_api/order_service.rb +0 -1
- data/lib/ozon_api/version.rb +1 -1
- data/lib/ozon_api.rb +50 -1
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29b82b33e617de476fe7ffc47ac4a73ced8c4e33
|
4
|
+
data.tar.gz: 6b2c1d8d172f7b8a83cc81f1f88c5354e0c42617
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de3bfa78a25a5151f4ef1a3b2d2ce22a21c1fd6ad21222742f225c5d6b37db266676cea034df12ccd497398a61ccc976b158896ad4d06ea99c89e54ffeebded9
|
7
|
+
data.tar.gz: c754f6c6e32ad284f582200fc470f50c862016ae49c9db3aa98c0ec65f50e144d3d9c9f6e11b6586d17a3a8d5ffaca1bcc84bac8e251c3b8c455415cc5b824c7
|
@@ -27,7 +27,7 @@ module OzonApi
|
|
27
27
|
search_text:,
|
28
28
|
search_text_match_preferred:,
|
29
29
|
limit: 20
|
30
|
-
|
30
|
+
)
|
31
31
|
@client.get(
|
32
32
|
[BASE_PATH, 'SearchStreets'].join('/'),
|
33
33
|
'cityId': city_id,
|
@@ -36,6 +36,5 @@ module OzonApi
|
|
36
36
|
'limit': limit
|
37
37
|
)
|
38
38
|
end
|
39
|
-
|
40
39
|
end
|
41
40
|
end
|
data/lib/ozon_api/client.rb
CHANGED
@@ -5,16 +5,12 @@ require 'json'
|
|
5
5
|
|
6
6
|
module OzonApi
|
7
7
|
class Client
|
8
|
-
InvalidConfigurationError = Class.new(StandardError)
|
9
8
|
ApiError = Class.new(StandardError)
|
10
9
|
|
11
|
-
CONFIGURATION_KEYS = [:scheme, :host, :base_path, :login, :password, :out].freeze
|
12
10
|
SUCCESS_STATUS = 2
|
13
11
|
|
14
|
-
def initialize(
|
15
|
-
@config =
|
16
|
-
CONFIGURATION_KEYS.include? key.to_sym
|
17
|
-
end
|
12
|
+
def initialize(configuration)
|
13
|
+
@config = configuration
|
18
14
|
end
|
19
15
|
|
20
16
|
def get(path, params = {})
|
@@ -67,33 +63,27 @@ module OzonApi
|
|
67
63
|
end
|
68
64
|
|
69
65
|
def base_path
|
70
|
-
@
|
66
|
+
@config.base_path
|
71
67
|
end
|
72
68
|
|
73
69
|
def scheme
|
74
|
-
@
|
70
|
+
@config.scheme
|
75
71
|
end
|
76
72
|
|
77
73
|
def host
|
78
|
-
@
|
74
|
+
@config.host
|
79
75
|
end
|
80
76
|
|
81
77
|
def login
|
82
|
-
|
83
|
-
@login = @config[:login] || ENV['OZON_LOGIN']
|
84
|
-
raise InvalidConfigurationError, 'Missing OZON_LOGIN' if @login.nil?
|
85
|
-
@login
|
78
|
+
@config.login
|
86
79
|
end
|
87
80
|
|
88
81
|
def password
|
89
|
-
|
90
|
-
@password = @config[:password] || ENV['OZON_PASSWORD']
|
91
|
-
raise InvalidConfigurationError, 'Missing OZON_PASSWORD' if @password.nil?
|
92
|
-
@password
|
82
|
+
@config.password
|
93
83
|
end
|
94
84
|
|
95
85
|
def out
|
96
|
-
@config
|
86
|
+
@config.out
|
97
87
|
end
|
98
88
|
|
99
89
|
def parse_response(data)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'active_model'
|
3
|
+
|
4
|
+
module OzonApi
|
5
|
+
class Configuration
|
6
|
+
include ActiveModel::Validations
|
7
|
+
|
8
|
+
def self.attribute_names
|
9
|
+
[:scheme, :host, :base_path, :login, :password, :out]
|
10
|
+
end
|
11
|
+
|
12
|
+
def attribute_names
|
13
|
+
self.class.attribute_names
|
14
|
+
end
|
15
|
+
|
16
|
+
attr_accessor *attribute_names
|
17
|
+
|
18
|
+
validates :scheme, :host, :base_path, :login, :password, presence: true
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
@base_path = 'PartnerService'
|
22
|
+
@scheme = 'https'
|
23
|
+
@host = 'ows.ozon.ru'
|
24
|
+
@login = ENV['OZON_LOGIN']
|
25
|
+
@password = ENV['OZON_PASSWORD']
|
26
|
+
@out = STDOUT
|
27
|
+
|
28
|
+
yield(self) if block_given?
|
29
|
+
|
30
|
+
[
|
31
|
+
@base_path,
|
32
|
+
@scheme,
|
33
|
+
@host,
|
34
|
+
@login,
|
35
|
+
@password
|
36
|
+
].each(&:freeze)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/ozon_api/version.rb
CHANGED
data/lib/ozon_api.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
2
|
module OzonApi
|
3
|
+
require 'ozon_api/configuration'
|
4
4
|
require 'ozon_api/client'
|
5
5
|
require 'ozon_api/item_service'
|
6
6
|
require 'ozon_api/detail_service'
|
@@ -9,4 +9,53 @@ module OzonApi
|
|
9
9
|
require 'ozon_api/checkout_service'
|
10
10
|
require 'ozon_api/order_service'
|
11
11
|
require 'ozon_api/address_service'
|
12
|
+
|
13
|
+
InvalidConfigurationError = Class.new(StandardError)
|
14
|
+
|
15
|
+
def self.setup(&blk)
|
16
|
+
@config ||= OzonApi::Configuration.new(&blk)
|
17
|
+
|
18
|
+
if @config.invalid?
|
19
|
+
msg = "OzonApi configuration ERROR:\n"
|
20
|
+
raise InvalidConfigurationError, msg + @config.errors.full_messages.join("\n")
|
21
|
+
end
|
22
|
+
|
23
|
+
@config
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.reset
|
27
|
+
@config = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.client
|
31
|
+
@client ||= OzonApi::Client.new(@config)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.item_service
|
35
|
+
@item_service ||= OzonApi::ItemService.new(client)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.detail_service
|
39
|
+
@detail_service ||= OzonApi::DetailService.new(client)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.client_service
|
43
|
+
@client_service ||= OzonApi::ClientService.new(client)
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.cart_service
|
47
|
+
@cart_service ||= OzonApi::CartService.new(client)
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.checkout_service
|
51
|
+
@checkout_service ||= OzonApi::CheckoutService.new(client)
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.order_service
|
55
|
+
@order_service ||= OzonApi::OrderService.new(client)
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.address_service
|
59
|
+
@address_service ||= OzonApi::AddressService.new(client)
|
60
|
+
end
|
12
61
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ozon_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yury Kotov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
12
|
-
dependencies:
|
11
|
+
date: 2016-10-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activemodel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: Ruby Ozon API wrapper.
|
14
28
|
email:
|
15
29
|
- non.gi.suong@ya.ru
|
@@ -24,6 +38,7 @@ files:
|
|
24
38
|
- lib/ozon_api/checkout_service.rb
|
25
39
|
- lib/ozon_api/client.rb
|
26
40
|
- lib/ozon_api/client_service.rb
|
41
|
+
- lib/ozon_api/configuration.rb
|
27
42
|
- lib/ozon_api/detail_service.rb
|
28
43
|
- lib/ozon_api/item_service.rb
|
29
44
|
- lib/ozon_api/order_service.rb
|