Module: OzonLogistics
- Defined in:
- lib/ozon-logistics.rb,
lib/ozon-logistics/request.rb,
lib/ozon-logistics/version.rb,
lib/ozon-logistics/response.rb,
lib/ozon-logistics/ozon_error.rb,
lib/ozon-logistics/api_request.rb,
lib/ozon-logistics/ozon_logistics_error.rb,
lib/generators/ozon_logistics/install/install_generator.rb
Defined Under Namespace
Classes: APIRequest, DynamicSetting, InstallGenerator, OzonError, OzonLogisticsError, Request, Response
Constant Summary
collapse
- VERSION =
"0.0.1"
Class Method Summary
collapse
Class Method Details
.add_reader(name) ⇒ Object
26
27
28
29
30
|
# File 'lib/ozon-logistics.rb', line 26
def add_reader(name)
define_singleton_method(name) do |*args|
send("#{name}_setting").value(*args)
end
end
|
.add_writer(name, type) ⇒ Object
32
33
34
35
36
|
# File 'lib/ozon-logistics.rb', line 32
def add_writer(name, type)
define_singleton_method("#{name}=") do |value|
send("#{name}_setting=", DynamicSetting.build(value, type))
end
end
|
.generate_access_token(client_id = OzonLogistics.client_id, client_secret = OzonLogistics.client_secret, grant_type = OzonLogistics.grant_type) ⇒ Object
9
10
11
12
|
# File 'lib/ozon-logistics.rb', line 9
def generate_access_token(client_id=OzonLogistics.client_id, client_secret=OzonLogistics.client_secret, grant_type=OzonLogistics.grant_type)
response = Faraday.post(OzonLogistics.url_token, "grant_type=#{grant_type}&client_id=#{client_id}&client_secret=#{client_secret}")
JSON.parse(response.body)
end
|
.register(name, value, type = nil) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/ozon-logistics.rb', line 18
def register(name, value, type = nil)
cattr_accessor "#{name}_setting".to_sym
add_reader(name)
add_writer(name, type)
send "#{name}=", value
end
|
.setup {|_self| ... } ⇒ Object
14
15
16
|
# File 'lib/ozon-logistics.rb', line 14
def setup
yield self
end
|