yandex-delivery 0.0.6 → 0.0.7
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 879dec72178429f7404eda56de3ffa39002530a8451a82753ce79e26cb64e38e
|
4
|
+
data.tar.gz: 99cb8023968d3a40c9b03a834a812b418ac410a79287fcfd72a5fe1f36f20493
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bc51ee3f55b3fbab1c6939fc926435d6e25b27cdc06e80d9691166e579c8207a8c565353081b4aa6999aa746bad7c9ce9689800d0c11f479235e4259d3fb108
|
7
|
+
data.tar.gz: b6ea88f077d315ed92a2be1512c25a4ca202db48ee2c2ef352290004afeee27642e1183cdb75d1cf4cea2a85ad1f6810b9f07c1905d27e17616c904e5fa612fb
|
@@ -5,6 +5,7 @@ YandexDelivery.setup do |config|
|
|
5
5
|
template = ERB.new(File.new('config/yandex_delivery2.yml').read)
|
6
6
|
processed = YAML.safe_load(template.result(binding))
|
7
7
|
|
8
|
+
config::Request.app_id = processed['YANDEX_DELIVERY_APP_ID']
|
8
9
|
config::Request.api_key = processed['YANDEX_DELIVERY_ACCESS_TOKEN']
|
9
10
|
config::Request.timeout = 15
|
10
11
|
config::Request.open_timeout = 15
|
@@ -81,6 +81,10 @@ module YandexDelivery
|
|
81
81
|
@request_builder.api_key
|
82
82
|
end
|
83
83
|
|
84
|
+
def app_id
|
85
|
+
@request_builder.app_id
|
86
|
+
end
|
87
|
+
|
84
88
|
def api_endpoint
|
85
89
|
@request_builder.api_endpoint
|
86
90
|
end
|
@@ -140,7 +144,7 @@ module YandexDelivery
|
|
140
144
|
if request
|
141
145
|
request.params.merge!(params) if params
|
142
146
|
request.headers['Content-Type'] = 'application/json'
|
143
|
-
request.headers['Authorization'] = "OAuth #{self.api_key}"
|
147
|
+
request.headers['Authorization'] = "OAuth oauth_token=\"#{self.api_key}\", oauth_client_id=\"#{self.app_id}\""
|
144
148
|
request.headers.merge!(headers) if headers
|
145
149
|
request.body = body if body
|
146
150
|
request.options.timeout = self.timeout
|
@@ -181,6 +185,9 @@ module YandexDelivery
|
|
181
185
|
unless self.api_key
|
182
186
|
raise YandexDelivery::YandexDeliveryError, "You must set an api_key prior to making a call"
|
183
187
|
end
|
188
|
+
unless self.app_id
|
189
|
+
raise YandexDelivery::YandexDeliveryError, "You must set an app_id prior to making a call"
|
190
|
+
end
|
184
191
|
end
|
185
192
|
|
186
193
|
def api_url
|
@@ -1,14 +1,16 @@
|
|
1
1
|
module YandexDelivery
|
2
2
|
class Request
|
3
|
-
attr_accessor :api_key, :api_endpoint, :timeout, :open_timeout, :proxy, :faraday_adapter, :symbolize_keys, :debug, :logger
|
3
|
+
attr_accessor :api_key, :app_id, :api_endpoint, :timeout, :open_timeout, :proxy, :faraday_adapter, :symbolize_keys, :debug, :logger
|
4
4
|
|
5
5
|
DEFAULT_TIMEOUT = 60
|
6
6
|
DEFAULT_OPEN_TIMEOUT = 60
|
7
7
|
|
8
|
-
def initialize(api_key: nil, api_endpoint: nil, timeout: nil, open_timeout: nil, proxy: nil, faraday_adapter: nil, symbolize_keys: false, debug: false, logger: nil)
|
8
|
+
def initialize(api_key: nil, app_id: nil, api_endpoint: nil, timeout: nil, open_timeout: nil, proxy: nil, faraday_adapter: nil, symbolize_keys: false, debug: false, logger: nil)
|
9
9
|
@path_parts = []
|
10
10
|
@api_key = api_key || self.class.api_key || ENV['YANDEX_DELIVERY_ACCESS_TOKEN']
|
11
11
|
@api_key = @api_key.strip if @api_key
|
12
|
+
@app_id = app_id || self.class.app_id || ENV['YANDEX_DELIVERY_APP_ID']
|
13
|
+
@app_id = @app_id.strip if @app_id
|
12
14
|
@api_endpoint = api_endpoint || self.class.api_endpoint
|
13
15
|
@timeout = timeout || self.class.timeout || DEFAULT_TIMEOUT
|
14
16
|
@open_timeout = open_timeout || self.class.open_timeout || DEFAULT_OPEN_TIMEOUT
|
@@ -80,10 +82,12 @@ module YandexDelivery
|
|
80
82
|
end
|
81
83
|
|
82
84
|
class << self
|
83
|
-
attr_accessor :api_key, :timeout, :open_timeout, :api_endpoint, :proxy, :faraday_adapter, :symbolize_keys, :debug, :logger
|
85
|
+
attr_accessor :api_key, :app_id, :timeout, :open_timeout, :api_endpoint, :proxy, :faraday_adapter, :symbolize_keys, :debug, :logger
|
84
86
|
|
85
87
|
def method_missing(sym, *args, &block)
|
86
|
-
new(api_key: self.api_key,
|
88
|
+
new(api_key: self.api_key, app_id: self.app_id, api_endpoint: self.api_endpoint, timeout: self.timeout,
|
89
|
+
open_timeout: self.open_timeout, faraday_adapter: self.faraday_adapter, symbolize_keys: self.symbolize_keys,
|
90
|
+
debug: self.debug, proxy: self.proxy, logger: self.logger).send(sym, *args, &block)
|
87
91
|
end
|
88
92
|
|
89
93
|
def respond_to_missing?(method_name, include_private = false)
|