upnext / BeaconControl

Setup and manage large beacon deployments with BeaconControl open source platform
https://beaconcontrol.io
BSD 3-Clause "New" or "Revised" License
93 stars 63 forks source link

Issues Adding coupon with image #40

Open David1916 opened 7 years ago

David1916 commented 7 years ago

I am trying a coupon with image consuming the activities api, insert all the information except the image, this is the example of the Json

{ "activity": { "scheme": "coupon", "name": "Prueba Api2Api Coupon 16", "trigger_attributes": { "type": "BeaconTrigger", "event_type": "near", "zone_ids": [1] }, "coupon_attributes": { "name": "Unilever", "title": "Promoción Unilever", "description": "Pide un 10% de descuento con este cupón", "button_label": "", "button_link": "", "button_font_color": "", "button_background_color": "", "template": "template_2", "image_attributes": { "type": "image", "file": "data:image/jpeg;base64,/...." }

  }
}

}

please HELP!!

jkurdel commented 7 years ago

Hi @David116 ,

Unfortunately there is a bug in POST /s2s_api/v1/applications/:application_id/activities endpoint implementation. I will try to prepare fix as quick as possible. At the moment I can share with you a quick fix solution:

  1. Copy & Paste parse_image_data and clean_tempfile methods from https://gist.github.com/ifightcrime/9291167a0a4367bb55a2 to app/controllers/s2s_api/v1/activities_controller.rb file
  2. Change permitted_params method
    def permitted_params
    if file = params.try(:[], :activity).try(:[], :coupon_attributes).try(:[], :image_attributes).try(:[], :file)
    params[:activity][:coupon_attributes][:image_attributes][:file] = parse_image_data(file)
    end
    { activity: ActivityParams.new(params).call }
    end

Best, Jan