ylecuyer/survey-gizmo-ruby

how to chose a resource type (on survey object)

emsedano opened this issue · 3 comments

hi, i'm implementing your gem...

my code

def self.create(survey)
    setup_gizmo do |conn|
      gizmo_survey = SurveyGizmo::API::Survey.create(:title => survey.title, :_type => "survey")
      gizmo_survey.save
    end
  end

if i type gizmo_survey.title or gizmo_survey._type i reach both values correctly and both values are present too, BUT when i try to gizmo_survey.save
this erros i was given

gizmo_survey.errors
=> ["Please select a type (survey, poll, form, quiz)(PUT)",
 "Please select a type (survey, poll, form, quiz)(PUT)"]

how is the right way to "Select a type" ?? it seems that documentation doesn't say clearly how to create a Survey (it supposed to be the same as any other resource, but looks it's not as easy as it appears)

this is the instance before the gizmo_survey.save

[15] pry(Gizmo::SurveyConnector)> gizmo_survey.instance_values
=> {"title"=>"Kiubo kiubo cuando",
 "_type"=>"survey",
 "id"=>nil,
 "team"=>nil,
 "_subtype"=>nil,
 "status"=>nil,
 "forward_only"=>nil,
 "internal_title"=>nil,
 "title_ml"=>{},
 "links"=>{},
 "theme"=>nil,
 "blockby"=>nil,
 "languages"=>[],
 "statistics"=>[],
 "created_on"=>nil,
 "modified_on"=>nil,
 "copy"=>nil,
 "_response"=>
  #<SurveyGizmo::Resource::Response:0x007fe17b3386c8
   @_message="Please select a type (survey, poll, form, quiz)(PUT)",
   @response=
    {"result_ok"=>false,
     "code"=>0,
     "message"=>"Please select a type (survey, poll, form, quiz)(PUT)"}>,
 "errors"=>
  ["Please select a type (survey, poll, form, quiz)(PUT)",
   "Please select a type (survey, poll, form, quiz)(PUT)",
   "Please select a type (survey, poll, form, quiz)(PUT)",
   "Please select a type (survey, poll, form, quiz)(PUT)"]}

cheers guys.. nice job !!!

Would like to get an answer for this; same error message. Can't seem to create a survey.

Fixed in 1.0.4 thanks to @adibsaad PR #16