From 6558becea4e244488a12ba5202a03d534d37523a Mon Sep 17 00:00:00 2001 From: Rob Madden Date: Tue, 24 Oct 2017 14:30:23 -0700 Subject: [PATCH] Add update function --- lib/adzerk/client.rb | 9 +++++++++ lib/adzerk/creative.rb | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/lib/adzerk/client.rb b/lib/adzerk/client.rb index 79e172d..6a0438c 100644 --- a/lib/adzerk/client.rb +++ b/lib/adzerk/client.rb @@ -69,6 +69,15 @@ def create_creative(data={}, image_path='') response end + def update_creative(data={}, image_path='') + response = RestClient.patch(@config[:host] + 'creative', + {:creative => camelize_data(data).to_json}, + :X_Adzerk_ApiKey => @api_key, + :accept => :json) + response = upload_creative(JSON.parse(response)["Id"], image_path) unless image_path.empty? + response + end + def upload_creative(id, image_path, size_override: false) image = File.new(image_path, 'rb') url = @config[:host] + 'creative/' + id.to_s + '/upload' diff --git a/lib/adzerk/creative.rb b/lib/adzerk/creative.rb index 0e70252..5fc16a3 100644 --- a/lib/adzerk/creative.rb +++ b/lib/adzerk/creative.rb @@ -8,6 +8,11 @@ def create(data= {}, imagepath='') uncamelize_data(JSON.parse(response)) end + def update(data= {}, imagepath='') + response = @client.update_creative(data, imagepath) + uncamelize_data(JSON.parse(response)) + end + def list(advertiserId) url = 'advertiser/' + advertiserId.to_s + "/creatives" parse_response(@client.get_request(url))