Sha256: 30d0b97e7e5e88cd1ec562b2a4307e506bb8d7b0be07ce613f11cdb71843ed4f

Contents?: true

Size: 897 Bytes

Versions: 18

Compression:

Stored size: 897 Bytes

Contents

require 'base64'

class CityGrid
  class API
    class Advertising
      class Image < Advertising
        def self.upload name, type, image_path, options = {}
          token = extract_auth_token options
          image_data = Base64.encode64(File.open(image_path).read.to_s).gsub(/\n/, "")
          format = options[: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
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
citygrid_api-0.0.28 lib/citygrid/api/advertising/image.rb
citygrid_api-0.0.27 lib/citygrid/api/advertising/image.rb
citygrid_api-0.0.26 lib/citygrid/api/advertising/image.rb
citygrid_api-0.0.25 lib/citygrid/api/advertising/image.rb
citygrid_api-0.0.24 lib/citygrid/api/advertising/image.rb
citygrid_api-0.0.23 lib/citygrid/api/advertising/image.rb
citygrid_api-0.0.22 lib/citygrid/api/advertising/image.rb
citygrid_api-0.0.21 lib/citygrid/api/advertising/image.rb
citygrid_api-0.0.20 lib/citygrid/api/advertising/image.rb
citygrid_api-0.0.19 lib/citygrid/api/advertising/image.rb
citygrid_api-0.0.18 lib/citygrid/api/advertising/image.rb
citygrid_api-0.0.17 lib/citygrid/api/advertising/image.rb
citygrid_api-0.0.16 lib/citygrid/api/advertising/image.rb
citygrid_api-0.0.15 lib/citygrid/api/advertising/image.rb
citygrid_api-0.0.14 lib/citygrid/api/advertising/image.rb
citygrid_api-0.0.13 lib/citygrid/api/advertising/image.rb
citygrid_api-0.0.12 lib/citygrid/api/advertising/image.rb
citygrid_api-0.0.11 lib/citygrid/api/advertising/image.rb