Class: MoreappAPI::RegistrationFile
- Inherits:
-
Object
- Object
- MoreappAPI::RegistrationFile
- Defined in:
- lib/moreapp_api/registration_file.rb
Instance Method Summary collapse
-
#initialize(customer) ⇒ RegistrationFile
constructor
A new instance of RegistrationFile.
- #post(filename, content_type = 'image/png') ⇒ Object
Constructor Details
#initialize(customer) ⇒ RegistrationFile
Returns a new instance of RegistrationFile.
5 6 7 |
# File 'lib/moreapp_api/registration_file.rb', line 5 def initialize(customer) @customer = customer end |
Instance Method Details
#post(filename, content_type = 'image/png') ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/moreapp_api/registration_file.rb', line 9 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 |