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
27
28
29
30
31
|
# File 'lib/ozon-logistics.rb', line 27
def add_reader(name)
define_singleton_method(name) do |*args|
send("#{name}_setting").value(*args)
end
end
|
.add_writer(name, type) ⇒ Object
33
34
35
36
37
|
# File 'lib/ozon-logistics.rb', line 33
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
10
11
12
13
|
# File 'lib/ozon-logistics.rb', line 10
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
19
20
21
22
23
24
25
|
# File 'lib/ozon-logistics.rb', line 19
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
15
16
17
|
# File 'lib/ozon-logistics.rb', line 15
def setup
yield self
end
|