Class: YandexOffers::Request
- Inherits:
-
Object
- Object
- YandexOffers::Request
- Includes:
- HTTParty
- Defined in:
- lib/yandex_offers/request.rb
Class Method Summary collapse
- .headers ⇒ Object
- .post(url, body) ⇒ Object
- .post_with_authorization(url, body) ⇒ Object
- .token ⇒ Object
Class Method Details
.headers ⇒ Object
26 27 28 |
# File 'lib/yandex_offers/request.rb', line 26 def headers @headers ||= { "Content-Type" => "application/json", "Accept" => "application/json" } end |
.post(url, body) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/yandex_offers/request.rb', line 7 def post(url, body) = {} [:format] = :json [:body] = body HTTParty.post("#{YandexOffers.configuration.base_url}#{url}", ).parsed_response end |
.post_with_authorization(url, body) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/yandex_offers/request.rb', line 14 def (url, body) = {} [:format] = :json [:body] = body.to_json [:headers] = self.headers.merge({"Authorization" => "Bearer #{self.token}"}) HTTParty.post("#{YandexOffers.configuration.base_url}#{url}", ).parsed_response end |
.token ⇒ Object
22 23 24 |
# File 'lib/yandex_offers/request.rb', line 22 def token @token ||= YandexOffers::Authorization.new.get_token end |