README.md in survey-gizmo-ruby-4.0.0 vs README.md in survey-gizmo-ruby-4.1.0

- old
+ new

@@ -38,24 +38,30 @@ # Configure your credentials SurveyGizmo.configure do |config| config.user = 'still_tippin@woodgraingrip.com' config.password = 'it_takes_grindin_to_be_a_king' - # api_version defaults to v4, but you can probably set to v3 safely if you suspect a bug in v4 + # Optional - Defaults to v4, but you can probably set to v3 safely if you suspect a bug in v4 config.api_version = 'v4' + + # Optional - Defaults to 50, maximum 500. Setting too high may cause SurveyGizmo to start throwing timeouts. + config.results_per_page = 100 end -# Retrieve all your surveys +# Retrieve the first page of your surveys surveys = SurveyGizmo::API::Survey.all +# Retrieve ALL your surveys (handle pagination for you) +surveys = SurveyGizmo::API::Survey.all(all_pages: true) # Retrieve the survey with id: 12345 survey = SurveyGizmo::API::Survey.first(id: 12345) survey.title # => "My Title" survey.pages # => [page1, page2,...] survey.number_of_completed_responses # => 355 survey.server_has_new_results_since?(Time.now.utc - 2.days) # => true survey.team_names # => ['Development', 'Test'] +survey.belongs_to?('Development') # => true # Retrieving Questions for a given survey. Note that page_id is a required parameter. questions = SurveyGizmo::API::Question.all(survey_id: survey.id, page_id: 1) # Or just retrieve all questions for all pages of this survey questions = survey.questions @@ -66,17 +72,31 @@ question.title = "Do you LOVE Ruby?" question.save # Destroy a question question.destroy -# Retrieving SurveyResponses for a given survey. -# Note that because both options are hashes, you need to enclose them both in -# braces to page successfully! -responses = SurveyGizmo::API::Response.all({ survey_id: survey.id }, { page: 1 }) - -# Retrieving page 2 of non test data SurveyResponses -filters = { page: 2, filters: [{ field: 'istestdata', operator: '<>', value: 1 }] } -responses = SurveyGizmo::API::Response.all({ survey_id: survey_id }, filters) +# Retrieve 2nd page of SurveyResponses for a given survey. +responses = SurveyGizmo::API::Response.all(survey_id: 12345, page: 2) +# Retrieve all responses for a given survey. +responses = SurveyGizmo::API::Response.all(all_pages: true, survey_id: 12345) +# Retrieving page 3 of completed, non test data SurveyResponses submitted within the past 3 days +# for contact id 999. This example shows you how to use some of the gem's built in filters and +# filter generators as well as how to construct your own raw filter. +# See: http://apihelp.surveygizmo.com/help/article/link/filters for more info on filters +responses = SurveyGizmo::API::Response.all( + survey_id: 12345, + page: 3, + filters: [ + SurveyGizmo::API::Response::NO_TEST_DATA, + SurveyGizmo::API::Response::ONLY_COMPLETED, + SurveyGizmo::API::Response.submitted_since_filter(Time.now - 72.hours), + { + field: 'contact_id', + operator: '=', + value: 999 + } + ] +) ``` ## On API Timeouts API timeouts are a regular occurrence with the SurveyGizmo API. At Lumos Labs we use our own [Pester gem](https://github.com/lumoslabs/pester) to manage retry strategies. It might work for you.