Class: CityGrid::API::Advertising::Image
- Inherits:
-
CityGrid::API::Advertising
- Object
- CityGrid::API
- CityGrid::API::Advertising
- CityGrid::API::Advertising::Image
- Defined in:
- lib/citygrid/api/advertising/image.rb
Constant Summary
Constants inherited from CityGrid::API
CityGrid::API::AdCenter, DEFAULT_ACTION_OPTIONS, DEFAULT_HEADERS
Class Method Summary collapse
Methods inherited from CityGrid::API
define_action, endpoint, newendpoint, request
Methods included from CityGridExceptions
Class Method Details
.upload(name, type, image_path, options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/citygrid/api/advertising/image.rb', line 7 def self.upload name, type, image_path, = {} token = extract_auth_token image_data = Base64.encode64(File.open(image_path).read.to_s).gsub(/\n/, "") format = [:format] || image_path.split(".").last request_and_handle :post, "#{base_uri}/#{endpoint}/upload", :body => {"mutateOperationListResource" => [ { "operand" => { "imageType" => type, "imageName" => name, "imageFormat" => format, "image" => image_data }, "operator" => "ADD" } ]}.to_json, :headers => merge_headers("authToken" => token) end |