Sha256: cfea1ebff0d28205746e2106d371a09522b8f2a52a960bb62e2aa17583f5c0a3

Contents?: true

Size: 946 Bytes

Versions: 1

Compression:

Stored size: 946 Bytes

Contents

require 'base64'

class CityGrid
  class API
    class Advertising
      class Image < Advertising
        def self.upload user_id, 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" => {
                	"image_type" => type,
                	"image_name" => name,
                	"image_format" => format,
                	"image" => image_data
                  },
                "operator" => "ADD",
                "userId" => user_id
              }
            ]}.to_json,
            :headers => merge_headers("authToken" => token)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
citygrid_api-0.0.6 lib/citygrid/api/advertising/image.rb