Sha256: 92727769ed690a5f848eabe0d603d41b97fd446536c77eb4ab804c94c7e891c1

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

class MoreappAPI
  class RegistrationFile


    def initialize(customer)
      @customer = customer
    end

    def post(filename, content_type = 'image/png')
      # !!! Undocumented more-app API
      # !!! TODO verify this still works after API changes of 08/2020

      image_data = Base64.encode64(File.open(filename, "rb").read)

      response = @customer.moreapp_api.request(:post, "/api/v1.0/client/registrations/files/base64", nil, {},
                                  {
                                      customerNumber: customer.id,
                                      base64FileContent: "data:#{content_type};base64," + image_data,
                                      filename: File.basename(filename)
                                  }.to_json,
                                  { 'Content-Type' => 'application/json' } )

      # returns a body containing the location of the image. Looks something like "gridfs://registrationFiles/#{image_location_id}"
      # which can then be used as a value for a "photo" - field
      response.body
    end


  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
moreapp-api-0.0.4 lib/moreapp_api/registration_file.rb
moreapp-api-0.0.3 lib/moreapp_api/registration_file.rb