Skip to content

Commit

Permalink
Merge pull request #5 from krivospitsky/master
Browse files Browse the repository at this point in the history
offline reports
  • Loading branch information
rikkimongoose authored Aug 1, 2019
2 parents edcdfec + d336493 commit 55e0e93
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/ya/api/direct/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ module API
module Direct
API_V5 = {
"AdGroups" => [
"add", "update", "delete", "get"
"add", "update", "delete", "get"
],
"AgencyClients" => [
"add", "update", "get"
],
"Ads" => [
"add", "update", "delete", "suspend", "resume", "archive", "unarchive", "moderate", "get"
Expand Down
9 changes: 8 additions & 1 deletion lib/ya/api/direct/gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ def request(method, params, service = "", version = nil)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = @config[:ssl] ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
response = http.request(request)

begin
response = http.request(request)
if (response.kind_of? Net::HTTPCreated) || (response.kind_of? Net::HTTPAccepted)
sleep response['retryIn'].to_i
end
end while(response.kind_of? Net::HTTPCreated) || (response.kind_of? Net::HTTPAccepted)

if response.kind_of? Net::HTTPSuccess
UrlHelper.parse_data response, ver
else
Expand Down
2 changes: 1 addition & 1 deletion lib/ya/api/direct/url_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def self.extract_response_units(response_header)
private

def self.parse_data(response, ver)
if response["Content-Type"] == "application/json; charset=utf-8"
if response["Content-Type"].start_with?("application/json")
response_body = JSON.parse(response.body)
validate_response! response_body
result = { data: response_body }
Expand Down

0 comments on commit 55e0e93

Please sign in to comment.